diff --git a/src/components/layout/Sidebar.tsx b/src/components/layout/Sidebar.tsx index c1c46a6..c393dde 100644 --- a/src/components/layout/Sidebar.tsx +++ b/src/components/layout/Sidebar.tsx @@ -12,7 +12,6 @@ import { Shield, BadgeCheck, GitBranch, - Briefcase, ChevronDown, ChevronRight, Bell, @@ -73,18 +72,6 @@ const tenantAdminPlatformMenu: MenuItem[] = [ path: "/tenant/roles", requiredPermission: { resource: "roles" }, }, - { - icon: Briefcase, - label: "My Tasks", - path: "/tenant/tasks", - requiredPermission: { resource: "workflow" }, - }, - { - icon: Users, - label: "Users", - path: "/tenant/users", - requiredPermission: { resource: "users" }, - }, { icon: Building2, label: "Departments", @@ -97,12 +84,6 @@ const tenantAdminPlatformMenu: MenuItem[] = [ path: "/tenant/designations", requiredPermission: { resource: "designations" }, }, - { - icon: GitBranch, - label: "Workflow Definitions", - path: "/tenant/workflow-definitions", - requiredPermission: { resource: "workflow" }, - }, { icon: Users, label: "Suppliers", @@ -110,23 +91,70 @@ const tenantAdminPlatformMenu: MenuItem[] = [ requiredPermission: { resource: "supplier" }, }, { - icon: FileText, - label: "Document Services", + icon: Users, + label: "Users", + path: "/tenant/users", + requiredPermission: { resource: "users" }, + }, +]; + +const tenantAdminPlatformServiceMenu: MenuItem[] = [ + { + icon: GitBranch, + label: "Workflows", isGroup: true, children: [ - { label: "Document Lists", path: "/tenant/documents", requiredPermission: { resource: "document" } }, - { label: "Create Document", path: "/tenant/documents/create", requiredPermission: { resource: "document", action: "create" } }, - { label: "Categories", path: "/tenant/documents/categories", requiredPermission: { resource: "document" } }, - { label: "Due for Review", path: "/tenant/documents/due-for-review", requiredPermission: { resource: "document" } }, + { + label: "Definitions", + path: "/tenant/workflows/definitions", + requiredPermission: { resource: "workflow" }, + }, + { + label: "Tasks", + path: "/tenant/workflows/tasks", + requiredPermission: { resource: "workflow" }, + }, + ], + requiredPermission: { resource: "workflow" }, + }, + { + icon: FileText, + label: "Documents", + isGroup: true, + children: [ + { + label: "Document Lists", + path: "/tenant/documents", + requiredPermission: { resource: "document" }, + }, + { + label: "Create Document", + path: "/tenant/documents/create", + requiredPermission: { resource: "document", action: "create" }, + }, + { + label: "Categories", + path: "/tenant/documents/categories", + requiredPermission: { resource: "document" }, + }, + { + label: "Due for Review", + path: "/tenant/documents/due-for-review", + requiredPermission: { resource: "document" }, + }, ], requiredPermission: { resource: "document" }, }, { icon: Paperclip, - label: "File Attachment Services", + label: "File Attachments", isGroup: true, children: [ - { label: "Files List", path: "/tenant/files", requiredPermission: { resource: "files" } }, + { + label: "Files List", + path: "/tenant/files", + requiredPermission: { resource: "files" }, + }, ], requiredPermission: { resource: "files" }, }, @@ -153,31 +181,37 @@ const tenantAdminSystemMenu: MenuItem[] = [ }, ]; -const GroupMenuItem = ({ - item, - childrenItems, - location, - isSuperAdmin, - theme, - onClose -}: { - item: MenuItem; - childrenItems: any[]; - location: any; - isSuperAdmin: boolean; - theme: any; +const GroupMenuItem = ({ + item, + childrenItems, + location, + isSuperAdmin, + theme, + onClose, +}: { + item: MenuItem; + childrenItems: any[]; + location: any; + isSuperAdmin: boolean; + theme: any; onClose: () => void; }) => { const isChildActive = (path: string) => { // Special handling for Document Lists to NOT show as active when sub-actions are active if (path === "/tenant/documents") { const subActions = ["/create", "/categories", "/due-for-review", "/edit"]; - const isSubActionActive = subActions.some(sub => location.pathname.startsWith(path + sub)); + const isSubActionActive = subActions.some((sub) => + location.pathname.startsWith(path + sub), + ); if (isSubActionActive) return false; } - return location.pathname === path || location.pathname.startsWith(`${path}/`); + return ( + location.pathname === path || location.pathname.startsWith(`${path}/`) + ); }; - const isAnyChildActive = childrenItems.some(child => isChildActive(child.path)); + const isAnyChildActive = childrenItems.some((child) => + isChildActive(child.path), + ); const [isExpanded, setIsExpanded] = useState(isAnyChildActive); useEffect(() => { @@ -192,22 +226,41 @@ const GroupMenuItem = ({ onClick={() => setIsExpanded(!isExpanded)} className={cn( "flex items-center justify-between gap-2.5 px-3 py-2 rounded-md transition-all min-h-[44px]", - isAnyChildActive ? "shadow-[0px_2px_8px_0px_rgba(15,23,42,0.15)]" : "text-[#0f1724] hover:bg-gray-50" + isAnyChildActive + ? "shadow-[0px_2px_8px_0px_rgba(15,23,42,0.15)]" + : "text-[#0f1724] hover:bg-gray-50", )} - style={isAnyChildActive ? { - backgroundColor: !isSuperAdmin && theme?.primary_color ? theme.primary_color : "#112868", - color: !isSuperAdmin && theme?.secondary_color ? theme.secondary_color : "#23dce1" - } : undefined} + style={ + isAnyChildActive + ? { + backgroundColor: + !isSuperAdmin && theme?.primary_color + ? theme.primary_color + : "#112868", + color: + !isSuperAdmin && theme?.secondary_color + ? theme.secondary_color + : "#23dce1", + } + : undefined + } >
- + {item.label}
- {isExpanded ? : } + {isExpanded ? ( + + ) : ( + + )} - + {isExpanded && (
{childrenItems.map((child) => { @@ -223,13 +276,24 @@ const GroupMenuItem = ({ }} className={cn( "flex items-center px-4 py-2 rounded-r-md text-[13px] font-medium transition-all", - isActive - ? "text-[#112868] font-bold bg-gray-50" - : "text-[#475569] hover:text-[#0f1724] hover:bg-gray-50" + isActive + ? "text-[#112868] font-bold bg-gray-50" + : "text-[#475569] hover:text-[#0f1724] hover:bg-gray-50", )} - style={isActive ? { color: !isSuperAdmin && theme?.primary_color ? theme.primary_color : "#112868" } : undefined} + style={ + isActive + ? { + color: + !isSuperAdmin && theme?.primary_color + ? theme.primary_color + : "#112868", + } + : undefined + } > - {child.label} + + {child.label} + ); })} @@ -348,11 +412,11 @@ export const Sidebar = ({ isOpen, onClose }: SidebarProps) => { child.requiredPermission.action, ); }); - + // We need to return a new object to avoid issues if (filteredChildren.length > 0) { - (item as any)._filteredChildren = filteredChildren; - return true; + (item as any)._filteredChildren = filteredChildren; + return true; } return false; } @@ -365,6 +429,9 @@ export const Sidebar = ({ isOpen, onClose }: SidebarProps) => { const platformMenu = filterMenuItems( isSuperAdmin ? superAdminPlatformMenu : tenantAdminPlatformMenu, ); + const platformServiceMenu = filterMenuItems( + isSuperAdmin ? [] : tenantAdminPlatformServiceMenu, + ); const systemMenu = filterMenuItems( isSuperAdmin ? superAdminSystemMenu : tenantAdminSystemMenu, ); @@ -386,11 +453,12 @@ export const Sidebar = ({ isOpen, onClose }: SidebarProps) => {
{items.map((item) => { if (item.isGroup) { - const children = (item as any)._filteredChildren || item.children || []; + const children = + (item as any)._filteredChildren || item.children || []; return ( - { const isTenantDashboardPath = item.path === "/tenant"; const isActive = isTenantDashboardPath ? location.pathname === "/tenant" - : item.path && (location.pathname === item.path || - location.pathname.startsWith(`${item.path}/`)); + : item.path && + (location.pathname === item.path || + location.pathname.startsWith(`${item.path}/`)); return ( { } > - + {item.label} @@ -513,6 +585,7 @@ export const Sidebar = ({ isOpen, onClose }: SidebarProps) => {
{/* Platform Menu */} + {/* System Menu */} @@ -551,7 +624,11 @@ export const Sidebar = ({ isOpen, onClose }: SidebarProps) => { src={logoUrl} alt="Logo" className="h-9 w-auto max-w-[180px] object-contain" - fallback={
} + fallback={ +
+ +
+ } /> ) : null}
{ {platformMenu.length > 0 && ( )} + {platformServiceMenu.length > 0 && ( + + )} {/* System Menu */} {systemMenu.length > 0 && ( diff --git a/src/components/shared/NotificationBell.tsx b/src/components/shared/NotificationBell.tsx index 7758708..d52a649 100644 --- a/src/components/shared/NotificationBell.tsx +++ b/src/components/shared/NotificationBell.tsx @@ -78,7 +78,7 @@ export const NotificationBell = () => { // Special handling for tasks as requested - redirect to My Tasks tab if (['workflow', 'training'].includes(notification.category || '')) { - navigate('/tenant/tasks'); + navigate('/tenant/workflows/tasks'); setIsOpen(false); return; } diff --git a/src/components/shared/NotificationProvider.tsx b/src/components/shared/NotificationProvider.tsx index b86ea1e..9c106d3 100644 --- a/src/components/shared/NotificationProvider.tsx +++ b/src/components/shared/NotificationProvider.tsx @@ -41,7 +41,7 @@ export const NotificationProvider = ({ children }: NotificationProviderProps) => label: 'View', onClick: () => { if (['workflow', 'training'].includes(notification.category || '')) { - navigate('/tenant/tasks'); + navigate('/tenant/workflows/tasks'); } else { navigate(notification.action_url); } diff --git a/src/pages/tenant/Dashboard.tsx b/src/pages/tenant/Dashboard.tsx index b9cd98d..752d4d6 100644 --- a/src/pages/tenant/Dashboard.tsx +++ b/src/pages/tenant/Dashboard.tsx @@ -335,7 +335,7 @@ const Dashboard = (): ReactElement => {

My Tasks

+ )} +
, }, { - path: "/tenant/workflow-definitions", + path: "/tenant/workflows/definitions", element: , }, { @@ -121,7 +121,7 @@ export const tenantAdminRoutes: RouteConfig[] = [ element: , }, { - path: "/tenant/tasks", + path: "/tenant/workflows/tasks", element: , }, { diff --git a/src/services/file-attachment-service.ts b/src/services/file-attachment-service.ts index 016493b..2bd5b96 100644 --- a/src/services/file-attachment-service.ts +++ b/src/services/file-attachment-service.ts @@ -154,6 +154,7 @@ export interface FileListParams { category?: string; category_id?: string; source_module?: string; + source_module_id?: string; search?: string; tags?: string; uploaded_by?: string; diff --git a/src/services/workflow-service.ts b/src/services/workflow-service.ts index fb33c0c..1f56a1b 100644 --- a/src/services/workflow-service.ts +++ b/src/services/workflow-service.ts @@ -93,13 +93,18 @@ class WorkflowService { return response.data; } - async listTasks(params?: { limit?: number; offset?: number }): Promise { + async listTasks(params?: { + limit?: number; + offset?: number; + status?: string | null; + module_id?: string | null; + }): Promise { const response = await apiClient.get(`${this.baseUrl}/tasks`, { params }); return response.data; } - async getTaskCounts(): Promise { - const response = await apiClient.get(`${this.baseUrl}/tasks/counts`); + async getTaskCounts(params?: { module_id?: string | null; entity_type?: string | null; entity_id?: string | null }): Promise { + const response = await apiClient.get(`${this.baseUrl}/tasks/counts`, { params }); return response.data; }