import React from "react"; import { Link, useLocation, useNavigate } from "react-router-dom"; import { useAuth } from "../hooks/useAuth"; import { ThemePreference, useTheme } from "../hooks/useTheme"; import { api } from "../services/api"; import { Rocket, Sun, Moon, Monitor } from "lucide-react"; const themeOptions: { value: ThemePreference; label: string; Icon: typeof Sun }[] = [ { value: "light", label: "Light", Icon: Sun }, { value: "dark", label: "Dark", Icon: Moon }, { value: "system", label: "System", Icon: Monitor }, ]; export function Layout({ children }: { children: React.ReactNode }) { const { user, refresh } = useAuth(); const { theme, setTheme } = useTheme(); const location = useLocation(); const navigate = useNavigate(); const handleLogout = async () => { await api.auth.logout(); await refresh(); navigate("/login"); }; const navLink = (to: string, label: string) => ( {label} ); return (
PR Previews
{user && ( )}
{themeOptions.map(({ value, label, Icon }) => { const selected = theme === value; return ( ); })}
{user && ( )}
{children}
); }