import { Link, useMatchRoute } from "@tanstack/react-router"; import { House, LayoutDashboard, LogIn, Settings, Users, Video, } from "lucide-react"; import { useTranslation } from "react-i18next"; import { useSession } from "../lib/session"; import { useStore } from "../lib/store"; import { Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupLabel, SidebarHeader, SidebarMenu, SidebarMenuButton, SidebarMenuItem, SidebarSeparator, } from "./ui/sidebar"; export default function SidebarComponent() { const { t } = useTranslation("common"); const { state } = useSession(); const isAuthenticated = state.status === "authenticated"; const matchRoute = useMatchRoute(); // Active state follows the current route. Home matches exactly (the // root route is an ancestor of every page); the others match their // sub-routes too (e.g. /settings/account highlights Settings). const isHomeActive = matchRoute({ to: "/", fuzzy: false }) !== false; const isVideosActive = matchRoute({ to: "/videos", fuzzy: false }) !== false; const isDashboardActive = matchRoute({ to: "/dashboard", fuzzy: true }) !== false; const isSettingsActive = matchRoute({ to: "/settings", fuzzy: true }) !== false; return ( {t("nav-home")} {t("nav-following")} {isAuthenticated && ( {t("nav-dashboard", { defaultValue: "Dashboard" })} )} {t("nav-account")} useStore.getState().openLoginModal()} > {t("log-in")} {t("nav-settings")} ); }