From c13afa75543f5d1196d08293584564a4a8739221 Mon Sep 17 00:00:00 2001 From: "santasri.pachhal" Date: Mon, 10 Aug 2026 16:08:50 +0530 Subject: [PATCH] feat(ui): improve collapsed sidebar and status action icons --- .../(modules)/roles/components/RoleTable.tsx | 9 ++- .../(modules)/users/components/UserTable.tsx | 9 ++- src/components/app-sidebar.tsx | 55 +++++++++++++++++++ src/components/data-table/index.tsx | 8 ++- 4 files changed, 75 insertions(+), 6 deletions(-) diff --git a/src/app/(modules)/roles/components/RoleTable.tsx b/src/app/(modules)/roles/components/RoleTable.tsx index 8b0f95e..8aa8834 100644 --- a/src/app/(modules)/roles/components/RoleTable.tsx +++ b/src/app/(modules)/roles/components/RoleTable.tsx @@ -2,7 +2,7 @@ import type { ColumnDef, SortingState } from '@tanstack/react-table'; import type { ReactNode } from 'react'; -import { Edit, RotateCcw } from 'lucide-react'; +import { Edit, ShieldCheck, ShieldX } from 'lucide-react'; import { DataTable } from '@/components/data-table'; import { PERMISSIONS } from '@/constants/permissions'; @@ -58,7 +58,12 @@ export function RoleTable({ }, { label: (role) => (role.effective_status ? 'Deactivate' : 'Activate'), - icon: , + icon: (role) => + role.effective_status ? ( + + ) : ( + + ), permission: PERMISSIONS.ROLE.DELETE, disabled: () => isStatusPending, onClick: onToggleStatus, diff --git a/src/app/(modules)/users/components/UserTable.tsx b/src/app/(modules)/users/components/UserTable.tsx index cb1476e..2997abb 100644 --- a/src/app/(modules)/users/components/UserTable.tsx +++ b/src/app/(modules)/users/components/UserTable.tsx @@ -2,7 +2,7 @@ import type { ReactNode } from 'react'; import type { ColumnDef, SortingState } from '@tanstack/react-table'; -import { Edit, RotateCcw } from 'lucide-react'; +import { Edit, UserCheck, UserX } from 'lucide-react'; import { DataTable } from '@/components/data-table'; import { PERMISSIONS } from '@/constants/permissions'; @@ -59,7 +59,12 @@ export function UserTable({ { label: (user) => user.effective_status === 'active' ? 'Deactivate' : 'Activate', - icon: , + icon: (user) => + user.effective_status === 'active' ? ( + + ) : ( + + ), permission: PERMISSIONS.USER.DELETE, disabled: (user) => pendingUserId === user.id || user.effective_status === 'pending', diff --git a/src/components/app-sidebar.tsx b/src/components/app-sidebar.tsx index cf76c3a..0647935 100644 --- a/src/components/app-sidebar.tsx +++ b/src/components/app-sidebar.tsx @@ -14,6 +14,14 @@ import { CollapsibleContent, CollapsibleTrigger, } from '@/components/ui/collapsible'; +import { + DropdownMenu, + DropdownMenuContent, + DropdownMenuItem, + DropdownMenuLabel, + DropdownMenuSeparator, + DropdownMenuTrigger, +} from '@/components/ui/dropdown-menu'; import { Sidebar, SidebarContent, @@ -124,6 +132,7 @@ function SidebarNavItem({ item: MenuItem; pathname: string; }) { + const { isMobile, state } = useSidebar(); const isActive = isRouteActive(pathname, item.path); const isChildActive = item.children?.some((child) => isRouteActive(pathname, child.path)) ?? @@ -136,6 +145,52 @@ function SidebarNavItem({ }, [isChildActive]); if (hasChildren) { + if (state === 'collapsed' && !isMobile) { + return ( + + + + + + {item.title} + + + + + {item.title} + + {item.children?.map((child) => + child.path ? ( + + + + {child.title} + + + ) : null, + )} + + + + ); + } + return ( { label: string | ((item: TData) => string); - icon: React.ReactNode; + icon: React.ReactNode | ((item: TData) => React.ReactNode); onClick: (item: TData) => void; permission?: PermissionInput; disabled?: (item: TData) => boolean; @@ -163,6 +163,10 @@ function DataTableContent({ typeof action.label === 'function' ? action.label(item) : action.label; + const icon = + typeof action.icon === 'function' + ? action.icon(item) + : action.icon; return ( ({ action.onClick(item); }} > - {action.icon} + {icon} ); })}