import { Navigate, Outlet, Route, Routes, useLocation } from "react-router-dom"; import { useQuery } from "@tanstack/react-query"; import { Layout } from "./components/Layout"; import { authApi } from "./api/auth"; import { healthApi } from "./api/health"; import { Dashboard } from "./pages/Dashboard"; import { Companies } from "./pages/Companies"; import { Agents } from "./pages/Agents"; import { AgentDetail } from "./pages/AgentDetail"; import { Projects } from "./pages/Projects"; import { ProjectDetail } from "./pages/ProjectDetail"; import { Issues } from "./pages/Issues"; import { IssueDetail } from "./pages/IssueDetail"; import { Goals } from "./pages/Goals"; import { GoalDetail } from "./pages/GoalDetail"; import { Approvals } from "./pages/Approvals"; import { ApprovalDetail } from "./pages/ApprovalDetail"; import { Costs } from "./pages/Costs"; import { Activity } from "./pages/Activity"; import { Inbox } from "./pages/Inbox"; import { CompanySettings } from "./pages/CompanySettings"; import { DesignGuide } from "./pages/DesignGuide"; import { AuthPage } from "./pages/Auth"; import { InviteLandingPage } from "./pages/InviteLanding"; import { queryKeys } from "./lib/queryKeys"; function BootstrapPendingPage() { return (

Instance setup required

No instance admin exists yet. Run this command in your Paperclip environment to generate the first admin invite URL:

{`pnpm paperclip auth bootstrap-ceo`}
        
); } function CloudAccessGate() { const location = useLocation(); const healthQuery = useQuery({ queryKey: queryKeys.health, queryFn: () => healthApi.get(), retry: false, }); const isAuthenticatedMode = healthQuery.data?.deploymentMode === "authenticated"; const sessionQuery = useQuery({ queryKey: queryKeys.auth.session, queryFn: () => authApi.getSession(), enabled: isAuthenticatedMode, retry: false, }); if (healthQuery.isLoading || (isAuthenticatedMode && sessionQuery.isLoading)) { return
Loading...
; } if (healthQuery.error) { return (
{healthQuery.error instanceof Error ? healthQuery.error.message : "Failed to load app state"}
); } if (isAuthenticatedMode && healthQuery.data?.bootstrapStatus === "bootstrap_pending") { return ; } if (isAuthenticatedMode && !sessionQuery.data) { const next = encodeURIComponent(`${location.pathname}${location.search}`); return ; } return ; } export function App() { return ( } /> } /> }> }> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> } /> ); }