feat: похуй 2.0
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
import { Navigate, Outlet } from 'react-router-dom'
|
||||
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={ROUTES.WALLET} replace />
|
||||
if (isAuthenticated) return <Navigate to={from} replace />
|
||||
return <Outlet />
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user