← full-stack-fastapi-template  /  frontend/src/components/Sidebar/AppSidebar.tsx

1
import { Briefcase, Home, Users } from "lucide-react"
2
3
import { SidebarAppearance } from "@/components/Common/Appearance"
4
import { Logo } from "@/components/Common/Logo"
5
import {
6
  Sidebar,
7
  SidebarContent,
8
  SidebarFooter,
9
  SidebarHeader,
10
} from "@/components/ui/sidebar"
11
import useAuth from "@/hooks/useAuth"
12
import { type Item, Main } from "./Main"
13
import { User } from "./User"
14
15
const baseItems: Item[] = [
16
  { icon: Home, title: "Dashboard", path: "/" },
17
  { icon: Briefcase, title: "Items", path: "/items" },
18
]
19
20
export function AppSidebar() {
21
  const { user: currentUser } = useAuth()
22
23
  const items = currentUser?.is_superuser
24
    ? [...baseItems, { icon: Users, title: "Admin", path: "/admin" }]
25
    : baseItems
26
27
  return (
28
    <Sidebar collapsible="icon">
29
      <SidebarHeader className="px-4 py-6 group-data-[collapsible=icon]:px-0 group-data-[collapsible=icon]:items-center">
30
        <Logo variant="responsive" />
31
      </SidebarHeader>
32
      <SidebarContent>
33
        <Main items={items} />
34
      </SidebarContent>
35
      <SidebarFooter>
36
        <SidebarAppearance />
37
        <User user={currentUser} />
38
      </SidebarFooter>
39
    </Sidebar>
40
  )
41
}
42
43
export default AppSidebar
44