CityTracker/client/src/components/layout/ProtectedRoute.tsx
Claudio Schaad 3debb1ce1e Add CityTracker v1: map-based city tracker with multi-user support
React/Vite frontend and Express/SQLite backend for tracking visited and
planned cities on a map, with per-city notes, photos, links, and
participant-based sharing between family members. Includes session auth
with admin-managed user accounts, an OSM/Nominatim geocoding proxy, and a
single-image Docker deployment.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-20 20:29:25 +02:00

12 lines
396 B
TypeScript

import { Navigate } from 'react-router-dom';
import type { ReactNode } from 'react';
import { useAuth } from '../../context/AuthContext';
export function ProtectedRoute({ children }: { children: ReactNode }) {
const { user, needsSetup } = useAuth();
if (needsSetup) return <Navigate to="/setup" replace />;
if (!user) return <Navigate to="/login" replace />;
return <>{children}</>;
}