Skip to content

Wire the contact form to the API contact endpoint - #17

Merged
amrtgaber merged 1 commit into
mainfrom
contact-form-wiring
Jul 21, 2026
Merged

Wire the contact form to the API contact endpoint#17
amrtgaber merged 1 commit into
mainfrom
contact-form-wiring

Conversation

@amrtgaber

Copy link
Copy Markdown
Contributor

Summary

The contact form previously ran e.preventDefault() + setSubmitted(true) — a success card with no request. This wires it to the API's new POST /contact (api PR #18).

  • First real use of the template's orval flow: pnpm generate-api output committed under src/api/generated (typed React Query hooks, zod schemas, MSW mocks), with @faker-js/faker added as a dev dependency for the generated mocks.
  • The page submits via the generated useSubmitContactContactPost mutation through the existing ky client (VITE_API_URL base), with honest states: pending disables the button ("Sending..."), failure renders a role="alert" error line, and the thank-you card appears only after a 202.
  • Hidden website honeypot field (off-screen, tabIndex=-1, aria-hidden) matching the API's bot-drop behavior; minLength={10} on the message to mirror API validation.

Testing

  • Vitest suite and tsc -b/vite build pass.
  • Verified in a real browser against a locally-running API: failure path (API unconfigured → error alert, no fake success) and success path (real Resend send to the provider's test inbox → thank-you card).

The form previously showed a success card without sending anything.

- Generate the orval API client for the first time (pnpm generate-api):
  typed React Query hooks, zod schemas, and MSW mocks under
  src/api/generated; add @faker-js/faker (dev) which the generated
  mocks import
- Contact page submits through useSubmitContactContactPost with real
  states: button disables to "Sending..." while pending, a role=alert
  error line renders on failure, and the thank-you card only appears
  after the API accepts the message
- Add the hidden honeypot field (website) the API uses to drop bot
  submissions, and minLength on the message field matching the API's
  validation
@netlify

netlify Bot commented Jul 21, 2026

Copy link
Copy Markdown

Deploy Preview for treepolitics-web ready!

Name Link
🔨 Latest commit d6ab716
🔍 Latest deploy log https://app.netlify.com/projects/treepolitics-web/deploys/6a5ecbddc13f160008bac61e
😎 Deploy Preview https://deploy-preview-17--treepolitics-web.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@amrtgaber
amrtgaber merged commit 9ec5fb7 into main Jul 21, 2026
6 checks passed
@amrtgaber
amrtgaber deleted the contact-form-wiring branch July 21, 2026 02:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant