Skip to content

Commit dd3b0eb

Browse files
committed
feat: book cover in borrowing
1 parent fef673e commit dd3b0eb

File tree

4 files changed

+30
-4
lines changed

4 files changed

+30
-4
lines changed

app/(protected)/books/page.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import { getListBooks } from '@/lib/api/book'
2626
import Link from 'next/link'
2727
import type { Metadata } from 'next'
2828
import { SITE_NAME } from '@/lib/consts'
29+
import Image from 'next/image'
2930

3031
export const metadata: Metadata = {
3132
title: `Books · ${SITE_NAME}`,
@@ -91,6 +92,7 @@ export default async function Books({
9192
{/* <TableCaption>List of books available in the library.</TableCaption> */}
9293
<TableHeader>
9394
<TableRow>
95+
<TableHead>Cover</TableHead>
9496
<TableHead>Code</TableHead>
9597
<TableHead>Title</TableHead>
9698
<TableHead>Library</TableHead>
@@ -101,6 +103,19 @@ export default async function Books({
101103
<TableBody>
102104
{res.data.map((b) => (
103105
<TableRow key={b.id}>
106+
<TableCell>
107+
{b.cover && (
108+
<div className="w-12 h-auto">
109+
<Image
110+
src={b.cover}
111+
alt={b.title + "'s cover"}
112+
width={50}
113+
height={50}
114+
className="rounded"
115+
/>
116+
</div>
117+
)}
118+
</TableCell>
104119
<TableCell>{b.code}</TableCell>
105120
<TableCell>{b.title}</TableCell>
106121
<TableCell>{b.library?.name}</TableCell>

app/(protected)/borrows/[id]/page.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { Cardstaff } from '@/components/staffs/CardStaff'
1818
import { Cardsubscription } from '@/components/subscriptions/CardSubscription'
1919
import { CardMembership } from '@/components/memberships/CardMembership'
2020
import { BtnReturnBook } from '@/components/borrows/BtnReturnBorrow'
21+
import Image from 'next/image'
2122

2223
export default async function BorrowDetailsPage({
2324
params,
@@ -78,6 +79,15 @@ export default async function BorrowDetailsPage({
7879
</div>
7980

8081
<div className="grid grid-cols-1 md:grid-cols-3 gap-4">
82+
{borrowRes.data.book?.cover && (
83+
<Image
84+
src={borrowRes.data.book.cover}
85+
alt={borrowRes.data.book.title + "'s cover"}
86+
width={256}
87+
height={256}
88+
className="rounded-lg w-56 h-auto place-self-center row-span-2"
89+
/>
90+
)}
8191
<CardBorrow borrow={borrowRes.data} />
8292
<CardBook book={borrowRes.data.book} />
8393
<Carduser user={borrowRes.data.subscription.user} />

app/(protected)/libraries/[id]/page.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ export default async function LibraryDetail({
7979
<Image
8080
src={libRes.data.logo}
8181
alt={libRes.data.name}
82-
width={400}
83-
height={400}
84-
className="rounded-lg w-auto h-auto"
82+
width={256}
83+
height={256}
84+
className="rounded-lg w-56 h-auto"
8585
/>
8686
)}
8787
<div className="">
@@ -102,7 +102,7 @@ export default async function LibraryDetail({
102102
</div>
103103
</div>
104104

105-
<div className="grid md:grid-cols-2 gap-4">
105+
<div className="grid md:grid-cols-2 gap-4 ">
106106
<div className="border border-gray-200 my-4">
107107
<Table>
108108
<TableCaption>Latest added books from the library.</TableCaption>

lib/types/book.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export type Book = WithCommon<{
66
author: string
77
year: number
88
code: string
9+
cover?: string
910
library_id: string
1011
library?: Pick<Library, 'id' | 'name'>
1112
}>

0 commit comments

Comments
 (0)