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:
@@ -1,6 +1,4 @@
|
||||
import fc from 'fast-check';
|
||||
import type { ContactField, ContactValues } from '../contact/types';
|
||||
import type { ContactFormEvent } from '../lib/contactFormReducer';
|
||||
import type { LightboxEvent } from '../lib/lightboxReducer';
|
||||
import { shootPageView, type ShootPageView } from '../lib/shootPageView';
|
||||
import type { Point } from '../lib/swipeDirection';
|
||||
@@ -339,77 +337,6 @@ export const anyTestimonial: fc.Arbitrary<Testimonial> = fc.oneof(
|
||||
),
|
||||
);
|
||||
|
||||
// Shoot values as the form offers them for the live packages
|
||||
const shootValue = fc.constantFrom(
|
||||
'zwangerschap',
|
||||
'newborn',
|
||||
'gezin',
|
||||
'overig',
|
||||
);
|
||||
|
||||
// Values that pass every rule: realistic text within the limits
|
||||
export const contactValues: fc.Arbitrary<ContactValues> = fc.record({
|
||||
naam: nonBlank,
|
||||
email: validEmail.map(({ user, domain }) => `${user}@${domain}`),
|
||||
shoot: shootValue,
|
||||
bericht: fc
|
||||
.string({ minLength: 1, maxLength: 300 })
|
||||
.filter((text) => text.trim() !== ''),
|
||||
});
|
||||
|
||||
// Valid and broken values mixed: empty, whitespace, too long, bad e-mail
|
||||
export const anyContactValues: fc.Arbitrary<ContactValues> = fc.oneof(
|
||||
contactValues,
|
||||
fc.record({
|
||||
naam: fc.oneof(nonBlank, fc.constantFrom('', ' ', 'x'.repeat(101))),
|
||||
email: fc.oneof(
|
||||
validEmail.map(({ user, domain }) => `${user}@${domain}`),
|
||||
fc.constantFrom(
|
||||
'',
|
||||
'geen-adres',
|
||||
'a@b',
|
||||
'a b@c.nl',
|
||||
'x'.repeat(255),
|
||||
),
|
||||
fc.string({ maxLength: 20 }),
|
||||
),
|
||||
shoot: fc.oneof(shootValue, fc.constantFrom('', 'bruiloft')),
|
||||
bericht: fc.oneof(
|
||||
nonBlank,
|
||||
fc.constantFrom('', ' ', 'x'.repeat(2001)),
|
||||
),
|
||||
}),
|
||||
);
|
||||
|
||||
const contactField = fc.constantFrom<ContactField>(
|
||||
'naam',
|
||||
'email',
|
||||
'shoot',
|
||||
'bericht',
|
||||
);
|
||||
|
||||
// Anything that can happen to the form, for the state machine test
|
||||
export const contactEvent: fc.Arbitrary<ContactFormEvent> = fc.oneof(
|
||||
fc.record({
|
||||
type: fc.constant('edit' as const),
|
||||
field: contactField,
|
||||
value: fc.oneof(
|
||||
nonBlank,
|
||||
fc.constantFrom('', 'a@b.nl', 'newborn', 'overig'),
|
||||
),
|
||||
}),
|
||||
fc.record({ type: fc.constant('blur' as const), field: contactField }),
|
||||
fc.record({ type: fc.constant('preselect' as const), shoot: shootValue }),
|
||||
fc.record({
|
||||
type: fc.constant('submit' as const),
|
||||
honeypot: fc.constantFrom('', '', '', 'http://spam.example'),
|
||||
shownAt: fc.constant(0),
|
||||
now: fc.constantFrom(500, 5000, 10000),
|
||||
}),
|
||||
fc.constant({ type: 'resolved' as const }),
|
||||
fc.constant({ type: 'rejected' as const }),
|
||||
);
|
||||
|
||||
// --- Gallery (portfolio) ---
|
||||
|
||||
// A touch position on a screen, in CSS pixels
|
||||
|
||||
Reference in New Issue
Block a user