@@ -96,6 +96,7 @@ export function ContactForm() {
9696 const [ form , setForm ] = useState < ContactFormState > ( INITIAL_FORM_STATE )
9797 const [ errors , setErrors ] = useState < ContactErrors > ( { } )
9898 const [ submitSuccess , setSubmitSuccess ] = useState ( false )
99+ const [ isSubmitting , setIsSubmitting ] = useState ( false )
99100 const [ website , setWebsite ] = useState ( '' )
100101 const [ widgetReady , setWidgetReady ] = useState ( false )
101102 const [ turnstileSiteKey , setTurnstileSiteKey ] = useState < string | undefined > ( )
@@ -124,7 +125,8 @@ export function ContactForm() {
124125
125126 async function handleSubmit ( event : React . FormEvent < HTMLFormElement > ) {
126127 event . preventDefault ( )
127- if ( contactMutation . isPending ) return
128+ if ( contactMutation . isPending || isSubmitting ) return
129+ setIsSubmitting ( true )
128130
129131 const parsed = contactRequestSchema . safeParse ( {
130132 ...form ,
@@ -141,6 +143,7 @@ export function ContactForm() {
141143 subject : fieldErrors . subject ?. [ 0 ] ,
142144 message : fieldErrors . message ?. [ 0 ] ,
143145 } )
146+ setIsSubmitting ( false )
144147 return
145148 }
146149
@@ -163,8 +166,11 @@ export function ContactForm() {
163166 }
164167
165168 contactMutation . mutate ( { ...parsed . data , website, captchaToken, captchaUnavailable } )
169+ setIsSubmitting ( false )
166170 }
167171
172+ const isBusy = contactMutation . isPending || isSubmitting
173+
168174 const submitError = contactMutation . isError
169175 ? toError ( contactMutation . error ) . message || 'Failed to send message. Please try again.'
170176 : null
@@ -194,7 +200,7 @@ export function ContactForm() {
194200 }
195201
196202 return (
197- < form onSubmit = { handleSubmit } className = 'flex flex-col gap-5' >
203+ < form onSubmit = { handleSubmit } className = 'relative flex flex-col gap-5' >
198204 { /* Honeypot */ }
199205 < div
200206 aria-hidden = 'true'
@@ -329,8 +335,8 @@ export function ContactForm() {
329335 </ p >
330336 ) : null }
331337
332- < button type = 'submit' disabled = { contactMutation . isPending } className = { LANDING_SUBMIT } >
333- { contactMutation . isPending ? 'Sending...' : 'Send message' }
338+ < button type = 'submit' disabled = { isBusy } className = { LANDING_SUBMIT } >
339+ { isBusy ? 'Sending...' : 'Send message' }
334340 </ button >
335341
336342 < p className = 'text-center font-season text-[12px] text-[var(--landing-text-muted)] leading-[1.6]' >
0 commit comments