mirror of
https://github.com/Nezumi-2711/react-training.git
synced 2026-09-22 20:01:59 +00:00
Update common file
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
import { useAccount } from '@hook/authentication/useAccount';
|
||||
import { ReactNode } from 'react';
|
||||
import { Navigate } from 'react-router-dom';
|
||||
|
||||
interface IRouteProtected {
|
||||
children: ReactNode;
|
||||
}
|
||||
const RouteProtected = ({ children }: IRouteProtected) => {
|
||||
// Load user login
|
||||
const { account } = useAccount();
|
||||
|
||||
return !account ? <Navigate to="/login" /> : children;
|
||||
};
|
||||
|
||||
export default RouteProtected;
|
||||
Reference in New Issue
Block a user