From 412286ecf0f9e1fb52cf4a5331d833fd176eef35 Mon Sep 17 00:00:00 2001 From: sriharsh05 Date: Sun, 4 Feb 2024 10:43:00 +0530 Subject: [PATCH] add max validation for doctor experience in user profile page --- src/Components/Users/UserAdd.tsx | 3 +-- src/Components/Users/UserProfile.tsx | 13 ++++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/Components/Users/UserAdd.tsx b/src/Components/Users/UserAdd.tsx index 4c63868b19e..b3fc9b830f8 100644 --- a/src/Components/Users/UserAdd.tsx +++ b/src/Components/Users/UserAdd.tsx @@ -366,8 +366,7 @@ export const UserAdd = (props: UserProps) => { state.form.user_type === "Doctor" && Number(state.form.doctor_experience_commenced_on) > 100 ) { - errors["doctor_experience_commenced_on"] = - "Doctor experience should be less than 100 years"; + errors[field] = "Doctor experience should be less than 100 years"; invalidForm = true; } return; diff --git a/src/Components/Users/UserProfile.tsx b/src/Components/Users/UserProfile.tsx index 170de558e41..767fc9b73b8 100644 --- a/src/Components/Users/UserProfile.tsx +++ b/src/Components/Users/UserProfile.tsx @@ -244,8 +244,19 @@ export default function UserProfile() { invalidForm = true; } return; - case "doctor_qualification": case "doctor_experience_commenced_on": + if (states.form.user_type === "Doctor" && !states.form[field]) { + errors[field] = "Field is required"; + invalidForm = true; + } else if ( + states.form.user_type === "Doctor" && + Number(states.form.doctor_experience_commenced_on) > 100 + ) { + errors[field] = "Doctor experience should be less than 100 years"; + invalidForm = true; + } + return; + case "doctor_qualification": case "doctor_medical_council_registration": if (states.form.user_type === "Doctor" && !states.form[field]) { errors[field] = "Field is required";