fix: Admin

Deskripsi:
- Penambahan field nama rekening di db bank
- Optimalisasi event
## No Issue
This commit is contained in:
2024-09-03 10:10:31 +08:00
parent 8a018462c7
commit 74108c3096
117 changed files with 2976 additions and 1144 deletions

View File

@@ -1,8 +1,6 @@
"use client";
import { RouterAdminDonasi_OLD } from "@/app/lib/router_hipmi/router_admin";
import {
ActionIcon,
Avatar,
Box,
Button,
@@ -11,99 +9,137 @@ import {
Grid,
Group,
Modal,
Pagination,
Paper,
ScrollArea,
Spoiler,
Stack,
Table,
Text,
TextInput,
Title,
} from "@mantine/core";
import {
IconBan,
IconChevronLeft,
IconEyeCheck,
IconEyeShare,
IconShare,
} from "@tabler/icons-react";
import { IconCircleCheck, IconEyeShare, IconSearch } from "@tabler/icons-react";
import { useRouter } from "next/navigation";
import { useDisclosure } from "@mantine/hooks";
import { useState } from "react";
import TampilanRupiahDonasi from "@/app_modules/donasi/component/tampilan_rupiah";
import ComponentAdminDonasi_TombolKembali from "../../donasi/component/tombol_kembali";
import { RouterProfile } from "@/app/lib/router_hipmi/router_katalog";
import {
MODEL_EVENT,
MODEL_EVENT_PESERTA,
} from "@/app_modules/event/model/interface";
import ComponentAdminGlobal_HeaderTamplate from "../../_admin_global/header_tamplate";
import moment from "moment";
import _ from "lodash";
import { AdminEvent_funEditStatusPublishById } from "../fun/edit/fun_edit_status_publish_by_id";
import { AppRouterInstance } from "next/dist/shared/lib/app-router-context.shared-runtime";
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
import { AdminEvent_getListTableByStatusId } from "../fun/get/get_list_table_by_status_id";
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal";
import { RouterProfile } from "@/app/lib/router_hipmi/router_katalog";
import { AdminEvent_getListPesertaById } from "../fun/get/get_list_peserta_by_id";
import { useState } from "react";
import ComponentAdminGlobal_HeaderTamplate from "../../_admin_global/header_tamplate";
import { adminEvent_getListPesertaById } from "../fun/get/get_list_peserta_by_id";
import { adminEvent_funGetListPublish } from "../fun";
import { RouterAdminEvent } from "@/app/lib/router_admin/router_admin_event";
export default function AdminEvent_TablePublish({
listPublish,
}: {
listPublish: MODEL_EVENT[];
listPublish: any;
}) {
return (
<>
<Stack>
<ComponentAdminGlobal_HeaderTamplate name="Event: Table Publish" />
<ComponentAdminGlobal_HeaderTamplate name="Event" />
<TableStatus listPublish={listPublish} />
</Stack>
</>
);
}
function TableStatus({ listPublish }: { listPublish: MODEL_EVENT[] }) {
function TableStatus({ listPublish }: { listPublish: any }) {
const router = useRouter();
const [opened, { open, close }] = useDisclosure(false);
const [data, setData] = useState(listPublish);
const [data, setData] = useState<MODEL_EVENT[]>(listPublish.data);
const [isNPage, setNPage] = useState(listPublish.nPage);
const [isActivePage, setActivePage] = useState(1);
const [isSearch, setSearch] = useState("");
const [peserta, setPeserta] = useState<MODEL_EVENT_PESERTA[]>();
const [eventId, setEventId] = useState("");
const [loading, setLoading] = useState(false);
async function onSearch(s: string) {
setSearch(s);
const loadData = await adminEvent_funGetListPublish({
page: 1,
search: s,
});
setData(loadData.data as any);
setNPage(loadData.nPage);
}
async function onPageClick(p: any) {
setActivePage(p);
const loadData = await adminEvent_funGetListPublish({
search: isSearch,
page: p,
});
setData(loadData.data as any);
setNPage(loadData.nPage);
}
const TableRows = data.map((e, i) => (
<tr key={i}>
<td>{e?.Author?.Profile?.name}</td>
<td>{e?.title}</td>
<td>{e?.lokasi}</td>
<td>{e?.EventMaster_TipeAcara?.name}</td>
<td>{e?.tanggal.toLocaleString("id-ID", { dateStyle: "full" })}</td>
<td>
{e.tanggal.toLocaleTimeString([], {
timeStyle: "short",
hourCycle: "h24",
})}
<Center w={200}>
<Text>{e?.Author?.username}</Text>
</Center>
</td>
<td>
<Spoiler hideLabel="sembunyikan" maxHeight={50} showLabel="tampilkan">
{e.deskripsi}
</Spoiler>
<Center w={200}>
<Text lineClamp={2}>{e.title}</Text>
</Center>
</td>
<td>
<Center w={200}>
<Text>{e.lokasi}</Text>
</Center>
</td>
<td>
<Center w={200}>
<Text>{e.EventMaster_TipeAcara.name}</Text>
</Center>
</td>
<td>
<Center w={200}>
{e.tanggal.toLocaleString("id-ID", { dateStyle: "full" })}
</Center>
</td>
<td>
<Center w={200}>
{e.tanggal.toLocaleTimeString([], {
timeStyle: "short",
hourCycle: "h24",
})}
</Center>
</td>
<td>
<Center w={400}>
<Spoiler hideLabel="sembunyikan" maxHeight={50} showLabel="tampilkan">
{e.deskripsi}
</Spoiler>
</Center>
</td>
<td>
<Button
loading={e.id === eventId ? (loading === true ? true : false) : false}
color={"green"}
leftIcon={<IconEyeShare />}
leftIcon={<IconCircleCheck />}
radius={"xl"}
onClick={async () => {
setEventId(e.id);
setLoading(true);
await new Promise((v) => setTimeout(v, 500));
await AdminEvent_getListPesertaById(e.id).then((res: any) => {
setPeserta(res);
setLoading(false);
});
open();
router.push(RouterAdminEvent.detail_peserta + e.id);
// setEventId(e.id);
// setLoading(true);
// await new Promise((v) => setTimeout(v, 500));
// await adminEvent_getListPesertaById(e.id).then((res: any) => {
// setPeserta(res);
// setLoading(false);
// });
// open();
}}
>
Lihat Peserta
@@ -114,6 +150,78 @@ function TableStatus({ listPublish }: { listPublish: MODEL_EVENT[] }) {
return (
<>
<Stack spacing={"xs"} h={"100%"}>
<Group
position="apart"
bg={"green.4"}
p={"xs"}
style={{ borderRadius: "6px" }}
>
<Title order={4}>Publish</Title>
<TextInput
icon={<IconSearch size={20} />}
radius={"xl"}
placeholder="Masukan judul"
onChange={(val) => {
onSearch(val.currentTarget.value);
}}
/>
</Group>
<Paper p={"md"} withBorder shadow="lg" h={"80vh"}>
<ScrollArea w={"100%"} h={"90%"}>
<Table
verticalSpacing={"md"}
horizontalSpacing={"md"}
p={"md"}
w={1500}
striped
highlightOnHover
>
<thead>
<tr>
<th>
<Center>Username</Center>
</th>
<th>
<Center>Judul</Center>
</th>
<th>
<Center>Lokasi</Center>
</th>
<th>
<Center>Tipe Acara</Center>
</th>
<th>
<Center>Tanggal</Center>
</th>
<th>
<Center>Jam</Center>
</th>
<th>
<Center>Deskripsi</Center>
</th>
<th>
<Center>Aksi</Center>
</th>
</tr>
</thead>
<tbody>{TableRows}</tbody>
</Table>
</ScrollArea>
<Center mt={"xl"}>
<Pagination
value={isActivePage}
total={isNPage}
onChange={(val) => {
onPageClick(val);
}}
/>
</Center>
</Paper>
</Stack>
<Modal opened={opened} onClose={close}>
<Paper>
<Stack>
@@ -153,49 +261,6 @@ function TableStatus({ listPublish }: { listPublish: MODEL_EVENT[] }) {
</Stack>
</Paper>
</Modal>
<Box>
<Box bg={"green.1"} p={"xs"}>
<Title order={6} c={"green"}>
PUBLISH
</Title>
</Box>
<Table
withBorder
verticalSpacing={"md"}
horizontalSpacing={"xl"}
p={"md"}
striped
highlightOnHover
>
<thead>
<tr>
<th>Author</th>
<th>Judul</th>
<th>Lokasi</th>
<th>Tipe Acara</th>
<th>Tanggal</th>
<th>Jam</th>
<th>
<Center>Deskripsi</Center>
</th>
<th>
<Center>Aksi</Center>
</th>
</tr>
</thead>
<tbody>{TableRows}</tbody>
</Table>
<Center>
{_.isEmpty(TableRows) ? (
<Center h={"50vh"}>
<Title order={6}>Tidak Ada Data</Title>
</Center>
) : (
""
)}
</Center>
</Box>
</>
);
}