upd: global admin

Deskripsi:
- variable global untuk task

NO Issues
This commit is contained in:
amel
2024-09-10 16:48:25 +08:00
parent 6a33333ecf
commit 6ba2c0fc79
9 changed files with 94 additions and 71 deletions

View File

@@ -0,0 +1,28 @@
'use client'
import { useHookstate } from "@hookstate/core";
import { useShallowEffect } from "@mantine/hooks";
import { globalIsAdminDivision } from "../lib/val_division";
import { funGetDivisionById } from "../lib/api_division";
import { useParams } from "next/navigation";
import { funGetUserByCookies } from "@/module/auth";
export default function WrapLayoutDivision({ children }: { children: React.ReactNode }) {
const isAdmin = useHookstate(globalIsAdminDivision)
const param = useParams<{ id: string }>()
const getData = async () => {
const res = await funGetDivisionById(param.id);
const login = await funGetUserByCookies()
const cek = res.data.member.some((i: any) => i.idUser == login.id && i.isAdmin == true)
isAdmin.set(cek)
}
useShallowEffect(() => {
getData()
}, [])
return (
<>
{children}
</>
);
}