Первоначальная версия VidConf

This commit is contained in:
2026-07-23 01:04:01 +03:00
commit 896455381a
335 changed files with 61527 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
import type { ReactNode } from 'react'
import { Navigate, useLocation } from 'react-router-dom'
import { useAuth } from '@/auth/useAuth'
/**
* Обёртка для приватных маршрутов: пока идёт восстановление сессии —
* показывает лоадер, без сессии — редиректит на /login (сохраняя исходный
* путь, чтобы вернуться туда после входа).
*/
export function RequireAuth({ children }: { children: ReactNode }) {
const { status } = useAuth()
const location = useLocation()
if (status === 'loading') {
return (
<div className="app-loader" role="status" aria-live="polite">
Загрузка сессии
</div>
)
}
if (status === 'unauthenticated') {
return <Navigate to="/login" state={{ from: location }} replace />
}
return <>{children}</>
}