Skip to content

Commit

Permalink
fix negative age
Browse files Browse the repository at this point in the history
  • Loading branch information
rajku-dev committed Jan 9, 2025
1 parent 27e1e0d commit a596d2f
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/components/Patient/PatientRegistration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,6 @@ export default function PatientRegistration(
</div>
))}
</div>

<br />
<Tabs
value={ageDob}
Expand Down Expand Up @@ -570,15 +569,16 @@ export default function PatientRegistration(
</Label>
<Input
value={form.age ? form.age : undefined}
onChange={(e) =>
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"
/>
<div className="mt-1" data-input-error>
Expand Down

0 comments on commit a596d2f

Please sign in to comment.