58 lines
1.7 KiB
TypeScript
58 lines
1.7 KiB
TypeScript
"use client";
|
|
|
|
import * as React from "react";
|
|
|
|
import { NavMain } from "@/app/(pages)/(admin)/_components/navigations/nav-main";
|
|
import { NavReports } from "@/app/(pages)/(admin)/_components/navigations/nav-report";
|
|
import { NavUser } from "@/app/(pages)/(admin)/_components/navigations/nav-user";
|
|
|
|
import {
|
|
Sidebar,
|
|
SidebarContent,
|
|
SidebarFooter,
|
|
SidebarHeader,
|
|
SidebarRail,
|
|
} from "@/app/_components/ui/sidebar";
|
|
import { NavPreMain } from "./navigations/nav-pre-main";
|
|
import { navData } from "@/prisma/data/nav";
|
|
import { TeamSwitcher } from "../../../_components/team-switcher";
|
|
import { useGetCurrentUserQuery } from "../dashboard/user-management/_queries/queries";
|
|
|
|
|
|
export function AppSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) {
|
|
const { data: user, isPending, error } = useGetCurrentUserQuery()
|
|
|
|
// React.useEffect(() => {
|
|
// async function fetchUser() {
|
|
// try {
|
|
// setIsLoading(true);
|
|
// const userData = await getCurrentUser();
|
|
// setUser(userData.data.user);
|
|
// } catch (error) {
|
|
// console.error("Failed to fetch user:", error);
|
|
// } finally {
|
|
// setIsLoading(false);
|
|
// }
|
|
// }
|
|
|
|
// fetchUser();
|
|
// }, []);
|
|
|
|
return (
|
|
<Sidebar collapsible="icon" {...props}>
|
|
<SidebarHeader>
|
|
<TeamSwitcher teams={navData.teams} />
|
|
</SidebarHeader>
|
|
<SidebarContent>
|
|
<NavPreMain items={navData.NavPreMain} />
|
|
<NavMain items={navData.navMain} />
|
|
<NavReports reports={navData.reports} />
|
|
</SidebarContent>
|
|
<SidebarFooter>
|
|
<NavUser user={user ?? null} />
|
|
</SidebarFooter>
|
|
<SidebarRail />
|
|
</Sidebar>
|
|
);
|
|
}
|