fix admin
- responsive ui
This commit is contained in:
6
bun.lock
6
bun.lock
@@ -19,7 +19,7 @@
|
|||||||
"@mantine/tiptap": "^7.5.3",
|
"@mantine/tiptap": "^7.5.3",
|
||||||
"@prisma/client": "^6.3.0",
|
"@prisma/client": "^6.3.0",
|
||||||
"@react-pdf/renderer": "^3.4.4",
|
"@react-pdf/renderer": "^3.4.4",
|
||||||
"@tabler/icons-react": "^2.38.0",
|
"@tabler/icons-react": "^3.31.0",
|
||||||
"@tiptap/extension-highlight": "^2.2.3",
|
"@tiptap/extension-highlight": "^2.2.3",
|
||||||
"@tiptap/extension-link": "^2.2.3",
|
"@tiptap/extension-link": "^2.2.3",
|
||||||
"@tiptap/extension-subscript": "^2.2.3",
|
"@tiptap/extension-subscript": "^2.2.3",
|
||||||
@@ -919,9 +919,9 @@
|
|||||||
|
|
||||||
"@swc/helpers": ["@swc/helpers@0.5.2", "", { "dependencies": { "tslib": "^2.4.0" } }, "sha512-E4KcWTpoLHqwPHLxidpOqQbcrZVgi0rsmmZXUle1jXmJfuIf/UWpczUJ7MZZ5tlxytgJXyp0w4PGkkeLiuIdZw=="],
|
"@swc/helpers": ["@swc/helpers@0.5.2", "", { "dependencies": { "tslib": "^2.4.0" } }, "sha512-E4KcWTpoLHqwPHLxidpOqQbcrZVgi0rsmmZXUle1jXmJfuIf/UWpczUJ7MZZ5tlxytgJXyp0w4PGkkeLiuIdZw=="],
|
||||||
|
|
||||||
"@tabler/icons": ["@tabler/icons@2.47.0", "", {}, "sha512-4w5evLh+7FUUiA1GucvGj2ReX2TvOjEr4ejXdwL/bsjoSkof6r1gQmzqI+VHrE2CpJpB3al7bCTulOkFa/RcyA=="],
|
"@tabler/icons": ["@tabler/icons@3.31.0", "", {}, "sha512-dblAdeKY3+GA1U+Q9eziZ0ooVlZMHsE8dqP0RkwvRtEsAULoKOYaCUOcJ4oW1DjWegdxk++UAt2SlQVnmeHv+g=="],
|
||||||
|
|
||||||
"@tabler/icons-react": ["@tabler/icons-react@2.47.0", "", { "dependencies": { "@tabler/icons": "2.47.0", "prop-types": "^15.7.2" }, "peerDependencies": { "react": "^16.5.1 || ^17.0.0 || ^18.0.0" } }, "sha512-iqly2FvCF/qUbgmvS8E40rVeYY7laltc5GUjRxQj59DuX0x/6CpKHTXt86YlI2whg4czvd/c8Ce8YR08uEku0g=="],
|
"@tabler/icons-react": ["@tabler/icons-react@3.31.0", "", { "dependencies": { "@tabler/icons": "3.31.0" }, "peerDependencies": { "react": ">= 16" } }, "sha512-2rrCM5y/VnaVKnORpDdAua9SEGuJKVqPtWxeQ/vUVsgaUx30LDgBZph7/lterXxDY1IKR6NO//HDhWiifXTi3w=="],
|
||||||
|
|
||||||
"@tiptap/core": ["@tiptap/core@2.11.5", "", { "peerDependencies": { "@tiptap/pm": "^2.7.0" } }, "sha512-jb0KTdUJaJY53JaN7ooY3XAxHQNoMYti/H6ANo707PsLXVeEqJ9o8+eBup1JU5CuwzrgnDc2dECt2WIGX9f8Jw=="],
|
"@tiptap/core": ["@tiptap/core@2.11.5", "", { "peerDependencies": { "@tiptap/pm": "^2.7.0" } }, "sha512-jb0KTdUJaJY53JaN7ooY3XAxHQNoMYti/H6ANo707PsLXVeEqJ9o8+eBup1JU5CuwzrgnDc2dECt2WIGX9f8Jw=="],
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@
|
|||||||
"@mantine/tiptap": "^7.5.3",
|
"@mantine/tiptap": "^7.5.3",
|
||||||
"@prisma/client": "^6.3.0",
|
"@prisma/client": "^6.3.0",
|
||||||
"@react-pdf/renderer": "^3.4.4",
|
"@react-pdf/renderer": "^3.4.4",
|
||||||
"@tabler/icons-react": "^2.38.0",
|
"@tabler/icons-react": "^3.31.0",
|
||||||
"@tiptap/extension-highlight": "^2.2.3",
|
"@tiptap/extension-highlight": "^2.2.3",
|
||||||
"@tiptap/extension-link": "^2.2.3",
|
"@tiptap/extension-link": "^2.2.3",
|
||||||
"@tiptap/extension-subscript": "^2.2.3",
|
"@tiptap/extension-subscript": "^2.2.3",
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
bun --env-file=.env run --bun start -p 3005
|
bun --env-file=.env run --bun start -p 3000
|
||||||
@@ -2,7 +2,6 @@ import { NextResponse } from "next/server";
|
|||||||
|
|
||||||
export async function GET(req: Request) {
|
export async function GET(req: Request) {
|
||||||
const token = req.headers.get("Authorization")?.split(" ")[1];
|
const token = req.headers.get("Authorization")?.split(" ")[1];
|
||||||
console.log("Token received in API Validation:", token, `<<<<<<<<<<<<<<<`);
|
|
||||||
|
|
||||||
if (!token) return NextResponse.json({ success: false }, { status: 401 });
|
if (!token) return NextResponse.json({ success: false }, { status: 401 });
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import adminNotifikasi_getByUserId from "@/app_modules/admin/notifikasi/fun/get/
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import versionUpdate from "../../../../package.json";
|
import versionUpdate from "../../../../package.json";
|
||||||
import { redirect } from "next/navigation";
|
import { redirect } from "next/navigation";
|
||||||
|
import { Admin_V3_MainLayout } from "@/app_modules/admin/_components_v3/main_layout";
|
||||||
|
|
||||||
export default async function Layout({
|
export default async function Layout({
|
||||||
children,
|
children,
|
||||||
@@ -15,24 +16,33 @@ export default async function Layout({
|
|||||||
const userLoginId = await funGetUserIdByToken();
|
const userLoginId = await funGetUserIdByToken();
|
||||||
const version = versionUpdate.version;
|
const version = versionUpdate.version;
|
||||||
|
|
||||||
const dataUser = await funGlobal_getUserById({
|
// const listNotifikasi = await adminNotifikasi_getByUserId({ page: 1 });
|
||||||
userId: userLoginId as string,
|
// const countNotifikasi = await adminNotifikasi_countNotifikasi();
|
||||||
});
|
|
||||||
const listNotifikasi = await adminNotifikasi_getByUserId({ page: 1 });
|
|
||||||
const countNotifikasi = await adminNotifikasi_countNotifikasi();
|
|
||||||
|
|
||||||
if (dataUser?.masterUserRoleId == "1") return redirect("/dev/home");
|
// const dataUser = await funGlobal_getUserById({
|
||||||
|
// userId: userLoginId as string,
|
||||||
|
// });
|
||||||
|
// if (dataUser?.masterUserRoleId == "1") return redirect("/dev/home");
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Admin_NewLayout
|
{/* <Admin_NewLayout
|
||||||
user={dataUser as any}
|
user={dataUser as any}
|
||||||
countNotifikasi={countNotifikasi as any}
|
countNotifikasi={countNotifikasi as any}
|
||||||
listNotifikasi={listNotifikasi as []}
|
listNotifikasi={listNotifikasi as []}
|
||||||
version={version}
|
version={version}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
</Admin_NewLayout>
|
</Admin_NewLayout> */}
|
||||||
|
|
||||||
|
<Admin_V3_MainLayout
|
||||||
|
userLoginId={userLoginId}
|
||||||
|
countNotifikasi={{} as any}
|
||||||
|
listNotifikasi={[] as []}
|
||||||
|
version={version}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</Admin_V3_MainLayout>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,6 @@
|
|||||||
import { AdminMain } from "@/app_modules/admin/main_dashboard";
|
import { AdminMain } from "@/app_modules/admin/main_dashboard";
|
||||||
import { AdminMainDashboard_CountPOrtofolio } from "@/app_modules/admin/main_dashboard/fun/count/fun_count_portofolio";
|
|
||||||
import { AdminMainDashboard_CountUser } from "@/app_modules/admin/main_dashboard/fun/count/fun_count_user";
|
|
||||||
|
|
||||||
export default async function Page() {
|
export default async function Page() {
|
||||||
// const countUser = await AdminMainDashboard_CountUser();
|
|
||||||
// const countPorto = await AdminMainDashboard_CountPOrtofolio();
|
|
||||||
|
|
||||||
// await new Promise((a, b) => {
|
// await new Promise((a, b) => {
|
||||||
// setTimeout(a, 4000);
|
// setTimeout(a, 4000);
|
||||||
// });
|
// });
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { AdminColor } from "@/app_modules/_global/color/color_pallet";
|
import { AdminColor } from "@/app_modules/_global/color/color_pallet";
|
||||||
import { Modal } from "@mantine/core";
|
import { Modal } from "@mantine/core";
|
||||||
import { reject } from "lodash";
|
|
||||||
|
|
||||||
export function Admin_ComponentModal({
|
export function Admin_ComponentModal({
|
||||||
children,
|
children,
|
||||||
@@ -15,7 +14,7 @@ export function Admin_ComponentModal({
|
|||||||
opened: boolean;
|
opened: boolean;
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
size?: "sm" | "md" | "lg" | "xl";
|
size?: "sm" | "md" | "lg" | "xl";
|
||||||
title: any;
|
title?: any;
|
||||||
withCloseButton?: boolean | undefined;
|
withCloseButton?: boolean | undefined;
|
||||||
closeOnClickOutside?: boolean | undefined;
|
closeOnClickOutside?: boolean | undefined;
|
||||||
}) {
|
}) {
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ export function Admin_ComponentButtonUserCircle({
|
|||||||
|
|
||||||
async function onClickLogout() {
|
async function onClickLogout() {
|
||||||
setLoadingLogout(true);
|
setLoadingLogout(true);
|
||||||
const res = await fetch(`/api/auth/logout?id=${dataUser.id}`, {
|
const res = await fetch(`/api/auth/logout?id=${dataUser?.id}`, {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -69,7 +69,7 @@ export function Admin_ComponentButtonUserCircle({
|
|||||||
<IconUser />
|
<IconUser />
|
||||||
</Grid.Col>
|
</Grid.Col>
|
||||||
<Grid.Col span={"auto"}>
|
<Grid.Col span={"auto"}>
|
||||||
<Text lineClamp={1}>{dataUser.username}</Text>
|
<Text lineClamp={1}>{dataUser?.username}</Text>
|
||||||
</Grid.Col>
|
</Grid.Col>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
@@ -78,7 +78,7 @@ export function Admin_ComponentButtonUserCircle({
|
|||||||
<IconPhone />
|
<IconPhone />
|
||||||
</Grid.Col>
|
</Grid.Col>
|
||||||
<Grid.Col span={"auto"}>
|
<Grid.Col span={"auto"}>
|
||||||
<Text lineClamp={1}>+{dataUser.nomor}</Text>
|
<Text lineClamp={1}>+{dataUser?.nomor}</Text>
|
||||||
</Grid.Col>
|
</Grid.Col>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
@@ -208,7 +208,7 @@ export function Admin_ComponentButtonUserCircle({
|
|||||||
<IconUser />
|
<IconUser />
|
||||||
</Grid.Col>
|
</Grid.Col>
|
||||||
<Grid.Col span={"auto"}>
|
<Grid.Col span={"auto"}>
|
||||||
<Text lineClamp={1}>{dataUser.username}</Text>
|
<Text lineClamp={1}>{dataUser?.username}</Text>
|
||||||
</Grid.Col>
|
</Grid.Col>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Menu.Item>
|
</Menu.Item>
|
||||||
@@ -218,7 +218,7 @@ export function Admin_ComponentButtonUserCircle({
|
|||||||
<IconPhone />
|
<IconPhone />
|
||||||
</Grid.Col>
|
</Grid.Col>
|
||||||
<Grid.Col span={"auto"}>
|
<Grid.Col span={"auto"}>
|
||||||
<Text lineClamp={1}>+{dataUser.nomor}</Text>
|
<Text lineClamp={1}>+{dataUser?.nomor}</Text>
|
||||||
</Grid.Col>
|
</Grid.Col>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Menu.Item>
|
</Menu.Item>
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ export default function Admin_UiNavbar({
|
|||||||
setActiveId,
|
setActiveId,
|
||||||
setActiveChildId,
|
setActiveChildId,
|
||||||
}: {
|
}: {
|
||||||
userRoleId: string;
|
userRoleId: string | null;
|
||||||
activeId: string;
|
activeId: string;
|
||||||
activeChildId: string;
|
activeChildId: string;
|
||||||
setActiveId: (val: any) => void;
|
setActiveId: (val: any) => void;
|
||||||
@@ -199,5 +199,5 @@ export default function Admin_UiNavbar({
|
|||||||
</Box>
|
</Box>
|
||||||
));
|
));
|
||||||
|
|
||||||
return userRoleId == "2" ? adminNavbar : developerNavbar;
|
return userRoleId == "3" ? developerNavbar : adminNavbar;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { AdminColor } from "@/app_modules/_global/color/color_pallet";
|
import { AdminColor } from "@/app_modules/_global/color/color_pallet";
|
||||||
import { Divider, Stack, Title } from "@mantine/core";
|
import { Stack, Title } from "@mantine/core";
|
||||||
|
|
||||||
export default function ComponentAdminGlobal_HeaderTamplate({name}: {name: string}) {
|
export default function ComponentAdminGlobal_HeaderTamplate({name}: {name: string}) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Stack spacing={5} >
|
<Stack spacing={5} >
|
||||||
<Title mb={"md"} c={AdminColor.white}>{name ? name : null}</Title>
|
<Title c={AdminColor.white}>{name ? name : null}</Title>
|
||||||
</Stack>
|
</Stack>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
257
src/app_modules/admin/_components_v3/comp_button_user_circle.tsx
Normal file
257
src/app_modules/admin/_components_v3/comp_button_user_circle.tsx
Normal file
@@ -0,0 +1,257 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { AccentColor } from "@/app_modules/_global/color";
|
||||||
|
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global";
|
||||||
|
import { MODEL_USER } from "@/app_modules/home/model/interface";
|
||||||
|
import { Warna } from "@/lib/warna";
|
||||||
|
import {
|
||||||
|
ActionIcon,
|
||||||
|
Button,
|
||||||
|
Center,
|
||||||
|
Divider,
|
||||||
|
Group,
|
||||||
|
Popover,
|
||||||
|
SimpleGrid,
|
||||||
|
Stack,
|
||||||
|
Text,
|
||||||
|
Title
|
||||||
|
} from "@mantine/core";
|
||||||
|
import {
|
||||||
|
IconBell,
|
||||||
|
IconHierarchy2,
|
||||||
|
IconLogout,
|
||||||
|
IconReplaceUser,
|
||||||
|
IconUser,
|
||||||
|
IconUserCircle
|
||||||
|
} from "@tabler/icons-react";
|
||||||
|
import { useRouter } from "next/navigation";
|
||||||
|
import { useState } from "react";
|
||||||
|
import { Admin_ComponentModal } from "../_admin_global/_component/comp_admin_modal";
|
||||||
|
|
||||||
|
export function Admin_V3_ComponentButtonUserCircle({
|
||||||
|
dataUser,
|
||||||
|
}: {
|
||||||
|
dataUser: MODEL_USER | null;
|
||||||
|
}) {
|
||||||
|
const router = useRouter();
|
||||||
|
const [isOpenMenuUser, setOpenMenuUser] = useState(false);
|
||||||
|
const [openPop, setOpenPop] = useState(false);
|
||||||
|
const [openModalLogout, setOpenModalLogout] = useState(false);
|
||||||
|
const [openModalReplaceUser, setOpenModalReplaceUser] = useState(false);
|
||||||
|
const [loadingLogout, setLoadingLogout] = useState(false);
|
||||||
|
const [loadingReplaceUser, setLoadingReplaceUser] = useState(false);
|
||||||
|
|
||||||
|
const listMenu = [
|
||||||
|
{
|
||||||
|
icon: IconUser,
|
||||||
|
label: dataUser?.username,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
icon: IconHierarchy2,
|
||||||
|
label:
|
||||||
|
dataUser?.masterUserRoleId == "2"
|
||||||
|
? "Admin "
|
||||||
|
: dataUser?.masterUserRoleId == "3"
|
||||||
|
? "Super Admin"
|
||||||
|
: "",
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
const listAction = [
|
||||||
|
{
|
||||||
|
icon: IconBell,
|
||||||
|
label: "Notifikasi",
|
||||||
|
color: "",
|
||||||
|
onClick: () => console.log("Notifikasi"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
icon: IconReplaceUser,
|
||||||
|
label: "Tampilan user",
|
||||||
|
color: "",
|
||||||
|
onClick: () => setOpenModalReplaceUser(true),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
icon: IconLogout,
|
||||||
|
label: "Logout",
|
||||||
|
color: "red",
|
||||||
|
onClick: () => setOpenModalLogout(true),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
async function onClickLogout() {
|
||||||
|
setLoadingLogout(true);
|
||||||
|
const res = await fetch(`/api/auth/logout?id=${dataUser?.id}`, {
|
||||||
|
method: "GET",
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = await res.json();
|
||||||
|
if (res.status === 200) {
|
||||||
|
ComponentGlobal_NotifikasiBerhasil(result.message);
|
||||||
|
router.push("/", { scroll: false });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Popover opened={openPop} onChange={setOpenPop} position="left-start">
|
||||||
|
<Popover.Target>
|
||||||
|
<ActionIcon
|
||||||
|
disabled={!dataUser}
|
||||||
|
variant="transparent"
|
||||||
|
onClick={() => {
|
||||||
|
setOpenPop((o) => !o);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<IconUserCircle color={dataUser ? "white" : "gray"} />
|
||||||
|
</ActionIcon>
|
||||||
|
</Popover.Target>
|
||||||
|
|
||||||
|
<Popover.Dropdown
|
||||||
|
style={{
|
||||||
|
backgroundColor: AccentColor.blue,
|
||||||
|
color: AccentColor.white,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Stack>
|
||||||
|
{listMenu.map((e, i) => (
|
||||||
|
<Group key={i}>
|
||||||
|
<e.icon size={18} />
|
||||||
|
<Text lineClamp={1} >{e.label}</Text>
|
||||||
|
</Group>
|
||||||
|
))}
|
||||||
|
|
||||||
|
<Divider />
|
||||||
|
|
||||||
|
<SimpleGrid cols={3}>
|
||||||
|
{listAction.map((e, i) => (
|
||||||
|
<Center key={i}>
|
||||||
|
<ActionIcon variant="transparent" onClick={e.onClick}>
|
||||||
|
<e.icon color={e.color || "white"} />
|
||||||
|
</ActionIcon>
|
||||||
|
</Center>
|
||||||
|
))}
|
||||||
|
</SimpleGrid>
|
||||||
|
|
||||||
|
{/* <SimpleGrid cols={2}>
|
||||||
|
<Button
|
||||||
|
radius={"xl"}
|
||||||
|
onClick={() => router.push("/dev/home", { scroll: false })}
|
||||||
|
>
|
||||||
|
User Access
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
radius={"xl"}
|
||||||
|
color="red"
|
||||||
|
onClick={() => setOpenModal(true)}
|
||||||
|
>
|
||||||
|
Keluar
|
||||||
|
</Button>
|
||||||
|
</SimpleGrid> */}
|
||||||
|
</Stack>
|
||||||
|
</Popover.Dropdown>
|
||||||
|
</Popover>
|
||||||
|
|
||||||
|
{/* <Modal
|
||||||
|
opened={openModal}
|
||||||
|
onClose={() => setOpenModal(false)}
|
||||||
|
centered
|
||||||
|
withCloseButton={false}
|
||||||
|
closeOnClickOutside={false}
|
||||||
|
>
|
||||||
|
<Stack>
|
||||||
|
<Title order={6}>Anda yakin ingin keluar ?</Title>
|
||||||
|
<Group align="center" position="center">
|
||||||
|
<Button
|
||||||
|
onClick={() => {
|
||||||
|
setOpenModal(false);
|
||||||
|
}}
|
||||||
|
radius={50}
|
||||||
|
>
|
||||||
|
Batal
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
loaderPosition="center"
|
||||||
|
loading={loadingLogout ? true : false}
|
||||||
|
radius={50}
|
||||||
|
bg={Warna.merah}
|
||||||
|
color="red"
|
||||||
|
onClick={() => onClickLogout()}
|
||||||
|
>
|
||||||
|
Keluar
|
||||||
|
</Button>
|
||||||
|
</Group>
|
||||||
|
</Stack>
|
||||||
|
</Modal> */}
|
||||||
|
|
||||||
|
<Admin_ComponentModal
|
||||||
|
opened={openModalLogout}
|
||||||
|
onClose={() => setOpenModalLogout(false)}
|
||||||
|
withCloseButton={false}
|
||||||
|
closeOnClickOutside={false}
|
||||||
|
>
|
||||||
|
<Stack>
|
||||||
|
<Title order={5} c={AccentColor.white}>
|
||||||
|
Anda yakin ingin keluar ?
|
||||||
|
</Title>
|
||||||
|
<Group align="center" position="center">
|
||||||
|
<Button
|
||||||
|
onClick={() => {
|
||||||
|
setOpenPop((o) => !o);
|
||||||
|
setOpenModalLogout(false);
|
||||||
|
}}
|
||||||
|
radius={50}
|
||||||
|
>
|
||||||
|
Batal
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
loaderPosition="center"
|
||||||
|
loading={loadingLogout ? true : false}
|
||||||
|
radius={50}
|
||||||
|
bg={Warna.merah}
|
||||||
|
color="red"
|
||||||
|
onClick={() => onClickLogout()}
|
||||||
|
>
|
||||||
|
Keluar
|
||||||
|
</Button>
|
||||||
|
</Group>
|
||||||
|
</Stack>
|
||||||
|
</Admin_ComponentModal>
|
||||||
|
|
||||||
|
<Admin_ComponentModal
|
||||||
|
opened={openModalReplaceUser}
|
||||||
|
onClose={() => setOpenModalReplaceUser(false)}
|
||||||
|
withCloseButton={false}
|
||||||
|
closeOnClickOutside={false}
|
||||||
|
>
|
||||||
|
<Stack>
|
||||||
|
<Title order={5} c={AccentColor.white}>
|
||||||
|
Anda yakin ingin keluar ?
|
||||||
|
</Title>
|
||||||
|
<Group align="center" position="center">
|
||||||
|
<Button
|
||||||
|
onClick={() => {
|
||||||
|
setOpenPop((o) => !o);
|
||||||
|
setOpenModalReplaceUser(false);
|
||||||
|
}}
|
||||||
|
radius={50}
|
||||||
|
>
|
||||||
|
Batal
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
loaderPosition="center"
|
||||||
|
loading={loadingLogout ? true : false}
|
||||||
|
radius={50}
|
||||||
|
bg={AccentColor.softblue}
|
||||||
|
color="blue"
|
||||||
|
onClick={() => {
|
||||||
|
router.push("/dev/home", { scroll: false });
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
User Akses
|
||||||
|
</Button>
|
||||||
|
</Group>
|
||||||
|
</Stack>
|
||||||
|
</Admin_ComponentModal>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
213
src/app_modules/admin/_components_v3/main_layout.tsx
Normal file
213
src/app_modules/admin/_components_v3/main_layout.tsx
Normal file
@@ -0,0 +1,213 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { AccentColor, MainColor } from "@/app_modules/_global/color";
|
||||||
|
import { apiGetUserById } from "@/app_modules/_global/lib/api_user";
|
||||||
|
import { MODEL_USER } from "@/app_modules/home/model/interface";
|
||||||
|
import { MODEL_NOTIFIKASI } from "@/app_modules/notifikasi/model/interface";
|
||||||
|
import { gs_admin_ntf } from "@/lib/global_state";
|
||||||
|
import {
|
||||||
|
AppShell,
|
||||||
|
Burger,
|
||||||
|
Divider,
|
||||||
|
Group,
|
||||||
|
Header,
|
||||||
|
MediaQuery,
|
||||||
|
Navbar,
|
||||||
|
ScrollArea,
|
||||||
|
Stack,
|
||||||
|
Text,
|
||||||
|
useMantineTheme
|
||||||
|
} from "@mantine/core";
|
||||||
|
import { useDisclosure, useShallowEffect } from "@mantine/hooks";
|
||||||
|
import {
|
||||||
|
IconBriefcase,
|
||||||
|
IconCoin,
|
||||||
|
IconHome,
|
||||||
|
IconMessage,
|
||||||
|
IconUser
|
||||||
|
} from "@tabler/icons-react";
|
||||||
|
import { useAtom } from "jotai";
|
||||||
|
import { usePathname, useRouter } from "next/navigation";
|
||||||
|
import type React from "react";
|
||||||
|
import { useState } from "react";
|
||||||
|
import {
|
||||||
|
Admin_UiNavbar
|
||||||
|
} from "../_admin_global";
|
||||||
|
import {
|
||||||
|
gs_admin_navbar_menu,
|
||||||
|
gs_admin_navbar_subMenu,
|
||||||
|
} from "../_admin_global/new_global_state";
|
||||||
|
import { Admin_V3_ComponentButtonUserCircle } from "./comp_button_user_circle";
|
||||||
|
|
||||||
|
export function Admin_V3_MainLayout({
|
||||||
|
children,
|
||||||
|
userLoginId,
|
||||||
|
countNotifikasi,
|
||||||
|
listNotifikasi,
|
||||||
|
version,
|
||||||
|
}: {
|
||||||
|
children: React.ReactNode;
|
||||||
|
userLoginId: string;
|
||||||
|
countNotifikasi: number;
|
||||||
|
listNotifikasi: MODEL_NOTIFIKASI[];
|
||||||
|
version: string;
|
||||||
|
}) {
|
||||||
|
const router = useRouter();
|
||||||
|
const [dataUser, setDataUser] = useState<MODEL_USER | null>(null);
|
||||||
|
const userRoleId = dataUser?.masterUserRoleId;
|
||||||
|
const [activeId, setActiveId] = useAtom(gs_admin_navbar_menu);
|
||||||
|
const [activeChildId, setActiveChildId] = useAtom(gs_admin_navbar_subMenu);
|
||||||
|
const [dataNotifikasi, setDataNotifikasi] =
|
||||||
|
useState<MODEL_NOTIFIKASI[]>(listNotifikasi);
|
||||||
|
|
||||||
|
// Notifikasi
|
||||||
|
const [isDrawerNotifikasi, setDrawerNotifikasi] = useState(false);
|
||||||
|
const [countNtf, setCountNtf] = useState(countNotifikasi);
|
||||||
|
const [newAdminNtf, setNewAdminNtf] = useAtom(gs_admin_ntf);
|
||||||
|
|
||||||
|
useShallowEffect(() => {
|
||||||
|
handleLoadUser();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
async function handleLoadUser() {
|
||||||
|
try {
|
||||||
|
const response = await apiGetUserById({ id: userLoginId });
|
||||||
|
if (response && response.success) {
|
||||||
|
setDataUser(response.data);
|
||||||
|
} else {
|
||||||
|
console.error("Failed to fetch user data", response);
|
||||||
|
setDataUser(null);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error fetching user data", error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const [opened, { toggle, close }] = useDisclosure(false);
|
||||||
|
|
||||||
|
|
||||||
|
return (
|
||||||
|
<AppShell
|
||||||
|
bg={MainColor.darkblue}
|
||||||
|
padding={"md"}
|
||||||
|
navbarOffsetBreakpoint="md"
|
||||||
|
navbar={
|
||||||
|
<Navbar
|
||||||
|
p="md"
|
||||||
|
hiddenBreakpoint="md"
|
||||||
|
hidden={!opened}
|
||||||
|
width={{ base: 250 }}
|
||||||
|
bg={AccentColor.darkblue}
|
||||||
|
style={{ borderColor: "transparent", transition: " ease 1s" }}
|
||||||
|
height={"93vh"}
|
||||||
|
>
|
||||||
|
<Navbar.Section
|
||||||
|
h={"88vh"}
|
||||||
|
grow
|
||||||
|
component={ScrollArea}
|
||||||
|
style={{ color: "white", transition: "1s" }}
|
||||||
|
>
|
||||||
|
<Stack style={{ color: "white" }} mb={"lg"}>
|
||||||
|
<Admin_UiNavbar
|
||||||
|
userRoleId={userRoleId as any}
|
||||||
|
activeId={activeId as any}
|
||||||
|
activeChildId={activeChildId as any}
|
||||||
|
setActiveId={setActiveId}
|
||||||
|
setActiveChildId={setActiveChildId}
|
||||||
|
/>
|
||||||
|
</Stack>
|
||||||
|
</Navbar.Section>
|
||||||
|
|
||||||
|
<Navbar.Section h="5">
|
||||||
|
<Stack>
|
||||||
|
<Divider />
|
||||||
|
<Group position="center">
|
||||||
|
<Text fs={"italic"} c={"white"} fz={"xs"}>
|
||||||
|
V {version}
|
||||||
|
</Text>
|
||||||
|
</Group>
|
||||||
|
</Stack>
|
||||||
|
</Navbar.Section>
|
||||||
|
|
||||||
|
{/* <Box style={{ flex: "1" }}>
|
||||||
|
<Stack spacing="xs">
|
||||||
|
{navLinks.map((link) => (
|
||||||
|
<Anchor
|
||||||
|
key={link.path}
|
||||||
|
component={Link}
|
||||||
|
href={link.path}
|
||||||
|
color={isActive(link.path) ? "blue" : "dimmed"}
|
||||||
|
weight={500}
|
||||||
|
p="xs"
|
||||||
|
style={{
|
||||||
|
display: "flex",
|
||||||
|
borderRadius: theme.radius.sm,
|
||||||
|
backgroundColor: isActive(link.path)
|
||||||
|
? theme.colors.dark[6]
|
||||||
|
: "transparent",
|
||||||
|
}}
|
||||||
|
// onClick={() => {
|
||||||
|
// if (
|
||||||
|
// typeof window !== "undefined" &&
|
||||||
|
// window.innerWidth < theme.breakpoints.md
|
||||||
|
// ) {
|
||||||
|
// close();
|
||||||
|
// }
|
||||||
|
// }}
|
||||||
|
>
|
||||||
|
<Group>
|
||||||
|
<link.icon size={18} />
|
||||||
|
<Text>{link.label}</Text>
|
||||||
|
</Group>
|
||||||
|
</Anchor>
|
||||||
|
))}
|
||||||
|
</Stack>
|
||||||
|
</Box> */}
|
||||||
|
|
||||||
|
{/* <Box mt="auto">
|
||||||
|
<Divider my="sm" />
|
||||||
|
<Group position="center" mt="md">
|
||||||
|
<ThemeIcon size={36} radius="xl" color="blue">
|
||||||
|
<IconBrandGithub size={18} />
|
||||||
|
</ThemeIcon>
|
||||||
|
<ThemeIcon size={36} radius="xl" color="blue">
|
||||||
|
<IconBrandLinkedin size={18} />
|
||||||
|
</ThemeIcon>
|
||||||
|
<ThemeIcon size={36} radius="xl" color="blue">
|
||||||
|
<IconMail size={18} />
|
||||||
|
</ThemeIcon>
|
||||||
|
</Group>
|
||||||
|
</Box> */}
|
||||||
|
</Navbar>
|
||||||
|
}
|
||||||
|
header={
|
||||||
|
<Header
|
||||||
|
height={"7vh"}
|
||||||
|
px="md"
|
||||||
|
bg={AccentColor.darkblue}
|
||||||
|
// style={{ border: "none" }}
|
||||||
|
>
|
||||||
|
<Group style={{ height: "100%" }} position="apart">
|
||||||
|
<MediaQuery largerThan="md" styles={{ display: "none" }}>
|
||||||
|
<Burger
|
||||||
|
disabled={!dataUser}
|
||||||
|
opened={opened}
|
||||||
|
onClick={toggle}
|
||||||
|
size="sm"
|
||||||
|
color={!dataUser ? "gray" : AccentColor.white}
|
||||||
|
/>
|
||||||
|
</MediaQuery>
|
||||||
|
|
||||||
|
<Text size="lg" weight={700} c={MainColor.white}>
|
||||||
|
HIMPI DASHBOARD
|
||||||
|
</Text>
|
||||||
|
|
||||||
|
<Admin_V3_ComponentButtonUserCircle dataUser={dataUser as any} />
|
||||||
|
</Group>
|
||||||
|
</Header>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</AppShell>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -16,10 +16,10 @@ export default function AdminMain() {
|
|||||||
const [countUser, setCountUser] = useState<number | null>(null);
|
const [countUser, setCountUser] = useState<number | null>(null);
|
||||||
const [countPortofolio, setCountPortofolio] = useState<number | null>(null);
|
const [countPortofolio, setCountPortofolio] = useState<number | null>(null);
|
||||||
|
|
||||||
useShallowEffect(() => {
|
// useShallowEffect(() => {
|
||||||
onLoadDataUser();
|
// onLoadDataUser();
|
||||||
onLoadDataPortofolio();
|
// onLoadDataPortofolio();
|
||||||
}, []);
|
// }, []);
|
||||||
|
|
||||||
async function onLoadDataUser() {
|
async function onLoadDataUser() {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import {
|
|||||||
gs_admin_navbar_subMenu,
|
gs_admin_navbar_subMenu,
|
||||||
} from "../_admin_global/new_global_state";
|
} from "../_admin_global/new_global_state";
|
||||||
import { IAdmin_ActivePage } from "../notifikasi/route_setting/type_of_select_page";
|
import { IAdmin_ActivePage } from "../notifikasi/route_setting/type_of_select_page";
|
||||||
|
import { AccentColor } from "@/app_modules/_global/color";
|
||||||
|
|
||||||
export default function SplashDashboardAdmin() {
|
export default function SplashDashboardAdmin() {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
@@ -28,7 +29,7 @@ export default function SplashDashboardAdmin() {
|
|||||||
<>
|
<>
|
||||||
<Center h={"100vh"}>
|
<Center h={"100vh"}>
|
||||||
<Stack spacing={0}>
|
<Stack spacing={0}>
|
||||||
<Title>Welcome Admin</Title>
|
<Title c={AccentColor.white}>Welcome Admin</Title>
|
||||||
|
|
||||||
<AspectRatio ratio={1 / 1} mah={700} maw={700}>
|
<AspectRatio ratio={1 / 1} mah={700} maw={700}>
|
||||||
<Image src={"/aset/logo/logo-hipmi.png"} alt="Logo" />
|
<Image src={"/aset/logo/logo-hipmi.png"} alt="Logo" />
|
||||||
|
|||||||
Reference in New Issue
Block a user