diff --git a/my-library/src/App.jsx b/my-library/src/App.jsx
index 4873915..0b72acb 100644
--- a/my-library/src/App.jsx
+++ b/my-library/src/App.jsx
@@ -6,6 +6,7 @@ import Orders from './pages/Orders';
import Profile from './pages/Profile';
import NotFound from './pages/NotFound';
import AddBook from './pages/AddBook';
+import BookDetail from './pages/BookDetail';
export default function App() {
return (
@@ -17,6 +18,7 @@ export default function App() {
} />
} />
} />
+ } />
);
diff --git a/my-library/src/api/books.jsx b/my-library/src/api/books.jsx
index c9ba492..643d63f 100644
--- a/my-library/src/api/books.jsx
+++ b/my-library/src/api/books.jsx
@@ -6,4 +6,8 @@ export function getBooks(page = 0, size = 20) {
export function registerBook(book) {
return client.post('/api/books', book);
+}
+
+export function getBookById(id) {
+ return client.get(`/api/books/${id}`);
}
\ No newline at end of file
diff --git a/my-library/src/pages/BookDetail.jsx b/my-library/src/pages/BookDetail.jsx
new file mode 100644
index 0000000..68194d6
--- /dev/null
+++ b/my-library/src/pages/BookDetail.jsx
@@ -0,0 +1,31 @@
+import { useState, useEffect } from 'react';
+import { useParams, Link } from 'react-router-dom';
+import { getBookById } from '../api/books';
+
+export default function BookDetail() {
+ const { bookId } = useParams();
+ const [book, setBook] = useState(null);
+ const [loading, setLoading] = useState(true);
+ const [error, setError] = useState(null);
+
+ useEffect(() => {getBookById(bookId).then((response) => setBook(response.data)).catch((err) => {console.error(err);setError('Livre introuvable.');}).finally(() => setLoading(false));}, [bookId]);
+
+ if (loading) return Chargement…
;
+ if (error) return {error}
← Retour au catalogue;
+
+ return (
+
+ ← Retour au catalogue
+ {book.title}
+ Auteur : {book.author}
+ ISBN : {book.isbn}
+ Éditeur : {book.publisher}
+ Publié le : {book.publicationDate}
+ Prix : {book.price} €
+ Stock : {book.quantity}
+ Langue : {book.language}
+ Catégories : {book.categories?.join(', ')}
+ {book.description && {book.description}
}
+
+ );
+}
\ No newline at end of file
diff --git a/my-library/src/pages/Books.jsx b/my-library/src/pages/Books.jsx
index 393db4e..0c283e5 100644
--- a/my-library/src/pages/Books.jsx
+++ b/my-library/src/pages/Books.jsx
@@ -32,7 +32,9 @@ export default function Books() {
{books.map((book) => (
-
- {book.title} - {book.author}
+
+ {book.title} - {book.author}
+
))}