Redesign Modern/Tijdreis, contactformulier via CMS, taalbestanden #17

Merged
Sluijsens merged 48 commits from feature/redesign-modern-timetravel into master 2026-11-16 11:51:47 +01:00
5 changed files with 96 additions and 0 deletions
Showing only changes of commit 7da6d98a15 - Show all commits
@@ -7,6 +7,7 @@ import {
type SubjectOption,
type TokenResult,
} from '../../../cms-client/contact';
import { contactMessages } from '../../../i18n/cmsClientMessages';
import { trackEvent } from '../../../shared/analytics/trackEvent';
import { useContactPreselect } from '../../../shared/contact/useContactPreselect';
import { buildSubjectOptions, subjectForSlug } from '../../../shared/contact/subjects';
@@ -62,6 +63,7 @@ export function ContactFormView({ client, token, refreshToken }: ContactFormView
const form = useContactForm({
idPrefix: 'contact',
messages: contactMessages,
subjectOptions,
preselect: { subject: subjectForSlug(packages, preselect.subject), key: preselect.key },
initialSubject: subjectForSlug(packages, preselect.subject),
+16
View File
@@ -0,0 +1,16 @@
import { describe, expect, it } from 'vitest';
import { messagesNl } from '../cms-client/contact/messages.nl';
import { contactMessages } from './cmsClientMessages';
describe('cms-client contact texts from the language file', () => {
it('match the package defaults exactly', () => {
expect(contactMessages.fieldErrors).toEqual(messagesNl.fieldErrors);
expect(contactMessages.fallbackFieldError).toBe(messagesNl.fallbackFieldError);
expect(contactMessages.tooLarge).toBe(messagesNl.tooLarge);
expect(contactMessages.captchaRequired).toBe(messagesNl.captchaRequired);
expect(contactMessages.sendingLabel).toBe(messagesNl.sendingLabel);
expect(contactMessages.rateLimited(1)).toBe(messagesNl.rateLimited(1));
expect(contactMessages.rateLimited(5)).toBe(messagesNl.rateLimited(5));
expect(contactMessages.failed('info@example.nl')).toBe(messagesNl.failed('info@example.nl'));
});
});
+41
View File
@@ -0,0 +1,41 @@
import type { ContactMessages } from '../cms-client/contact/messages.nl';
import { t } from './index';
/**
* Texts of the cms-client package, taken from the site language file (block `cmsClient`:
* package -> component -> texts). The package keeps its own Dutch defaults (messages.nl.ts) as a
* fallback for sites that pass nothing; this site overrides them with the texts below.
*/
export const contactMessages: ContactMessages = {
fieldErrors: {
name: {
required: t('cmsClient.contact.fieldErrors.name.required'),
tooLong: t('cmsClient.contact.fieldErrors.name.tooLong'),
invalid: t('cmsClient.contact.fieldErrors.name.invalid'),
},
email: {
required: t('cmsClient.contact.fieldErrors.email.required'),
tooLong: t('cmsClient.contact.fieldErrors.email.tooLong'),
invalid: t('cmsClient.contact.fieldErrors.email.invalid'),
},
subject: {
required: t('cmsClient.contact.fieldErrors.subject.required'),
tooLong: t('cmsClient.contact.fieldErrors.subject.tooLong'),
invalid: t('cmsClient.contact.fieldErrors.subject.invalid'),
},
message: {
required: t('cmsClient.contact.fieldErrors.message.required'),
tooLong: t('cmsClient.contact.fieldErrors.message.tooLong'),
invalid: t('cmsClient.contact.fieldErrors.message.invalid'),
},
},
fallbackFieldError: t('cmsClient.contact.fallbackFieldError'),
rateLimited: (minutes) =>
minutes === 1
? t('cmsClient.contact.rateLimited.one', { minutes })
: t('cmsClient.contact.rateLimited.other', { minutes }),
tooLarge: t('cmsClient.contact.tooLarge'),
captchaRequired: t('cmsClient.contact.captchaRequired'),
failed: (address) => t('cmsClient.contact.failed', { address }),
sendingLabel: t('cmsClient.contact.sendingLabel'),
};
+35
View File
@@ -196,5 +196,40 @@
"subjectPlaceholder": "-- KIES --",
"honeypot": "Laat dit veld leeg"
}
},
"cmsClient": {
"contact": {
"fieldErrors": {
"name": {
"required": "Vul je naam in.",
"tooLong": "De naam is te lang.",
"invalid": "Deze naam is ongeldig."
},
"email": {
"required": "Vul je e-mailadres in.",
"tooLong": "Het e-mailadres is te lang.",
"invalid": "Dit e-mailadres is ongeldig."
},
"subject": {
"required": "Kies een onderwerp.",
"tooLong": "Dit onderwerp is te lang.",
"invalid": "Kies een onderwerp."
},
"message": {
"required": "Schrijf hier je vraag.",
"tooLong": "Het bericht is te lang.",
"invalid": "Dit bericht bevat ongeldige tekens."
}
},
"fallbackFieldError": "Controleer dit veld.",
"rateLimited": {
"one": "Je hebt net al een bericht gestuurd. Probeer het over {minutes} minuut opnieuw.",
"other": "Je hebt net al een bericht gestuurd. Probeer het over {minutes} minuten opnieuw."
},
"tooLarge": "Je bericht is te groot.",
"captchaRequired": "Bevestig eerst dat je geen robot bent.",
"failed": "Versturen lukte niet. Probeer het later nog eens of mail naar {address}.",
"sendingLabel": "Versturen…"
}
}
}
+2
View File
@@ -10,6 +10,7 @@ import {
import { contactForm, contactInfo } from '../../features/landing/data/content';
import { usePackagesQuery } from '../../features/landing/hooks/usePackagesQuery';
import { t } from '../../i18n';
import { contactMessages } from '../../i18n/cmsClientMessages';
import { trackEvent } from '../../shared/analytics/trackEvent';
import { useContactPreselect } from '../../shared/contact/useContactPreselect';
import { buildSubjectOptions, subjectForSlug } from '../../shared/contact/subjects';
@@ -65,6 +66,7 @@ export function TerminalForm({ client, token, refreshToken }: TerminalFormProps)
const form = useContactForm({
idPrefix: 'contact',
messages: contactMessages,
subjectOptions,
preselect: { subject: subjectForSlug(packages, preselect.subject), key: preselect.key },
initialSubject: subjectForSlug(packages, preselect.subject),