Skip to content

Commit d779b70

Browse files
committed
feat: remove error boundary
1 parent 5d805e4 commit d779b70

File tree

2 files changed

+78
-81
lines changed

2 files changed

+78
-81
lines changed

app/(protected)/admin/borrows/page.tsx

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -191,30 +191,25 @@ export default async function Borrows({
191191

192192
<div className="grid gap-4 md:grid-cols-2 lg:grid-cols-3">
193193
{res.data.map((borrow, idx) => (
194-
<BorrowCardErrorBoundary key={borrow.id} idx={skip + idx + 1}>
195-
<ListCardBorrow
196-
borrow={borrow}
197-
idx={skip + idx + 1}
198-
searchParams={{
199-
book_id,
200-
borrowed_at,
201-
due_at,
202-
lost_at,
203-
returned_at,
204-
status,
205-
user_id,
206-
subscription_id,
207-
}}
208-
>
209-
<BtnReturnBook
210-
variant="outline"
211-
className="w-full"
212-
borrow={borrow}
213-
>
214-
Return Book
215-
</BtnReturnBook>
216-
</ListCardBorrow>
217-
</BorrowCardErrorBoundary>
194+
<ListCardBorrow
195+
key={borrow.id}
196+
borrow={borrow}
197+
idx={skip + idx + 1}
198+
searchParams={{
199+
book_id,
200+
borrowed_at,
201+
due_at,
202+
lost_at,
203+
returned_at,
204+
status,
205+
user_id,
206+
subscription_id,
207+
}}
208+
>
209+
<BtnReturnBook variant="outline" className="w-full" borrow={borrow}>
210+
Return Book
211+
</BtnReturnBook>
212+
</ListCardBorrow>
218213
))}
219214
</div>
220215
<Pagination>

components/borrows/ListCardBorrow.tsx

Lines changed: 59 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -47,63 +47,65 @@ export const ListCardBorrow: React.FC<
4747
).toString()) as Route<string>
4848

4949
return (
50-
<Card
51-
key={borrow.id}
52-
className={cn('relative', status === 'lost' && 'bg-destructive/5')}
53-
>
54-
<CardHeader>
55-
<Link href={href} className="flex justify-between items-start min-h-20">
56-
<div>
57-
<CardTitle className="text-lg line-clamp-2">
58-
<abbr title={borrow.book.title} className="no-underline">
59-
{borrow.book.title}
60-
</abbr>
61-
</CardTitle>
62-
<CardDescription>
63-
<span className="text-muted-foreground/80 font-bold tracking-wider">
64-
#&nbsp;{idx.toString().padStart(4, '0')}
65-
</span>
66-
</CardDescription>
67-
</div>
68-
<Badge
69-
variant={
70-
getBorrowStatus(borrow) === 'overdue'
71-
? 'destructive'
72-
: getBorrowStatus(borrow) === 'active'
73-
? 'default'
74-
: 'secondary'
75-
}
76-
className="capitalize"
50+
<ViewTransition name={borrow.id} key={borrow.id}>
51+
<Card className={cn('relative', status === 'lost' && 'bg-destructive/5')}>
52+
<CardHeader>
53+
<Link
54+
href={href}
55+
className="flex justify-between items-start min-h-20"
7756
>
78-
{getBorrowStatus(borrow)}
79-
</Badge>
80-
</Link>
81-
</CardHeader>
82-
<CardContent className="space-y-3">
83-
<div className="flex items-center gap-2 text-sm">
84-
<User className="size-4 text-muted-foreground" />
85-
<span>{borrow.subscription.user.name}</span>
86-
</div>
87-
<div className="flex items-center gap-2 text-sm">
88-
<LibraryIcon className="size-4 text-muted-foreground" />
89-
<span>{borrow.subscription.membership.library.name}</span>
90-
</div>
91-
<div className="flex items-center gap-2 text-sm">
92-
<Calendar className="size-4 text-muted-foreground" />
93-
<span>Borrowed: {formatDate(borrow.borrowed_at)}</span>
94-
</div>
95-
<div className="flex items-center gap-2 text-sm">
96-
{isDue ? (
97-
<CalendarX className="size-4 text-destructive" />
98-
) : (
99-
<CalendarClock className="size-4 text-muted-foreground" />
100-
)}
101-
<span className={cn(isDue && 'text-destructive')}>
102-
Due: {formatDate(borrow.due_at)}
103-
</span>
104-
</div>
105-
</CardContent>
106-
<CardFooter>{children}</CardFooter>
107-
</Card>
57+
<div>
58+
<CardTitle className="text-lg line-clamp-2">
59+
<abbr title={borrow.book.title} className="no-underline">
60+
{borrow.book.title}
61+
</abbr>
62+
</CardTitle>
63+
<CardDescription>
64+
<span className="text-muted-foreground/80 font-bold tracking-wider">
65+
#&nbsp;{idx.toString().padStart(4, '0')}
66+
</span>
67+
</CardDescription>
68+
</div>
69+
<Badge
70+
variant={
71+
getBorrowStatus(borrow) === 'overdue'
72+
? 'destructive'
73+
: getBorrowStatus(borrow) === 'active'
74+
? 'default'
75+
: 'secondary'
76+
}
77+
className="capitalize"
78+
>
79+
{getBorrowStatus(borrow)}
80+
</Badge>
81+
</Link>
82+
</CardHeader>
83+
<CardContent className="space-y-3">
84+
<div className="flex items-center gap-2 text-sm">
85+
<User className="size-4 text-muted-foreground" />
86+
<span>{borrow.subscription.user.name}</span>
87+
</div>
88+
<div className="flex items-center gap-2 text-sm">
89+
<LibraryIcon className="size-4 text-muted-foreground" />
90+
<span>{borrow.subscription.membership.library.name}</span>
91+
</div>
92+
<div className="flex items-center gap-2 text-sm">
93+
<Calendar className="size-4 text-muted-foreground" />
94+
<span>Borrowed: {formatDate(borrow.borrowed_at)}</span>
95+
</div>
96+
<div className="flex items-center gap-2 text-sm">
97+
{isDue ? (
98+
<CalendarX className="size-4 text-destructive" />
99+
) : (
100+
<CalendarClock className="size-4 text-muted-foreground" />
101+
)}
102+
<span className={cn(isDue && 'text-destructive')}>
103+
Due: {formatDate(borrow.due_at)}
104+
</span>
105+
</div>
106+
</CardContent>
107+
<CardFooter>{children}</CardFooter>
108+
</Card>
109+
</ViewTransition>
108110
)
109111
}

0 commit comments

Comments
 (0)