From 0f114f19b57231b3b8af9a3454ff84726ec636e2 Mon Sep 17 00:00:00 2001 From: admin Date: Fri, 20 Feb 2026 17:00:10 +0700 Subject: [PATCH] 260220:1700 20260220 TASK-BEFE-001 Refactor by ADR-014 #5 --- frontend/components/layout/sidebar.tsx | 40 +++++++------- frontend/hooks/use-drawing.ts | 52 +++++++++++-------- .../lib/services/asbuilt-drawing.service.ts | 12 ++--- .../lib/services/contract-drawing.service.ts | 16 +++--- frontend/lib/services/shop-drawing.service.ts | 12 ++--- .../lib/services/workflow-engine.service.ts | 40 +++++++------- 6 files changed, 88 insertions(+), 84 deletions(-) diff --git a/frontend/components/layout/sidebar.tsx b/frontend/components/layout/sidebar.tsx index ffb8130..7f4c743 100644 --- a/frontend/components/layout/sidebar.tsx +++ b/frontend/components/layout/sidebar.tsx @@ -13,13 +13,22 @@ import { Shield, Menu, Layers, - BookOpen, + LucideIcon, } from 'lucide-react'; import { Button } from '@/components/ui/button'; import { useState } from 'react'; import { Can } from '@/components/common/can'; +import { useAuthStore } from '@/lib/stores/auth-store'; -export const mainNavItems = [ +export type NavItem = { + title: string; + href: string; + icon: LucideIcon; + permission?: string | null; + adminOnly?: boolean; +}; + +export const mainNavItems: NavItem[] = [ { title: 'Dashboard', href: '/dashboard', @@ -67,24 +76,7 @@ export const mainNavItems = [ href: '/admin', icon: Shield, permission: null, - }, - { - title: 'Security', - href: '/admin/access-control/roles', - icon: Shield, - permission: 'system.manage_security', - }, - { - title: 'System Logs', - href: '/admin/monitoring/system-logs/numbering', - icon: Layers, - permission: 'system.view_logs', - }, - { - title: 'Reference Data', - href: '/admin/doc-control/reference', - icon: BookOpen, - permission: 'master_data.view', + adminOnly: true, }, ]; @@ -95,6 +87,8 @@ interface SidebarProps { export function Sidebar({ className }: SidebarProps) { const pathname = usePathname(); const [collapsed, setCollapsed] = useState(false); + const user = useAuthStore((state) => state.user); + const isAdmin = user?.role === 'ADMIN' || user?.role === 'DC'; return (