From 2fea710998d14025ed880bb0daf5a43462c5cfd1 Mon Sep 17 00:00:00 2001 From: vgeffer Date: Sat, 11 Nov 2023 21:39:06 +0100 Subject: [PATCH] feat(reg, user): changed phone number format submitted to server --- src/components/Profile/ProfileForm.tsx | 6 +++--- src/components/RegisterForm/RegisterForm.tsx | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/components/Profile/ProfileForm.tsx b/src/components/Profile/ProfileForm.tsx index 73e78afb..de004b03 100644 --- a/src/components/Profile/ProfileForm.tsx +++ b/src/components/Profile/ProfileForm.tsx @@ -78,8 +78,8 @@ export const ProfileForm: FC = () => { first_name: data.first_name, last_name: data.last_name, school: data.school?.id, - phone: data.phone, - parent_phone: data.parent_phone, + phone: data.phone?.replaceAll(/\s+/gu, ''), + parent_phone: data.parent_phone?.replaceAll(/\s+/gu, ''), grade: data.grade, }, new_school_description: data.new_school_description || '', @@ -100,7 +100,7 @@ export const ProfileForm: FC = () => { const phoneRule = { validate: (val?: string) => { if (val && !/^(\+\d{10,12})$/u.test(val.replaceAll(/\s+/gu, ''))) - return '* Zadaj telefónne číslo vo formáte validnom formáte +421 123 456 789 alebo +421123456789.' + return '* Zadaj telefónne číslo vo formáte +421 123 456 789 alebo +421123456789.' }, } return ( diff --git a/src/components/RegisterForm/RegisterForm.tsx b/src/components/RegisterForm/RegisterForm.tsx index 90bdc2fc..437555fd 100644 --- a/src/components/RegisterForm/RegisterForm.tsx +++ b/src/components/RegisterForm/RegisterForm.tsx @@ -65,8 +65,8 @@ export const RegisterForm: FC = () => { first_name: data.first_name, last_name: data.last_name, school: data.school?.id, - phone: data.phone, - parent_phone: data.parent_phone, + phone: data.phone?.replaceAll(/\s+/gu, ''), + parent_phone: data.parent_phone?.replaceAll(/\s+/gu, ''), gdpr: data.gdpr, grade: data.grade, }, @@ -88,7 +88,7 @@ export const RegisterForm: FC = () => { const phoneRule = { validate: (val?: string) => { if (val && !/^(\+\d{10,12})$/u.test(val.replaceAll(/\s+/gu, ''))) - return '* Zadaj telefónne číslo vo formáte validnom formáte +421 123 456 789 alebo +421123456789.' + return '* Zadaj telefónne číslo vo formáte +421 123 456 789 alebo +421123456789.' }, } return (