Complete main functionallity of backend and frontend.

This commit is contained in:
2026-02-21 18:29:22 +01:00 Verified
parent 3a795418d3
commit 7ce44979b9
16 changed files with 383 additions and 168 deletions
+3 -22
View File
@@ -1,36 +1,19 @@
// frontend/src/components/Layout/Layout.jsx
import { Moon, Sun } from 'lucide-react';
import { useEffect, useState } from 'react';
import { useState } from 'react';
import { Outlet, useLocation, useNavigate } from 'react-router-dom';
import api, { getToken } from '../../services/api';
import { getToken } from '../../services/api';
import Navbar from './Navbar';
export default function Layout({ darkMode, setDarkMode }) {
const [isAdmin, setIsAdmin] = useState(false);
const [isAdmin, setIsAdmin] = useState(!!getToken());
const [navTitle, setNavTitle] = useState('');
const [navSubtitle, setNavSubtitle] = useState('');
// State to trigger settings modals from Navbar
const [showSettings, setShowSettings] = useState(false);
const location = useLocation();
const navigate = useNavigate();
const isDashboard = location.pathname === '/';
useEffect(() => {
const checkAuth = async () => {
if (getToken()) {
try {
const res = await api.get('/auth/check');
setIsAdmin(res.is_admin);
} catch {
setIsAdmin(false);
}
}
};
checkAuth();
}, [location.pathname]);
const handleLogout = () => {
localStorage.removeItem('volleyToken');
@@ -44,8 +27,6 @@ export default function Layout({ darkMode, setDarkMode }) {
subtitle={navSubtitle}
isAdmin={isAdmin}
onLogout={handleLogout}
onOpenSettings={() => setShowSettings(true)}
isDashboard={isDashboard}
/>
<main className="flex-1 overflow-hidden relative flex flex-col">