From 2353f3be2e6ea40f75bb252d8c231dce6485239e Mon Sep 17 00:00:00 2001 From: Ashesh3 <3626859+Ashesh3@users.noreply.github.com> Date: Fri, 12 Jan 2024 16:28:20 +0530 Subject: [PATCH] Update weekly_working_hours to allow null value --- src/Components/Users/UserProfile.tsx | 23 ++++++++++++----------- src/Components/Users/models.tsx | 2 +- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/Components/Users/UserProfile.tsx b/src/Components/Users/UserProfile.tsx index 1fcc8fb385e..170de558e41 100644 --- a/src/Components/Users/UserProfile.tsx +++ b/src/Components/Users/UserProfile.tsx @@ -34,7 +34,7 @@ type EditForm = { doctor_qualification: string | undefined; doctor_experience_commenced_on: number | string | undefined; doctor_medical_council_registration: string | undefined; - weekly_working_hours: string | undefined; + weekly_working_hours: string | null; }; type ErrorForm = { firstName: string; @@ -253,13 +253,11 @@ export default function UserProfile() { } return; case "weekly_working_hours": - if (!states.form[field]) { - errors[field] = "This field is required"; - invalidForm = true; - } else if ( - Number(states.form[field]) < 0 || - Number(states.form[field]) > 168 || - !/^\d+$/.test(states.form[field] ?? "") + if ( + states.form[field] && + (Number(states.form[field]) < 0 || + Number(states.form[field]) > 168 || + !/^\d+$/.test(states.form[field] ?? "")) ) { errors[field] = "Average weekly working hours must be a number between 0 and 168"; @@ -331,7 +329,11 @@ export default function UserProfile() { states.form.user_type === "Doctor" ? states.form.doctor_medical_council_registration : undefined, - weekly_working_hours: states.form.weekly_working_hours, + weekly_working_hours: + states.form.weekly_working_hours && + states.form.weekly_working_hours !== "" + ? states.form.weekly_working_hours + : null, }; const { res } = await request(routes.partialUpdateUser, { pathParams: { username: authUser.username }, @@ -588,7 +590,7 @@ export default function UserProfile() { Average weekly working hours