# fix
- Layout katalog dan porto clear # No isuue
This commit is contained in:
@@ -3,12 +3,13 @@ import { RouterAdminEvent } from "@/app/lib/router_admin/router_admin_event";
|
||||
import { RouterAdminForum } from "@/app/lib/router_admin/router_admin_forum";
|
||||
import { RouterAdminJob } from "@/app/lib/router_admin/router_admin_job";
|
||||
import { RouterAdminVote } from "@/app/lib/router_admin/router_admin_vote";
|
||||
import { RouterAdminUserAccess } from "@/app/lib/router_admin/router_admn_user_acces";
|
||||
import {
|
||||
RouterAdminDashboard,
|
||||
RouterAdminDonasi,
|
||||
RouterAdminInvestasi,
|
||||
} from "@/app/lib/router_hipmi/router_admin";
|
||||
import { IconBriefcase, IconDashboard, IconMessages } from "@tabler/icons-react";
|
||||
import { IconBriefcase, IconDashboard, IconMessages, IconUserCog } from "@tabler/icons-react";
|
||||
import {
|
||||
IconHeartHandshake,
|
||||
IconHome,
|
||||
@@ -172,6 +173,13 @@ export const listAdminPage = [
|
||||
// },
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 98,
|
||||
name: "User Access",
|
||||
path: RouterAdminUserAccess.main,
|
||||
icon: <IconUserCog />,
|
||||
child: [],
|
||||
},
|
||||
{
|
||||
id: 99,
|
||||
name: "Developer",
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
import { revalidatePath } from "next/cache";
|
||||
|
||||
export default async function adminUserAccess_funEditAccess(
|
||||
userId: string,
|
||||
value: boolean
|
||||
) {
|
||||
const updt = await prisma.user.update({
|
||||
where: {
|
||||
id: userId,
|
||||
},
|
||||
data: {
|
||||
active: value,
|
||||
},
|
||||
});
|
||||
|
||||
if (!updt) return { status: 400, message: "Update gagal" };
|
||||
revalidatePath("/dev/admin/user-access");
|
||||
return { status: 200, message: "Update berhasil" };
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
"use server";
|
||||
|
||||
import prisma from "@/app/lib/prisma";
|
||||
|
||||
export default async function adminUserAccess_getListUser() {
|
||||
const get = await prisma.user.findMany({
|
||||
where: {
|
||||
masterUserRoleId: "1",
|
||||
},
|
||||
});
|
||||
|
||||
return get;
|
||||
}
|
||||
3
src/app_modules/admin/user-access/index.tsx
Normal file
3
src/app_modules/admin/user-access/index.tsx
Normal file
@@ -0,0 +1,3 @@
|
||||
import AdminUserAccess_View from "./view";
|
||||
|
||||
export {AdminUserAccess_View}
|
||||
135
src/app_modules/admin/user-access/view/index.tsx
Normal file
135
src/app_modules/admin/user-access/view/index.tsx
Normal file
@@ -0,0 +1,135 @@
|
||||
"use client";
|
||||
|
||||
import { MODEL_USER } from "@/app_modules/home/model/interface";
|
||||
import {
|
||||
Button,
|
||||
Center,
|
||||
Group,
|
||||
Paper,
|
||||
ScrollArea,
|
||||
Stack,
|
||||
Table,
|
||||
TextInput,
|
||||
Title,
|
||||
} from "@mantine/core";
|
||||
import { IconSearch } from "@tabler/icons-react";
|
||||
import adminUserAccess_funEditAccess from "../fun/edit/fun_edit_access";
|
||||
import { useState } from "react";
|
||||
import adminUserAccess_getListUser from "../fun/get/get_list_all_user";
|
||||
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/component_global/notif_global/notifikasi_berhasil";
|
||||
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/component_global/notif_global/notifikasi_gagal";
|
||||
|
||||
export default function AdminUserAccess_View({
|
||||
listUser,
|
||||
}: {
|
||||
listUser: MODEL_USER[];
|
||||
}) {
|
||||
const [data, setData] = useState(listUser);
|
||||
async function onAccess(id: string) {
|
||||
await adminUserAccess_funEditAccess(id, true).then(async (res) => {
|
||||
if (res.status === 200) {
|
||||
const value = await adminUserAccess_getListUser();
|
||||
setData(value as any);
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async function onDelAccess(id: string) {
|
||||
await adminUserAccess_funEditAccess(id, false).then(async (res) => {
|
||||
if (res.status === 200) {
|
||||
const value = await adminUserAccess_getListUser();
|
||||
setData(value as any);
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
const tableBody = data.map((e, i) => (
|
||||
<tr key={e.id}>
|
||||
<td>
|
||||
<Center>{e.username}</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center>{e.nomor}</Center>
|
||||
</td>
|
||||
<td>
|
||||
{e.active === false ? (
|
||||
<Center>
|
||||
<Button
|
||||
radius={"xl"}
|
||||
color="Green"
|
||||
onClick={() => {
|
||||
onAccess(e.id);
|
||||
}}
|
||||
>
|
||||
Give Access
|
||||
</Button>
|
||||
</Center>
|
||||
) : (
|
||||
<Center>
|
||||
<Button
|
||||
radius={"xl"}
|
||||
color="red"
|
||||
onClick={() => {
|
||||
onDelAccess(e.id);
|
||||
}}
|
||||
>
|
||||
Delete Access
|
||||
</Button>
|
||||
</Center>
|
||||
)}
|
||||
</td>
|
||||
</tr>
|
||||
));
|
||||
return (
|
||||
<>
|
||||
<Stack spacing={"xs"}>
|
||||
{/* <pre>{JSON.stringify(listUser, null, 2)}</pre> */}
|
||||
<Group
|
||||
position="apart"
|
||||
bg={"blue.4"}
|
||||
p={"xs"}
|
||||
style={{ borderRadius: "6px" }}
|
||||
>
|
||||
<Title order={4}>Table User</Title>
|
||||
{/* <TextInput
|
||||
icon={<IconSearch size={20} />}
|
||||
radius={"xl"}
|
||||
placeholder="Masukan username"
|
||||
/> */}
|
||||
</Group>
|
||||
<Paper p={"md"} withBorder shadow="lg" h={"80vh"}>
|
||||
<ScrollArea h={"70vh"}>
|
||||
<Table
|
||||
verticalSpacing={"xs"}
|
||||
horizontalSpacing={"md"}
|
||||
p={"md"}
|
||||
striped
|
||||
highlightOnHover
|
||||
>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
<Center>Username</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Nomor</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Aksi</Center>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>{tableBody}</tbody>
|
||||
</Table>
|
||||
</ScrollArea>
|
||||
</Paper>
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user