go-guess/frontend/src/app/App.tsx

34 lines
1.3 KiB
TypeScript
Raw Normal View History

2026-10-01 09:06:58 +02:00
import {Route, Routes, useLocation} from 'react-router-dom'
import {useAuthSession} from '../components/actions'
import {NotFound} from '../components/ui/NotFound'
import {ParticipantInterviewPage} from '../features/assessments'
import {ParticipantMeetingPage} from '../features/interviews'
import {LoginPage} from '../features/login/LoginPage'
import {AuthenticatedApp} from './AuthenticatedApp'
import {DataProvider} from './DataContext'
2026-09-19 20:31:14 +02:00
export default function App() {
2026-10-01 09:06:58 +02:00
const location = useLocation();
const {authenticated, sessionExpired, ssoStatus, completeLogin, logout} = useAuthSession();
2026-10-01 09:06:58 +02:00
if (location.pathname.startsWith('/participant/')) {
return (
<Routes>
<Route path="/participant/meeting/:token" element={<ParticipantMeetingPage/>}/>
<Route path="/participant/:invitationId" element={<ParticipantInterviewPage/>}/>
<Route path="*" element={<NotFound/>}/>
</Routes>
)
}
if (!authenticated) {
if (ssoStatus !== 'idle') {
return <main className="login-shell"><p>Redirecting to sign in…</p></main>
}
2026-10-01 09:06:58 +02:00
return <LoginPage onLogin={completeLogin} sessionExpired={sessionExpired}/>
}
2026-09-19 20:31:14 +02:00
return (
2026-10-01 09:06:58 +02:00
<DataProvider>
<AuthenticatedApp onLogout={logout}/>
</DataProvider>
2026-09-19 20:31:14 +02:00
)
}