import { useState } from "react"; import { useNavigate } from "react-router-dom"; import CheckCircleOutlineIcon from "@mui/icons-material/CheckCircleOutline"; import LogoutOutlinedIcon from "@mui/icons-material/LogoutOutlined"; import MenuIcon from "@mui/icons-material/Menu"; import NotificationsNoneOutlinedIcon from "@mui/icons-material/NotificationsNoneOutlined"; import PersonOutlineOutlinedIcon from "@mui/icons-material/PersonOutlineOutlined"; import SettingsOutlinedIcon from "@mui/icons-material/SettingsOutlined"; import { AppBar, Avatar, Box, Divider, IconButton, ListItemIcon, ListItemText, Menu, MenuItem, Toolbar, Typography, } from "@mui/material"; import { useAuthContext } from "@/providers/auth-context"; type AppTopbarProps = { onToggleNav: () => void; }; export function AppTopbar({ onToggleNav }: AppTopbarProps) { const navigate = useNavigate(); const { user, logout } = useAuthContext(); const [notifAnchor, setNotifAnchor] = useState(null); const [userAnchor, setUserAnchor] = useState(null); const handleLogout = () => { setUserAnchor(null); logout(); }; const userInitials = user?.name ? user.name .split(" ") .map((part) => part[0]) .join("") .slice(0, 2) .toUpperCase() : "U"; return ( setNotifAnchor(event.currentTarget)} sx={{ color: "var(--color-header-text-muted)", "&:hover": { color: "var(--color-header-text)", backgroundColor: "var(--color-header-chip-hover)", }, }} > setUserAnchor(event.currentTarget)} sx={{ color: "var(--color-header-text-muted)", "&:hover": { color: "var(--color-header-text)", backgroundColor: "var(--color-header-chip-hover)", }, }} > setNotifAnchor(null)} transformOrigin={{ horizontal: "right", vertical: "top" }} anchorOrigin={{ horizontal: "right", vertical: "bottom" }} slotProps={{ paper: { sx: { width: 300, mt: 1, boxShadow: "var(--shadow-lg)" }, }, }} > Notifications No new notifications setUserAnchor(null)} transformOrigin={{ horizontal: "right", vertical: "top" }} anchorOrigin={{ horizontal: "right", vertical: "bottom" }} slotProps={{ paper: { sx: { width: 260, mt: 1, boxShadow: "var(--shadow-lg)" }, }, }} > {userInitials} {user?.name || "User"} {user?.email || ""} { setUserAnchor(null); navigate("/settings/dropdowns"); }} > Settings Logout ); }