- 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>
24 lines
678 B
TypeScript
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 />
|
|
}
|