Terms of Service checkbox on the signup form

React · React · beginner · modification

Legal asked for an explicit Terms of Service and Privacy Policy acceptance at signup. `src/signup/SignupForm.jsx` adds an `agreed` state and a checkbox whose label links to both documents (opening in a new tab), includes the box's state in the signup as `acceptedTerms`, and takes it into account when deciding whether Create account is enabled. `src/signup/SignupForm.css` lays the checkbox and its label out side by side. `src/signup/SignupForm.test.jsx` updates the existing tests to tick the box and adds one that checks the payload sent to `onSubmit`.

Marketing-site signup on React 18.3 (Vite, function components). Tests run with `npm test`: Vitest 2 with @testing-library/react 16 in jsdom. Existing and unchanged: `SignupPage.jsx` renders `<SignupForm onSubmit={signup} />`. `signup(values)` POSTs `values` as the JSON body of `/api/signup` and resolves once the API has created the account and emailed a sign-in link (the page then navigates to `/check-email` itself, which can unmount the form); it rejects with an `Error` on any failure, including the API's 400 for an empty or malformed email. The API stores `acceptedTerms` with the request time as the user's consent record and creates the account whatever its value: it does not check the flag (a server-side check is a separate ticket), so the form is the only gate. `/terms` and `/privacy` are static pages of the same site.

Requirements

Files touched

Review this PR

React practice