import { useState } from "react"; import { useTranslation } from "react-i18next"; import { Link, useLocation } from "react-router-dom"; import { authServiceClient } from "@/grpcweb"; import { useWorkspaceStore, useUserStore } from "@/stores"; import { PlanType } from "@/types/proto/api/v1/subscription_service"; import { Role } from "@/types/proto/api/v1/user_service"; import AboutDialog from "./AboutDialog"; import Icon from "./Icon"; import Logo from "./Logo"; 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 === Role.ADMIN; const shouldShowRouterSwitch = location.pathname === "/shortcuts" || location.pathname === "/collections"; const selectedSection = location.pathname === "/shortcuts" ? "Shortcuts" : location.pathname === "/collections" ? "Collections" : ""; const handleSignOutButtonClick = async () => { await authServiceClient.signOut({}); window.location.href = "/auth"; }; return ( <>
Slash {profile.subscription?.plan && [PlanType.PRO, PlanType.ENTERPRISE].includes(profile.subscription.plan) && ( {/* PRO or ENT */} {profile.subscription.plan.substring(0, 3)} )} {shouldShowRouterSwitch && ( <> / {selectedSection} } 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;