6f18dd24a5
- Add OIDC authentication with PKCE flow - Create dashboard shell with sidebar and header - Implement project management UI (list, create, detail) - Add tool spawn page with tool/project selection - Create tool instance detail page with status and controls - Set up React Router with route guards - Add Zustand auth store and API client with types
21 lines
570 B
TypeScript
21 lines
570 B
TypeScript
import { Navigate } from 'react-router-dom'
|
|
import { useAuthStore } from '../stores/auth'
|
|
|
|
export default function RouteGuard({ children }: { children: React.ReactNode }) {
|
|
const { state } = useAuthStore()
|
|
|
|
if (state === 'loading') {
|
|
return (
|
|
<div className="flex min-h-screen items-center justify-center">
|
|
<div className="animate-spin rounded-full h-8 w-8 border-b-2 border-accent"></div>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
if (state === 'unauthenticated' || state === 'error') {
|
|
return <Navigate to="/login" replace />
|
|
}
|
|
|
|
return <>{children}</>
|
|
}
|