From a596d2f5ad4f11fb8b29ae9673df26278f9edbb6 Mon Sep 17 00:00:00 2001 From: totregex Date: Thu, 9 Jan 2025 06:02:03 +0530 Subject: [PATCH] fix negative age --- src/components/Patient/PatientRegistration.tsx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/components/Patient/PatientRegistration.tsx b/src/components/Patient/PatientRegistration.tsx index 94289124403..91d624898a3 100644 --- a/src/components/Patient/PatientRegistration.tsx +++ b/src/components/Patient/PatientRegistration.tsx @@ -468,7 +468,6 @@ export default function PatientRegistration( ))} -
+ onChange={(e) => { + const age = Math.max(0, Number(e.target.value)); setForm((f) => ({ ...f, - age: e.target.value, - year_of_birth: e.target.value - ? new Date().getFullYear() - Number(e.target.value) + age: String(age), + year_of_birth: age + ? new Date().getFullYear() - age : undefined, - })) - } + })); + }} type="number" />