Connects the contact form to the CMS API through the cms-client package
Copies the headless cms-client package (SlpSoftware 93fa729) and builds the form on useContactForm: availability check when the form is in view (no request while switched off), the readable shoot label as subject, the Friendly Captcha widget as its own lazy chunk, trackEvent for contact-sent and contact-failed. Removes the old reducer, validation and submit stub. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
# cms-client (draft package)
|
||||
|
||||
Headless client for the SLP CMS API, written inside the SlpSoftware frontend first and meant to move to the SlpModularCms repository as the package `cms-client` (decision of the product owner, 2026-11-09).
|
||||
|
||||
- **Boundary**: nothing in this folder may import from the rest of the app (`features`, `components`, `shared`, `theme`, `utils`, ...); enforced by ESLint (`no-restricted-imports`) and a test. Allowed: `react` and files inside `src/cms-client`.
|
||||
- **Parts** (import only what a site uses): `contact/` (validation, reducer, client, `useContactForm`), `http/` (internal helpers). `offerings/` follows later.
|
||||
- **Contract**: see `aidlc-docs/features/redesign-modern-timetravel/inception/application-design/contact-api-contract.md` and the CMS file `openapi/slpsoftware.v1.json`.
|
||||
- **No markup, no styling**: sites render their own fields from `useContactForm().getFieldProps`.
|
||||
- **Privacy**: nothing here logs form values, tokens or idempotency keys.
|
||||
|
||||
## Captcha slot and initial subject
|
||||
|
||||
- The token response may carry `captcha: { provider, siteKey, apiEndpoint }` (`apiEndpoint` is `global` or `eu`, default `global`). `useContactForm` returns `captcha`, `captchaRequired`, `captchaToken`, `setCaptchaToken(token | null)` and `captchaResetCount`. The package renders no widget: the site mounts the provider widget client-side, calls `setCaptchaToken(response)` when solved and `setCaptchaToken(null)` when it expires or fails, and resets the widget whenever `captchaResetCount` changes (a response can be used once).
|
||||
- With captcha required, submit sends nothing until a response is set and shows `messages.captchaRequired`; the payload then carries `captchaToken`. Without captcha the field is omitted.
|
||||
- `initialSubject` (option of `useContactForm`) applies a subject chosen before the form was mounted, as soon as it exists in `subjectOptions` and unless the visitor already picked one. Unknown values are ignored.
|
||||
- Subject values are the readable labels (they appear in the mail and the CMS message list); a site keeps its own ids only for links/preselect.
|
||||
Reference in New Issue
Block a user