Files
aso/frontend/dashboard/src/guards/GuestGuard.tsx
Linksehat Staging Server ce024c2bcd merge
2023-05-08 08:50:15 +07:00

23 lines
545 B
TypeScript
Executable File

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}</>;
}