/
zxclovly
/
LUME
Обзор
Документация
Войти
/
zxclovly
/
LUME
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
src/components/auth/ProtectedRoute.tsx
26 строк
763 B
lovlygod
chore: prepare frontend for vercel
12 мар 2026, 00:05
12 мар 2026, 00:05
ce263e7
Код
Авторство
О чём код?
import { Navigate, Outlet, useLocation } from "react-router-dom"; import { useAuth } from "@/contexts/AuthContext"; const ProtectedRoute = () => { const { isAuthenticated, loading } = useAuth(); const location = useLocation(); if (loading) { return ( <div className="flex min-h-screen items-center justify-center bg-background text-white"> <div className="flex items-center gap-3 text-sm text-white/70"> <span className="h-4 w-4 animate-spin rounded-full border-2 border-white/70 border-t-transparent" /> Loading... </div> </div> ); } if (!isAuthenticated()) { return <Navigate to="/login" replace state={{ from: location }} />; } return <Outlet />; }; export default ProtectedRoute;