feat(forms): builder UI, management pages, and public fill page (Phase 3)

- components/forms/form-renderer.tsx: one controlled renderer for all 8
  field types, shared by the builder preview and the public page
- components/forms/form-builder.tsx: easy builder — label-only field
  creation (keys auto-derived and de-duped at save), one-click type
  buttons, up/down reordering, inline options editor, live preview;
  edit mode adds publish/close/draft/delete and copy-public-link
- /forms directory, /forms/new, /forms/[id]/edit, /forms/[id]/results
  (CSV download). Server-gated by lib/forms-guard.ts (forms.manage via
  the same RPC the RLS uses; RLS remains the real boundary)
- public app/f/[slug] (outside the app group): getPublicForm serves
  only published public forms — members-only forms are never exposed
  there; waiver consent, anon email capture, signed-in gate for
  public_auth, thank-you state
- sidebar "Forms & waivers" link; sonner toasts (codebase convention)
- ARCHITECTURE + HANDOFF updated

285/285 tests, build clean, all four routes compiled. No deploy.
This commit is contained in:
Moheeb Zara
2026-05-16 15:03:48 -07:00
parent 897fa30ec1
commit 03bb3a7466
16 changed files with 1182 additions and 8 deletions
+4 -3
View File
@@ -422,9 +422,10 @@ forms + waivers).
### Forms & waivers (migration 026 — Phase 1: schema + RLS)
`forms` and `form_submissions` back a custom form/waiver builder. Phase 1 is
schema + RLS only; server actions, the builder UI, the public `/f/[slug]` page,
onboarding integration, and retro-linking are later phases. Security shape:
`forms` and `form_submissions` back a custom form/waiver builder. Phases 1-3
are done (schema + RLS; server actions in `lib/actions/forms.ts`; the builder
UI under `/forms` + the public `/f/[slug]` page). Onboarding integration and
automatic retro-linking are Phases 4-5. Security shape:
all submissions (anonymous, public-authenticated, or members) are written by a
single validated server action using the service client AFTER server-side
schema validation and snapshotting (same pattern as `finishOnboarding`); the