Revert "feat: open administration to all users"

This reverts commit b4b21fb21b.
This commit is contained in:
Cauê Faleiros
2026-08-28 12:47:13 -03:00
parent b4b21fb21b
commit 9f4db67f4f
6 changed files with 35 additions and 25 deletions

View File

@@ -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 } from './dataService';
import { isAuthenticated, isSuperAdmin } from './dataService';
const Dashboard = React.lazy(() => import('./pages/Dashboard'));
const Products = React.lazy(() => import('./pages/Products'));
@@ -34,6 +34,13 @@ 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" />
@@ -68,8 +75,8 @@ function App() {
<Route path="rfm" element={<Rfm />} />
<Route path="campaigns" element={<Campaigns />} />
<Route path="registrations" element={<Registrations />} />
<Route path="admin/users" element={<AdminUsers />} />
<Route path="admin/olist" element={<OlistSync />} />
<Route path="admin/users" element={<SuperAdminRoute><AdminUsers /></SuperAdminRoute>} />
<Route path="admin/olist" element={<SuperAdminRoute><OlistSync /></SuperAdminRoute>} />
</Route>
</Routes>
</Suspense>

View File

@@ -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 { logout } from '../dataService';
import { isSuperAdmin, logout } from '../dataService';
import { rangeForLastDays } from '../dateRanges';
const emptyOrdersData: OrderData[] = [];
@@ -61,10 +61,12 @@ const Layout = () => {
};
const showSidebarLabels = !isSidebarCollapsed || isMobileNavOpen;
const adminNavigation = [
{ name: 'Olist', href: '/admin/olist', icon: Radio },
{ name: 'Usuários', href: '/admin/users', icon: Shield }
];
const adminNavigation = isSuperAdmin()
? [
{ name: 'Olist', href: '/admin/olist', icon: Radio },
{ name: 'Usuários', href: '/admin/users', icon: Shield }
]
: [];
const navigationSections = [
{
label: 'Painel',
@@ -90,7 +92,7 @@ const Layout = () => {
{ name: 'Campanhas', href: '/campaigns', icon: Megaphone },
],
},
{ label: 'Administração', items: adminNavigation },
...(adminNavigation.length ? [{ label: 'Super admin', items: adminNavigation }] : []),
];
return (