From 21a9bb17c5e082f208e8f9ad9e5f0435affb7452 Mon Sep 17 00:00:00 2001 From: SamixYasuke Date: Sat, 27 Jun 2026 04:38:41 +0100 Subject: [PATCH] fIX: logout redirect --- frontend/src/App.jsx | 87 ++++++++++++++++++++++-------- frontend/src/components/Navbar.jsx | 26 +++++---- 2 files changed, 79 insertions(+), 34 deletions(-) diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx index ea2ef66..44a1f98 100644 --- a/frontend/src/App.jsx +++ b/frontend/src/App.jsx @@ -22,40 +22,81 @@ import { ThemeProvider } from './context/ThemeContext'; import { ToastProvider } from './context/ToastContext'; import { NetworkStatusProvider } from './context/NetworkStatusContext'; import { OfflineBanner } from './components/OfflineBanner'; +import { useAuth } from './context/AuthContext'; export default function App() { const location = useLocation(); const hideNavbar = location.pathname.startsWith('/widget/') || location.pathname.startsWith('/embed/'); + function PrivateRoute({ children }) { + const { user, ready } = useAuth(); + if (!ready) return null; + return user ? children : ; + } return ( - - {!hideNavbar && } - - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } - /> - } /> - + + {!hideNavbar && } + + } /> + + + + } + /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + + + + } + /> + + + + } + /> + + + + } + /> + + + + } + /> + } + /> + } /> + diff --git a/frontend/src/components/Navbar.jsx b/frontend/src/components/Navbar.jsx index 29f3028..b2bbdac 100644 --- a/frontend/src/components/Navbar.jsx +++ b/frontend/src/components/Navbar.jsx @@ -65,21 +65,25 @@ export default function Navbar() { } } - function handleLogout() { - logout(); - navigate('/'); + async function handleMarkRead(id) { + try { + await api.markNotificationRead(id); + setNotifications((prev) => + prev.map((n) => (n.id === id ? { ...n, read_at: new Date().toISOString() } : n)) + ); + } catch (_err) {} } - function handleMarkRead(id) { - api.markNotificationRead(id).catch(() => {}); - setNotifications((prev) => - prev.map((n) => (n.id === id ? { ...n, read_at: new Date().toISOString() } : n)) - ); + async function handleMarkAllRead() { + try { + await api.markAllNotificationsRead(); + setNotifications((prev) => prev.map((n) => ({ ...n, read_at: new Date().toISOString() }))); + } catch (_err) {} } - function handleMarkAllRead() { - api.markAllNotificationsRead().catch(() => {}); - setNotifications((prev) => prev.map((n) => ({ ...n, read_at: new Date().toISOString() }))); + async function handleLogout() { + await logout(); + navigate('/'); } return (