@@ -96,18 +96,19 @@ const CommonForm = ({ form, title, submit_title, submit_body, submit_button_titl
9696 role : role ,
9797 form : form ,
9898 } }
99- onSubmit = { async ( values ) => {
99+ onSubmit = { async ( values , { setStatus } ) => {
100100 if ( isValidRole ( values . role ) && isValidEmail ( values . email ) ) {
101101 const { success } = await submitForm ( { memberFormOne : values } ) ;
102102 if ( success ) {
103+ setStatus ( null ) ;
103104 setMemberFormOne ( values ) ;
104105 setStepNumber ( 1 ) ;
105106 setSubmit ( true ) ;
106107 // window.scrollTo(0,window.scrollY - 800);
107108 // confirmationMessageRef.current.scrollIntoView({ behavior: 'smooth' })
108109 scrollElementIntoView ( confirmationMessageRef . current , navBarOffset ) ;
109110 } else {
110- alert ( "Submission failed. Please try again." ) ;
111+ setStatus ( { submitError : "Submission failed. Please try again." } ) ;
111112 }
112113 } else {
113114 // if (!(values.google || values.github || values.twitter || values.linkedin)) {
@@ -128,7 +129,11 @@ const CommonForm = ({ form, title, submit_title, submit_body, submit_button_titl
128129 }
129130 } }
130131 >
131- < Form className = "form" method = "post" >
132+ { ( { status } ) => (
133+ < Form className = "form" method = "post" aria-describedby = "common-form-status" >
134+ < div id = "common-form-status" className = "form-error" role = "alert" aria-live = "assertive" >
135+ { status ?. submitError || "" }
136+ </ div >
132137 < label htmlFor = "firstname" className = "form-name" > First Name < span className = "required-sign" > *</ span > </ label >
133138 < Field type = "text" className = "text-field" id = "firstname" name = "firstname" maxLength = "32" pattern = "^[\p{L}]+('[\p{L}]*)?(?:-[\p{L}]+)*([\s][\p{L}]+('[\p{L}]*)?(?:-[\p{L}]+)*){0,31}$" required />
134139 < label htmlFor = "lastname" className = "form-name" > Last Name < span className = "required-sign" > *</ span > </ label >
@@ -288,6 +293,7 @@ const CommonForm = ({ form, title, submit_title, submit_body, submit_button_titl
288293
289294 < Button $secondary className = "btn" title = { submit_button_title || "Submit" } />
290295 </ Form >
296+ ) }
291297 </ Formik >
292298 </ div >
293299 }
0 commit comments