upd: kataloh
Deskripsi: - api di katalog No Issues
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import KatalogLayout from "./layout";
|
||||
import LayoutKatalogNew from "./layout_new";
|
||||
|
||||
export { KatalogLayout };
|
||||
export { LayoutKatalogNew }
|
||||
|
||||
60
src/app_modules/katalog/main/layout_new.tsx
Normal file
60
src/app_modules/katalog/main/layout_new.tsx
Normal file
@@ -0,0 +1,60 @@
|
||||
'use client'
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
import { UIGlobal_LayoutHeaderTamplate, UIGlobal_LayoutTamplate } from "@/app_modules/_global/ui";
|
||||
import { apiGetUserProfile } from "@/app_modules/user";
|
||||
import { ActionIcon } from "@mantine/core";
|
||||
import { useDisclosure, useShallowEffect } from "@mantine/hooks";
|
||||
import { IconDotsVertical } from "@tabler/icons-react";
|
||||
import { useParams } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import DrawerKatalogNew from "../component/drawer_katalog_new";
|
||||
|
||||
export default function LayoutKatalogNew({ children }: { children: any }) {
|
||||
const param = useParams<{ id: string }>()
|
||||
const [authorId, setAuthorId] = useState("")
|
||||
const [userRoleId, setUserRoleId] = useState("")
|
||||
const [userLoginId, setUserLoginId] = useState("")
|
||||
const [opened, { open, close }] = useDisclosure()
|
||||
|
||||
async function getProfile() {
|
||||
try {
|
||||
const response = await apiGetUserProfile(`?profile=${param.id}`)
|
||||
const response2 = await funGetUserIdByToken()
|
||||
if (response.success) {
|
||||
setAuthorId(response.data.id)
|
||||
setUserRoleId(response.data.masterUserRoleId)
|
||||
setUserLoginId(response2)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
|
||||
useShallowEffect(() => {
|
||||
getProfile()
|
||||
}, [])
|
||||
|
||||
return (
|
||||
<>
|
||||
<UIGlobal_LayoutTamplate
|
||||
header={
|
||||
<UIGlobal_LayoutHeaderTamplate
|
||||
title="KATALOG"
|
||||
customButtonRight={
|
||||
authorId !== userLoginId ? (
|
||||
<ActionIcon disabled variant="transparent"></ActionIcon>
|
||||
) : (
|
||||
<ActionIcon c="white" variant="transparent" onClick={() => open()}>
|
||||
<IconDotsVertical />
|
||||
</ActionIcon>
|
||||
)
|
||||
}
|
||||
/>
|
||||
}
|
||||
>
|
||||
{children}
|
||||
<DrawerKatalogNew opened={opened} close={() => close()} userRoleId={userRoleId} userId={userLoginId} />
|
||||
</UIGlobal_LayoutTamplate>
|
||||
</>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user