Skip to content

Commit

Permalink
fix years and months calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
T-Damer committed Mar 28, 2024
1 parent a8aafe0 commit 45bc4dd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/components/CreatePatientCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ function AddPatientForm() {
</label>
<div className="flex w-full items-center justify-between">
<button
className="btn transition-all disabled:opacity-70 disabled:text-black hover:bg-red-300 border-0 w-28"
className="btn transition-all disabled:opacity-70hover:bg-red-300 border-0 w-28"
onClick={clearData}
disabled={!fullName && !birthDate}
>
Clear
</button>

<button
className="btn w-28 transition-all disabled:opacity-70 disabled:text-black enabled:bg-green-700 enabled:border-0 enabled:text-white hover:enabled:bg-green-500"
className="btn w-28 transition-all disabled:opacity-70 enabled:bg-green-700 enabled:border-0 enabled:text-white hover:enabled:bg-green-500"
onClick={onSubmit}
disabled={disabled}
>
Expand Down
5 changes: 3 additions & 2 deletions src/screens/DetailsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ export default function ({ name }: { name: string }) {
const today = new Date()
const birth = new Date(birthDate)

const years = today.getFullYear() - birth.getFullYear()
const months = today.getMonth() - birth.getMonth()
const yearsWithMonths = daysFromBirth / 365
const years = Math.floor(yearsWithMonths)
const months = Math.floor((yearsWithMonths - years) * 12)

const deleteEntry = useCallback(() => {
if (!patientsData[name]) return
Expand Down

0 comments on commit 45bc4dd

Please sign in to comment.