e434c439c9
- Rename all component files to PascalCase matching exported names - Move components into feature directories (git/, session/, project/, terminal/, workspace/, ui/, layout/) - Rename all page files to PascalCase with Page suffix - Rename all API files to kebab-case - Update all imports across codebase with corrected relative depths - Preserve git history via git mv Quality gates: tsc (pass), eslint (pass), 66/74 tests pass (8 pre-existing failures) Refs: repo-restructure Task 4.4
20 lines
546 B
TypeScript
20 lines
546 B
TypeScript
import { Navigate, useLocation } from "react-router-dom";
|
|
|
|
import { useAuth } from "../state/auth";
|
|
|
|
export const ProtectedRoute = ({ children }: { children: React.ReactNode }) => {
|
|
const { state } = useAuth();
|
|
const location = useLocation();
|
|
|
|
if (state === "loading") {
|
|
return <div className="center-screen">Checking session...</div>;
|
|
}
|
|
|
|
if (state === "unauthenticated") {
|
|
const nextPath = encodeURIComponent(location.pathname);
|
|
return <Navigate to={`/login?next=${nextPath}`} replace />;
|
|
}
|
|
|
|
return <>{children}</>;
|
|
};
|