# Frontend Components — contact-form (U4) ## Component hierarchy ```mermaid graph TD cs[ContactSection] --> cp[ContactPanel] cp --> ma[MailtoPanel] cp --> fv[ContactFormView] fv --> fld[Field components] fv --> hp[Honeypot] fv --> pn[PrivacyNote] fv --> sm[StatusMessages] cp -.uses.-> av[useContactAvailability] fv -.uses.-> uf[useContactForm] uf -.uses.-> cl[createContactClient] cp -.uses.-> pre[useContactPreselect] cp -.uses.-> pq[usePackagesQuery] cl --> api[(contact-messages API)] classDef page fill:#2196F3,stroke:#0d47a1,color:#000; classDef ui fill:#4CAF50,stroke:#2e7d32,color:#000; classDef hook fill:#9C27B0,stroke:#4a148c,color:#000; classDef ext fill:#F44336,stroke:#b71c1c,color:#000; class cs page; class cp,ma,fv,fld,hp,pn,sm ui; class av,uf,cl,pre,pq hook; class api ext; ``` Text alternative: the contact section shows a panel that is either the mailto panel or the form; the form uses the headless hook and client, the preselect context and the offerings for subject options. ## Components and hooks | Unit | Props / state | |---|---| | `ContactPanel` | decides between `MailtoPanel` and `ContactFormView` from `useContactAvailability`; keeps `data-testid="contact-panel"` | | `MailtoPanel` | the U2 content (mailto button) with address assembled after mount | | `ContactFormView` | `subjectOptions`, `preselect`, `token source`; renders fields, honeypot, privacy sentence, submit button "Verstuur", status messages; B skin (panel colours, underline inputs on `bg-field`, brand submit button) | | `useContactAvailability(sectionRef)` | `'unknown' \| 'open' \| 'closed'` plus the token; IntersectionObserver trigger; never fetches during server/test render without observer support (falls back to first focus) | | `useContactForm(options)` (headless) | per `component-methods.md`: values, errors, status, `getFieldProps`, `honeypot`, `formProps`, `retry`, `reset`, `focusFirstError`; options `idPrefix`, `subjectOptions`, `preselect`, `getToken`, `submit`, `messages`, `fallbackAddress` | | `createContactClient` | `getToken()`, `submit(payload, ctx)`; injectable `fetch`; uses `apiUrl()` | ## User interaction flows - Section scrolls near → token → form appears (or stays mailto). Fill → blur errors → submit → success or failure (with retry and mailto address). - Package CTA → preselect → subject set, scroll to contact. ## Form validation rules BR-U4-4 (same codes and limits as the API). ## API integration points `GET /api/v1/contact-messages/token`, `POST /api/v1/contact-messages` (headers `Idempotency-Key`), offerings query for subject options. ## Acceptance tests 1. Validation table and property tests; reducer invariants; serialization round trips (PBT). 2. Availability: 200 → form; 404/500/network/captcha → mailto panel; no fetch before the section nears the viewport. 3. Submit success (202), honeypot silent success without call, 400 field errors mapped, token expired → one refetch and repeat, 413, 429 with minutes, 5xx/network failure keeps input, retry reuses the idempotency key, reset renews it. 4. Preselect fills the subject; unknown value ignored; second click with the same package re-applies. 5. Accessibility: labels, `aria-invalid`/`aria-describedby`, focus on first error, `role=alert`, `role=status` + focus on success, honeypot hidden from AT, 44px targets. 6. No PII in console/Sentry/Umami calls (spy) during a full flow. 7. Boundary: lint rule forbids imports from `src/cms-client` to the app (rule test).