Files
lux_fiscal/frontend/src/features/auth/ProtectedRoute.tsx
T
lauadminandClaude Opus 5.5 b8f2fe6b6e Translate UI and user-facing messages to Ukrainian (#5)
- All frontend pages, labels, notices and errors; html lang=uk, uk-UA money format
- Brand "Assistant System" in the top bar and page title
- Backend error details returned to the UI (auth, orders, receipts,
  cash registers, Checkbox/CRM/NP errors) and CLI output
- Tests updated for the new messages

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-25 15:27:39 +03:00

24 lines
678 B
TypeScript

import { Navigate, Outlet, useLocation } from 'react-router-dom'
import { useAuth } from '@/features/auth/useAuth'
/** Пропускает дальше только аутентифицированных; остальных отправляет на /login. */
export function ProtectedRoute() {
const { status } = useAuth()
const location = useLocation()
if (status === 'loading') {
return (
<div className="page-center">
<span className="spinner" aria-label="Завантаження" />
</div>
)
}
if (status === 'unauthenticated') {
return <Navigate to="/login" state={{ from: location }} replace />
}
return <Outlet />
}