Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

1.5 KB
Raw Blame
import { useLocation } from "@tanstack/react-router";
import { useEffect } from "react";
import { normalizeSettingsPath } from "@/components/settings/nav/get-settings-breadcrumb";
import { SettingsNavGroup } from "@/components/settings/nav/settings-nav-group";
import { SettingsNavProjects } from "@/components/settings/nav/settings-nav-projects";
import { SettingsSidebarHeader } from "@/components/settings/nav/settings-sidebar-header";
import type { SettingsNav } from "@/components/settings/nav/types";
import { Sidebar, SidebarContent, useSidebar } from "@/components/ui/sidebar";

type SettingsSidebarProps = {
  nav: SettingsNav;
  onLeave: (() => void) | undefined;
};

export function SettingsSidebar({ nav, onLeave }: SettingsSidebarProps) {
  const pathname = useLocation({
    select: (location) => normalizeSettingsPath(location.pathname),
  });
  const { setOpenMobile } = useSidebar();

  useEffect(() => {
    if (pathname) setOpenMobile(false);
  }, [pathname, setOpenMobile]);

  return (
    <Sidebar collapsible="offcanvas" variant="inset" className="border-none">
      <SettingsSidebarHeader onLeave={onLeave} />
      <SidebarContent className="gap-0 pb-2">
        <SettingsNavGroup group={nav.account} pathname={pathname} />
        <SettingsNavGroup group={nav.workspace} pathname={pathname} />
        <SettingsNavProjects projects={nav.projects} pathname={pathname} />
        {nav.admin ? (
          <SettingsNavGroup group={nav.admin} pathname={pathname} />
        ) : null}
      </SidebarContent>
    </Sidebar>
  );
}