diff --git a/my-library/src/context/LoanContext.js b/my-library/src/context/LoanContext.js
index 08b8bb2..85e688b 100644
--- a/my-library/src/context/LoanContext.js
+++ b/my-library/src/context/LoanContext.js
@@ -8,13 +8,13 @@ export function LoanProvider({ children }) {
return saved ? JSON.parse(saved) : [];
});
- function addLoan(book, borrowerPhone, dueDate) {
+ function addLoan(book, borrowerUsername, dueDate) {
const loan = {
loanId: crypto.randomUUID(),
bookId: book.isbn,
bookTitle: book.title,
bookAuthor: book.author,
- borrowerPhone,
+ borrowerUsername,
dueDate,
status: 'ACTIVE',
loanedAt: new Date().toISOString(),
diff --git a/my-library/src/pages/Books.jsx b/my-library/src/pages/Books.jsx
index e4d4115..43a2cfd 100644
--- a/my-library/src/pages/Books.jsx
+++ b/my-library/src/pages/Books.jsx
@@ -29,17 +29,21 @@ export default function Books() {
return (
- Catalogue
- {user?.role === 'admin' && + Ajouter un livre}
-
);
}
\ No newline at end of file
diff --git a/my-library/src/pages/Home.jsx b/my-library/src/pages/Home.jsx
index 09ca41a..3eff349 100644
--- a/my-library/src/pages/Home.jsx
+++ b/my-library/src/pages/Home.jsx
@@ -1,9 +1,28 @@
import { Link } from 'react-router-dom';
-import '../styles/home.css';
+import { useAuth } from '../context/AuthContext';
export default function Home() {
+ const { user } = useAuth();
+
return (
+ Bienvenue sur Biblio
+ Gérez vos livres, réservations et abonnements depuis une seule interface.
+
+
+ Accès rapide
+
+ - 📚 Parcourir le catalogue
+ {user?.role === 'user' && - 🔖 Mes réservations
}
+ {user?.role === 'user' && - 📖 Mes prêts
}
+ {user?.role === 'user' && - ⭐ Mon abonnement
}
+ {user && - 🛒 Passer une commande
}
+ {user && - 👥 Commandes groupées
}
+ {user?.role === 'admin' && - 👤 Gestion des clients
}
+ {user?.role === 'admin' && - ↩️ Retours de livres
}
+ {!user && - Connexion
}
+
+
);
-}
\ No newline at end of file
+}
diff --git a/my-library/src/pages/Loans.jsx b/my-library/src/pages/Loans.jsx
index 473d048..999ef87 100644
--- a/my-library/src/pages/Loans.jsx
+++ b/my-library/src/pages/Loans.jsx
@@ -20,7 +20,7 @@ export default function Loans() {
{l.bookTitle} — {l.bookAuthor}
- Prêté à : {l.borrowerPhone}
+ Emprunteur : {l.borrowerUsername}
À rendre avant le : {new Date(l.dueDate).toLocaleDateString('fr-FR')}
@@ -41,7 +41,7 @@ export default function Loans() {
{l.bookTitle} — {l.bookAuthor}
- Prêté à : {l.borrowerPhone}
+ Emprunteur : {l.borrowerUsername}
Rendu ✓
diff --git a/my-library/src/pages/Profile.jsx b/my-library/src/pages/Profile.jsx
index 581f560..42e77b6 100644
--- a/my-library/src/pages/Profile.jsx
+++ b/my-library/src/pages/Profile.jsx
@@ -1,3 +1,45 @@
+import { useAuth } from '../context/AuthContext';
+import { useReservations } from '../context/ReservationContext';
+import { useLoans } from '../context/LoanContext';
+import { useSubscription } from '../context/SubscriptionContext';
+
export default function Profile() {
- return Mon compte
;
-}
\ No newline at end of file
+ const { user } = useAuth();
+ const { reservations } = useReservations();
+ const { loans } = useLoans();
+ const { subscription } = useSubscription();
+
+ const activeReservations = reservations.filter(r => r.status !== 'CANCELLED');
+ const activeLoans = loans.filter(l => l.status === 'ACTIVE');
+
+ return (
+
+ Mon compte
+
+
+ Informations
+ Nom d'utilisateur : {user?.username}
+ Rôle : {user?.role === 'admin' ? 'Administrateur' : 'Utilisateur'}
+
+
+ {user?.role === 'user' && (
+ <>
+
+ Abonnement
+ {subscription ? (
+ Plan actif : {subscription.planName}
+ ) : (
+ Aucun abonnement actif.
+ )}
+
+
+
+ Activité
+ Réservations en cours : {activeReservations.length}
+ Prêts en cours : {activeLoans.length}
+
+ >
+ )}
+
+ );
+}
diff --git a/my-library/src/pages/Reservations.jsx b/my-library/src/pages/Reservations.jsx
index b66f0f0..a8d3bca 100644
--- a/my-library/src/pages/Reservations.jsx
+++ b/my-library/src/pages/Reservations.jsx
@@ -21,7 +21,7 @@ export default function Reservations() {
const form = loanForms[reservation.reservationId] || {};
addLoan(
{ isbn: reservation.bookId, title: reservation.bookTitle, author: reservation.bookAuthor },
- form.borrowerPhone,
+ form.borrowerUsername,
form.dueDate
);
setLoanStatuses(prev => ({ ...prev, [reservation.reservationId]: 'Prêt enregistré avec succès !' }));
@@ -58,12 +58,12 @@ export default function Reservations() {
Prêter ce livre à un autre lecteur