Fix version 1.2.16

This commit is contained in:
2024-12-03 14:27:05 +08:00
parent 270065f46b
commit b638865c33
8 changed files with 53 additions and 25 deletions

View File

@@ -1,20 +0,0 @@
import { RouterAdminDashboard } from "@/app/lib/router_hipmi/router_admin";
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
import { funGlobal_getUserById } from "@/app_modules/_global/fun/get/fun_get_user_by_id";
import { redirect } from "next/navigation";
export default async function Layout({
children,
}: {
children: React.ReactNode;
}) {
const userLoginId = await funGetUserIdByToken();
const dataUser = await funGlobal_getUserById({
userId: userLoginId as string,
});
if (dataUser?.masterUserRoleId != "1")
return redirect(RouterAdminDashboard.splash_admin);
return <>{children}</>;
}

View File

@@ -14,6 +14,7 @@ export default async function Layout({
const authorId = dataProfile?.userId; const authorId = dataProfile?.userId;
const userLoginId = await funGetUserIdByToken(); const userLoginId = await funGetUserIdByToken();
const userRoleId = dataProfile?.User?.masterUserRoleId;
return ( return (
<> <>
@@ -21,6 +22,7 @@ export default async function Layout({
profileId={profileId} profileId={profileId}
userLoginId={userLoginId as string} userLoginId={userLoginId as string}
authorId={authorId as any} authorId={authorId as any}
userRoleId={userRoleId as string}
> >
{children} {children}
</KatalogLayout> </KatalogLayout>

View File

@@ -14,6 +14,7 @@ import {
Menu, Menu,
Modal, Modal,
Popover, Popover,
SimpleGrid,
Stack, Stack,
Text, Text,
Title, Title,
@@ -82,11 +83,21 @@ export function Admin_ComponentButtonUserCircle({
<Divider /> <Divider />
<Center> <SimpleGrid cols={2}>
<Button radius={"xl"} onClick={() => setOpenModal(true)}> <Button
radius={"xl"}
onClick={() => router.push("/dev/home", { scroll: false })}
>
User Access
</Button>
<Button
radius={"xl"}
color="red"
onClick={() => setOpenModal(true)}
>
Keluar Keluar
</Button> </Button>
</Center> </SimpleGrid>
</Stack> </Stack>
</Popover.Dropdown> </Popover.Dropdown>
</Popover> </Popover>

View File

@@ -11,10 +11,12 @@ export function ComponentKatalog_ButtonHeaderRight({
profileId, profileId,
userLoginId, userLoginId,
authorId, authorId,
userRoleId,
}: { }: {
profileId: string; profileId: string;
userLoginId: string; userLoginId: string;
authorId: string; authorId: string;
userRoleId: string
}) { }) {
const [opened, { open, close }] = useDisclosure(); const [opened, { open, close }] = useDisclosure();
@@ -33,6 +35,7 @@ export function ComponentKatalog_ButtonHeaderRight({
close={() => close()} close={() => close()}
profileId={profileId} profileId={profileId}
userId={userLoginId} userId={userLoginId}
userRoleId={userRoleId}
/> />
</> </>
); );

View File

@@ -1,3 +1,4 @@
import { RouterAdminDashboard } from "@/app/lib/router_hipmi/router_admin";
import { import {
RouterPortofolio, RouterPortofolio,
RouterProfile, RouterProfile,
@@ -14,6 +15,7 @@ import {
Text, Text,
} from "@mantine/core"; } from "@mantine/core";
import { import {
IconDashboard,
IconEdit, IconEdit,
IconPencilPlus, IconPencilPlus,
IconPhotoEdit, IconPhotoEdit,
@@ -27,16 +29,19 @@ export function ComponentKatalog_DrawerKatalog({
opened, opened,
close, close,
profileId, profileId,
userId userId,
userRoleId
}: { }: {
opened: boolean; opened: boolean;
close: () => void; close: () => void;
profileId: string; profileId: string;
userId: string userId: string
userRoleId: string
}) { }) {
const router = useRouter(); const router = useRouter();
const [pageId, setPageId] = useState(""); const [pageId, setPageId] = useState("");
const [isLoading, setIsLoading] = useState(false); const [isLoading, setIsLoading] = useState(false);
const [isLoadingAdmin, setIsLoadingAdmin] = useState(false);
const listPage = [ const listPage = [
{ {
@@ -125,6 +130,27 @@ export function ComponentKatalog_DrawerKatalog({
))} ))}
<Component_ButtonLogout userId={userId} /> <Component_ButtonLogout userId={userId} />
{userRoleId != "1" && (
<Stack align="center" spacing={"xs"}>
<ActionIcon
variant="transparent"
c="white"
onClick={() => {
router.push(RouterAdminDashboard.main_admin, { scroll: false });
setIsLoadingAdmin(true);
}}
>
{isLoadingAdmin ? (
<ComponentGlobal_Loader />
) : (
<IconDashboard/>
)}
</ActionIcon>
<Text align="center" color="white">
Dashboard Admin
</Text>
</Stack>
)}
</SimpleGrid> </SimpleGrid>
</Stack> </Stack>
</Drawer> </Drawer>

View File

@@ -9,11 +9,13 @@ export default function KatalogLayout({
profileId, profileId,
userLoginId, userLoginId,
authorId, authorId,
userRoleId,
}: { }: {
children: any; children: any;
profileId: any; profileId: any;
userLoginId: string; userLoginId: string;
authorId: string; authorId: string;
userRoleId: string
}) { }) {
return ( return (
<> <>
@@ -26,6 +28,7 @@ export default function KatalogLayout({
profileId={profileId} profileId={profileId}
userLoginId={userLoginId} userLoginId={userLoginId}
authorId={authorId as any} authorId={authorId as any}
userRoleId={userRoleId}
/> />
} }
/> />

View File

@@ -10,13 +10,15 @@ import { useState } from "react";
export function Profile_ComponentLoadBackgroundImage({ export function Profile_ComponentLoadBackgroundImage({
fileId, fileId,
size
}: { }: {
fileId: string; fileId: string;
size?: number
}) { }) {
const router = useRouter(); const router = useRouter();
const [isImage, setIsImage] = useState<boolean | null>(null); const [isImage, setIsImage] = useState<boolean | null>(null);
const [isLoading, setLoading] = useState(false); const [isLoading, setLoading] = useState(false);
const url = APIs.GET({ fileId: fileId }); const url = APIs.GET({ fileId: fileId,size: size ? size.toString() : "200" });
useShallowEffect(() => { useShallowEffect(() => {
onLoadImage(); onLoadImage();

View File

@@ -68,6 +68,7 @@ export function Profile_UiView({
<Box> <Box>
<Profile_ComponentLoadBackgroundImage <Profile_ComponentLoadBackgroundImage
fileId={profile.imageBackgroundId as any} fileId={profile.imageBackgroundId as any}
size={500}
/> />
<Box <Box