CognxSafeTrack commited on
Commit ·
3a9e766
1
Parent(s): 7eaff31
feat: implement conditional dashboard routing and adaptive sidebar based on organization useCase
Browse files- apps/admin/src/App.tsx +16 -10
apps/admin/src/App.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
import React from 'react';
|
| 2 |
import { BrowserRouter as Router, Routes, Route, Link, Navigate } from 'react-router-dom';
|
| 3 |
-
import { Users, BookOpen, Lightbulb, BarChart2, Mic, Activity, Building2, TrendingUp
|
| 4 |
|
| 5 |
import { AuthProvider, useAuth } from './lib/auth';
|
| 6 |
import { TenantProvider } from './lib/tenant';
|
|
@@ -51,18 +51,17 @@ function AppShell() {
|
|
| 51 |
}
|
| 52 |
}, [user, isSuperAdmin, setSelectedOrgId]);
|
| 53 |
|
| 54 |
-
const isCrmMode =
|
| 55 |
|
| 56 |
const allNavItems = [
|
| 57 |
{ to: '/', label: 'Dashboard', icon: <BarChart2 className="w-4 h-4" /> },
|
| 58 |
{ to: '/analytics', label: 'Statistiques', icon: <TrendingUp className="w-4 h-4 text-amber-500" /> },
|
| 59 |
-
{ to: '/
|
| 60 |
-
{ to: '/contacts', label: 'Base Contacts', icon: <Users className="w-4 h-4 text-blue-400" />, show: isCrmMode },
|
| 61 |
{ to: '/content', label: 'Parcours', icon: <BookOpen className="w-4 h-4" />, show: !isCrmMode },
|
| 62 |
-
{ to: '/live-feed', label: 'Modération', icon: <Mic className="w-4 h-4 text-emerald-500" /> },
|
| 63 |
-
{ to: '/clients', label: 'Clients B2B', icon: <Building2 className="w-4 h-4 text-indigo-400" />, superOnly: true },
|
| 64 |
-
{ to: '/training', label: 'Training Lab', icon: <Activity className="w-4 h-4 text-purple-400" />, superOnly: true },
|
| 65 |
-
{ to: '/users', label: 'Utilisateurs', icon: <Users className="w-4 h-4" /> },
|
| 66 |
{ to: '/settings', label: 'Paramètres', icon: <Lightbulb className="w-4 h-4" /> },
|
| 67 |
];
|
| 68 |
|
|
@@ -129,12 +128,19 @@ function AppShell() {
|
|
| 129 |
</aside>
|
| 130 |
<main className="flex-1 overflow-auto">
|
| 131 |
<Routes>
|
| 132 |
-
<Route
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 133 |
<Route path="/analytics" element={<AnalyticsPage />} />
|
| 134 |
<Route
|
| 135 |
path="/crm"
|
| 136 |
element={
|
| 137 |
-
|
| 138 |
? <CrmConversationalDashboard />
|
| 139 |
: <ConversationalDashboard />
|
| 140 |
}
|
|
|
|
| 1 |
import React from 'react';
|
| 2 |
import { BrowserRouter as Router, Routes, Route, Link, Navigate } from 'react-router-dom';
|
| 3 |
+
import { Users, BookOpen, Lightbulb, BarChart2, Mic, Activity, Building2, TrendingUp } from 'lucide-react';
|
| 4 |
|
| 5 |
import { AuthProvider, useAuth } from './lib/auth';
|
| 6 |
import { TenantProvider } from './lib/tenant';
|
|
|
|
| 51 |
}
|
| 52 |
}, [user, isSuperAdmin, setSelectedOrgId]);
|
| 53 |
|
| 54 |
+
const isCrmMode = currentOrg?.useCase === 'CRM_WHATSAPP';
|
| 55 |
|
| 56 |
const allNavItems = [
|
| 57 |
{ to: '/', label: 'Dashboard', icon: <BarChart2 className="w-4 h-4" /> },
|
| 58 |
{ to: '/analytics', label: 'Statistiques', icon: <TrendingUp className="w-4 h-4 text-amber-500" /> },
|
| 59 |
+
{ to: '/contacts', label: 'Clients', icon: <Users className="w-4 h-4 text-blue-400" />, show: isCrmMode },
|
|
|
|
| 60 |
{ to: '/content', label: 'Parcours', icon: <BookOpen className="w-4 h-4" />, show: !isCrmMode },
|
| 61 |
+
{ to: '/live-feed', label: 'Modération', icon: <Mic className="w-4 h-4 text-emerald-500" />, show: !isCrmMode },
|
| 62 |
+
{ to: '/clients', label: 'Clients B2B', icon: <Building2 className="w-4 h-4 text-indigo-400" />, superOnly: true, show: !isCrmMode },
|
| 63 |
+
{ to: '/training', label: 'Training Lab', icon: <Activity className="w-4 h-4 text-purple-400" />, superOnly: true, show: !isCrmMode },
|
| 64 |
+
{ to: '/users', label: 'Utilisateurs', icon: <Users className="w-4 h-4" />, show: !isCrmMode },
|
| 65 |
{ to: '/settings', label: 'Paramètres', icon: <Lightbulb className="w-4 h-4" /> },
|
| 66 |
];
|
| 67 |
|
|
|
|
| 128 |
</aside>
|
| 129 |
<main className="flex-1 overflow-auto">
|
| 130 |
<Routes>
|
| 131 |
+
<Route
|
| 132 |
+
path="/"
|
| 133 |
+
element={
|
| 134 |
+
isCrmMode
|
| 135 |
+
? <CrmConversationalDashboard />
|
| 136 |
+
: <DashboardPage />
|
| 137 |
+
}
|
| 138 |
+
/>
|
| 139 |
<Route path="/analytics" element={<AnalyticsPage />} />
|
| 140 |
<Route
|
| 141 |
path="/crm"
|
| 142 |
element={
|
| 143 |
+
isCrmMode
|
| 144 |
? <CrmConversationalDashboard />
|
| 145 |
: <ConversationalDashboard />
|
| 146 |
}
|