From 8ede458a711ce3e8cf5eabc897a4fc258570057b Mon Sep 17 00:00:00 2001 From: seriouselly Date: Fri, 12 Jun 2026 11:27:23 +0700 Subject: [PATCH 1/3] refactor(sidebar): set initial state to collapsed by default - Update `isSidebarOpen` initial state from true to false in `sidebar.tsx`. - Ensure the sidebar starts in a mini/collapsed mode when the dashboard is first loaded to provide more space for the main content. --- apps/web/src/components/layout/sidebar.tsx | 23 ++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/apps/web/src/components/layout/sidebar.tsx b/apps/web/src/components/layout/sidebar.tsx index 0a53a54..8fa5825 100644 --- a/apps/web/src/components/layout/sidebar.tsx +++ b/apps/web/src/components/layout/sidebar.tsx @@ -13,21 +13,31 @@ import { ChartBar, } from "lucide-react"; import { MobileNav } from "./mobile-nav"; +import { useAuthStore } from "@/store/auth-store"; const NAV_ITEMS = [ { path: "/dashboard", label: "Dashboard", icon: LayoutDashboard }, { path: "/scan", label: "Pindai Daun", icon: Scan }, { path: "/diagnoses", label: "Diagnosa", icon: Activity }, { path: "/catalog", label: "Pustaka", icon: BookOpen, altPath: "/library" }, - { path: "/expert/reviews", label: "Tinjauan Pakar", icon: UserCheck }, - { path: "/telemetry", label: "Telemetry", icon: ChartBar }, + { path: "/expert/reviews", label: "Tinjauan Pakar", icon: UserCheck, expertOnly: true }, + { path: "/telemetry", label: "Telemetry", icon: ChartBar, expertOnly: true }, ]; export function Sidebar() { const location = useLocation(); - const [isSidebarOpen, setIsSidebarOpen] = useState(true); + const [isSidebarOpen, setIsSidebarOpen] = useState(false); const [mobileMenuOpen, setMobileMenuOpen] = useState(false); + const user = useAuthStore((state) => state.user); + const isExpert = user?.role === "expert"; + + const filteredNavItems = NAV_ITEMS.filter((item) => { if (!item.expertOnly || isExpert) { + return true; + } + return false; +}); + const isActive = (path: string, altPath?: string) => { if (path === "/dashboard" || path === "/scan") { return location.pathname === path; @@ -83,7 +93,12 @@ export function Sidebar() {