Add community question message type with pre-fill from study community

This commit is contained in:
nmemmert
2026-05-21 14:39:30 -04:00
parent 367ebc88b4
commit 01143d3ec9
2 changed files with 20 additions and 5 deletions
+2 -2
View File
@@ -1151,7 +1151,7 @@ export function ColossiansStudySectionPage({ content }: Props) {
</ol>
<div style={{ marginTop: '1.25rem', display: 'flex', gap: '0.75rem', flexWrap: 'wrap' }}>
<Link to={`/study/${study.slug}/community`} className="btn-primary">Go to Community</Link>
<Link to="/contact" className="btn-secondary">Ask Nate</Link>
<Link to={`/contact?source=community&study=${encodeURIComponent(study.title)}`} className="btn-secondary">Ask Nate</Link>
</div>
</article>
</div>
@@ -1879,7 +1879,7 @@ export function StudyCommunityPage({ content }: Props) {
<p className="study-course-hero-copy">Talk with other enrolled students. Keep it gracious and on topic.</p>
<div className="study-course-hero-actions">
<Link to={`/study/${study.slug}`} className="btn-secondary">Back to Study</Link>
<Link to="/contact" className="btn-primary">Ask Nate</Link>
<Link to={`/contact?source=community&study=${encodeURIComponent(study.title)}`} className="btn-primary">Ask Nate</Link>
</div>
</div>
</section>
+18 -3
View File
@@ -1,6 +1,6 @@
import { useState } from 'react'
import { useState, useEffect } from 'react'
import type { ChangeEvent } from 'react'
import { useNavigate } from 'react-router-dom'
import { useNavigate, useSearchParams } from 'react-router-dom'
interface ContactFields {
firstName: string
@@ -12,13 +12,27 @@ interface ContactFields {
export default function ContactForm() {
const navigate = useNavigate()
const [searchParams] = useSearchParams()
const source = searchParams.get('source')
const studyName = searchParams.get('study')
const [fields, setFields] = useState<ContactFields>({
firstName: '',
lastName: '',
email: '',
message: '',
messageType: 'question',
messageType: source === 'community' ? 'community' : 'question',
})
useEffect(() => {
if (source === 'community' && studyName) {
setFields(f => ({
...f,
messageType: 'community',
message: f.message.startsWith('[From ') ? f.message : `[From ${decodeURIComponent(studyName)} community]\n\n${f.message}`,
}))
}
}, [source, studyName])
const [subscribe, setSubscribe] = useState(true)
const [honey, setHoney] = useState('')
const [status, setStatus] = useState<'idle' | 'submitting' | 'error'>('idle')
@@ -85,6 +99,7 @@ export default function ContactForm() {
Message Type
<select name="messageType" value={fields.messageType} onChange={handleSelectChange}>
<option value="question">Bible Question</option>
<option value="community">Community Question</option>
<option value="testimony">Testimony</option>
<option value="topic">Topic Request</option>
<option value="general">General Message</option>