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'; const Dashboard = React.lazy(() => import('./pages/Dashboard')); const Products = React.lazy(() => import('./pages/Products')); const ProductDetails = React.lazy(() => import('./pages/ProductDetails')); const ProductGroupDetails = React.lazy(() => import('./pages/ProductGroupDetails')); const Replenishment = React.lazy(() => import('./pages/Replenishment')); const Cutting = React.lazy(() => import('./pages/Cutting')); const ProductionOrders = React.lazy(() => import('./pages/ProductionOrders')); const Supplies = React.lazy(() => import('./pages/Supplies')); const Clients = React.lazy(() => import('./pages/Clients')); const ClientDetails = React.lazy(() => import('./pages/ClientDetails')); const Campaigns = React.lazy(() => import('./pages/Campaigns')); const Rfm = React.lazy(() => import('./pages/Rfm')); const Registrations = React.lazy(() => import('./pages/Registrations')); const Login = React.lazy(() => import('./pages/Login')); const AdminUsers = React.lazy(() => import('./pages/AdminUsers')); function PrivateRoute({ children }: { children: React.ReactNode }) { const location = useLocation(); if (!isAuthenticated()) { return ; } return children; } function SuperAdminRoute({ children }: { children: React.ReactNode }) { if (!isSuperAdmin()) { return ; } return children; } const RouteFallback = () => (
); function App() { return ( }> } /> } /> }> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> ); } export default App;