Fix: Cookies

This commit is contained in:
2024-11-26 01:06:46 +08:00
parent ac5b8a8c4b
commit 038c40a6fb
29 changed files with 341 additions and 172 deletions

View File

@@ -3,27 +3,40 @@
import { RouterAuth } from "@/app/lib/router_hipmi/router_auth";
import { useShallowEffect } from "@mantine/hooks";
import { useRouter } from "next/navigation";
import { MODEL_USER } from "../home/model/interface";
import { RouterHome } from "@/app/lib/router_hipmi/router_home";
import { RouterAdminDashboard } from "@/app/lib/router_hipmi/router_admin";
export function CheckCookies_UiLayout({
children,
dataUser,
}: {
children: React.ReactNode;
dataUser: MODEL_USER;
}) {
const router = useRouter();
useShallowEffect(() => {
onCheckCookies();
}, []);
// useShallowEffect(() => {
// onCheckCookies();
// }, []);
async function onCheckCookies() {
const cek = await fetch("/api/check-cookies");
// async function onCheckCookies() {
// const cek = await fetch("/api/check-cookies");
const result = await cek.json();
// const result = await cek.json();
if (result.success === false) {
router.push(RouterAuth.login, { scroll: false });
}
}
// if (result.success === false) {
// router.push(RouterAuth.login, { scroll: false });
// }
// }
// if (dataUser.masterUserRoleId === "1") {
// router.push(RouterHome.main_home, { scroll: false });
// }
// if (dataUser.masterUserRoleId !== "1") {
// router.push(RouterAdminDashboard.splash_admin, { scroll: false });
// }
return children;
}