layer5 icon indicating copy to clipboard operation
layer5 copied to clipboard

refactor: extract webhook submission logic into a `useWebhookSubmit`

Open Manishnemade12 opened this issue 8 months ago • 25 comments

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.

Signed commits

  • [x] Yes, I signed my commits.

Manishnemade12 avatar Mar 22 '26 06:03 Manishnemade12

🚀 Preview for commit 709d5f4df9b4162151017107d5c250c00430bc72 at: https://69bf9360215bccffd0afcbeb--layer5.netlify.app

l5io avatar Mar 22 '26 07:03 l5io

🚀 Preview for commit c17fb1c46e0e79a73ce1f4ba627bc9f70d705819 at: https://69bfa8b06f2ab006b9de4b89--layer5.netlify.app

l5io avatar Mar 22 '26 08:03 l5io

🚀 Preview for commit aeb3e6884e78097c732ae973cd8cc1b688b13a11 at: https://69c1f9b6c87786311b23e0c6--layer5.netlify.app

l5io avatar Mar 24 '26 02:03 l5io

@CodexRaunak can you please review this pr

Manishnemade12 avatar Mar 24 '26 04:03 Manishnemade12

🚀 Preview for commit b1f5d728184d16116f7a6b49f6716f3ad7fed819 at: https://69c230ab39fb22adc0c2d56b--layer5.netlify.app

l5io avatar Mar 24 '26 06:03 l5io

@saurabhraghuvanshii can you please review this pr

Manishnemade12 avatar Mar 25 '26 08:03 Manishnemade12

🚀 Preview for commit 9dede11238f11a76255176fe7288ce49c50d270a at: https://69c3a8772f6d231371e28811--layer5.netlify.app

l5io avatar Mar 25 '26 09:03 l5io

🚀 Preview for commit bff750839fe47ed9f1d905895b01d6414c403f45 at: https://69c3dc33a1de532588f1acdb--layer5.netlify.app

l5io avatar Mar 25 '26 13:03 l5io

@saurabhraghuvanshii can you please review this pr

Manishnemade12 avatar Mar 26 '26 05:03 Manishnemade12

🚀 Preview for commit 96f097da639d98d02cd95baeaf293f376ceef355 at: https://69c4cecb8748eee6140f5f36--layer5.netlify.app

l5io avatar Mar 26 '26 06:03 l5io

🚀 Preview for commit f744db58b31e4fa737b55b1fc9040e3d6727d676 at: https://69c7e653c5238f112a3bf1aa--layer5.netlify.app

l5io avatar Mar 28 '26 14:03 l5io

@rishiraj38 i addressed your changes can you please review it now

Manishnemade12 avatar Mar 28 '26 18:03 Manishnemade12

🚀 Preview for commit 185c96e624a97fc0895bbe88154b64f36abed3f4 at: https://69c81ea05353dd80e8a52b9b--layer5.netlify.app

l5io avatar Mar 28 '26 18:03 l5io

@saurabhraghuvanshii can you please review this pr

Manishnemade12 avatar Apr 03 '26 05:04 Manishnemade12

🚀 Preview for commit 5b5f726638bc08f7fbae054b6c2fb615f5fd306f at: https://69cf571d9fc8b8195bffb68c--layer5.netlify.app

l5io avatar Apr 03 '26 05:04 l5io

@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.

Manishnemade12 avatar Apr 03 '26 09:04 Manishnemade12

🚀 Preview for commit f5f53846063909798ee8869dee37aa82128168cb at: https://69cf8a11fa0a08bd41a76430--layer5.netlify.app

l5io avatar Apr 03 '26 09:04 l5io

@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)) .

Manishnemade12 avatar Apr 05 '26 06:04 Manishnemade12

Please take a look at copilot suggestions.

rishiraj38 avatar Apr 05 '26 08:04 rishiraj38

Please take a look at copilot suggestions.

@rishiraj38 i addressed all Copilot comments

Manishnemade12 avatar Apr 05 '26 13:04 Manishnemade12