11import { BorrowDetail } from '@/lib/types/borrow'
22import { Card , CardContent , CardHeader , CardTitle } from '@/components/ui/card'
3- import { formatDate , isBorrowDue } from '@/lib/utils'
4- import { differenceInDays , formatDistanceToNowStrict } from 'date-fns'
3+ import { isBorrowDue } from '@/lib/utils'
4+ import { differenceInDays , format , formatDistanceToNowStrict } from 'date-fns'
55
66export const CardBorrow : React . FC < { borrow : BorrowDetail } > = ( { borrow } ) => {
77 const overduedDays = differenceInDays (
@@ -22,15 +22,15 @@ export const CardBorrow: React.FC<{ borrow: BorrowDetail }> = ({ borrow }) => {
2222 < div className = "grid grid-cols-3" >
2323 < dt className = "font-medium" > Borrowed At:</ dt >
2424 < dd className = "col-span-2" >
25- { formatDate ( borrow . borrowed_at ) }
25+ { format ( new Date ( borrow . borrowed_at ) , 'dd-M-yy hh:mm a' ) }
2626 { ! borrow . returning &&
2727 ` (${ formatDistanceToNowStrict ( new Date ( borrow . borrowed_at ) , { addSuffix : true } ) } )` }
2828 </ dd >
2929 </ div >
3030 < div className = "grid grid-cols-3" >
3131 < dt className = "font-medium" > Due At:</ dt >
3232 < dd className = "col-span-2" >
33- { formatDate ( borrow . due_at ) }
33+ { format ( new Date ( borrow . due_at ) , 'dd-M-yy hh:mm a' ) }
3434 { ! borrow . returning &&
3535 ` (${ formatDistanceToNowStrict ( new Date ( borrow . due_at ) , { addSuffix : true } ) } )` }
3636 </ dd >
@@ -41,7 +41,10 @@ export const CardBorrow: React.FC<{ borrow: BorrowDetail }> = ({ borrow }) => {
4141 < div className = "grid grid-cols-3" >
4242 < dt className = "font-medium" > Returned At:</ dt >
4343 < dd className = "col-span-2" >
44- { formatDate ( borrow . returning . returned_at ) }
44+ { format (
45+ new Date ( borrow . returning . returned_at ) ,
46+ 'dd-M-yy hh:mm a'
47+ ) }
4548 </ dd >
4649 </ div >
4750 < div className = "grid grid-cols-3" >
@@ -52,7 +55,7 @@ export const CardBorrow: React.FC<{ borrow: BorrowDetail }> = ({ borrow }) => {
5255 </ div >
5356 </ >
5457 ) }
55- { isBorrowDue ( borrow ) && (
58+ { isBorrowDue ( borrow ) && ! borrow . returning && (
5659 < div className = "grid grid-cols-3" >
5760 < dt className = "font-medium" > Fine:</ dt >
5861 < dd className = "col-span-2" > { fine ?? '-' } Pts</ dd >
0 commit comments