From 66dbb3d29f8506386cd7652c84ab69e838a770d0 Mon Sep 17 00:00:00 2001 From: Nadav Nir Date: Tue, 16 Jun 2026 20:46:52 +0200 Subject: [PATCH] feat: add phone field to agent registration form Adds a required phone input to AccountStep after confirmPassword, validates minimum 7 chars, and sends phone in person object on POST /user. Closes https://github.com/need4deed-org/fe/issues/676 Co-Authored-By: Claude Sonnet 4.6 --- public/locales/de/translations.json | 2 ++ public/locales/en/translations.json | 2 ++ .../AgentRegistration/AgentRegistration.tsx | 1 + src/components/AgentRegistration/helpers.ts | 2 ++ .../AgentRegistration/steps/AccountStep.tsx | 11 +++++++++++ src/components/AgentRegistration/types.ts | 2 ++ 6 files changed, 20 insertions(+) diff --git a/public/locales/de/translations.json b/public/locales/de/translations.json index 42e6fdd5..2128b848 100644 --- a/public/locales/de/translations.json +++ b/public/locales/de/translations.json @@ -1905,6 +1905,7 @@ "email": "E-Mail-Adresse", "password": "Passwort", "confirmPassword": "Passwort bestätigen", + "phone": "Telefonnummer", "organizationName": "Name der Organisation", "organizationType": "Art der Organisation", "selectOrganizationType": "Typ auswählen…", @@ -1921,6 +1922,7 @@ "errors": { "passwordTooShort": "Das Passwort muss mindestens 8 Zeichen lang sein", "passwordMismatch": "Die Passwörter stimmen nicht überein", + "phoneTooShort": "Die Telefonnummer muss mindestens 7 Zeichen lang sein", "emailDomainNotAllowed": "Ihre E-Mail-Domain ist nicht auf unserer genehmigten NGO-Liste. Bitte verwenden Sie die E-Mail-Adresse Ihrer Organisation.", "missingToken": "Dein Registrierungslink ist ungültig oder abgelaufen. Bitte verwende den Link aus deiner Bestätigungs-E-Mail." }, diff --git a/public/locales/en/translations.json b/public/locales/en/translations.json index e5945cee..57a336e6 100644 --- a/public/locales/en/translations.json +++ b/public/locales/en/translations.json @@ -1537,6 +1537,7 @@ "email": "Email address", "password": "Password", "confirmPassword": "Confirm password", + "phone": "Phone number", "organizationName": "Organisation name", "organizationType": "Organisation type", "selectOrganizationType": "Select type…", @@ -1553,6 +1554,7 @@ "errors": { "passwordTooShort": "Password must be at least 8 characters", "passwordMismatch": "Passwords do not match", + "phoneTooShort": "Phone number must be at least 7 characters", "emailDomainNotAllowed": "Your email domain is not on our approved NGO list. Please use your organisation email address.", "missingToken": "Your registration link is invalid or has expired. Please use the link from your verification email." }, diff --git a/src/components/AgentRegistration/AgentRegistration.tsx b/src/components/AgentRegistration/AgentRegistration.tsx index f34f7e46..78e6111b 100644 --- a/src/components/AgentRegistration/AgentRegistration.tsx +++ b/src/components/AgentRegistration/AgentRegistration.tsx @@ -68,6 +68,7 @@ export function AgentRegistration() { person: { firstName: formData.firstName, lastName: formData.lastName, + phone: formData.phone, }, }); diff --git a/src/components/AgentRegistration/helpers.ts b/src/components/AgentRegistration/helpers.ts index 34043db9..6deca269 100644 --- a/src/components/AgentRegistration/helpers.ts +++ b/src/components/AgentRegistration/helpers.ts @@ -45,6 +45,8 @@ export function validateStep( if (!data.confirmPassword) errors.confirmPassword = required; else if (data.password !== data.confirmPassword) errors.confirmPassword = t("agentRegistration.errors.passwordMismatch"); + if (!data.phone.trim()) errors.phone = required; + else if (data.phone.trim().length < 7) errors.phone = t("agentRegistration.errors.phoneTooShort"); } return errors; diff --git a/src/components/AgentRegistration/steps/AccountStep.tsx b/src/components/AgentRegistration/steps/AccountStep.tsx index 8fe0c14f..e35e5f22 100644 --- a/src/components/AgentRegistration/steps/AccountStep.tsx +++ b/src/components/AgentRegistration/steps/AccountStep.tsx @@ -70,6 +70,17 @@ export function AccountStep({ data, onChange, errors }: Props) { errors={errors.confirmPassword ? [errors.confirmPassword] : []} /> + + + {t("agentRegistration.fields.phone")} + onChange({ phone: v })} + placeHolder={t("agentRegistration.fields.phone")} + errors={errors.phone ? [errors.phone] : []} + /> + ); } diff --git a/src/components/AgentRegistration/types.ts b/src/components/AgentRegistration/types.ts index 7e52b605..51e3d04e 100644 --- a/src/components/AgentRegistration/types.ts +++ b/src/components/AgentRegistration/types.ts @@ -6,6 +6,7 @@ export interface AgentRegistrationData { email: string; password: string; confirmPassword: string; + phone: string; } export const defaultAgentRegistrationData: AgentRegistrationData = { @@ -14,6 +15,7 @@ export const defaultAgentRegistrationData: AgentRegistrationData = { email: "", password: "", confirmPassword: "", + phone: "", }; export const TOTAL_STEPS = 1;