import { Avatar } from "@mui/joy"; import { useState } from "react"; import { useTranslation } from "react-i18next"; import { Link, useLocation } from "react-router-dom"; import useWorkspaceStore from "@/stores/v1/workspace"; import { PlanType } from "@/types/proto/api/v2/subscription_service"; import * as api from "../helpers/api"; import useUserStore from "../stores/v1/user"; import AboutDialog from "./AboutDialog"; import Icon from "./Icon"; import Dropdown from "./common/Dropdown"; const Header: React.FC = () => { const { t } = useTranslation(); const location = useLocation(); const workspaceStore = useWorkspaceStore(); const currentUser = useUserStore().getCurrentUser(); const [showAboutDialog, setShowAboutDialog] = useState(false); const profile = workspaceStore.profile; const isAdmin = currentUser.role === "ADMIN"; const shouldShowRouterSwitch = location.pathname === "/" || location.pathname === "/collections"; const handleSignOutButtonClick = async () => { await api.signout(); window.location.href = "/auth"; }; return ( <>
Slash {profile.plan === PlanType.PRO && ( PRO )} {shouldShowRouterSwitch && ( <> / {location.pathname === "/" ? "Shortcuts" : "Collections"} } actionsClassName="!w-36 -left-4" actions={ <> Shortcuts Collections } > )}
{currentUser.nickname} } actionsClassName="!w-32" actions={ <> {t("user.profile")} {isAdmin && ( {t("settings.self")} )} } >
{showAboutDialog && setShowAboutDialog(false)} />} ); }; export default Header;