feat: open administration to all users
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m33s
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m33s
This commit is contained in:
13
src/App.tsx
13
src/App.tsx
@@ -2,7 +2,7 @@ import React, { Suspense } from 'react';
|
||||
import { Routes, Route, Navigate, useLocation } from 'react-router-dom';
|
||||
import { Loader2 } from 'lucide-react';
|
||||
import Layout from './components/Layout';
|
||||
import { isAuthenticated, isSuperAdmin } from './dataService';
|
||||
import { isAuthenticated } from './dataService';
|
||||
|
||||
const Dashboard = React.lazy(() => import('./pages/Dashboard'));
|
||||
const Products = React.lazy(() => import('./pages/Products'));
|
||||
@@ -34,13 +34,6 @@ function PrivateRoute({ children }: { children: React.ReactNode }) {
|
||||
return children;
|
||||
}
|
||||
|
||||
function SuperAdminRoute({ children }: { children: React.ReactNode }) {
|
||||
if (!isSuperAdmin()) {
|
||||
return <Navigate to="/graph" replace />;
|
||||
}
|
||||
return children;
|
||||
}
|
||||
|
||||
const RouteFallback = () => (
|
||||
<div className="flex min-h-screen items-center justify-center bg-dark-bg text-brand-primary">
|
||||
<Loader2 className="h-8 w-8 animate-spin" />
|
||||
@@ -75,8 +68,8 @@ function App() {
|
||||
<Route path="rfm" element={<Rfm />} />
|
||||
<Route path="campaigns" element={<Campaigns />} />
|
||||
<Route path="registrations" element={<Registrations />} />
|
||||
<Route path="admin/users" element={<SuperAdminRoute><AdminUsers /></SuperAdminRoute>} />
|
||||
<Route path="admin/olist" element={<SuperAdminRoute><OlistSync /></SuperAdminRoute>} />
|
||||
<Route path="admin/users" element={<AdminUsers />} />
|
||||
<Route path="admin/olist" element={<OlistSync />} />
|
||||
</Route>
|
||||
</Routes>
|
||||
</Suspense>
|
||||
|
||||
@@ -2,7 +2,7 @@ import { useState, useEffect } from 'react';
|
||||
import { Outlet, Link, useLocation } from 'react-router-dom';
|
||||
import { LayoutDashboard, Users, BarChart3, ChevronLeft, ChevronRight, Package, LogOut, Megaphone, Grid3X3, Shield, Moon, Sun, Tags, Boxes, ClipboardList, Menu, X, BriefcaseBusiness, Radio } from 'lucide-react';
|
||||
import type { DateRange, OrderData } from '../types';
|
||||
import { isSuperAdmin, logout } from '../dataService';
|
||||
import { logout } from '../dataService';
|
||||
import { rangeForLastDays } from '../dateRanges';
|
||||
|
||||
const emptyOrdersData: OrderData[] = [];
|
||||
@@ -61,12 +61,10 @@ const Layout = () => {
|
||||
};
|
||||
const showSidebarLabels = !isSidebarCollapsed || isMobileNavOpen;
|
||||
|
||||
const adminNavigation = isSuperAdmin()
|
||||
? [
|
||||
{ name: 'Olist', href: '/admin/olist', icon: Radio },
|
||||
{ name: 'Usuários', href: '/admin/users', icon: Shield }
|
||||
]
|
||||
: [];
|
||||
const adminNavigation = [
|
||||
{ name: 'Olist', href: '/admin/olist', icon: Radio },
|
||||
{ name: 'Usuários', href: '/admin/users', icon: Shield }
|
||||
];
|
||||
const navigationSections = [
|
||||
{
|
||||
label: 'Painel',
|
||||
@@ -92,7 +90,7 @@ const Layout = () => {
|
||||
{ name: 'Campanhas', href: '/campaigns', icon: Megaphone },
|
||||
],
|
||||
},
|
||||
...(adminNavigation.length ? [{ label: 'Super admin', items: adminNavigation }] : []),
|
||||
{ label: 'Administração', items: adminNavigation },
|
||||
];
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user