23 lines
545 B
TypeScript
Executable File
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}</>;
|
|
}
|