This commit is contained in:
+19
-12
@@ -69,13 +69,11 @@ export default function App() {
|
|||||||
const handleAuthSuccess = (newToken: string, newUser: User) => {
|
const handleAuthSuccess = (newToken: string, newUser: User) => {
|
||||||
localStorage.setItem("authToken", newToken);
|
localStorage.setItem("authToken", newToken);
|
||||||
localStorage.setItem("user", JSON.stringify(newUser));
|
localStorage.setItem("user", JSON.stringify(newUser));
|
||||||
|
|
||||||
setAuthState({
|
setAuthState({
|
||||||
user: newUser,
|
user: newUser,
|
||||||
isAuthenticated: true,
|
isAuthenticated: true,
|
||||||
loading: false,
|
loading: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
navigate("/");
|
navigate("/");
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -100,7 +98,6 @@ export default function App() {
|
|||||||
: location.pathname === "/mentions-legales"? "mentions-legales"
|
: location.pathname === "/mentions-legales"? "mentions-legales"
|
||||||
: "home";
|
: "home";
|
||||||
|
|
||||||
// LOAD RECENT DOCUMENTS
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (authState.isAuthenticated) {
|
if (authState.isAuthenticated) {
|
||||||
getDocuments()
|
getDocuments()
|
||||||
@@ -116,13 +113,13 @@ export default function App() {
|
|||||||
|
|
||||||
const handleNavClick = (item: NavItem) => {
|
const handleNavClick = (item: NavItem) => {
|
||||||
const path =
|
const path =
|
||||||
item === "home" ? "/"
|
item === "home" ? "/"
|
||||||
: item === "documents" ? "/documents"
|
: item === "documents" ? "/documents"
|
||||||
: item === "ingredient-search" ? "/ingredient-search"
|
: item === "ingredient-search" ? "/ingredient-search"
|
||||||
: item === "recent-updates" ? "/recent-updates"
|
: item === "recent-updates" ? "/recent-updates"
|
||||||
: item === "about" ? "/about"
|
: item === "about" ? "/about"
|
||||||
: item === "contact" ? "/contact"
|
: item === "contact" ? "/contact"
|
||||||
: item === "cgu" ? "/cgu"
|
: item === "cgu" ? "/cgu"
|
||||||
: "/mentions-legales";
|
: "/mentions-legales";
|
||||||
navigate(path);
|
navigate(path);
|
||||||
};
|
};
|
||||||
@@ -135,15 +132,25 @@ export default function App() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Si pas authentifié, afficher la page de login
|
// ← CookieBanner visible même sans connexion
|
||||||
if (!authState.isAuthenticated) {
|
if (!authState.isAuthenticated) {
|
||||||
return <AuthPage onAuthSuccess={handleAuthSuccess} />;
|
return (
|
||||||
|
<>
|
||||||
|
<AuthPage onAuthSuccess={handleAuthSuccess} />
|
||||||
|
<CookieBanner />
|
||||||
|
</>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.app}>
|
<div className={styles.app}>
|
||||||
<div className={styles.contentWrapper}>
|
<div className={styles.contentWrapper}>
|
||||||
<Sidebar activeNav={activeNav} onNavClick={handleNavClick} onLogout={handleLogout} user={authState.user} />
|
<Sidebar
|
||||||
|
activeNav={activeNav}
|
||||||
|
onNavClick={handleNavClick}
|
||||||
|
onLogout={handleLogout}
|
||||||
|
user={authState.user}
|
||||||
|
/>
|
||||||
<main className={styles.main}>
|
<main className={styles.main}>
|
||||||
<Routes>
|
<Routes>
|
||||||
<Route path="/" element={<HomePage handleNavClick={handleNavClick} recentDocuments={recentDocuments} />} />
|
<Route path="/" element={<HomePage handleNavClick={handleNavClick} recentDocuments={recentDocuments} />} />
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ export default function CookieBanner() {
|
|||||||
gap: "1rem"
|
gap: "1rem"
|
||||||
}} role="dialog">
|
}} role="dialog">
|
||||||
<p style={{ flex: 1, margin: 0 }}>
|
<p style={{ flex: 1, margin: 0 }}>
|
||||||
Ce site utilise des cookies pour améliorer votre expérience.
|
Ce site utilise des cookies pour améliorer votre expérience utilisateur.
|
||||||
</p>
|
</p>
|
||||||
<button
|
<button
|
||||||
onClick={handleAccept}
|
onClick={handleAccept}
|
||||||
|
|||||||
Reference in New Issue
Block a user