refactor: extract webhook submission logic into a `useWebhookSubmit`
Description
This PR fixes #7536
This PR abstracts and centralizes the duplicated webhook submission logic by introducing a custom useWebhookSubmit hook. It integrates this new hook into the CommonForm (index.js and events.js) and ContactForm (index.js) components. Previously, these forms used an unhandled axios.post inside a useEffect triggered by a state flag, which risked silent data loss on network failure. By awaiting the network requests directly inside the Formik onSubmit handlers, we ensure the UI transitions to the "Thank You" screen only upon a confirmed HTTP success.
Notes for Reviewers
- The new hook is located at src/utils/hooks/useWebhookSubmit.js.
- This change affects
/contact,/community/events, and other form pages. - To test locally: Submit a form and verify it proceeds to the success step. If you drop your network connection before submitting, it will correctly alert you of the failure and retain your form state instead of showing a false success.
- [x] Yes, I signed my commits.
🚀 Preview for commit 709d5f4df9b4162151017107d5c250c00430bc72 at: https://69bf9360215bccffd0afcbeb--layer5.netlify.app
🚀 Preview for commit c17fb1c46e0e79a73ce1f4ba627bc9f70d705819 at: https://69bfa8b06f2ab006b9de4b89--layer5.netlify.app
🚀 Preview for commit aeb3e6884e78097c732ae973cd8cc1b688b13a11 at: https://69c1f9b6c87786311b23e0c6--layer5.netlify.app
@CodexRaunak can you please review this pr
🚀 Preview for commit b1f5d728184d16116f7a6b49f6716f3ad7fed819 at: https://69c230ab39fb22adc0c2d56b--layer5.netlify.app
@saurabhraghuvanshii can you please review this pr
🚀 Preview for commit 9dede11238f11a76255176fe7288ce49c50d270a at: https://69c3a8772f6d231371e28811--layer5.netlify.app
🚀 Preview for commit bff750839fe47ed9f1d905895b01d6414c403f45 at: https://69c3dc33a1de532588f1acdb--layer5.netlify.app
@saurabhraghuvanshii can you please review this pr
🚀 Preview for commit 96f097da639d98d02cd95baeaf293f376ceef355 at: https://69c4cecb8748eee6140f5f36--layer5.netlify.app
🚀 Preview for commit f744db58b31e4fa737b55b1fc9040e3d6727d676 at: https://69c7e653c5238f112a3bf1aa--layer5.netlify.app
@rishiraj38 i addressed your changes can you please review it now
🚀 Preview for commit 185c96e624a97fc0895bbe88154b64f36abed3f4 at: https://69c81ea05353dd80e8a52b9b--layer5.netlify.app
@saurabhraghuvanshii can you please review this pr
🚀 Preview for commit 5b5f726638bc08f7fbae054b6c2fb615f5fd306f at: https://69cf571d9fc8b8195bffb68c--layer5.netlify.app
@rishiraj38 Replaced the blocking alert() on form submission failure with an inline, accessible error message using Formik status and an aria-live region. This keeps users in context, improves accessibility, and avoids disruptive browser modals.
🚀 Preview for commit f5f53846063909798ee8869dee37aa82128168cb at: https://69cf8a11fa0a08bd41a76430--layer5.netlify.app
@rishiraj38 i Replaced alert("Submission failed...") in both index.js and index.js with Formik setStatus + inline accessible error UI (role="alert", aria-live="assertive"). Also clear error status on successful submit (setStatus(null)) .
Please take a look at copilot suggestions.
Please take a look at copilot suggestions.
@rishiraj38 i addressed all Copilot comments