@@ -37,9 +37,10 @@ const EventForm = ({ form, title, submit_title, submit_body }) => {
3737 org : org ,
3838 form : form ,
3939 } }
40- onSubmit = { async ( values ) => {
40+ onSubmit = { async ( values , { setStatus } ) => {
4141 const { success } = await submitForm ( { memberFormOne : values } ) ;
4242 if ( success ) {
43+ setStatus ( null ) ;
4344 setStepNumber ( 1 ) ;
4445 setSubmit ( true ) ;
4546 window . scrollTo ( 0 , window . scrollY - 800 ) ;
@@ -49,11 +50,15 @@ const EventForm = ({ form, title, submit_title, submit_body }) => {
4950 setOccupation ( values . occupation ) ;
5051 setOrg ( values . org ) ;
5152 } else {
52- alert ( "Submission failed. Please try again." ) ;
53+ setStatus ( { submitError : "Submission failed. Please try again." } ) ;
5354 }
5455 } }
5556 >
56- < Form className = "form" method = "post" >
57+ { ( { status } ) => (
58+ < Form className = "form" method = "post" aria-describedby = "event-form-status" >
59+ < div id = "event-form-status" className = "form-error" role = "alert" aria-live = "assertive" >
60+ { status ?. submitError || "" }
61+ </ div >
5762 < label htmlFor = "firstname" className = "form-name" > First Name < span className = "required-sign" > *</ span > </ label >
5863 < Field type = "text" className = "text-field" id = "firstname" name = "firstname" maxLength = "32" pattern = "[A-Za-z]{1,32}" required />
5964 < label htmlFor = "lastname" className = "form-name" > Last Name < span className = "required-sign" > *</ span > </ label >
@@ -66,7 +71,8 @@ const EventForm = ({ form, title, submit_title, submit_body }) => {
6671 < Field type = "text" className = "text-field" id = "org" name = "org" />
6772
6873 < Button $secondary className = "btn" title = "Submit" />
69- </ Form >
74+ </ Form >
75+ ) }
7076 </ Formik >
7177 </ div >
7278 }
0 commit comments