feat(auth): implement role-based dashboard redirect

This commit is contained in:
dhinesh-m24
2026-01-29 11:43:19 +05:30
parent d07d42ad0b
commit e214e32c17
12 changed files with 713 additions and 78 deletions

View File

@@ -0,0 +1,240 @@
import {
LayoutDashboard,
Briefcase,
Calendar,
Users,
ShoppingBag,
FileText,
PiggyBank,
BarChart2,
Clock,
ClipboardList,
Scale,
UserPlus,
Users2,
ShieldCheck,
Receipt,
Building2,
DollarSign,
PieChart,
History,
MessageSquare,
BookOpen,
HelpCircle,
} from 'lucide-react';
import type { LucideIcon } from 'lucide-react';
export type Role = 'Admin' | 'Client' | 'Vendor';
export interface NavItem {
label: string;
path: string;
icon: LucideIcon;
allowedRoles: Role[];
}
export interface NavGroup {
title: string;
items: NavItem[];
}
export const ALL_ROLES: Role[] = ['Admin', 'Client', 'Vendor'];
export const NAV_CONFIG: NavGroup[] = [
{
title: 'Overview',
items: [
{
label: 'Dashboard',
path: '/dashboard/admin',
icon: LayoutDashboard,
allowedRoles: ['Admin'],
},
{
label: 'Dashboard',
path: '/dashboard/client',
icon: LayoutDashboard,
allowedRoles: ['Client'],
},
{
label: 'Dashboard',
path: '/dashboard/vendor',
icon: LayoutDashboard,
allowedRoles: ['Vendor'],
},
{
label: 'Savings Engine',
path: '/savings',
icon: PiggyBank,
allowedRoles: ALL_ROLES,
},
{
label: 'Vendor Performance',
path: '/performance',
icon: BarChart2,
allowedRoles: ['Vendor', 'Admin'],
},
],
},
{
title: 'Operations',
items: [
{
label: 'Orders',
path: '/orders/client',
icon: Briefcase,
allowedRoles: ['Client'],
},
{
label: 'Orders',
path: '/orders/vendor',
icon: Briefcase,
allowedRoles: ['Vendor'],
},
{
label: 'Orders',
path: '/orders',
icon: Briefcase,
allowedRoles: ['Admin'],
},
{
label: 'Schedule',
path: '/schedule',
icon: Calendar,
allowedRoles: ALL_ROLES,
},
{
label: 'Staff Availability',
path: '/availability',
icon: Clock,
allowedRoles: ALL_ROLES,
},
{
label: 'Task Board',
path: '/tasks',
icon: ClipboardList,
allowedRoles: ALL_ROLES,
},
],
},
{
title: 'Marketplace',
items: [
{
label: 'Discovery',
path: '/marketplace',
icon: ShoppingBag,
allowedRoles: ['Client', 'Admin'],
},
{
label: 'Compare Rates',
path: '/marketplace/compare',
icon: Scale,
allowedRoles: ['Client', 'Admin'],
},
],
},
{
title: 'Workforce',
items: [
{
label: 'Staff Directory',
path: '/staff',
icon: Users,
allowedRoles: ALL_ROLES,
},
{
label: 'Onboarding',
path: '/onboarding',
icon: UserPlus,
allowedRoles: ALL_ROLES,
},
{
label: 'Teams',
path: '/teams',
icon: Users2,
allowedRoles: ALL_ROLES,
},
{
label: 'Compliance',
path: '/compliance',
icon: ShieldCheck,
allowedRoles: ['Vendor', 'Admin'],
},
{
label: 'Documents',
path: '/documents',
icon: FileText,
allowedRoles: ['Vendor', 'Admin'],
},
],
},
{
title: 'Finance',
items: [
{
label: 'Invoices',
path: '/invoices',
icon: Receipt,
allowedRoles: ALL_ROLES,
},
],
},
{
title: 'Business',
items: [
{
label: 'Clients',
path: '/clients',
icon: Building2,
allowedRoles: ['Vendor', 'Admin'],
},
{
label: 'Service Rates',
path: '/rates',
icon: DollarSign,
allowedRoles: ['Vendor', 'Admin'],
},
],
},
{
title: 'Analytics & Comm',
items: [
{
label: 'Reports',
path: '/reports',
icon: PieChart,
allowedRoles: ALL_ROLES,
},
{
label: 'Activity Log',
path: '/activity',
icon: History,
allowedRoles: ['Vendor', 'Admin'],
},
{
label: 'Messages',
path: '/messages',
icon: MessageSquare,
allowedRoles: ALL_ROLES,
},
{
label: 'Tutorials',
path: '/tutorials',
icon: BookOpen,
allowedRoles: ['Client', 'Admin'],
},
],
},
{
title: 'Support',
items: [
{
label: 'Help Center',
path: '/support',
icon: HelpCircle,
allowedRoles: ['Client', 'Admin'],
},
],
},
];