import './App.css' import { Toaster } from "@/components/ui/toaster" import { QueryClientProvider } from '@tanstack/react-query' import { queryClientInstance } from '@/lib/query-client' import VisualEditAgent from '@/lib/VisualEditAgent' import NavigationTracker from '@/lib/NavigationTracker' import { pagesConfig } from './pages.config' import { BrowserRouter as Router, Route, Routes, useLocation } from 'react-router-dom'; import { setupIframeMessaging } from './lib/iframe-messaging'; import PageNotFound from './lib/PageNotFound'; import { AuthProvider, useAuth } from '@/lib/AuthContext'; import ErrorBoundary from '@/lib/ErrorBoundary'; import { appParams } from '@/lib/app-params'; import UserNotRegisteredError from '@/components/UserNotRegisteredError'; import FeatureReport from './pages/FeatureReport'; import LandingPage from './pages/LandingPage'; import KrowX from './pages/KrowX'; import AboutUs from './pages/AboutUs'; import ThePlatform from './pages/ThePlatform'; import ForWorkers from './pages/ForWorkers'; import PredictiveIntelligence from './pages/PredictiveIntelligence'; import KrowEdgePage from './pages/KrowEdge'; import Recruiting from './pages/Recruiting'; import Communications from './pages/Communications'; import Announcements from './pages/Announcements'; import StaffProfileDemo from './pages/StaffProfileDemo'; import CapabilityMap from './pages/CapabilityMap'; import PlatformOnboarding from './pages/PlatformOnboarding'; import DailyPL from './pages/DailyPL'; import Sales from './pages/Sales'; import PayrollDetail from './pages/PayrollDetail'; import EmployeeTimecard from './pages/EmployeeTimecard'; import ClientLaborReport from './pages/ClientLaborReport'; import WorkforceNetwork from './pages/WorkforceNetwork'; import KrowAI from './pages/KrowAI'; import StaffingMarketplace from './pages/StaffingMarketplace'; import KrowConsole from './pages/KrowConsole'; import KrowCommand from './pages/KrowCommand'; import DemandSupply from './pages/DemandSupply'; import DocumentApproval from './pages/DocumentApproval'; import VendorReports from './pages/VendorReports'; const { Pages, Layout, mainPage } = pagesConfig; const mainPageKey = mainPage ?? Object.keys(Pages)[0]; const MainPage = mainPageKey ? Pages[mainPageKey] : <>; setupIframeMessaging(); const LayoutWrapper = ({ children, currentPageName }) => Layout ? {children} : <>{children}; // Routes that render for anyone, signed in or not. LandingPage is pure marketing // markup — it reads no entities and never touches useAuth — so the only thing the // auth gate ever did for it was bounce visitors to a Google login before they // could read what the product is. Its CTAs point at /Dashboard, which is still // gated, so signing in stays one click away. const PUBLIC_ROUTES = new Set(['/LandingPage']); const isPublicRoute = (pathname) => { // Tolerate a trailing slash so /LandingPage/ isn't quietly sent to login. const normalized = pathname.length > 1 ? pathname.replace(/\/+$/, '') : pathname; return PUBLIC_ROUTES.has(normalized); }; const AuthenticatedApp = () => { const { isLoadingAuth, isLoadingPublicSettings, authError, isAuthenticated, navigateToLogin } = useAuth(); const location = useLocation(); // Ahead of both gates below. The spinner would stall this page on a network // round-trip it has no use for, and the auth gate would redirect away from it — // either one defeats the point of a public page. if (isPublicRoute(location.pathname)) { return ( } /> ); } // Show loading spinner while checking app public settings or auth if (isLoadingPublicSettings || isLoadingAuth) { return (
); } // Handle authentication errors if (authError) { if (authError.type === 'user_not_registered') { return ; } else if (authError.type === 'auth_required') { // Redirect to login automatically navigateToLogin(); return null; } // Anything else (bad/missing app id, unreachable backend, network failure) // used to fall straight through to the app, which then crashed on the empty // data and left a blank page. Say what happened instead. return (

Unable to load the app

{authError.message || 'The Base44 backend could not be reached.'}

App ID: {String(appParams.appId)}
Backend: {String(appParams.serverUrl)}

); } // Render the main app return ( } /> {Object.entries(Pages).map(([path, Page]) => ( } /> ))} } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> ); }; function App() { return ( ) } export default App