import { lazy, Suspense, Component } from 'react'; import { BrowserRouter, Routes, Route, Navigate, useParams } from 'react-router-dom'; import { AuthProvider, useAuth } from './context/AuthContext'; import ProtectedRoute from './components/ProtectedRoute'; import PageLoader from './components/PageLoader'; class ChunkErrorBoundary extends Component { state = { error: null }; static getDerivedStateFromError(error) { return { error }; } componentDidCatch(error) { const isChunkError = error?.name === 'ChunkLoadError' || error?.message?.includes('dynamically imported module') || error?.message?.includes('Failed to fetch'); if (isChunkError) { const key = 'chunk_reload_attempted'; if (!sessionStorage.getItem(key)) { sessionStorage.setItem(key, '1'); window.location.reload(); return; } sessionStorage.removeItem(key); } } render() { if (this.state.error) { return (
Page failed to load.
); } return this.props.children; } } import Login from './pages/Login'; import PayInvoice from './pages/PayInvoice'; const ProfilePage = lazy(() => import('./pages/Settings')); const CompaniesPage = lazy(() => import('./pages/CompaniesPage')); const CompanyDetail = lazy(() => import('./pages/CompanyDetail')); const Invoices = lazy(() => import('./pages/team/Invoices')); const RequestDetail = lazy(() => import('./pages/RequestDetail')); const CreateInvoice = lazy(() => import('./pages/team/CreateInvoice')); const CreateSubcontractorPO = lazy(() => import('./pages/team/CreateSubcontractorPO')); const InvoiceDetail = lazy(() => import('./pages/team/InvoiceDetail')); const SubcontractorPODetail = lazy(() => import('./pages/team/SubcontractorPODetail')); const SubInvoiceDetail = lazy(() => import('./pages/team/SubInvoiceDetail')); const SurveyMaker = lazy(() => import('./pages/SurveyMaker')); const BrandBook = lazy(() => import('./pages/BrandBook')); const Converters = lazy(() => import('./pages/Converters')); const FileSharing = lazy(() => import('./pages/FileSharing')); const FourgePasswords = lazy(() => import('./pages/team/FourgePasswords')); const MyPurchaseOrders = lazy(() => import('./pages/external/MyPurchaseOrders')); const ExternalMyInvoices = lazy(() => import('./pages/external/MyInvoices')); const ExternalMyInvoiceDetail = lazy(() => import('./pages/external/MyInvoiceDetail')); const ExternalMyInvoiceCreate = lazy(() => import('./pages/external/MyInvoiceCreate')); const Projects = lazy(() => import('./pages/Projects')); const ProjectDetailPage = lazy(() => import('./pages/ProjectDetailPage')); const DashboardPage = lazy(() => import('./pages/DashboardPage')); const TeamDashboard = lazy(() => import('./pages/team/TeamDashboard')); const RequestsPage = lazy(() => import('./pages/RequestsPage')); const TeamTasksPage = lazy(() => import('./pages/team/TeamTasksPage')); const MyInvoices = lazy(() => import('./pages/client/MyInvoices')); const NewRequest = lazy(() => import('./pages/client/NewRequest')); const NewProject = lazy(() => import('./pages/client/NewProject')); function RedirectProjectDetail() { const { id } = useParams(); return ; } function RedirectRequestDetail() { const { id } = useParams(); return ; } function NavigateCompanyDetail() { const { id } = useParams(); return ; } export default function App() { return ( }> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> ); }