Amelioration de linterface et corrections bugs

This commit is contained in:
AISSI-JUDE-CHRIST
2026-06-14 20:45:13 +02:00
parent dabf1df6b9
commit 65b9eed6dc
8 changed files with 340 additions and 23 deletions
+2 -2
View File
@@ -8,13 +8,13 @@ export function LoanProvider({ children }) {
return saved ? JSON.parse(saved) : []; return saved ? JSON.parse(saved) : [];
}); });
function addLoan(book, borrowerPhone, dueDate) { function addLoan(book, borrowerUsername, dueDate) {
const loan = { const loan = {
loanId: crypto.randomUUID(), loanId: crypto.randomUUID(),
bookId: book.isbn, bookId: book.isbn,
bookTitle: book.title, bookTitle: book.title,
bookAuthor: book.author, bookAuthor: book.author,
borrowerPhone, borrowerUsername,
dueDate, dueDate,
status: 'ACTIVE', status: 'ACTIVE',
loanedAt: new Date().toISOString(), loanedAt: new Date().toISOString(),
+13 -9
View File
@@ -29,17 +29,21 @@ export default function Books() {
return ( return (
<main> <main>
<h1>Catalogue</h1> <div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', marginBottom: '1rem' }}>
{user?.role === 'admin' && <Link to="/books/new">+ Ajouter un livre</Link>} <h1 style={{ margin: 0 }}>Catalogue</h1>
<ul> {user?.role === 'admin' && <Link to="/books/new">+ Ajouter un livre</Link>}
</div>
<div className="card-grid">
{books.map((book) => ( {books.map((book) => (
<li key={book.isbn}> <Link to={`/books/${book.isbn}`} key={book.isbn} style={{ textDecoration: 'none', color: 'inherit' }}>
<Link to={`/books/${book.isbn}`}> <div className="card">
<strong>{book.title}</strong> - {book.author} <h3>{book.title}</h3>
</Link> <p>{book.author}</p>
</li> <p style={{ marginTop: '0.5rem', fontSize: '0.8rem', color: '#999' }}>ISBN : {book.isbn}</p>
</div>
</Link>
))} ))}
</ul> </div>
</main> </main>
); );
} }
+21 -2
View File
@@ -1,9 +1,28 @@
import { Link } from 'react-router-dom'; import { Link } from 'react-router-dom';
import '../styles/home.css'; import { useAuth } from '../context/AuthContext';
export default function Home() { export default function Home() {
const { user } = useAuth();
return ( return (
<main> <main>
<h1>Bienvenue sur Biblio</h1>
<p>Gérez vos livres, réservations et abonnements depuis une seule interface.</p>
<section>
<h2>Accès rapide</h2>
<ul>
<li><Link to="/books">📚 Parcourir le catalogue</Link></li>
{user?.role === 'user' && <li><Link to="/reservations">🔖 Mes réservations</Link></li>}
{user?.role === 'user' && <li><Link to="/loans">📖 Mes prêts</Link></li>}
{user?.role === 'user' && <li><Link to="/subscription"> Mon abonnement</Link></li>}
{user && <li><Link to="/orders">🛒 Passer une commande</Link></li>}
{user && <li><Link to="/group-orders">👥 Commandes groupées</Link></li>}
{user?.role === 'admin' && <li><Link to="/customers">👤 Gestion des clients</Link></li>}
{user?.role === 'admin' && <li><Link to="/returns"> Retours de livres</Link></li>}
{!user && <li><Link to="/login">Connexion</Link></li>}
</ul>
</section>
</main> </main>
); );
} }
+2 -2
View File
@@ -20,7 +20,7 @@ export default function Loans() {
<li key={l.loanId}> <li key={l.loanId}>
<strong>{l.bookTitle}</strong> {l.bookAuthor} <strong>{l.bookTitle}</strong> {l.bookAuthor}
<br /> <br />
Prêté à : {l.borrowerPhone} Emprunteur : {l.borrowerUsername}
<br /> <br />
À rendre avant le : {new Date(l.dueDate).toLocaleDateString('fr-FR')} À rendre avant le : {new Date(l.dueDate).toLocaleDateString('fr-FR')}
<br /> <br />
@@ -41,7 +41,7 @@ export default function Loans() {
<li key={l.loanId}> <li key={l.loanId}>
<strong>{l.bookTitle}</strong> {l.bookAuthor} <strong>{l.bookTitle}</strong> {l.bookAuthor}
<br /> <br />
Prêté à : {l.borrowerPhone} Emprunteur : {l.borrowerUsername}
<br /> <br />
<small>Rendu </small> <small>Rendu </small>
</li> </li>
+44 -2
View File
@@ -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() { export default function Profile() {
return <main><h1>Mon compte</h1></main>; 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 (
<main>
<h1>Mon compte</h1>
<section>
<h2>Informations</h2>
<p><strong>Nom d'utilisateur :</strong> {user?.username}</p>
<p><strong>Rôle :</strong> {user?.role === 'admin' ? 'Administrateur' : 'Utilisateur'}</p>
</section>
{user?.role === 'user' && (
<>
<section>
<h2>Abonnement</h2>
{subscription ? (
<p><strong>Plan actif :</strong> {subscription.planName}</p>
) : (
<p>Aucun abonnement actif.</p>
)}
</section>
<section>
<h2>Activité</h2>
<p>Réservations en cours : <strong>{activeReservations.length}</strong></p>
<p>Prêts en cours : <strong>{activeLoans.length}</strong></p>
</section>
</>
)}
</main>
);
}
+6 -6
View File
@@ -21,7 +21,7 @@ export default function Reservations() {
const form = loanForms[reservation.reservationId] || {}; const form = loanForms[reservation.reservationId] || {};
addLoan( addLoan(
{ isbn: reservation.bookId, title: reservation.bookTitle, author: reservation.bookAuthor }, { isbn: reservation.bookId, title: reservation.bookTitle, author: reservation.bookAuthor },
form.borrowerPhone, form.borrowerUsername,
form.dueDate form.dueDate
); );
setLoanStatuses(prev => ({ ...prev, [reservation.reservationId]: 'Prêt enregistré avec succès !' })); setLoanStatuses(prev => ({ ...prev, [reservation.reservationId]: 'Prêt enregistré avec succès !' }));
@@ -58,12 +58,12 @@ export default function Reservations() {
<summary>Prêter ce livre à un autre lecteur</summary> <summary>Prêter ce livre à un autre lecteur</summary>
<form onSubmit={e => handleLoan(e, r)}> <form onSubmit={e => handleLoan(e, r)}>
<label> <label>
Téléphone de l'emprunteur : Identifiant de l'emprunteur :
<input <input
type="tel" type="text"
value={loanForms[r.reservationId]?.borrowerPhone || ''} value={loanForms[r.reservationId]?.borrowerUsername || ''}
onChange={e => handleLoanChange(r.reservationId, 'borrowerPhone', e.target.value)} onChange={e => handleLoanChange(r.reservationId, 'borrowerUsername', e.target.value)}
placeholder="0612345678" placeholder="ex: alice"
required required
/> />
</label> </label>
+196
View File
@@ -0,0 +1,196 @@
*, *::before, *::after {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
font-family: system-ui, sans-serif;
font-size: 15px;
line-height: 1.6;
color: #222;
background: #f7f7f7;
}
main {
max-width: 860px;
margin: 2rem auto;
padding: 0 1.25rem;
}
h1 {
font-size: 1.6rem;
font-weight: 600;
margin-bottom: 1.25rem;
color: #111;
}
h2 {
font-size: 1.15rem;
font-weight: 600;
margin: 1.5rem 0 0.75rem;
color: #333;
}
p {
margin-bottom: 0.75rem;
}
a {
color: #2563eb;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
ul {
list-style: none;
padding: 0;
}
li {
padding: 0.75rem 0;
border-bottom: 1px solid #e5e5e5;
line-height: 1.7;
}
li:last-child {
border-bottom: none;
}
/* Forms */
form {
display: flex;
flex-direction: column;
gap: 0.75rem;
max-width: 480px;
}
label {
display: flex;
flex-direction: column;
gap: 0.25rem;
font-size: 0.9rem;
color: #444;
}
input, select, textarea {
padding: 0.45rem 0.65rem;
border: 1px solid #ccc;
border-radius: 4px;
font-size: 0.95rem;
font-family: inherit;
background: #fff;
width: 100%;
}
input:focus, select:focus, textarea:focus {
outline: none;
border-color: #2563eb;
}
/* Buttons */
button {
display: inline-block;
padding: 0.45rem 1rem;
font-size: 0.9rem;
font-family: inherit;
border: 1px solid #ccc;
border-radius: 4px;
background: #fff;
cursor: pointer;
color: #222;
}
button:hover {
background: #f0f0f0;
}
button[type="submit"],
button.primary {
background: #2563eb;
color: #fff;
border-color: #2563eb;
}
button[type="submit"]:hover,
button.primary:hover {
background: #1d4ed8;
}
button:disabled {
opacity: 0.5;
cursor: not-allowed;
}
/* Sections */
section {
margin-bottom: 2rem;
}
/* Details / summary */
details {
margin-top: 0.5rem;
}
summary {
cursor: pointer;
color: #2563eb;
font-size: 0.9rem;
}
summary:hover {
text-decoration: underline;
}
details form {
margin-top: 0.75rem;
padding: 0.75rem;
background: #fff;
border: 1px solid #e5e5e5;
border-radius: 4px;
}
/* Status messages */
.msg-success {
color: #15803d;
}
.msg-error {
color: #dc2626;
}
/* Cards (book list etc.) */
.card-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
gap: 1rem;
margin-top: 1rem;
}
.card {
background: #fff;
border: 1px solid #e5e5e5;
border-radius: 6px;
padding: 1rem;
}
.card h3 {
font-size: 1rem;
font-weight: 600;
margin-bottom: 0.25rem;
}
.card p {
font-size: 0.875rem;
color: #555;
margin: 0;
}
+56
View File
@@ -0,0 +1,56 @@
.navbar {
display: flex;
align-items: center;
gap: 1.5rem;
padding: 0 1.25rem;
height: 52px;
background: #fff;
border-bottom: 1px solid #e5e5e5;
position: sticky;
top: 0;
z-index: 100;
}
.navbar__logo {
font-weight: 700;
font-size: 1.1rem;
color: #111;
text-decoration: none;
margin-right: 0.5rem;
}
.navbar__links {
display: flex;
align-items: center;
gap: 0.25rem;
list-style: none;
flex: 1;
flex-wrap: wrap;
}
.navbar__links a {
padding: 0.3rem 0.6rem;
font-size: 0.875rem;
color: #444;
text-decoration: none;
border-radius: 4px;
}
.navbar__links a:hover {
background: #f0f0f0;
color: #111;
}
.navbar__actions {
display: flex;
align-items: center;
gap: 0.75rem;
font-size: 0.875rem;
color: #555;
white-space: nowrap;
}
.navbar__actions button {
padding: 0.3rem 0.75rem;
font-size: 0.85rem;
}