Auth forms on TanStack Form v2 #410
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
spec
wayfinder:grilling
wayfinder:map
wayfinder:prototype
wayfinder:research
wayfinder:task
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
amaurycoudr/chess-project#410
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem Statement
The front's forms are hand-rolled, and the largest ones show it:
useStateper field and validate by hand at submit.Source: the front audit,
docs/research/front-audit.md, sections 2.2 and 2.2.1. The owner chose TanStack Form v2, on the alpha, now (section 5).Solution
Every auth form runs on TanStack Form v2. The design-system input and the form's refusal and submit button are bound once. Contract schemas and our refusal mapping stay the source of truth for what is valid and what the Player reads. A Player sees the same forms, the same checks and the same messages as today.
User Stories
Seams
apps/e2eaccounts.spec(e2e, existing). Covers sign-up and sign-in in a real browser; it stays green unchanged. No new e2e test: no new behaviour.Implementation Decisions
@tanstack/react-formpinned to an exact 2.0.0 alpha (2.0.0-alpha.2, or the latest alpha after reading its release notes and the issues below).lateston npm is still 1.x.lib/, built withcreateFormHook: a text field component bound once throughgetFormHookHelpers().fieldComponent.strict, taking thefieldas a prop; a refusal line and a submit button as form components. Allowed by the rules spec (review rule 4 exemption,@/lib/formin components).{ run, triggers }) that call the existing credential checks and return our refusal unions. Not a zod schema passed directly: zod's issue messages are English, and ADR 0025 wants catalogue copy. The contract schemas stay the source of what is valid (ADR 0040).onSubmitawaits the mutation, maps the refusal code (and the rate limit) to form and field errors, and returns them withcreateValidationError({ form, fields }), never throws: a throw is caught and only logged in alpha.2, and issue #2306 will change that.isPendingdrives the button (v2 has no submit meta yet, issue #2303);aria-disabledrather thandisabled, per the Form docs.Testing Decisions
sign-up.test.tsx,sign-in.test.tsx,forgot-password.test.tsx,reset-password.test.tsx,account-page.test.tsx;accounts.spec.tsinapps/e2e.Out of Scope
Fieldcomponent.Further Notes
docs/research/front-audit.md, section 2.2.1, on branchclaude/nestjs-best-practices-audit-716d79.alphabranch is ahead of alpha.2 (e.g.schemaOutputsrenamedvalidatorOutputs); v2 docs: https://tanstack.com/form/alpha/docs/framework/react/quick-start.marked this issue as related to #408
mentioned in issue #408
mentioned in issue #418
marked this issue as related to #418
mentioned in issue #419
marked this issue as related to #419
mentioned in issue #420
marked this issue as related to #420
mentioned in merge request !533
mentioned in merge request !543