graph + mail dispatcher, test-email endpoint, notifications global
This commit is contained in:
+56
-1
@@ -146,6 +146,7 @@ type SubmitFormResult =
|
||||
| { success: false; reason: 'turnstile' }
|
||||
| { success: false; reason: 'validation'; field?: string; kind?: 'required' | 'too_long' | 'unknown_fields' }
|
||||
| { success: false; reason: 'not_found' }
|
||||
| { success: false; reason: 'consent'; field?: string }
|
||||
| { success: false; reason: 'error' }
|
||||
```
|
||||
|
||||
@@ -162,4 +163,58 @@ function errorMessage(r) {
|
||||
}
|
||||
```
|
||||
|
||||
Ten sam wzorzec co consent: plugin nie zaszywa języka, oddaje dane.
|
||||
Ten sam wzorzec co consent: plugin nie zaszywa języka, oddaje dane.
|
||||
|
||||
|
||||
## Zgoda RODO (consent field)
|
||||
|
||||
Pole zgody RODO to checkbox o nazwie `consent` (konfigurowalna przez
|
||||
`FormsOption.consentFieldName`). Plugin WYMUSZA jego zaznaczenie SERVER-SIDE —
|
||||
niezależnie od tego, jak redaktor ustawił pole w panelu.
|
||||
|
||||
### Dlaczego server-side
|
||||
|
||||
Zgoda egzekwowana jest w `validateSubmission`, nie flagą w panelu. To jedyne
|
||||
miejsce, którego redaktor nie osłabi (zapominając `required`) ani nie naruszy
|
||||
(ustawiając `defaultValue: true` — pre-zaznaczenie, którego RODO zabrania), a
|
||||
front nie obejdzie. Jeśli formularz ma pole `consent`, MUSI być zaznaczone,
|
||||
inaczej `submitForm` zwraca `reason: 'consent'`.
|
||||
|
||||
### Jak użyć
|
||||
|
||||
1. Redaktor dodaje w panelu checkbox o nazwie `consent`, label „Akceptuję
|
||||
politykę prywatności [link]" (link do polityki wpisuje w label — treść zgody
|
||||
należy do panelu).
|
||||
2. Plugin wymusza zaznaczenie. Niezaznaczony → `reason: 'consent'`.
|
||||
3. Komunikat z modułu notifications (`notifications.form.consent`, per język).
|
||||
|
||||
Zmiana nazwy pola:
|
||||
|
||||
```ts
|
||||
ipalKit({ forms: { consentFieldName: 'zgoda' } })
|
||||
```
|
||||
|
||||
## Komunikaty — resolveFormMessage (zalecane)
|
||||
|
||||
Zamiast ręcznego switcha po `reason`, użyj `resolveFormMessage` z modułu
|
||||
notifications — mapuje kod na tekst z panelu, per język, z interpolacją `{field}`:
|
||||
|
||||
```tsx
|
||||
import { resolveFormMessage, getNotificationTexts } from '@intecion/ipal-kit'
|
||||
|
||||
const notifications = await getNotificationTexts({ payload, locale })
|
||||
// w FormRenderer:
|
||||
if (!result.success) {
|
||||
setError(resolveFormMessage(result, notifications.form))
|
||||
}
|
||||
```
|
||||
|
||||
To obsługuje WSZYSTKIE kody (w tym `consent`, `rate_limited`, `validation` z
|
||||
`{field}`) tekstami z panelu. Ręczny switch (wyżej) zostaw tylko, jeśli nie
|
||||
używasz modułu notifications. Szczegóły: [notifications.md](./notifications.md).
|
||||
|
||||
## PUŁAPKA — pola captchy
|
||||
|
||||
Turnstile wstrzykuje ukryte pole `cf-turnstile-response`. Plugin je toleruje
|
||||
(nie odrzuca jako `unknown_fields`) — bo sam obsługuje Turnstile. Nie musisz go
|
||||
filtrować w kliencie.
|
||||
Reference in New Issue
Block a user