Add community question message type with pre-fill from study community
This commit is contained in:
@@ -1151,7 +1151,7 @@ export function ColossiansStudySectionPage({ content }: Props) {
|
|||||||
</ol>
|
</ol>
|
||||||
<div style={{ marginTop: '1.25rem', display: 'flex', gap: '0.75rem', flexWrap: 'wrap' }}>
|
<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={`/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>
|
</div>
|
||||||
</article>
|
</article>
|
||||||
</div>
|
</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>
|
<p className="study-course-hero-copy">Talk with other enrolled students. Keep it gracious and on topic.</p>
|
||||||
<div className="study-course-hero-actions">
|
<div className="study-course-hero-actions">
|
||||||
<Link to={`/study/${study.slug}`} className="btn-secondary">Back to Study</Link>
|
<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>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { useState } from 'react'
|
import { useState, useEffect } from 'react'
|
||||||
import type { ChangeEvent } from 'react'
|
import type { ChangeEvent } from 'react'
|
||||||
import { useNavigate } from 'react-router-dom'
|
import { useNavigate, useSearchParams } from 'react-router-dom'
|
||||||
|
|
||||||
interface ContactFields {
|
interface ContactFields {
|
||||||
firstName: string
|
firstName: string
|
||||||
@@ -12,13 +12,27 @@ interface ContactFields {
|
|||||||
|
|
||||||
export default function ContactForm() {
|
export default function ContactForm() {
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate()
|
||||||
|
const [searchParams] = useSearchParams()
|
||||||
|
const source = searchParams.get('source')
|
||||||
|
const studyName = searchParams.get('study')
|
||||||
|
|
||||||
const [fields, setFields] = useState<ContactFields>({
|
const [fields, setFields] = useState<ContactFields>({
|
||||||
firstName: '',
|
firstName: '',
|
||||||
lastName: '',
|
lastName: '',
|
||||||
email: '',
|
email: '',
|
||||||
message: '',
|
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 [subscribe, setSubscribe] = useState(true)
|
||||||
const [honey, setHoney] = useState('')
|
const [honey, setHoney] = useState('')
|
||||||
const [status, setStatus] = useState<'idle' | 'submitting' | 'error'>('idle')
|
const [status, setStatus] = useState<'idle' | 'submitting' | 'error'>('idle')
|
||||||
@@ -85,6 +99,7 @@ export default function ContactForm() {
|
|||||||
Message Type
|
Message Type
|
||||||
<select name="messageType" value={fields.messageType} onChange={handleSelectChange}>
|
<select name="messageType" value={fields.messageType} onChange={handleSelectChange}>
|
||||||
<option value="question">Bible Question</option>
|
<option value="question">Bible Question</option>
|
||||||
|
<option value="community">Community Question</option>
|
||||||
<option value="testimony">Testimony</option>
|
<option value="testimony">Testimony</option>
|
||||||
<option value="topic">Topic Request</option>
|
<option value="topic">Topic Request</option>
|
||||||
<option value="general">General Message</option>
|
<option value="general">General Message</option>
|
||||||
|
|||||||
Reference in New Issue
Block a user