@@ -10,17 +10,27 @@ import Link from 'next/link'
1010import { Verify } from '@/lib/firebase/firebase'
1111import { getBorrow } from '@/lib/api/borrow'
1212import { Badge } from '@/components/ui/badge'
13- import { formatDate , getBorrowStatus , isBorrowDue } from '@/lib/utils'
13+ import {
14+ formatDate ,
15+ getBorrowStatus ,
16+ getSubscriptionStatus ,
17+ isBorrowDue ,
18+ isSubscriptionActive ,
19+ } from '@/lib/utils'
1420import { BtnReturnBook } from '@/components/borrows/BtnReturnBorrow'
1521import Image from 'next/image'
1622import { Card , CardContent , CardHeader , CardTitle } from '@/components/ui/card'
1723import {
24+ Book ,
1825 Calendar ,
1926 CalendarCheck ,
2027 CalendarClock ,
2128 CalendarX ,
29+ Clock ,
30+ CreditCard ,
2231 Gavel ,
2332 Library ,
33+ Tally5 ,
2434 User ,
2535 UserCog ,
2636} from 'lucide-react'
@@ -122,12 +132,19 @@ export default async function BorrowDetailsPage({
122132 < User className = "h-4 w-4" />
123133 < p >
124134 < span className = "font-medium" > Name: </ span >
135+ { /* <Link href={`/users/${borrowRes.data.subscription.user.id}`}> */ }
125136 { borrowRes . data . subscription . user . name }
137+ { /* </Link> */ }
126138 </ p >
127139 < Library className = "h-4 w-4" />
128140 < p >
129141 < span className = "font-medium" > Library: </ span >
130- { borrowRes . data . subscription . membership . library . name }
142+ < Link
143+ className = "link"
144+ href = { `/libraries/${ borrowRes . data . subscription . membership . library . id } ` }
145+ >
146+ { borrowRes . data . subscription . membership . library . name }
147+ </ Link >
131148 </ p >
132149 { /* <CreditCard className="h-4 w-4" />
133150 <p>
@@ -168,17 +185,21 @@ export default async function BorrowDetailsPage({
168185 < p >
169186 < span className = "font-medium" > Fine Expected: </ span >
170187 { differenceInDays (
171- new Date ( ) ,
188+ borrowRes . data . returning
189+ ? new Date ( borrowRes . data . returning . returned_at )
190+ : new Date ( ) ,
172191 new Date ( borrowRes . data . due_at )
173192 ) +
174193 ' x ' +
175- borrowRes . data . subscription . fine_per_day +
194+ ( borrowRes . data . subscription . fine_per_day ?? 0 ) +
176195 ' = ' +
177196 differenceInDays (
178- new Date ( ) ,
197+ borrowRes . data . returning
198+ ? new Date ( borrowRes . data . returning . returned_at )
199+ : new Date ( ) ,
179200 new Date ( borrowRes . data . due_at )
180201 ) *
181- borrowRes . data . subscription . fine_per_day +
202+ ( borrowRes . data . subscription . fine_per_day ?? 0 ) +
182203 ' Pts' }
183204 </ p >
184205 < CalendarX className = "h-4 w-4 text-destructive" />
@@ -217,6 +238,69 @@ export default async function BorrowDetailsPage({
217238 </CardContent>
218239 </Card> */ }
219240
241+ < Card >
242+ < CardHeader >
243+ < div className = "flex justify-between items-center" >
244+ < CardTitle className = "text-lg line-clamp-2" >
245+ Membership Information
246+ </ CardTitle >
247+
248+ < Badge
249+ variant = {
250+ isSubscriptionActive ( borrowRes . data . subscription )
251+ ? 'default'
252+ : 'secondary'
253+ }
254+ className = "capitalize"
255+ >
256+ { getSubscriptionStatus ( borrowRes . data . subscription ) }
257+ </ Badge >
258+ </ div >
259+ </ CardHeader >
260+ < CardContent className = "grid gap-2 grid-cols-[max-content,1fr] md:grid-cols-[max-content,1fr,max-content,1fr] items-center" >
261+ < CreditCard className = "h-4 w-4" />
262+ < p >
263+ < span className = "font-medium" > Membership: </ span >
264+ < Link
265+ href = { `/subscriptions/${ borrowRes . data . subscription . id } ` }
266+ className = "link"
267+ >
268+ { borrowRes . data . subscription . membership . name }
269+ </ Link >
270+ </ p >
271+ < Clock className = "h-4 w-4" />
272+ < p >
273+ < span className = "font-medium" > Expires: </ span >
274+ { formatDate ( borrowRes . data . subscription . expires_at ) }
275+ </ p >
276+ < CalendarClock className = "h-4 w-4" />
277+ < p >
278+ < span className = "font-medium" > Borrow Period: </ span >
279+ { borrowRes . data . subscription . loan_period } D
280+ </ p >
281+ < Tally5 className = "h-4 w-4" />
282+ < p >
283+ < span className = "font-medium" > Usage Limit: </ span >
284+ { borrowRes . data . subscription . usage_limit ?? '-' }
285+ </ p >
286+ < Book className = "h-4 w-4" />
287+ < p >
288+ < span className = "font-medium" > Active Borrow Limit: </ span >
289+ { borrowRes . data . subscription . active_loan_limit ?? '-' }
290+ </ p >
291+ < Gavel className = "h-4 w-4" />
292+ < p >
293+ < span className = "font-medium" > Fine per Day: </ span >
294+ { borrowRes . data . subscription . fine_per_day ?? '-' } Pts
295+ </ p >
296+ < Calendar className = "h-4 w-4" />
297+ < p >
298+ < span className = "font-medium" > Purchased At: </ span >
299+ { formatDate ( borrowRes . data . subscription . created_at ) }
300+ </ p >
301+ </ CardContent >
302+ </ Card >
303+
220304 { ! borrowRes . data . returning && (
221305 < div className = "bottom-0 sticky py-2" >
222306 < BtnReturnBook
0 commit comments