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/Profile')); const CompaniesPage = lazy(() => import('./pages/Companies')); const CompanyDetail = lazy(() => import('./pages/CompanyDetail')); const TeamInvoices = lazy(() => import('./pages/team/TeamInvoices')); const TaskDetail = lazy(() => import('./pages/TaskDetail')); const TeamCreateSubcontractorPO = lazy(() => import('./pages/team/TeamCreateSubcontractorPO')); const TeamInvoiceDetail = lazy(() => import('./pages/team/TeamInvoiceDetail')); const TeamSubcontractorPODetail = lazy(() => import('./pages/team/TeamSubcontractorPODetail')); const TeamSubInvoiceDetail = lazy(() => import('./pages/team/TeamSubInvoiceDetail')); const SurveyMaker = lazy(() => import('./pages/SurveyMaker')); const BrandBook = lazy(() => import('./pages/BrandBook')); const Converters = lazy(() => import('./pages/Converters')); const TeamFourgePasswords = lazy(() => import('./pages/team/TeamFourgePasswords')); const TeamReports = lazy(() => import('./pages/team/TeamReports')); const ExternalMyPurchaseOrders = lazy(() => import('./pages/external/ExternalMyPurchaseOrders')); const ExternalMyInvoices = lazy(() => import('./pages/external/ExternalMyInvoices')); const ExternalMyInvoiceDetail = lazy(() => import('./pages/external/ExternalMyInvoiceDetail')); const ExternalMyInvoiceCreate = lazy(() => import('./pages/external/ExternalMyInvoiceCreate')); const ProjectDetailPage = lazy(() => import('./pages/ProjectDetail')); const TeamDashboard = lazy(() => import('./pages/team/TeamDashboard')); const RequestsPage = lazy(() => import('./pages/Tasks')); const ClientMyInvoices = lazy(() => import('./pages/client/ClientMyInvoices')); function RedirectProjectDetail() { const { id } = useParams(); return ; } function RedirectClientDetail() { const { id } = useParams(); return ; } function RedirectToTask() { const { id } = useParams(); return ; } function RedirectTeamInvoiceDetail() { const { id } = useParams(); return ; } function RedirectSubsInvoiceDetail() { const { id } = useParams(); return ; } function NavigateCompanyDetail() { const { id } = useParams(); return ; } export default function App() { return ( }> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> ); }