One-time `prettier --write` across the 22 source files not already touched
by the preceding tooling commit (b5ceedc). Pure formatting — no behaviour
change, no logic change. Reviewable as "all whitespace/reflow".
From here the lint-staged pre-commit hook keeps new and edited code
consistent automatically.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
26 lines
640 B
TypeScript
26 lines
640 B
TypeScript
import { Navigate, useLocation } from 'react-router-dom';
|
|
import type { ReactNode } from 'react';
|
|
import { Spin } from 'antd';
|
|
import { useAuth } from '../hooks/useAuth';
|
|
|
|
export function RequireAuth({ children }: { children: ReactNode }) {
|
|
const { user, loading } = useAuth();
|
|
const location = useLocation();
|
|
|
|
if (loading) {
|
|
return (
|
|
<div
|
|
style={{ display: 'flex', justifyContent: 'center', alignItems: 'center', height: '100vh' }}
|
|
>
|
|
<Spin size="large" />
|
|
</div>
|
|
);
|
|
}
|
|
|
|
if (!user) {
|
|
return <Navigate to="/login" state={{ from: location }} replace />;
|
|
}
|
|
|
|
return <>{children}</>;
|
|
}
|