-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdiff-sidebar.patch
More file actions
138 lines (135 loc) · 4.66 KB
/
diff-sidebar.patch
File metadata and controls
138 lines (135 loc) · 4.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
diff --git a/admin/src/components/layout/Sidebar.tsx b/admin/src/components/layout/Sidebar.tsx
index e9204271..9dd7ca50 100644
--- a/admin/src/components/layout/Sidebar.tsx
+++ b/admin/src/components/layout/Sidebar.tsx
@@ -1,39 +1,81 @@
import React from 'react';
import { NavLink } from 'react-router-dom';
+import { useAuth } from '@/context/AuthContext';
import {
BarChart3,
FileText,
+ CreditCard,
History,
Webhook,
Key,
Building,
GitBranch,
Settings,
+ User,
+ LogOut,
+ ScrollText,
+ Book,
+ HelpCircle,
} from 'lucide-react';
+import type { LucideIcon } from 'lucide-react';
import { cn } from '@/lib/utils';
-const navigation = [
- { name: 'Dashboard', href: '/', icon: BarChart3 },
- { name: 'Rules', href: '/rules', icon: FileText },
- { name: 'Validation Logs', href: '/validation-logs', icon: History },
- { name: 'Webhooks', href: '/webhooks', icon: Webhook },
- { name: 'API Keys', href: '/api-keys', icon: Key },
- { name: 'Tenants', href: '/tenants', icon: Building },
- { name: 'Versions', href: '/versions', icon: GitBranch },
- { name: 'Settings', href: '/settings', icon: Settings },
-];
+
+export const ROUTE_PATHS = {
+ DASHBOARD: '/',
+ RULES: '/rules',
+ BILLING: '/billing',
+ LOGS: '/logs',
+ VALIDATION_LOGS: '/validation-logs',
+ DOCS: '/docs',
+ SUPPORT: '/support',
+ WEBHOOKS: '/webhooks',
+ API_KEYS: '/api-keys',
+ TENANTS: '/tenants',
+ VERSIONS: '/versions',
+ SETTINGS: '/settings',
+ PROFILE: '/profile',
+} as const;
+
+export type RouteKey = keyof typeof ROUTE_PATHS;
+export type RoutePath = (typeof ROUTE_PATHS)[RouteKey];
+
+type NavigationItem = Readonly<{
+ name: string;
+ href: RoutePath;
+ icon: LucideIcon;
+}>;
+
+const NAVIGATION_ITEMS = [
+ { name: 'Dashboard', href: ROUTE_PATHS.DASHBOARD, icon: BarChart3 },
+ { name: 'Rules', href: ROUTE_PATHS.RULES, icon: FileText },
+ { name: 'Billing', href: ROUTE_PATHS.BILLING, icon: CreditCard },
+ { name: 'Logs', href: ROUTE_PATHS.LOGS, icon: ScrollText },
+ { name: 'Validation Logs', href: ROUTE_PATHS.VALIDATION_LOGS, icon: History },
+ { name: 'Docs', href: ROUTE_PATHS.DOCS, icon: Book },
+ { name: 'Support', href: ROUTE_PATHS.SUPPORT, icon: HelpCircle },
+ { name: 'Webhooks', href: ROUTE_PATHS.WEBHOOKS, icon: Webhook },
+ { name: 'API Keys', href: ROUTE_PATHS.API_KEYS, icon: Key },
+ { name: 'Tenants', href: ROUTE_PATHS.TENANTS, icon: Building },
+ { name: 'Versions', href: ROUTE_PATHS.VERSIONS, icon: GitBranch },
+ { name: 'Settings', href: ROUTE_PATHS.SETTINGS, icon: Settings },
+ { name: 'Profile', href: ROUTE_PATHS.PROFILE, icon: User },
+] as const satisfies ReadonlyArray<NavigationItem>;
const Sidebar: React.FC = () => {
+ const { currentUser, logout } = useAuth();
+
return (
- <div className="w-64 bg-card border-r border-border">
+ <div className="w-64 bg-card border-r border-border flex flex-col h-full">
<div className="flex items-center h-16 px-6 border-b border-border">
<h1 className="text-xl font-bold">
{import.meta.env.VITE_DASHBOARD_TITLE || 'ICC Rule Engine'}
</h1>
</div>
- <nav className="mt-8 px-4">
+
+ <nav className="mt-8 px-4 flex-1">
<ul className="space-y-2">
- {navigation.map((item) => (
+ {NAVIGATION_ITEMS.map((item) => (
<li key={item.name}>
<NavLink
to={item.href}
@@ -53,8 +95,36 @@ const Sidebar: React.FC = () => {
))}
</ul>
</nav>
+
+ {/* User info and logout */}
+ {currentUser && (
+ <div className="p-4 border-t border-border">
+ <div className="space-y-3">
+ <div className="text-sm">
+ <p className="font-medium text-foreground truncate">
+ {(() => {
+ const name = [currentUser.first_name, currentUser.last_name].filter(Boolean).join(' ');
+ return name || currentUser.email;
+ })()}
+ </p>
+ <p className="text-muted-foreground text-xs truncate">{currentUser.email}</p>
+ <p className="text-muted-foreground text-xs capitalize">
+ {currentUser.role === 'admin' ? 'Admin' : 'User'}
+ </p>
+ </div>
+ <button
+ onClick={logout}
+ className="flex items-center w-full px-2 py-1 text-sm font-medium text-muted-foreground rounded-md hover:bg-accent hover:text-accent-foreground transition-colors"
+ >
+ <LogOut className="mr-3 h-4 w-4" />
+ Sign out
+ </button>
+ </div>
+ </div>
+ )}
</div>
);
};
-export { Sidebar };
\ No newline at end of file
+export { Sidebar };
+