Files
frontend/src/app/providers/GuestRoute.tsx
2026-05-14 00:31:06 +03:00

14 lines
504 B
TypeScript

import { Navigate, Outlet, useLocation } from 'react-router-dom'
import { useIsAuthenticated } from '@features/auth'
import { ROUTES } from '@shared/config/routes'
export function GuestRoute() {
const { isAuthenticated, isLoading } = useIsAuthenticated()
const location = useLocation()
const from = (location.state as { from?: { pathname: string } })?.from?.pathname ?? ROUTES.WALLET
if (isLoading) return null
if (isAuthenticated) return <Navigate to={from} replace />
return <Outlet />
}