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>
2.0 KiB
2.0 KiB
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:reactand files insidesrc/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.mdand the CMS fileopenapi/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 }(apiEndpointisglobaloreu, defaultglobal).useContactFormreturnscaptcha,captchaRequired,captchaToken,setCaptchaToken(token | null)andcaptchaResetCount. The package renders no widget: the site mounts the provider widget client-side, callssetCaptchaToken(response)when solved andsetCaptchaToken(null)when it expires or fails, and resets the widget whenevercaptchaResetCountchanges (a response can be used once). - With captcha required, submit sends nothing until a response is set and shows
messages.captchaRequired; the payload then carriescaptchaToken. Without captcha the field is omitted. initialSubject(option ofuseContactForm) applies a subject chosen before the form was mounted, as soon as it exists insubjectOptionsand 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.