Files
aso/frontend/client-portal/src/guards/GuestGuard.tsx
2023-07-03 11:39:08 +07:00

23 lines
545 B
TypeScript

import { ReactNode } from 'react';
import { Navigate } from 'react-router-dom';
// hooks
import useAuth from '../hooks/useAuth';
// routes
// import { PATH_DASHBOARD } from '../routes/paths';
// ----------------------------------------------------------------------
type GuestGuardProps = {
children: ReactNode;
};
export default function GuestGuard({ children }: GuestGuardProps) {
const { isAuthenticated } = useAuth();
if (isAuthenticated) {
return <Navigate to={'/dashboard'} replace={true}/>;
}
return <>{children}</>;
}