import { useState } from "react"; import { Navbar, Nav, NavDropdown } from "react-bootstrap"; import { Link, useLocation } from "react-router"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faSun, faMoon, faGear, faDharmachakra } from "@fortawesome/free-solid-svg-icons"; import { useAuth } from "../context/auth"; import { useSettings, ThemePreference } from "../context/settings"; import { DEN_URL, JIDLA_URL, PROFIL_URL, STATISTIKY_URL, TRENINKY_URL } from "../routes"; import SettingsModal from "./modals/SettingsModal"; import SpinWheelModal from "./modals/SpinWheelModal"; /** Položky hlavní navigace. */ const NAV_ITEMS = [ { url: DEN_URL, label: 'Můj den' }, { url: JIDLA_URL, label: 'Jídla' }, { url: TRENINKY_URL, label: 'Tréninky' }, { url: STATISTIKY_URL, label: 'Statistiky' }, { url: PROFIL_URL, label: 'Profil' }, ]; export default function Header() { const [settingsOpen, setSettingsOpen] = useState(false); const [wheelOpen, setWheelOpen] = useState(false); const auth = useAuth(); const settings = useSettings(); const location = useLocation(); const effectiveDark = settings?.effectiveDark ?? false; /** Případná podstránka nechá zvýrazněnou svou nadřazenou položku. */ const isActive = (url: string) => location.pathname === url || (url !== DEN_URL && location.pathname.startsWith(`${url}/`)); const toggleTheme = () => { const next: ThemePreference = effectiveDark ? 'light' : 'dark'; settings?.setThemePreference(next); }; return ( Food Tracer setSettingsOpen(false)} /> {wheelOpen && setWheelOpen(false)} />} ); }