api ulandi
This commit is contained in:
20
src/LoginLayout.tsx
Normal file
20
src/LoginLayout.tsx
Normal file
@@ -0,0 +1,20 @@
|
||||
import { getToken } from "@/shared/lib/cookie";
|
||||
import { useEffect, type ReactNode } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
|
||||
const LoginLayout = ({ children }: { children: ReactNode }) => {
|
||||
const token = getToken();
|
||||
const navigate = useNavigate();
|
||||
|
||||
useEffect(() => {
|
||||
if (!token) {
|
||||
navigate("/");
|
||||
} else if (token) {
|
||||
navigate("/dashboard");
|
||||
}
|
||||
}, [token, navigate]);
|
||||
|
||||
return children;
|
||||
};
|
||||
|
||||
export default LoginLayout;
|
||||
Reference in New Issue
Block a user