41
src/app/api/admin/investasi/[id]/detail_transaksi/route.ts
Normal file
41
src/app/api/admin/investasi/[id]/detail_transaksi/route.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import prisma from "@/lib/prisma";
|
||||
import backendLogger from "@/util/backendLogger";
|
||||
import { NextResponse } from "next/server";
|
||||
export async function GET(req: Request,
|
||||
{ params }: { params: { id: any } }) {
|
||||
try {
|
||||
let fixData;
|
||||
const { id } = params
|
||||
const data = await prisma.investasi_Invoice.findMany({
|
||||
where: {
|
||||
investasiId: id,
|
||||
isActive: true,
|
||||
},
|
||||
include: {
|
||||
Author: true,
|
||||
Images: true,
|
||||
StatusInvoice: true,
|
||||
MasterBank: true,
|
||||
}
|
||||
})
|
||||
fixData = {
|
||||
data: data,
|
||||
}
|
||||
return NextResponse.json({
|
||||
success: true,
|
||||
message: "Success get data detail transaksi",
|
||||
data: fixData,
|
||||
},
|
||||
{ status: 200 }
|
||||
)
|
||||
} catch (error) {
|
||||
backendLogger.error("Error get data detail transaksi", error);
|
||||
return NextResponse.json({
|
||||
success: false,
|
||||
message: "Error get data detail transaksi",
|
||||
reason: (error as Error).message
|
||||
},
|
||||
{ status: 500 }
|
||||
)
|
||||
}
|
||||
}
|
||||
14
src/app/dev/admin/investasi/detail/transaksi/[id]/page.tsx
Normal file
14
src/app/dev/admin/investasi/detail/transaksi/[id]/page.tsx
Normal file
@@ -0,0 +1,14 @@
|
||||
import DetailTransaksi from '@/app_modules/admin/investasi/_view/detail/view_detail_transaksi';
|
||||
import React from 'react';
|
||||
|
||||
|
||||
function Page() {
|
||||
|
||||
return (
|
||||
<>
|
||||
<DetailTransaksi />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export default Page;
|
||||
@@ -147,7 +147,7 @@ function TampilanListDonatur({ setReloadDonasi, donasi, isReload }: { setReloadD
|
||||
</td>
|
||||
<td>
|
||||
<Center >
|
||||
<Badge c={AccentColor.white} w={150} variant="dot">
|
||||
<Badge c={AccentColor.white} variant="dot">
|
||||
{e?.DonasiMaster_StatusInvoice?.name}
|
||||
</Badge>
|
||||
</Center>
|
||||
@@ -251,7 +251,7 @@ function TampilanListDonatur({ setReloadDonasi, donasi, isReload }: { setReloadD
|
||||
verticalSpacing={"xl"}
|
||||
horizontalSpacing={"md"}
|
||||
p={"md"}
|
||||
w={1500}
|
||||
w={1120}
|
||||
>
|
||||
<thead>
|
||||
<tr>
|
||||
|
||||
@@ -36,7 +36,7 @@ function TampilanListPencairan({
|
||||
<Text>{e.title}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td width={500}>
|
||||
<td>
|
||||
<Box w={"100%"}>
|
||||
<Spoiler c={AdminColor.white} hideLabel="Sembunyikan" maxHeight={70} showLabel="Lihat">
|
||||
{e.deskripsi}
|
||||
@@ -106,7 +106,7 @@ function TampilanListPencairan({
|
||||
verticalSpacing={"xl"}
|
||||
horizontalSpacing={"md"}
|
||||
p={"md"}
|
||||
w={1500}
|
||||
w={1100}
|
||||
|
||||
>
|
||||
<thead>
|
||||
|
||||
@@ -183,7 +183,7 @@ function TableStatus() {
|
||||
verticalSpacing={"md"}
|
||||
horizontalSpacing={"md"}
|
||||
p={"md"}
|
||||
w={1500}
|
||||
w={1120}
|
||||
|
||||
>
|
||||
<thead>
|
||||
|
||||
@@ -185,7 +185,7 @@ function TableStatus() {
|
||||
verticalSpacing={"md"}
|
||||
horizontalSpacing={"md"}
|
||||
p={"md"}
|
||||
w={1500}
|
||||
w={1125}
|
||||
|
||||
>
|
||||
<thead>
|
||||
|
||||
@@ -221,7 +221,7 @@ function TableStatus() {
|
||||
verticalSpacing={"md"}
|
||||
horizontalSpacing={"md"}
|
||||
p={"md"}
|
||||
w={1500}
|
||||
w={1120}
|
||||
h={"100%"}
|
||||
|
||||
>
|
||||
|
||||
510
src/app_modules/admin/event/_view/view_table_review.txt
Normal file
510
src/app_modules/admin/event/_view/view_table_review.txt
Normal file
@@ -0,0 +1,510 @@
|
||||
import { apiGetDataEventByStatus } from "@/app_modules/admin/event/_lib/api_fecth_admin_event";
|
||||
import {
|
||||
gs_adminEvent_triggerReview,
|
||||
IRealtimeData,
|
||||
} from "@/lib/global_state";
|
||||
import { AccentColor } from "@/app_modules/_global/color";
|
||||
import {
|
||||
ComponentGlobal_NotifikasiBerhasil,
|
||||
ComponentGlobal_NotifikasiGagal,
|
||||
ComponentGlobal_NotifikasiPeringatan,
|
||||
} from "@/app_modules/_global/notif_global";
|
||||
import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
|
||||
import { MODEL_EVENT } from "@/app_modules/event/_lib/interface";
|
||||
import { event_checkStatus } from "@/app_modules/event/fun/get/fun_check_status_by_id";
|
||||
import { clientLogger } from "@/util/clientLogger";
|
||||
import {
|
||||
Affix,
|
||||
Box,
|
||||
Button,
|
||||
Center,
|
||||
Group,
|
||||
Modal,
|
||||
Pagination,
|
||||
Paper,
|
||||
rem,
|
||||
ScrollArea,
|
||||
Spoiler,
|
||||
Stack,
|
||||
Table,
|
||||
Text,
|
||||
Textarea,
|
||||
TextInput,
|
||||
} from "@mantine/core";
|
||||
import { useDisclosure, useShallowEffect } from "@mantine/hooks";
|
||||
import {
|
||||
IconBan,
|
||||
IconCircleCheck,
|
||||
IconEyeCheck,
|
||||
IconRefresh,
|
||||
IconSearch,
|
||||
} from "@tabler/icons-react";
|
||||
import { useAtom } from "jotai";
|
||||
import moment from "moment";
|
||||
import { useState } from "react";
|
||||
import { WibuRealtime } from "wibu-pkg";
|
||||
import { ComponentAdminGlobal_TitlePage } from "../../_admin_global/_component";
|
||||
import { ComponentAdminGlobal_NotifikasiBerhasil } from "../../_admin_global/admin_notifikasi/notifikasi_berhasil";
|
||||
import { ComponentAdminGlobal_NotifikasiGagal } from "../../_admin_global/admin_notifikasi/notifikasi_gagal";
|
||||
import { ComponentAdminGlobal_NotifikasiPeringatan } from "../../_admin_global/admin_notifikasi/notifikasi_peringatan";
|
||||
import adminNotifikasi_funCreateToUser from "../../notifikasi/fun/create/fun_create_notif_user";
|
||||
import { adminEvent_funGetListReview } from "../fun";
|
||||
import { AdminEvent_funEditStatusPublishById } from "../fun/edit/fun_edit_status_publish_by_id";
|
||||
import { AdminEvent_funEditCatatanById } from "../fun/edit/fun_edit_status_reject_by_id";
|
||||
import { AdminColor } from "@/app_modules/_global/color/color_pallet";
|
||||
|
||||
export default function AdminEvent_ComponentTableReview() {
|
||||
const [data, setData] = useState<MODEL_EVENT[] | null>(null);
|
||||
const [isNPage, setNPage] = useState<number>(1);
|
||||
const [activePage, setActivePage] = useState(1);
|
||||
const [isSearch, setSearch] = useState("");
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const [isModal, setModal] = useState(false);
|
||||
const [opened, { open, close }] = useDisclosure(false);
|
||||
const [catatan, setCatatan] = useState("");
|
||||
const [eventId, setEventId] = useState("");
|
||||
|
||||
// Realtime state
|
||||
const [isAdminTriggerReview, setIsAdminTriggerReview] = useAtom(
|
||||
gs_adminEvent_triggerReview
|
||||
);
|
||||
const [isShowReload, setIsShowReload] = useState(false);
|
||||
|
||||
useShallowEffect(() => {
|
||||
loadInitialData();
|
||||
}, [activePage, isSearch]);
|
||||
|
||||
const loadInitialData = async () => {
|
||||
try {
|
||||
const response = await apiGetDataEventByStatus({
|
||||
name: "Review",
|
||||
page: `${activePage}`,
|
||||
search: isSearch,
|
||||
});
|
||||
|
||||
if (response?.success && response?.data?.data) {
|
||||
setData(response.data.data);
|
||||
setNPage(response.data.nPage || 1);
|
||||
} else {
|
||||
console.error("Invalid data format received:", response);
|
||||
setData([]);
|
||||
}
|
||||
} catch (error) {
|
||||
clientLogger.error("Error get data table publish", error);
|
||||
setData([]);
|
||||
}
|
||||
};
|
||||
|
||||
const onSearch = async (searchTerm: string) => {
|
||||
setSearch(searchTerm);
|
||||
setActivePage(1);
|
||||
};
|
||||
|
||||
const onPageClick = (page: number) => {
|
||||
setActivePage(page);
|
||||
};
|
||||
|
||||
async function onLoadData() {
|
||||
loadInitialData();
|
||||
setIsLoading(false);
|
||||
setIsShowReload(false);
|
||||
setIsAdminTriggerReview(false);
|
||||
}
|
||||
|
||||
async function onPublish({
|
||||
eventId,
|
||||
tanggal,
|
||||
}: {
|
||||
eventId: string;
|
||||
tanggal: Date;
|
||||
}) {
|
||||
const checkStatus = await event_checkStatus({ id: eventId });
|
||||
|
||||
if (checkStatus) {
|
||||
if (moment(tanggal).diff(Date.now(), "minutes") < 0)
|
||||
return ComponentGlobal_NotifikasiPeringatan(
|
||||
"Waktu acara telah lewat, Report untuk memberitahu user !"
|
||||
);
|
||||
|
||||
const res = await AdminEvent_funEditStatusPublishById(eventId, "1");
|
||||
if (res.status === 200) {
|
||||
setIsLoading(true);
|
||||
const dataNotifikasi: IRealtimeData = {
|
||||
appId: res.data?.id as any,
|
||||
status: res.data?.EventMaster_Status?.name as any,
|
||||
userId: res.data?.authorId as any,
|
||||
pesan: res.data?.title as any,
|
||||
kategoriApp: "EVENT",
|
||||
title: "Event publish",
|
||||
};
|
||||
|
||||
const notif = await adminNotifikasi_funCreateToUser({
|
||||
data: dataNotifikasi as any,
|
||||
});
|
||||
|
||||
if (notif.status === 201) {
|
||||
WibuRealtime.setData({
|
||||
type: "notification",
|
||||
pushNotificationTo: "USER",
|
||||
dataMessage: dataNotifikasi,
|
||||
});
|
||||
|
||||
WibuRealtime.setData({
|
||||
type: "trigger",
|
||||
pushNotificationTo: "USER",
|
||||
dataMessage: dataNotifikasi,
|
||||
});
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await apiGetDataEventByStatus({
|
||||
name: "Review",
|
||||
page: `${activePage}`,
|
||||
search: isSearch,
|
||||
});
|
||||
|
||||
if (response?.success && response?.data?.data) {
|
||||
|
||||
setData(response.data.data);
|
||||
setNPage(response.data.nPage || 1);
|
||||
} else {
|
||||
|
||||
setData([]);
|
||||
}
|
||||
} catch (error) {
|
||||
clientLogger.error("Error get data table publish", error);
|
||||
setData([]);
|
||||
}
|
||||
|
||||
ComponentAdminGlobal_NotifikasiBerhasil("Berhasil update status");
|
||||
} else {
|
||||
setModal(false);
|
||||
setIsLoading(false);
|
||||
ComponentAdminGlobal_NotifikasiGagal(res.message);
|
||||
}
|
||||
} else {
|
||||
setModal(false);
|
||||
ComponentAdminGlobal_NotifikasiPeringatan(
|
||||
"Review di batalkan oleh user, reload halaman review !"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
async function onReject(eventId: string, catatan: string) {
|
||||
if (catatan === "")
|
||||
return ComponentGlobal_NotifikasiPeringatan("Lengkapi Catatan");
|
||||
const body = {
|
||||
id: eventId,
|
||||
catatan: catatan,
|
||||
};
|
||||
|
||||
const res = await AdminEvent_funEditCatatanById(body as any, "4");
|
||||
if (res.status === 200) {
|
||||
const dataNotifikasi: IRealtimeData = {
|
||||
appId: res.data?.id as any,
|
||||
status: res.data?.EventMaster_Status?.name as any,
|
||||
userId: res.data?.authorId as any,
|
||||
pesan: res.data?.title as any,
|
||||
kategoriApp: "EVENT",
|
||||
title: "Event reject",
|
||||
};
|
||||
|
||||
const notif = await adminNotifikasi_funCreateToUser({
|
||||
data: dataNotifikasi as any,
|
||||
});
|
||||
|
||||
if (notif.status === 201) {
|
||||
WibuRealtime.setData({
|
||||
type: "notification",
|
||||
pushNotificationTo: "USER",
|
||||
dataMessage: dataNotifikasi,
|
||||
});
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await apiGetDataEventByStatus({
|
||||
name: "Review",
|
||||
page: `${activePage}`,
|
||||
search: isSearch,
|
||||
});
|
||||
|
||||
if (response?.success && response?.data?.data) {
|
||||
|
||||
setData(response.data.data);
|
||||
setNPage(response.data.nPage || 1);
|
||||
} else {
|
||||
console.error("Invalid data format received:", response);
|
||||
setData([]);
|
||||
}
|
||||
} catch (error) {
|
||||
clientLogger.error("Error get data table publish", error);
|
||||
setData([]);
|
||||
}
|
||||
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||
close();
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
}
|
||||
}
|
||||
|
||||
const renderTableBody = () => {
|
||||
if (!Array.isArray(data) || data.length === 0) {
|
||||
return (
|
||||
<tr>
|
||||
<td colSpan={12}>
|
||||
<Center>
|
||||
<Text color={"gray"}>Tidak ada data</Text>
|
||||
</Center>
|
||||
</td>
|
||||
</tr>
|
||||
);
|
||||
}
|
||||
|
||||
return data.map((e, i) => (
|
||||
<tr key={i}>
|
||||
<td>
|
||||
<Center c={AdminColor.white} >
|
||||
<Text>{e?.Author?.username}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center c={AdminColor.white} >
|
||||
<Text lineClamp={2}>{e.title}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center c={AdminColor.white} >
|
||||
<Text>{e.lokasi}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
|
||||
|
||||
<td>
|
||||
<Center c={AdminColor.white} >
|
||||
<Stack style={{ gap: "3px"}}>
|
||||
<Box>
|
||||
<Text align="center">
|
||||
{new Intl.DateTimeFormat("id-ID", {
|
||||
dateStyle: "full",
|
||||
}).format(new Date(e?.tanggal))}
|
||||
,{" "}
|
||||
<Text span inherit>
|
||||
{new Intl.DateTimeFormat("id-ID", {
|
||||
timeStyle: "short",
|
||||
}).format(new Date(e?.tanggal))}
|
||||
</Text>
|
||||
</Text>
|
||||
</Box>
|
||||
<Text ta="center">-</Text>
|
||||
<Box>
|
||||
<Text align="center">
|
||||
{new Intl.DateTimeFormat("id-ID", {
|
||||
dateStyle: "full",
|
||||
}).format(new Date(e?.tanggalSelesai))}
|
||||
,{" "}
|
||||
<Text span inherit>
|
||||
{new Intl.DateTimeFormat("id-ID", {
|
||||
timeStyle: "short",
|
||||
}).format(new Date(e?.tanggalSelesai))}
|
||||
</Text>
|
||||
</Text>
|
||||
</Box>
|
||||
</Stack>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center>
|
||||
<Stack>
|
||||
<Button
|
||||
color={"green"}
|
||||
leftIcon={<IconEyeCheck />}
|
||||
radius={"xl"}
|
||||
// onClick={() =>
|
||||
// onPublish({
|
||||
// eventId: e.id,
|
||||
// tanggal: e.tanggal,
|
||||
// })
|
||||
// }
|
||||
>
|
||||
Detail
|
||||
</Button>
|
||||
{/* <Button
|
||||
color={"red"}
|
||||
leftIcon={<IconBan />}
|
||||
radius={"xl"}
|
||||
onClick={async () => {
|
||||
const checkStatus = await event_checkStatus({ id: e.id });
|
||||
|
||||
if (checkStatus) {
|
||||
open();
|
||||
setEventId(e.id);
|
||||
} else {
|
||||
ComponentAdminGlobal_NotifikasiPeringatan(
|
||||
"Review di batalkan oleh user, muat kembali halaman ini !"
|
||||
);
|
||||
}
|
||||
}}
|
||||
>
|
||||
Reject
|
||||
</Button> */}
|
||||
</Stack>
|
||||
</Center>
|
||||
</td>
|
||||
</tr>
|
||||
));
|
||||
};
|
||||
|
||||
|
||||
return (
|
||||
<>
|
||||
<Stack spacing={"xs"} h={"100%"}>
|
||||
<ComponentAdminGlobal_TitlePage
|
||||
name="Review"
|
||||
color={AdminColor.softBlue}
|
||||
component={
|
||||
<TextInput
|
||||
disabled={!data}
|
||||
icon={<IconSearch size={20} />}
|
||||
radius={"xl"}
|
||||
placeholder="Masukan judul"
|
||||
onChange={(val) => {
|
||||
onSearch(val.currentTarget.value);
|
||||
}}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
|
||||
|
||||
|
||||
{!data ? (
|
||||
<CustomSkeleton height={"80vh"} width="100%" />
|
||||
) : (
|
||||
<Paper p={"md"} bg={AdminColor.softBlue} h={"80vh"}>
|
||||
{isShowReload && (
|
||||
<Affix position={{ top: rem(200) }} w={"100%"}>
|
||||
<Center>
|
||||
<Button
|
||||
style={{
|
||||
transition: "0.5s",
|
||||
border: `1px solid ${AccentColor.skyblue}`,
|
||||
}}
|
||||
bg={AccentColor.blue}
|
||||
loaderPosition="center"
|
||||
loading={isLoading}
|
||||
radius={"xl"}
|
||||
opacity={0.8}
|
||||
onClick={() => onLoadData()}
|
||||
leftIcon={<IconRefresh />}
|
||||
>
|
||||
Update Data
|
||||
</Button>
|
||||
</Center>
|
||||
</Affix>
|
||||
)}
|
||||
|
||||
<ScrollArea w={"100%"} h={"90%"}>
|
||||
<Table
|
||||
verticalSpacing={"md"}
|
||||
horizontalSpacing={"md"}
|
||||
p={"md"}
|
||||
w={1120}
|
||||
>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Username</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Judul</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Lokasi</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Tanggal & Waktu Mulai - Selesai</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Aksi</Center>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>{renderTableBody()}</tbody>
|
||||
</Table>
|
||||
</ScrollArea>
|
||||
|
||||
<Center mt={"xl"}>
|
||||
<Pagination
|
||||
value={activePage}
|
||||
total={isNPage}
|
||||
onChange={(val) => {
|
||||
onPageClick(val);
|
||||
}}
|
||||
/>
|
||||
</Center>
|
||||
</Paper>
|
||||
)}
|
||||
</Stack>
|
||||
|
||||
<Modal
|
||||
opened={opened}
|
||||
onClose={close}
|
||||
centered
|
||||
withCloseButton={false}
|
||||
size={"md"}
|
||||
>
|
||||
<Stack>
|
||||
<Textarea
|
||||
minRows={2}
|
||||
maxRows={5}
|
||||
maxLength={300}
|
||||
autosize
|
||||
label="Masukan Alasan Penolakan"
|
||||
placeholder="Contoh: Karena deskripsi kurang lengkap, dll"
|
||||
onChange={(val) => {
|
||||
setCatatan(val.target.value);
|
||||
}}
|
||||
/>
|
||||
<Group position="right">
|
||||
<Button radius={"xl"} onClick={close}>
|
||||
Batal
|
||||
</Button>
|
||||
<Button
|
||||
radius={"xl"}
|
||||
onClick={() => {
|
||||
onReject(eventId, catatan);
|
||||
}}
|
||||
>
|
||||
Simpan
|
||||
</Button>
|
||||
</Group>
|
||||
</Stack>
|
||||
</Modal>
|
||||
|
||||
{/* <Modal
|
||||
opened={isModal}
|
||||
title="Anda Yakin Ingin Mempublish Event Ini?"
|
||||
onClose={() => setModal(false)}
|
||||
centered
|
||||
withCloseButton={false}
|
||||
size={"md"}
|
||||
>
|
||||
<Stack>
|
||||
<Group position="right">
|
||||
<Button radius={"xl"} onClick={close}>
|
||||
Batal
|
||||
</Button>
|
||||
<Button
|
||||
radius={"xl"}
|
||||
// onClick={() => {
|
||||
// onPublish(eventId, tanggal);
|
||||
// }}
|
||||
>
|
||||
Simpan
|
||||
</Button>
|
||||
</Group>
|
||||
</Stack>
|
||||
</Modal> */}
|
||||
</>
|
||||
);
|
||||
}
|
||||
306
src/app_modules/admin/event/table_status/table_reject.txt
Normal file
306
src/app_modules/admin/event/table_status/table_reject.txt
Normal file
@@ -0,0 +1,306 @@
|
||||
"use client";
|
||||
|
||||
import {
|
||||
Box,
|
||||
Button,
|
||||
Center,
|
||||
Group,
|
||||
Modal,
|
||||
Pagination,
|
||||
Paper,
|
||||
ScrollArea,
|
||||
Spoiler,
|
||||
Stack,
|
||||
Table,
|
||||
Text,
|
||||
Textarea,
|
||||
TextInput,
|
||||
Title,
|
||||
} from "@mantine/core";
|
||||
import { IconEyeCheck, IconPencilPlus, IconSearch } from "@tabler/icons-react";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useDisclosure, useShallowEffect } from "@mantine/hooks";
|
||||
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
|
||||
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal";
|
||||
import { MODEL_EVENT } from "@/app_modules/event/_lib/interface";
|
||||
import { useState } from "react";
|
||||
import ComponentAdminGlobal_HeaderTamplate from "../../_admin_global/header_tamplate";
|
||||
import { adminEvent_funGetListReject } from "../fun";
|
||||
import { AdminEvent_funEditCatatanById } from "../fun/edit/fun_edit_status_reject_by_id";
|
||||
import { ComponentAdminGlobal_TitlePage } from "../../_admin_global/_component";
|
||||
import { MainColor } from "@/app_modules/_global/color";
|
||||
import { AdminColor } from "@/app_modules/_global/color/color_pallet";
|
||||
import { apiGetDataEventByStatus } from "@/app_modules/admin/event/_lib/api_fecth_admin_event";
|
||||
import { clientLogger } from "@/util/clientLogger";
|
||||
import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
|
||||
|
||||
export default function AdminEvent_TableReject() {
|
||||
return (
|
||||
<>
|
||||
<Stack>
|
||||
<ComponentAdminGlobal_HeaderTamplate name="Event" />
|
||||
<TableStatus />
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function TableStatus() {
|
||||
const router = useRouter();
|
||||
const [data, setData] = useState<MODEL_EVENT[] | null>(null);
|
||||
const [isNPage, setNPage] = useState<number>(1);
|
||||
const [activePage, setActivePage] = useState(1);
|
||||
const [isSearch, setSearch] = useState("");
|
||||
|
||||
const [opened, { open, close }] = useDisclosure(false);
|
||||
const [eventId, setEventId] = useState("");
|
||||
const [catatan, setCatatan] = useState("");
|
||||
|
||||
useShallowEffect(() => {
|
||||
const loadInitialData = async () => {
|
||||
try {
|
||||
const response = await apiGetDataEventByStatus({
|
||||
name: "Reject",
|
||||
page: `${activePage}`,
|
||||
search: isSearch,
|
||||
});
|
||||
|
||||
if (response?.success && response?.data?.data) {
|
||||
setData(response.data.data);
|
||||
setNPage(response.data.nPage || 1);
|
||||
} else {
|
||||
console.error("Invalid data format received:", response);
|
||||
setData([]);
|
||||
}
|
||||
} catch (error) {
|
||||
clientLogger.error("Error get data table publish", error);
|
||||
setData([]);
|
||||
}
|
||||
};
|
||||
|
||||
loadInitialData();
|
||||
}, [activePage, isSearch]);
|
||||
|
||||
const onSearch = async (searchTerm: string) => {
|
||||
setSearch(searchTerm);
|
||||
setActivePage(1);
|
||||
};
|
||||
|
||||
const onPageClick = (page: number) => {
|
||||
setActivePage(page);
|
||||
};
|
||||
|
||||
async function onUpdate(eventId: string, catatan: string) {
|
||||
const body = {
|
||||
id: eventId,
|
||||
catatan: catatan,
|
||||
};
|
||||
const res = await AdminEvent_funEditCatatanById(body as any, "4");
|
||||
if (res.status === 200) {
|
||||
try {
|
||||
const response = await apiGetDataEventByStatus({
|
||||
name: "Reject",
|
||||
page: `${activePage}`,
|
||||
search: isSearch,
|
||||
});
|
||||
|
||||
if (response?.success && response?.data?.data) {
|
||||
setData(response.data.data);
|
||||
setNPage(response.data.nPage || 1);
|
||||
} else {
|
||||
console.error("Invalid data format received:", response);
|
||||
setData([]);
|
||||
}
|
||||
} catch (error) {
|
||||
clientLogger.error("Error get data table publish", error);
|
||||
setData([]);
|
||||
}
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||
close();
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
}
|
||||
}
|
||||
|
||||
const renderTableBody = () => {
|
||||
if (!Array.isArray(data) || data.length === 0) {
|
||||
return (
|
||||
<tr>
|
||||
<td colSpan={12}>
|
||||
<Center>
|
||||
<Text color={"gray"}>Tidak ada data</Text>
|
||||
</Center>
|
||||
</td>
|
||||
</tr>
|
||||
);
|
||||
}
|
||||
|
||||
return data.map((e, i) => (
|
||||
<tr key={i}>
|
||||
<td>
|
||||
<Center c={AdminColor.white}>{e?.Author?.username}</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center c={AdminColor.white} >{e.title}</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center c={AdminColor.white}>{e.lokasi}</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Stack style={{ gap: "3px" }}>
|
||||
<Box>
|
||||
<Center c={AdminColor.white} >
|
||||
<Text align="center">
|
||||
{new Intl.DateTimeFormat("id-ID", {
|
||||
dateStyle: "full",
|
||||
}).format(new Date(e?.tanggal))}
|
||||
,{" "}
|
||||
<Text span inherit>
|
||||
{new Intl.DateTimeFormat("id-ID", {
|
||||
timeStyle: "short",
|
||||
}).format(new Date(e?.tanggal))}
|
||||
</Text>
|
||||
</Text>
|
||||
</Center>
|
||||
</Box>
|
||||
<Text ta={"center"} c={AdminColor.white}>-</Text>
|
||||
<Box>
|
||||
<Center c={AdminColor.white}>
|
||||
<Text align="center">
|
||||
{new Intl.DateTimeFormat("id-ID", {
|
||||
dateStyle: "full",
|
||||
}).format(new Date(e?.tanggalSelesai))}
|
||||
,{" "}
|
||||
<Text span inherit>
|
||||
{new Intl.DateTimeFormat("id-ID", {
|
||||
timeStyle: "short",
|
||||
}).format(new Date(e?.tanggalSelesai))}
|
||||
</Text>
|
||||
</Text>
|
||||
</Center>
|
||||
</Box>
|
||||
</Stack>
|
||||
</td>
|
||||
<td>
|
||||
<Center>
|
||||
<Button
|
||||
w={130}
|
||||
color={"green"}
|
||||
leftIcon={<IconEyeCheck size={20} />}
|
||||
radius={"xl"}
|
||||
onClick={() => {
|
||||
setEventId(e.id);
|
||||
setCatatan(e.catatan);
|
||||
open();
|
||||
}}
|
||||
>
|
||||
Detail
|
||||
</Button>
|
||||
</Center>
|
||||
</td>
|
||||
</tr>
|
||||
));
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<Stack spacing={"xs"} h={"100%"}>
|
||||
<ComponentAdminGlobal_TitlePage
|
||||
name="Reject"
|
||||
color={AdminColor.softBlue}
|
||||
component={
|
||||
<TextInput
|
||||
disabled={!data}
|
||||
icon={<IconSearch size={20} />}
|
||||
radius={"xl"}
|
||||
placeholder="Masukan judul"
|
||||
onChange={(val) => {
|
||||
onSearch(val.currentTarget.value);
|
||||
}}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
|
||||
{!data ? (
|
||||
<CustomSkeleton height={"80vh"} width="100%" />
|
||||
) : (
|
||||
<Paper p={"md"} bg={AdminColor.softBlue} h={"80vh"}>
|
||||
<ScrollArea w={"100%"} h={"90%"}>
|
||||
<Table
|
||||
verticalSpacing={"md"}
|
||||
horizontalSpacing={"md"}
|
||||
p={"md"}
|
||||
w={1100}
|
||||
|
||||
>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Username</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Judul</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Lokasi</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Tanggal & Waktu Mulai - Selesai</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Aksi</Center>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>{renderTableBody()}</tbody>
|
||||
</Table>
|
||||
</ScrollArea>
|
||||
|
||||
<Center mt={"xl"}>
|
||||
<Pagination
|
||||
value={activePage}
|
||||
total={isNPage}
|
||||
onChange={(val) => {
|
||||
onPageClick(val);
|
||||
}}
|
||||
/>
|
||||
</Center>
|
||||
</Paper>
|
||||
)}
|
||||
</Stack>
|
||||
|
||||
<Modal
|
||||
opened={opened}
|
||||
onClose={close}
|
||||
centered
|
||||
withCloseButton={false}
|
||||
size={"md"}
|
||||
>
|
||||
<Stack>
|
||||
<Textarea
|
||||
minRows={2}
|
||||
maxRows={5}
|
||||
maxLength={300}
|
||||
value={catatan}
|
||||
autosize
|
||||
label="Masukan Alasan Penolakan"
|
||||
placeholder="Contoh: Karena deskripsi kurang lengkap, dll"
|
||||
onChange={(val) => {
|
||||
setCatatan(val.target.value);
|
||||
}}
|
||||
/>
|
||||
<Group position="right">
|
||||
<Button
|
||||
radius={"xl"}
|
||||
onClick={() => {
|
||||
onUpdate(eventId, catatan);
|
||||
}}
|
||||
>
|
||||
Simpan
|
||||
</Button>
|
||||
</Group>
|
||||
</Stack>
|
||||
</Modal>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -6,6 +6,9 @@ export {
|
||||
apiGetAdminInvestasiById,
|
||||
apiGetAdminAllTransaksiById,
|
||||
apiGetAdminStatusTransaksi,
|
||||
apiGetAdminDetailTransaksi
|
||||
|
||||
|
||||
};
|
||||
const apiGetAdminInvestasiCountDashboard = async ({
|
||||
name,
|
||||
@@ -58,6 +61,24 @@ const apiGetAdminInvestasiByStatus = async ({
|
||||
return await response.json().catch(() => null);
|
||||
};
|
||||
|
||||
const apiGetAdminDetailTransaksi = async ({ id }: { id: string }) => {
|
||||
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
|
||||
if (!token) return await token.json().catch(() => null);
|
||||
|
||||
const response = await fetch(`/api/admin/investasi/${id}/detail_transaksi`, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Accept: "application/json",
|
||||
"Access-Control-Allow-Origin": "*",
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
});
|
||||
console.log("Ini response",response.json())
|
||||
|
||||
return await response.json().catch(() => null);
|
||||
}
|
||||
|
||||
const apiGetAdminInvestasiById = async ({ id }: { id: string }) => {
|
||||
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
|
||||
if (!token) return await token.json().catch(() => null);
|
||||
@@ -94,7 +115,7 @@ const apiGetAdminAllTransaksiById = async ({
|
||||
|
||||
// Fetch data
|
||||
const isStatus = status ? `&status=${status}` : "";
|
||||
console.log("Ini status",isStatus);
|
||||
console.log("Ini status", isStatus);
|
||||
const isPage = page ? `?page=${page}` : "";
|
||||
const response = await fetch(
|
||||
`/api/admin/investasi/${id}/transaksi${isPage}${isStatus}`,
|
||||
@@ -126,6 +147,7 @@ const apiGetAdminAllTransaksiById = async ({
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
const apiGetAdminStatusTransaksi = async () => {
|
||||
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
|
||||
if (!token) return await token.json().catch(() => null);
|
||||
@@ -142,3 +164,5 @@ const apiGetAdminStatusTransaksi = async () => {
|
||||
|
||||
return await response.json().catch(() => null);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ import { clientLogger } from "@/util/clientLogger";
|
||||
import {
|
||||
ActionIcon,
|
||||
Badge,
|
||||
Button,
|
||||
Center,
|
||||
Group,
|
||||
Pagination,
|
||||
@@ -25,8 +26,8 @@ import {
|
||||
Text,
|
||||
} from "@mantine/core";
|
||||
import { useShallowEffect } from "@mantine/hooks";
|
||||
import { IconReload } from "@tabler/icons-react";
|
||||
import { useParams } from "next/navigation";
|
||||
import { IconEyeCheck, IconReload } from "@tabler/icons-react";
|
||||
import { useParams, useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import {
|
||||
AdminInvestasi_ComponentButtonBandingTransaksi,
|
||||
@@ -34,6 +35,7 @@ import {
|
||||
AdminInvestasi_ComponentCekBuktiTransfer,
|
||||
} from "../../_component";
|
||||
import { apiGetAdminAllTransaksiById } from "../../_lib/api_fetch_admin_investasi";
|
||||
import { RouterAdminInvestasi } from "@/lib/router_admin/router_admin_investasi";
|
||||
|
||||
export function AdminInvestasi_ViewDaftarTransaksi() {
|
||||
const params = useParams<{ id: string }>();
|
||||
@@ -46,6 +48,9 @@ export function AdminInvestasi_ViewDaftarTransaksi() {
|
||||
const [isNPage, setNPage] = useState<number>(1);
|
||||
const [isActivePage, setActivePage] = useState(1);
|
||||
const [selectedStatus, setSelectedStatus] = useState("");
|
||||
const [isLoading, setLoading] = useState(false);
|
||||
const [idData, setIdData] = useState("");
|
||||
const router = useRouter();
|
||||
|
||||
useShallowEffect(() => {
|
||||
handleLoadData();
|
||||
@@ -123,21 +128,11 @@ export function AdminInvestasi_ViewDaftarTransaksi() {
|
||||
<td>
|
||||
<Center c={AdminColor.white}>{e?.Author?.username}</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center c={AdminColor.white}>{e?.MasterBank?.namaBank}</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center c={AdminColor.white}>
|
||||
<ComponentAdminGlobal_TampilanRupiah nominal={+e?.nominal} />
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center c={AdminColor.white}>
|
||||
{new Intl.NumberFormat("id-ID", {
|
||||
maximumFractionDigits: 10,
|
||||
}).format(+e?.lembarTerbeli)}
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center c={AdminColor.white}>
|
||||
{new Intl.DateTimeFormat("id-ID", { dateStyle: "full" }).format(
|
||||
@@ -173,7 +168,7 @@ export function AdminInvestasi_ViewDaftarTransaksi() {
|
||||
</td>
|
||||
<td>
|
||||
<Center>
|
||||
{e.statusInvoiceId === "1" && "-"}
|
||||
{/* {e.statusInvoiceId === "1" && "-"}
|
||||
{e.statusInvoiceId === "2" && (
|
||||
<AdminInvestasi_ComponentButtonKonfirmasiTransaksi
|
||||
invoiceId={e.id}
|
||||
@@ -196,7 +191,21 @@ export function AdminInvestasi_ViewDaftarTransaksi() {
|
||||
setNPage(val.nPage);
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
)} */}
|
||||
<Button
|
||||
loading={isLoading && idData == e.id}
|
||||
loaderPosition="center"
|
||||
color="green"
|
||||
leftIcon={<IconEyeCheck size={20} />}
|
||||
radius={"xl"}
|
||||
onClick={() => {
|
||||
setIdData(e.id);
|
||||
setLoading(true);
|
||||
router.push(RouterAdminInvestasi.detail_transaksi + e.id);
|
||||
}}
|
||||
>
|
||||
Detail
|
||||
</Button>
|
||||
</Center>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -249,22 +258,16 @@ export function AdminInvestasi_ViewDaftarTransaksi() {
|
||||
verticalSpacing={"xl"}
|
||||
horizontalSpacing={"md"}
|
||||
p={"md"}
|
||||
w={1500}
|
||||
w={1100}
|
||||
>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Nama Investor</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Nama Bank</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Jumlah Investasi</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Lembar Terbeli</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Tanggal</Center>
|
||||
</th>
|
||||
|
||||
@@ -0,0 +1,301 @@
|
||||
import { AdminColor } from "@/app_modules/_global/color/color_pallet";
|
||||
import { apiGetMasterStatusTransaksi } from "@/app_modules/_global/lib/api_fetch_master";
|
||||
import { globalStatusTransaksi } from "@/app_modules/_global/lib/master_list_app";
|
||||
import {
|
||||
ComponentAdminGlobal_TampilanRupiah,
|
||||
ComponentAdminGlobal_TitlePage,
|
||||
} from "@/app_modules/admin/_admin_global/_component";
|
||||
import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
|
||||
import {
|
||||
MODEL_INVOICE_INVESTASI,
|
||||
MODEL_STATUS_INVOICE_INVESTASI,
|
||||
} from "@/app_modules/investasi/_lib/interface";
|
||||
import { clientLogger } from "@/util/clientLogger";
|
||||
import {
|
||||
ActionIcon,
|
||||
Badge,
|
||||
Button,
|
||||
Center,
|
||||
Group,
|
||||
Pagination,
|
||||
Paper,
|
||||
ScrollArea,
|
||||
Select,
|
||||
Stack,
|
||||
Table,
|
||||
Text,
|
||||
} from "@mantine/core";
|
||||
import { useShallowEffect } from "@mantine/hooks";
|
||||
import { IconEyeCheck, IconReload } from "@tabler/icons-react";
|
||||
import { useParams } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import {
|
||||
AdminInvestasi_ComponentButtonBandingTransaksi,
|
||||
AdminInvestasi_ComponentButtonKonfirmasiTransaksi,
|
||||
AdminInvestasi_ComponentCekBuktiTransfer,
|
||||
} from "../../_component";
|
||||
import { apiGetAdminAllTransaksiById } from "../../_lib/api_fetch_admin_investasi";
|
||||
|
||||
export function AdminInvestasi_ViewDaftarTransaksi() {
|
||||
const params = useParams<{ id: string }>();
|
||||
const investasiId = params.id;
|
||||
const [listStatus, setListStatus] = useState<
|
||||
MODEL_STATUS_INVOICE_INVESTASI[] | null
|
||||
>(null);
|
||||
|
||||
const [data, setData] = useState<MODEL_INVOICE_INVESTASI[] | null>(null);
|
||||
const [isNPage, setNPage] = useState<number>(1);
|
||||
const [isActivePage, setActivePage] = useState(1);
|
||||
const [selectedStatus, setSelectedStatus] = useState("");
|
||||
const [isLoading, setLoading] = useState(false);
|
||||
const [idData, setIdData] = useState("");
|
||||
|
||||
useShallowEffect(() => {
|
||||
handleLoadData();
|
||||
}, [isActivePage, selectedStatus]);
|
||||
|
||||
useShallowEffect(() => {
|
||||
handleLoadStatus();
|
||||
}, []);
|
||||
|
||||
const handleLoadData = async () => {
|
||||
try {
|
||||
const cek = globalStatusTransaksi.find((e) => e.id === selectedStatus);
|
||||
const response = await apiGetAdminAllTransaksiById({
|
||||
id: investasiId,
|
||||
page: `${isActivePage}`,
|
||||
status: cek?.name,
|
||||
});
|
||||
|
||||
if (response?.success && response?.data?.data) {
|
||||
setData(response.data.data);
|
||||
setNPage(response.data.nPage || 1);
|
||||
} else {
|
||||
console.error("Invalid data format received:", response);
|
||||
setData([]);
|
||||
}
|
||||
} catch (error) {
|
||||
clientLogger.error("Error get data daftar tramnsaksi", error);
|
||||
setData([]);
|
||||
}
|
||||
};
|
||||
|
||||
const handleLoadStatus = async () => {
|
||||
try {
|
||||
const response = await apiGetMasterStatusTransaksi();
|
||||
|
||||
if (response?.success && response?.data) {
|
||||
setListStatus(response.data);
|
||||
} else {
|
||||
console.error("Invalid data format received:", response);
|
||||
setListStatus(null);
|
||||
}
|
||||
} catch (error) {
|
||||
clientLogger.error("Error get status transaksi", error);
|
||||
setListStatus(null);
|
||||
}
|
||||
};
|
||||
|
||||
const onPageClick = async (page: number) => {
|
||||
setActivePage(page);
|
||||
};
|
||||
|
||||
async function onSelected(selectStatus: any) {
|
||||
setSelectedStatus(selectStatus);
|
||||
}
|
||||
|
||||
async function onReload() {
|
||||
setSelectedStatus("");
|
||||
handleLoadData();
|
||||
}
|
||||
|
||||
const renderTableBody = () => {
|
||||
if (!Array.isArray(data) || data.length === 0) {
|
||||
return (
|
||||
<tr>
|
||||
<td colSpan={12}>
|
||||
<Center>
|
||||
<Text color="gray">Tidak ada data</Text>
|
||||
</Center>
|
||||
</td>
|
||||
</tr>
|
||||
);
|
||||
}
|
||||
return data?.map((e, i) => (
|
||||
<tr key={i}>
|
||||
<td>
|
||||
<Center c={AdminColor.white}>{e?.Author?.username}</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center c={AdminColor.white}>
|
||||
<ComponentAdminGlobal_TampilanRupiah nominal={+e?.nominal} />
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center c={AdminColor.white}>
|
||||
{new Intl.DateTimeFormat("id-ID", { dateStyle: "full" }).format(
|
||||
new Date(e?.createdAt)
|
||||
)}
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center>
|
||||
<Badge
|
||||
w={150}
|
||||
variant="light"
|
||||
color={
|
||||
e.statusInvoiceId === "1"
|
||||
? "green"
|
||||
: e.statusInvoiceId === "4"
|
||||
? "red"
|
||||
: "blue"
|
||||
}
|
||||
>
|
||||
{e?.StatusInvoice?.name}
|
||||
</Badge>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center>
|
||||
{e?.statusInvoiceId !== "3" ? (
|
||||
<AdminInvestasi_ComponentCekBuktiTransfer imageId={e?.imageId} />
|
||||
) : (
|
||||
"-"
|
||||
)}
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center>
|
||||
{/* {e.statusInvoiceId === "1" && "-"}
|
||||
{e.statusInvoiceId === "2" && (
|
||||
<AdminInvestasi_ComponentButtonKonfirmasiTransaksi
|
||||
invoiceId={e.id}
|
||||
investasiId={investasiId}
|
||||
lembarTerbeli={e.lembarTerbeli}
|
||||
onLoadData={(val) => {
|
||||
setData(val.data);
|
||||
setNPage(val.nPage);
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
{e.statusInvoiceId === "3" && "-"}
|
||||
{e.statusInvoiceId === "4" && (
|
||||
<AdminInvestasi_ComponentButtonBandingTransaksi
|
||||
invoiceId={e.id}
|
||||
investasiId={investasiId}
|
||||
lembarTerbeli={e.lembarTerbeli}
|
||||
onLoadData={(val) => {
|
||||
setData(val.data);
|
||||
setNPage(val.nPage);
|
||||
}}
|
||||
/>
|
||||
)} */}
|
||||
<Button
|
||||
loading={isLoading && idData == e.id}
|
||||
loaderPosition="center"
|
||||
color="green"
|
||||
leftIcon={<IconEyeCheck size={20} />}
|
||||
radius={"xl"}
|
||||
onClick={() => {
|
||||
setIdData(e.id);
|
||||
setLoading(true);
|
||||
|
||||
}}
|
||||
>
|
||||
Detail
|
||||
</Button>
|
||||
</Center>
|
||||
</td>
|
||||
</tr>
|
||||
));
|
||||
};
|
||||
|
||||
if (!data && !listStatus) return <CustomSkeleton height={"80vh"} />;
|
||||
|
||||
return (
|
||||
<>
|
||||
<Stack spacing={"xs"} h={"100%"}>
|
||||
<ComponentAdminGlobal_TitlePage
|
||||
name="Transkasi"
|
||||
color={AdminColor.softBlue}
|
||||
component={
|
||||
<Group>
|
||||
<ActionIcon
|
||||
size={"lg"}
|
||||
radius={"xl"}
|
||||
variant="light"
|
||||
onClick={() => {
|
||||
onReload();
|
||||
}}
|
||||
>
|
||||
<IconReload />
|
||||
</ActionIcon>
|
||||
<Select
|
||||
placeholder="Pilih status"
|
||||
value={selectedStatus}
|
||||
data={
|
||||
listStatus?.map((e, i) => ({
|
||||
value: e.id,
|
||||
label: e.name,
|
||||
})) || []
|
||||
}
|
||||
onChange={(val: any) => {
|
||||
onSelected(val);
|
||||
}}
|
||||
/>
|
||||
</Group>
|
||||
}
|
||||
/>
|
||||
|
||||
{!data ? (
|
||||
<CustomSkeleton height={"80vh"} width={"100%"} />
|
||||
) : (
|
||||
<Paper bg={AdminColor.softBlue} p={"md"} shadow="lg" h={"80vh"}>
|
||||
<ScrollArea w={"100%"} h={"90%"}>
|
||||
<Table
|
||||
verticalSpacing={"xl"}
|
||||
horizontalSpacing={"md"}
|
||||
p={"md"}
|
||||
w={1100}
|
||||
>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Nama Investor</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Jumlah Investasi</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Tanggal</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Status</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Bukti Transfer</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Aksi</Center>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>{renderTableBody()}</tbody>
|
||||
</Table>
|
||||
</ScrollArea>
|
||||
|
||||
<Center mt={"xl"}>
|
||||
<Pagination
|
||||
value={isActivePage}
|
||||
total={isNPage}
|
||||
onChange={(val) => {
|
||||
onPageClick(val);
|
||||
}}
|
||||
/>
|
||||
</Center>
|
||||
</Paper>
|
||||
)}
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
'use client'
|
||||
import { AdminColor } from '@/app_modules/_global/color/color_pallet';
|
||||
import AdminGlobal_ComponentBackButton from '@/app_modules/admin/_admin_global/back_button';
|
||||
import CustomSkeleton from '@/app_modules/components/CustomSkeleton';
|
||||
import { MODEL_INVOICE_INVESTASI } from '@/app_modules/investasi/_lib/interface';
|
||||
import { Button, Grid, Group, Paper, Stack, Text, Title } from '@mantine/core';
|
||||
import { useState } from 'react';
|
||||
import { apiGetAdminDetailTransaksi } from '../../_lib/api_fetch_admin_investasi';
|
||||
import { useParams } from 'next/navigation';
|
||||
import { clientLogger } from '@/util/clientLogger';
|
||||
import { useShallowEffect } from '@mantine/hooks';
|
||||
|
||||
|
||||
function DetailTransaksi() {
|
||||
const params = useParams<{ id: string }>();
|
||||
const [data, setData] = useState<MODEL_INVOICE_INVESTASI | null>(null);
|
||||
|
||||
useShallowEffect(() => {
|
||||
loadInitialData();
|
||||
}, [])
|
||||
|
||||
const loadInitialData = async () => {
|
||||
try {
|
||||
|
||||
const response = await apiGetAdminDetailTransaksi({
|
||||
id: params.id
|
||||
})
|
||||
|
||||
if (response?.success && response?.data.data) {
|
||||
setData(response.data.data)
|
||||
} else {
|
||||
console.error("Invalid data format recieved:", response)
|
||||
setData(null)
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
clientLogger.error("Invalid data format recieved:", error)
|
||||
setData(null)
|
||||
}
|
||||
}
|
||||
return (
|
||||
<Stack px={"lg"}>
|
||||
<Group position="apart">
|
||||
<AdminGlobal_ComponentBackButton />
|
||||
|
||||
{/* {data?.masterStatusInvestasiId === "2" ? ( */}
|
||||
<Group>
|
||||
<Button
|
||||
radius={"xl"}
|
||||
color="green"
|
||||
// onClick={() => setOpenModalPublish(true)}
|
||||
>
|
||||
Publish
|
||||
</Button>
|
||||
<Button
|
||||
radius={"xl"}
|
||||
color="red"
|
||||
// onClick={() => setOpenModalReject(true)}
|
||||
>
|
||||
Reject
|
||||
</Button>
|
||||
</Group>
|
||||
{/* // ) : (
|
||||
// ""
|
||||
// )} */}
|
||||
</Group>
|
||||
|
||||
<>
|
||||
{!data ? (<CustomSkeleton height={"50vh"} width={"100%"} />) : (
|
||||
<Paper w={"50%"} bg={AdminColor.softBlue} p={"lg"}>
|
||||
<Stack c={AdminColor.white}>
|
||||
<Title order={3}>Detail Transaksi</Title>
|
||||
<Stack spacing={"xs"}>
|
||||
<Grid>
|
||||
<Grid.Col span={6}>
|
||||
<Text fw={"bold"}>Nama Investor:</Text>
|
||||
</Grid.Col>
|
||||
<Grid.Col span={6}>
|
||||
<Text>{data?.Author?.username}</Text>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
<Grid>
|
||||
<Grid.Col span={6}>
|
||||
<Text fw={"bold"}>Nama Bank:</Text>
|
||||
</Grid.Col>
|
||||
<Grid.Col span={6}>
|
||||
<Text>@{data?.Author?.username}</Text>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
<Grid>
|
||||
<Grid.Col span={6}>
|
||||
<Text fw={"bold"}>Nomor:</Text>
|
||||
</Grid.Col>
|
||||
<Grid.Col span={6}>
|
||||
<Text>+ {data?.Author?.nomor}</Text>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
<Grid>
|
||||
<Grid.Col span={6}>
|
||||
<Text fw={"bold"}>Jumlah Investasi:</Text>
|
||||
</Grid.Col>
|
||||
<Grid.Col span={6}>
|
||||
<Text>{data?.nominal}</Text>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
<Grid>
|
||||
<Grid.Col span={6}>
|
||||
<Text fw={"bold"}>Lembar Terbeli:</Text>
|
||||
</Grid.Col>
|
||||
<Grid.Col span={6}>
|
||||
<Text>{data?.lembarTerbeli}</Text>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
<Grid>
|
||||
<Grid.Col span={6}>
|
||||
<Text fw={"bold"}>Tanggal:</Text>
|
||||
</Grid.Col>
|
||||
<Grid.Col span={6}>
|
||||
{data?.createdAt ? new Date(data.createdAt).toLocaleDateString() : ""}
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
<Grid>
|
||||
<Grid.Col span={6}>
|
||||
<Text fw={"bold"}>Status:</Text>
|
||||
</Grid.Col>
|
||||
<Grid.Col span={6}>
|
||||
<Text>{data?.statusInvoiceId}</Text>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
<Grid>
|
||||
<Grid.Col span={6}>
|
||||
<Text fw={"bold"}>Bukti Transfer:</Text>
|
||||
</Grid.Col>
|
||||
<Grid.Col span={6}>
|
||||
<Text>{data?.Profile?.alamat}</Text>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
</Stack>
|
||||
</Stack>
|
||||
</Paper>
|
||||
)}
|
||||
</>
|
||||
</Stack>
|
||||
);
|
||||
}
|
||||
|
||||
export default DetailTransaksi;
|
||||
@@ -114,47 +114,47 @@ function TableView() {
|
||||
return data.map((e, i) => (
|
||||
<tr key={i}>
|
||||
<td>
|
||||
<Center w={200}>
|
||||
<Center >
|
||||
<Text c={AccentColor.white} lineClamp={1}>
|
||||
{e.author.username}
|
||||
</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center w={400}>
|
||||
<Center >
|
||||
<Text c={AccentColor.white} lineClamp={1}>
|
||||
{e.title}
|
||||
</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center c={AccentColor.white} w={200}>
|
||||
<Center c={AccentColor.white} >
|
||||
{_.toNumber(e.progress).toFixed(2)} %
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center c={AccentColor.white} w={200}>
|
||||
<Center c={AccentColor.white} >
|
||||
{new Intl.NumberFormat("id-ID", {
|
||||
maximumFractionDigits: 10,
|
||||
}).format(+e.sisaLembar)}
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center c={AccentColor.white} w={200}>
|
||||
<Center c={AccentColor.white} >
|
||||
{new Intl.NumberFormat("id-ID", {
|
||||
maximumFractionDigits: 10,
|
||||
}).format(+e.totalLembar)}
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center w={200}>
|
||||
<Center >
|
||||
<Text c={AccentColor.white} lineClamp={1}>
|
||||
{e.Investasi_Invoice.length}
|
||||
</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center w={200}>
|
||||
<Center >
|
||||
<Button
|
||||
loading={isLoading && idData === e.id}
|
||||
loaderPosition="center"
|
||||
@@ -227,37 +227,37 @@ function TableView() {
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
<Center c={AccentColor.white} w={200}>
|
||||
<Center c={AccentColor.white} >
|
||||
Username
|
||||
</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AccentColor.white} w={400}>
|
||||
<Center c={AccentColor.white} >
|
||||
Nama Proyek
|
||||
</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AccentColor.white} w={200}>
|
||||
<Center c={AccentColor.white} >
|
||||
Progres
|
||||
</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AccentColor.white} w={200}>
|
||||
<Center c={AccentColor.white} >
|
||||
Sisa Saham
|
||||
</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AccentColor.white} w={200}>
|
||||
<Center c={AccentColor.white} >
|
||||
Total Saham
|
||||
</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AccentColor.white} w={200}>
|
||||
<Center c={AccentColor.white} >
|
||||
Validasi
|
||||
</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AccentColor.white} w={200}>
|
||||
<Center c={AccentColor.white} >
|
||||
Aksi
|
||||
</Center>
|
||||
</th>
|
||||
|
||||
@@ -173,23 +173,23 @@ function TableView() {
|
||||
return data.map((e, i) => (
|
||||
<tr key={i}>
|
||||
<td>
|
||||
<Center w={200}>
|
||||
<Center >
|
||||
<Text c={AccentColor.white} lineClamp={1}>{e.author.username}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center w={400}>
|
||||
<Center >
|
||||
<Text c={AccentColor.white} lineClamp={1}>{e.title}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center w={400}>
|
||||
<Center >
|
||||
<Text c={AccentColor.white} lineClamp={1}>{e.catatan}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<Center w={200}>
|
||||
<Center >
|
||||
<Button
|
||||
loading={isLoading && idData === e.id}
|
||||
loaderPosition="center"
|
||||
@@ -264,16 +264,16 @@ function TableView() {
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
<Center c={AccentColor.white} w={200}>Username</Center>
|
||||
<Center c={AccentColor.white} >Username</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AccentColor.white} w={400}>Nama Proyek</Center>
|
||||
<Center c={AccentColor.white} >Nama Proyek</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AccentColor.white} w={400}>Catatan Penolakan</Center>
|
||||
<Center c={AccentColor.white} >Catatan Penolakan</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AccentColor.white} w={200}>Aksi</Center>
|
||||
<Center c={AccentColor.white} >Aksi</Center>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
@@ -113,36 +113,36 @@ function TableView() {
|
||||
return data.map((e, i) => (
|
||||
<tr key={i}>
|
||||
<td>
|
||||
<Center c={AccentColor.white} w={200}>
|
||||
<Center c={AccentColor.white} >
|
||||
<Text lineClamp={1}>{e.author.username}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center c={AccentColor.white} w={400}>
|
||||
<Center c={AccentColor.white} >
|
||||
<Text lineClamp={1}>{e.title}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center c={AccentColor.white} w={200}>
|
||||
<Center c={AccentColor.white} >
|
||||
<Text lineClamp={1}>{e.roi} %</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center c={AccentColor.white} w={200}>
|
||||
<Center c={AccentColor.white} >
|
||||
<ComponentAdminGlobal_TampilanRupiahDonasi
|
||||
nominal={_.toNumber(e.targetDana)}
|
||||
/>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center c={AccentColor.white} w={200}>
|
||||
<Center c={AccentColor.white} >
|
||||
<ComponentAdminGlobal_TampilanRupiahDonasi
|
||||
nominal={_.toNumber(e.hargaLembar)}
|
||||
/>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center w={200}>
|
||||
<Center >
|
||||
<Button
|
||||
loading={isLoading && idData === e.id}
|
||||
loaderPosition="center"
|
||||
@@ -238,23 +238,23 @@ function TableView() {
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
<Center c={AccentColor.white} w={200}>Username</Center>
|
||||
<Center c={AccentColor.white} >Username</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AccentColor.white} w={400}>Nama Proyek</Center>
|
||||
<Center c={AccentColor.white} >Nama Proyek</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AccentColor.white} w={200}>ROI</Center>
|
||||
<Center c={AccentColor.white} >ROI</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AccentColor.white} w={200}>Target Dana</Center>
|
||||
<Center c={AccentColor.white} >Target Dana</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AccentColor.white} w={200}>Harga Perlembar</Center>
|
||||
<Center c={AccentColor.white} >Harga Perlembar</Center>
|
||||
</th>
|
||||
|
||||
<th>
|
||||
<Center c={AccentColor.white} w={200}>Aksi</Center>
|
||||
<Center c={AccentColor.white} >Aksi</Center>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
251
src/app_modules/admin/vote/child/table_publish/index.txt
Normal file
251
src/app_modules/admin/vote/child/table_publish/index.txt
Normal file
@@ -0,0 +1,251 @@
|
||||
"use client";
|
||||
|
||||
import {
|
||||
AccentColor,
|
||||
AdminColor,
|
||||
} from "@/app_modules/_global/color/color_pallet";
|
||||
import { ComponentAdminGlobal_TitlePage } from "@/app_modules/admin/_admin_global/_component";
|
||||
import ComponentAdminGlobal_HeaderTamplate from "@/app_modules/admin/_admin_global/header_tamplate";
|
||||
import ComponentAdminGlobal_IsEmptyData from "@/app_modules/admin/_admin_global/is_empty_data";
|
||||
import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
|
||||
import { MODEL_VOTING } from "@/app_modules/vote/model/interface";
|
||||
import { clientLogger } from "@/util/clientLogger";
|
||||
import {
|
||||
Box,
|
||||
Button,
|
||||
Center,
|
||||
Modal,
|
||||
Pagination,
|
||||
Paper,
|
||||
ScrollArea,
|
||||
Spoiler,
|
||||
Stack,
|
||||
Table,
|
||||
Text,
|
||||
TextInput
|
||||
} from "@mantine/core";
|
||||
import { useDisclosure, useShallowEffect } from "@mantine/hooks";
|
||||
import {
|
||||
IconCircleCheckFilled,
|
||||
IconSearch
|
||||
} from "@tabler/icons-react";
|
||||
import _ from "lodash";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import ComponentAdminVote_DetailHasil from "../../component/detail_hasil";
|
||||
import { AdminVote_getHasilById } from "../../fun/get/get_hasil_by_id";
|
||||
import { AdminVote_getListKontributorById } from "../../fun/get/get_list_kontributor_by_id";
|
||||
import { apiGetAdminVotingByStatus } from "../../lib/api_fetch_admin_voting";
|
||||
|
||||
export default function AdminVote_TablePublish() {
|
||||
return (
|
||||
<>
|
||||
<Stack>
|
||||
<ComponentAdminGlobal_HeaderTamplate name="Voting" />
|
||||
<TableStatus />
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function TableStatus() {
|
||||
const router = useRouter();
|
||||
const [opened, { open, close }] = useDisclosure(false);
|
||||
const [hasil, setHasil] = useState<any[]>();
|
||||
const [kontributor, setKontributor] = useState<any[]>();
|
||||
const [voteId, setVoteId] = useState("");
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
const [data, setData] = useState<MODEL_VOTING[] | null>(null);
|
||||
const [isNPage, setNPage] = useState(1);
|
||||
const [isActivePage, setActivePage] = useState(1);
|
||||
const [isSearch, setSearch] = useState("");
|
||||
|
||||
useShallowEffect(() => {
|
||||
handleLoadData();
|
||||
}, [isActivePage, isSearch]);
|
||||
|
||||
const handleLoadData = async () => {
|
||||
try {
|
||||
const response = await apiGetAdminVotingByStatus({
|
||||
name: "Publish",
|
||||
page: `${isActivePage}`,
|
||||
search: isSearch,
|
||||
});
|
||||
|
||||
if (response?.success && response?.data?.data) {
|
||||
setData(response.data.data);
|
||||
setNPage(response.data.nPage || 1);
|
||||
} else {
|
||||
console.error("Invalid data format received:", response);
|
||||
setData([]);
|
||||
}
|
||||
} catch (error) {
|
||||
clientLogger.error("Error get data table publish", error);
|
||||
setData([]);
|
||||
}
|
||||
};
|
||||
|
||||
async function onSearch(s: string) {
|
||||
setSearch(s);
|
||||
}
|
||||
|
||||
async function onPageClick(p: any) {
|
||||
setActivePage(p);
|
||||
}
|
||||
|
||||
const renderTableBody = () => {
|
||||
if (!Array.isArray(data) || data.length === 0) {
|
||||
return (
|
||||
<tr>
|
||||
<td colSpan={12}>
|
||||
<Center>
|
||||
<Text color={"gray"}>Tidak ada data</Text>
|
||||
</Center>
|
||||
</td>
|
||||
</tr>
|
||||
);
|
||||
}
|
||||
|
||||
return data?.map((e, i) => (
|
||||
<tr key={i}>
|
||||
<td>
|
||||
<Center c={AccentColor.white}>{e?.Author?.username}</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center c={AccentColor.white}>{e?.title}</Center>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<Stack>
|
||||
{e?.Voting_DaftarNamaVote.map((v) => (
|
||||
<Box key={v?.id}>
|
||||
<Text c={AccentColor.white}>- {v?.value}</Text>
|
||||
</Box>
|
||||
))}
|
||||
</Stack>
|
||||
</td>
|
||||
|
||||
|
||||
<td>
|
||||
<Center>
|
||||
<Button
|
||||
loading={
|
||||
e?.id === voteId ? (loading === true ? true : false) : false
|
||||
}
|
||||
radius={"xl"}
|
||||
color="green"
|
||||
leftIcon={<IconCircleCheckFilled />}
|
||||
onClick={async () => {
|
||||
setVoteId(e?.id);
|
||||
setLoading(true);
|
||||
await new Promise((r) => setTimeout(r, 500));
|
||||
onList(e?.id, setHasil, setKontributor, setLoading, open);
|
||||
}}
|
||||
>
|
||||
Lihat Hasil
|
||||
</Button>
|
||||
</Center>
|
||||
</td>
|
||||
</tr>
|
||||
));
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<Stack spacing={"xs"} h={"100%"}>
|
||||
<ComponentAdminGlobal_TitlePage
|
||||
name="Publish"
|
||||
color={AdminColor.softBlue}
|
||||
component={
|
||||
<TextInput
|
||||
icon={<IconSearch size={20} />}
|
||||
radius={"xl"}
|
||||
placeholder="Masukan judul"
|
||||
onChange={(val) => {
|
||||
onSearch(val.currentTarget.value);
|
||||
}}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
|
||||
{!data ? (
|
||||
<CustomSkeleton height={"80vh"} width="100%" />
|
||||
) : _.isEmpty(data) ? (
|
||||
<ComponentAdminGlobal_IsEmptyData />
|
||||
) : (
|
||||
<Paper p={"md"} bg={AdminColor.softBlue} shadow="lg" h={"80vh"}>
|
||||
<ScrollArea w={"100%"} h={"90%"}>
|
||||
<Table
|
||||
verticalSpacing={"md"}
|
||||
horizontalSpacing={"md"}
|
||||
p={"md"}
|
||||
w={1120}
|
||||
>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
<Center c={AccentColor.white}>Username</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AccentColor.white}>Judul</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AccentColor.white}>Pilihan</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AccentColor.white}>Aksi</Center>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>{renderTableBody()}</tbody>
|
||||
</Table>
|
||||
</ScrollArea>
|
||||
|
||||
<Center mt={"xl"}>
|
||||
<Pagination
|
||||
value={isActivePage}
|
||||
total={isNPage}
|
||||
onChange={(val) => {
|
||||
onPageClick(val);
|
||||
}}
|
||||
/>
|
||||
</Center>
|
||||
</Paper>
|
||||
)}
|
||||
</Stack>
|
||||
|
||||
<Modal
|
||||
opened={opened}
|
||||
onClose={close}
|
||||
size={"xl"}
|
||||
withCloseButton={false}
|
||||
>
|
||||
<ComponentAdminVote_DetailHasil
|
||||
hasil={hasil}
|
||||
kontributor={kontributor}
|
||||
/>
|
||||
</Modal>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
async function onList(
|
||||
voteId: string,
|
||||
setHasil: any,
|
||||
setKontributor: any,
|
||||
setLoading: any,
|
||||
open: any
|
||||
) {
|
||||
await AdminVote_getHasilById(voteId).then((res) => {
|
||||
setHasil(res);
|
||||
setLoading(false);
|
||||
});
|
||||
|
||||
await AdminVote_getListKontributorById(voteId).then((res) => {
|
||||
setKontributor(res);
|
||||
setLoading(false);
|
||||
});
|
||||
|
||||
open();
|
||||
}
|
||||
285
src/app_modules/admin/vote/child/table_reject/index.txt
Normal file
285
src/app_modules/admin/vote/child/table_reject/index.txt
Normal file
@@ -0,0 +1,285 @@
|
||||
"use client";
|
||||
|
||||
import {
|
||||
AccentColor,
|
||||
AdminColor,
|
||||
} from "@/app_modules/_global/color/color_pallet";
|
||||
import { ComponentAdminGlobal_TitlePage } from "@/app_modules/admin/_admin_global/_component";
|
||||
import { ComponentAdminGlobal_NotifikasiBerhasil } from "@/app_modules/admin/_admin_global/admin_notifikasi/notifikasi_berhasil";
|
||||
import { ComponentAdminGlobal_NotifikasiGagal } from "@/app_modules/admin/_admin_global/admin_notifikasi/notifikasi_gagal";
|
||||
import ComponentAdminGlobal_HeaderTamplate from "@/app_modules/admin/_admin_global/header_tamplate";
|
||||
import ComponentAdminGlobal_IsEmptyData from "@/app_modules/admin/_admin_global/is_empty_data";
|
||||
import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
|
||||
import { MODEL_VOTING } from "@/app_modules/vote/model/interface";
|
||||
import { clientLogger } from "@/util/clientLogger";
|
||||
import {
|
||||
Box,
|
||||
Button,
|
||||
Center,
|
||||
Group,
|
||||
Modal,
|
||||
Pagination,
|
||||
Paper,
|
||||
ScrollArea,
|
||||
Spoiler,
|
||||
Stack,
|
||||
Table,
|
||||
Text,
|
||||
Textarea,
|
||||
TextInput,
|
||||
} from "@mantine/core";
|
||||
import { useDisclosure, useShallowEffect } from "@mantine/hooks";
|
||||
import { IconBan, IconEyeCheck, IconSearch } from "@tabler/icons-react";
|
||||
import _ from "lodash";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import { AdminVote_funEditCatatanRejectById } from "../../fun/edit/fun_edit_catatan_reject_by_id";
|
||||
import { apiGetAdminVotingByStatus } from "../../lib/api_fetch_admin_voting";
|
||||
|
||||
export default function AdminVote_TableReject() {
|
||||
return (
|
||||
<>
|
||||
<Stack>
|
||||
<ComponentAdminGlobal_HeaderTamplate name="Voting" />
|
||||
<TableStatus />
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function TableStatus() {
|
||||
const router = useRouter();
|
||||
const [opened, { open, close }] = useDisclosure(false);
|
||||
const [votingId, setVotingId] = useState("");
|
||||
const [catatan, setCatatan] = useState("");
|
||||
const [isLoading, setLoading] = useState(false);
|
||||
|
||||
const [data, setData] = useState<MODEL_VOTING[] | null>(null);
|
||||
const [nPage, setNPage] = useState(1);
|
||||
const [isActivePage, setActivePage] = useState(1);
|
||||
const [isSearch, setSearch] = useState("");
|
||||
|
||||
useShallowEffect(() => {
|
||||
handleLoadData();
|
||||
}, [isActivePage, isSearch]);
|
||||
|
||||
const handleLoadData = async () => {
|
||||
try {
|
||||
const response = await apiGetAdminVotingByStatus({
|
||||
name: "Reject",
|
||||
page: `${isActivePage}`,
|
||||
search: isSearch,
|
||||
});
|
||||
|
||||
if (response?.success && response?.data?.data) {
|
||||
setData(response.data.data);
|
||||
setNPage(response.data.nPage || 1);
|
||||
} else {
|
||||
console.error("Invalid data format received:", response);
|
||||
setData([]);
|
||||
}
|
||||
} catch (error) {
|
||||
clientLogger.error("Error get data table publish", error);
|
||||
setData([]);
|
||||
}
|
||||
};
|
||||
|
||||
async function onSearch(s: string) {
|
||||
setSearch(s);
|
||||
}
|
||||
|
||||
async function onPageClick(p: any) {
|
||||
setActivePage(p);
|
||||
}
|
||||
|
||||
async function onReject() {
|
||||
try {
|
||||
setLoading(true);
|
||||
const res = await AdminVote_funEditCatatanRejectById(votingId, catatan);
|
||||
if (res.status === 200) {
|
||||
handleLoadData();
|
||||
ComponentAdminGlobal_NotifikasiBerhasil(res.message);
|
||||
} else {
|
||||
ComponentAdminGlobal_NotifikasiGagal(res.message);
|
||||
}
|
||||
} catch (error) {
|
||||
console.log("Error get data voting review", error);
|
||||
setVotingId("");
|
||||
} finally {
|
||||
close();
|
||||
setLoading(false);
|
||||
setVotingId("");
|
||||
}
|
||||
}
|
||||
|
||||
const renderTableBody = () => {
|
||||
if (!Array.isArray(data) || data.length === 0) {
|
||||
return (
|
||||
<tr>
|
||||
<td colSpan={12}>
|
||||
<Center>
|
||||
<Text color={"gray"}>Tidak ada data</Text>
|
||||
</Center>
|
||||
</td>
|
||||
</tr>
|
||||
);
|
||||
}
|
||||
|
||||
return data?.map((e, i) => (
|
||||
<tr key={i}>
|
||||
<td>
|
||||
<Center c={AccentColor.white}>{e?.Author?.Profile?.name}</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center c={AccentColor.white}>{e.title}</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center c={"white"}>
|
||||
<Spoiler
|
||||
hideLabel="sembunyikan"
|
||||
maw={400}
|
||||
maxHeight={50}
|
||||
showLabel="tampilkan"
|
||||
>
|
||||
{e.catatan}
|
||||
</Spoiler>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Stack>
|
||||
{e.Voting_DaftarNamaVote.map((v) => (
|
||||
<Box key={v.id}>
|
||||
<Text c={AccentColor.white}>- {v.value}</Text>
|
||||
</Box>
|
||||
))}
|
||||
</Stack>
|
||||
</td>
|
||||
<td>
|
||||
<Center>
|
||||
<Button
|
||||
color={"green"}
|
||||
leftIcon={<IconEyeCheck />}
|
||||
radius={"xl"}
|
||||
onClick={() => {
|
||||
open();
|
||||
setVotingId(e.id);
|
||||
setCatatan(e.catatan);
|
||||
}}
|
||||
>
|
||||
Detail
|
||||
</Button>
|
||||
</Center>
|
||||
</td>
|
||||
</tr>
|
||||
));
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<Stack spacing={"xs"} h={"100%"}>
|
||||
<ComponentAdminGlobal_TitlePage
|
||||
name="Reject"
|
||||
color={AdminColor.softBlue}
|
||||
component={
|
||||
<TextInput
|
||||
icon={<IconSearch size={20} />}
|
||||
radius={"xl"}
|
||||
placeholder="Masukan judul"
|
||||
onChange={(val) => {
|
||||
onSearch(val.currentTarget.value);
|
||||
}}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
|
||||
{!data ? (
|
||||
<CustomSkeleton height={"80vh"} width="100%" />
|
||||
) : _.isEmpty(data) ? (
|
||||
<ComponentAdminGlobal_IsEmptyData />
|
||||
) : (
|
||||
<Paper p={"md"} bg={AdminColor.softBlue} shadow="lg" h={"80vh"}>
|
||||
<ScrollArea w={"100%"} h={"90%"}>
|
||||
<Table
|
||||
verticalSpacing={"md"}
|
||||
horizontalSpacing={"md"}
|
||||
p={"md"}
|
||||
w={1120}
|
||||
>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
<Center c={AccentColor.white}>Author</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AccentColor.white}>Judul</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AccentColor.white}>Catatan</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AccentColor.white}>Pilihan</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AccentColor.white}>Aksi</Center>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>{renderTableBody()}</tbody>
|
||||
</Table>
|
||||
</ScrollArea>
|
||||
|
||||
<Center mt={"xl"}>
|
||||
<Pagination
|
||||
value={isActivePage}
|
||||
total={nPage}
|
||||
onChange={(val) => {
|
||||
onPageClick(val);
|
||||
}}
|
||||
/>
|
||||
</Center>
|
||||
</Paper>
|
||||
)}
|
||||
</Stack>
|
||||
|
||||
<Modal
|
||||
styles={{ body: { backgroundColor: AdminColor.softBlue } }}
|
||||
opened={opened}
|
||||
onClose={close}
|
||||
centered
|
||||
withCloseButton={false}
|
||||
size={"md"}
|
||||
>
|
||||
<Stack>
|
||||
<Textarea
|
||||
styles={{ label: { color: AdminColor.white } }}
|
||||
minRows={2}
|
||||
maxRows={5}
|
||||
maxLength={300}
|
||||
autosize
|
||||
label="Masukan Alasan Penolakan"
|
||||
placeholder="Contoh: Karena deskripsi kurang lengkap, dll"
|
||||
value={catatan}
|
||||
onChange={(val) => {
|
||||
setCatatan(val.target.value);
|
||||
}}
|
||||
/>
|
||||
<Group position="right">
|
||||
<Button radius={"xl"} onClick={() => close()}>
|
||||
Batal
|
||||
</Button>
|
||||
<Button
|
||||
loading={isLoading}
|
||||
loaderPosition="center"
|
||||
radius={"xl"}
|
||||
onClick={() => {
|
||||
onReject();
|
||||
}}
|
||||
>
|
||||
Simpan
|
||||
</Button>
|
||||
</Group>
|
||||
</Stack>
|
||||
</Modal>
|
||||
</>
|
||||
);
|
||||
}
|
||||
441
src/app_modules/admin/vote/child/table_review/index.txt
Normal file
441
src/app_modules/admin/vote/child/table_review/index.txt
Normal file
@@ -0,0 +1,441 @@
|
||||
"use client";
|
||||
|
||||
import ComponentAdminGlobal_HeaderTamplate from "@/app_modules/admin/_admin_global/header_tamplate";
|
||||
import { MODEL_VOTING } from "@/app_modules/vote/model/interface";
|
||||
import {
|
||||
Affix,
|
||||
Box,
|
||||
Button,
|
||||
Center,
|
||||
Group,
|
||||
Modal,
|
||||
Pagination,
|
||||
Paper,
|
||||
rem,
|
||||
ScrollArea,
|
||||
Spoiler,
|
||||
Stack,
|
||||
Table,
|
||||
Text,
|
||||
Textarea,
|
||||
TextInput,
|
||||
Title,
|
||||
} from "@mantine/core";
|
||||
import { useDisclosure, useShallowEffect } from "@mantine/hooks";
|
||||
import {
|
||||
IconBan,
|
||||
IconCircleCheck,
|
||||
IconEyeCheck,
|
||||
IconRefresh,
|
||||
IconSearch,
|
||||
} from "@tabler/icons-react";
|
||||
|
||||
import {
|
||||
gs_adminVoting_triggerReview,
|
||||
IRealtimeData,
|
||||
} from "@/lib/global_state";
|
||||
import { AccentColor, MainColor } from "@/app_modules/_global/color";
|
||||
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
|
||||
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal";
|
||||
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global/notifikasi_peringatan";
|
||||
import adminNotifikasi_funCreateToUser from "@/app_modules/admin/notifikasi/fun/create/fun_create_notif_user";
|
||||
import mqtt_client from "@/util/mqtt_client";
|
||||
import { useAtom } from "jotai";
|
||||
import moment from "moment";
|
||||
import { useState } from "react";
|
||||
import { WibuRealtime } from "wibu-pkg";
|
||||
import { adminVote_funGetListReview } from "../../fun";
|
||||
import { AdminVote_funEditStatusPublishById } from "../../fun/edit/fun_edit_status_publish_by_id";
|
||||
import { AdminEvent_funEditCatatanById } from "../../fun/edit/fun_edit_status_reject_by_id";
|
||||
import { ComponentAdminGlobal_TitlePage } from "@/app_modules/admin/_admin_global/_component";
|
||||
import { AdminColor } from "@/app_modules/_global/color/color_pallet";
|
||||
import { clientLogger } from "@/util/clientLogger";
|
||||
import { apiGetAdminVotingByStatus } from "../../lib/api_fetch_admin_voting";
|
||||
import _ from "lodash";
|
||||
import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
|
||||
import ComponentAdminGlobal_IsEmptyData from "@/app_modules/admin/_admin_global/is_empty_data";
|
||||
|
||||
export default function AdminVote_TableReview() {
|
||||
return (
|
||||
<>
|
||||
<Stack>
|
||||
<ComponentAdminGlobal_HeaderTamplate name="Voting" />
|
||||
<TableStatus />
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function TableStatus() {
|
||||
const [openedReject, { open: openReject, close: closeReject }] =
|
||||
useDisclosure(false);
|
||||
const [openedPublish, { open: openPublish, close: closePublish }] =
|
||||
useDisclosure(false);
|
||||
|
||||
const [data, setData] = useState<MODEL_VOTING[] | null>(null);
|
||||
const [nPage, setNPage] = useState(1);
|
||||
const [dataId, setDataId] = useState("");
|
||||
const [tanggalMulai, setTanggalMulai] = useState<Date>();
|
||||
const [catatan, setCatatan] = useState("");
|
||||
const [isLoadingPublish, setLoadingPublish] = useState(false);
|
||||
const [isSaveLoading, setSaveLoading] = useState(false);
|
||||
|
||||
const [isActivePage, setActivePage] = useState(1);
|
||||
const [isSearch, setSearch] = useState("");
|
||||
|
||||
// Realtine
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const [isAdminVoting_TriggerReview, setIsAdminVoting_TriggerReview] = useAtom(
|
||||
gs_adminVoting_triggerReview
|
||||
);
|
||||
const [isShowReload, setIsShowReload] = useState(false);
|
||||
|
||||
useShallowEffect(() => {
|
||||
if (isAdminVoting_TriggerReview) {
|
||||
setIsShowReload(true);
|
||||
}
|
||||
}, [isAdminVoting_TriggerReview, setIsShowReload]);
|
||||
|
||||
useShallowEffect(() => {
|
||||
handleLoadData();
|
||||
}, [isActivePage, isSearch]);
|
||||
|
||||
const handleLoadData = async () => {
|
||||
try {
|
||||
const response = await apiGetAdminVotingByStatus({
|
||||
name: "Review",
|
||||
page: `${isActivePage}`,
|
||||
search: isSearch,
|
||||
});
|
||||
|
||||
if (response?.success && response?.data?.data) {
|
||||
setData(response.data.data);
|
||||
setNPage(response.data.nPage || 1);
|
||||
} else {
|
||||
console.error("Invalid data format received:", response);
|
||||
setData([]);
|
||||
}
|
||||
} catch (error) {
|
||||
clientLogger.error("Error get data table publish", error);
|
||||
setData([]);
|
||||
}
|
||||
};
|
||||
|
||||
async function onSearch(s: string) {
|
||||
setSearch(s);
|
||||
}
|
||||
|
||||
async function onPageClick(p: any) {
|
||||
setActivePage(p);
|
||||
}
|
||||
|
||||
async function onLoadData() {
|
||||
handleLoadData();
|
||||
setIsLoading(false);
|
||||
setIsShowReload(false);
|
||||
setIsAdminVoting_TriggerReview(false);
|
||||
}
|
||||
|
||||
|
||||
async function onReject() {
|
||||
const data = {
|
||||
id: dataId,
|
||||
catatan: catatan,
|
||||
};
|
||||
|
||||
try {
|
||||
setSaveLoading(true);
|
||||
const res = await AdminEvent_funEditCatatanById(data as any);
|
||||
if (res.status === 200) {
|
||||
const dataNotifikasi: IRealtimeData = {
|
||||
appId: res.data?.id as string,
|
||||
status: res.data?.Voting_Status?.name as any,
|
||||
userId: res.data?.authorId as any,
|
||||
pesan: res.data?.title as any,
|
||||
kategoriApp: "VOTING",
|
||||
title: "Voting anda di tolak !",
|
||||
};
|
||||
|
||||
const notif = await adminNotifikasi_funCreateToUser({
|
||||
data: dataNotifikasi as any,
|
||||
});
|
||||
|
||||
if (notif.status === 201) {
|
||||
WibuRealtime.setData({
|
||||
type: "notification",
|
||||
pushNotificationTo: "USER",
|
||||
dataMessage: dataNotifikasi,
|
||||
});
|
||||
}
|
||||
|
||||
handleLoadData();
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error update voting admin", error);
|
||||
} finally {
|
||||
closeReject();
|
||||
setSaveLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
async function onPublish() {
|
||||
const hariIni = new Date();
|
||||
const cekHari = moment(tanggalMulai).diff(hariIni, "days");
|
||||
|
||||
if (cekHari < 0)
|
||||
return ComponentGlobal_NotifikasiPeringatan("Tanggal Voting Lewat");
|
||||
|
||||
try {
|
||||
setLoadingPublish(true);
|
||||
const res = await AdminVote_funEditStatusPublishById(dataId);
|
||||
if (res.status === 200) {
|
||||
const dataNotifikasi: IRealtimeData = {
|
||||
appId: res.data?.id as string,
|
||||
status: res.data?.Voting_Status?.name as any,
|
||||
userId: res.data?.authorId as any,
|
||||
pesan: res.data?.title as any,
|
||||
kategoriApp: "VOTING",
|
||||
title: "Voting publish",
|
||||
};
|
||||
const notif = await adminNotifikasi_funCreateToUser({
|
||||
data: dataNotifikasi as any,
|
||||
});
|
||||
if (notif.status === 201) {
|
||||
WibuRealtime.setData({
|
||||
type: "notification",
|
||||
pushNotificationTo: "USER",
|
||||
dataMessage: dataNotifikasi,
|
||||
});
|
||||
WibuRealtime.setData({
|
||||
type: "trigger",
|
||||
pushNotificationTo: "USER",
|
||||
dataMessage: dataNotifikasi,
|
||||
});
|
||||
}
|
||||
handleLoadData();
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||
closePublish()
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
}
|
||||
} catch (error) {
|
||||
console.log("Error get data voting", error);
|
||||
} finally {
|
||||
setLoadingPublish(false);
|
||||
}
|
||||
}
|
||||
|
||||
const renderTableBody = () => {
|
||||
if (!Array.isArray(data) || data.length === 0) {
|
||||
return (
|
||||
<tr>
|
||||
<td colSpan={12}>
|
||||
<Center>
|
||||
<Text color={"gray"}>Tidak ada data</Text>
|
||||
</Center>
|
||||
</td>
|
||||
</tr>
|
||||
);
|
||||
}
|
||||
|
||||
return data?.map((e, i) => (
|
||||
<tr key={i}>
|
||||
<td>
|
||||
<Center c={AccentColor.white}>{e?.Author?.username}</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center c={AccentColor.white}>{e.title}</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Stack>
|
||||
{e.Voting_DaftarNamaVote.map((v) => (
|
||||
<Box key={v.id}>
|
||||
<Text c={AccentColor.white}>- {v.value}</Text>
|
||||
</Box>
|
||||
))}
|
||||
</Stack>
|
||||
</td>
|
||||
<td>
|
||||
<Center>
|
||||
<Button
|
||||
w={120}
|
||||
color={"green"}
|
||||
leftIcon={<IconEyeCheck />}
|
||||
radius={"xl"}
|
||||
onClick={() => {
|
||||
openPublish();
|
||||
setDataId(e.id);
|
||||
setTanggalMulai(e.awalVote);
|
||||
}}
|
||||
>
|
||||
Detail
|
||||
</Button>
|
||||
</Center>
|
||||
</td>
|
||||
</tr>
|
||||
));
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<Stack spacing={"xs"} h={"100%"}>
|
||||
<ComponentAdminGlobal_TitlePage
|
||||
name="Review"
|
||||
color={AdminColor.softBlue}
|
||||
component={
|
||||
<TextInput
|
||||
icon={<IconSearch size={20} />}
|
||||
radius={"xl"}
|
||||
placeholder="Masukan judul"
|
||||
onChange={(val) => {
|
||||
onSearch(val.currentTarget.value);
|
||||
}}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
|
||||
{!data ? (
|
||||
<CustomSkeleton height={"80vh"} width="100%" />
|
||||
) : _.isEmpty(data) ? (
|
||||
<ComponentAdminGlobal_IsEmptyData />
|
||||
) : (
|
||||
<Paper p={"md"} bg={AdminColor.softBlue} shadow="lg" h={"80vh"}>
|
||||
{isShowReload && (
|
||||
<Affix position={{ top: rem(200) }} w={"100%"}>
|
||||
<Center>
|
||||
<Button
|
||||
style={{
|
||||
transition: "0.5s",
|
||||
border: `1px solid ${AccentColor.skyblue}`,
|
||||
}}
|
||||
bg={AccentColor.blue}
|
||||
loaderPosition="center"
|
||||
loading={isLoading}
|
||||
radius={"xl"}
|
||||
opacity={0.8}
|
||||
onClick={() => onLoadData()}
|
||||
leftIcon={<IconRefresh />}
|
||||
>
|
||||
Update Data
|
||||
</Button>
|
||||
</Center>
|
||||
</Affix>
|
||||
)}
|
||||
|
||||
<ScrollArea w={"100%"} h={"90%"}>
|
||||
<Table
|
||||
verticalSpacing={"md"}
|
||||
horizontalSpacing={"md"}
|
||||
p={"md"}
|
||||
w={1120}
|
||||
>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
<Center c={AccentColor.white}>Username</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AccentColor.white}>Judul</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AccentColor.white}>Pilihan</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AccentColor.white}>Aksi</Center>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>{renderTableBody()}</tbody>
|
||||
</Table>
|
||||
</ScrollArea>
|
||||
|
||||
<Center mt={"xl"}>
|
||||
<Pagination
|
||||
value={isActivePage}
|
||||
total={nPage}
|
||||
onChange={(val) => {
|
||||
onPageClick(val);
|
||||
}}
|
||||
/>
|
||||
</Center>
|
||||
</Paper>
|
||||
)}
|
||||
</Stack>
|
||||
|
||||
<Modal
|
||||
styles={{ body: { backgroundColor: AdminColor.softBlue}}}
|
||||
opened={openedReject}
|
||||
onClose={closeReject}
|
||||
centered
|
||||
withCloseButton={false}
|
||||
size={"md"}
|
||||
>
|
||||
<Stack >
|
||||
<Textarea
|
||||
styles={{ label: { color: AdminColor.white } }}
|
||||
minRows={2}
|
||||
maxRows={5}
|
||||
maxLength={300}
|
||||
autosize
|
||||
label="Masukan Alasan Penolakan"
|
||||
placeholder="Contoh: Karena deskripsi kurang lengkap, dll"
|
||||
onChange={(val) => {
|
||||
setCatatan(val.target.value);
|
||||
}}
|
||||
/>
|
||||
<Group position="right">
|
||||
<Button radius={"xl"} onClick={() => closeReject()}>
|
||||
Batal
|
||||
</Button>
|
||||
<Button
|
||||
loaderPosition="center"
|
||||
loading={isSaveLoading ? true : false}
|
||||
radius={"xl"}
|
||||
onClick={() => {
|
||||
onReject();
|
||||
}}
|
||||
style={{
|
||||
backgroundColor: MainColor.green,
|
||||
}}
|
||||
>
|
||||
Simpan
|
||||
</Button>
|
||||
</Group>
|
||||
</Stack>
|
||||
</Modal>
|
||||
<Modal
|
||||
styles={{ body: { backgroundColor: AdminColor.softBlue}}}
|
||||
opened={openedPublish}
|
||||
onClose={closePublish}
|
||||
centered
|
||||
withCloseButton={false}
|
||||
size={"md"}
|
||||
>
|
||||
<Stack align="center">
|
||||
<Title c={AdminColor.white} order={5}>Apakah anda yakin ingin mempublish vote ini?</Title>
|
||||
<Group position="center">
|
||||
<Button radius={"xl"} onClick={() => closePublish()}>
|
||||
Batal
|
||||
</Button>
|
||||
<Button
|
||||
loaderPosition="center"
|
||||
loading={isLoadingPublish ? true : false}
|
||||
radius={"xl"}
|
||||
onClick={() => {
|
||||
onPublish();
|
||||
}}
|
||||
style={{
|
||||
backgroundColor: MainColor.green,
|
||||
}}
|
||||
>
|
||||
Simpan
|
||||
</Button>
|
||||
</Group>
|
||||
</Stack>
|
||||
</Modal>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -121,6 +121,7 @@ export interface Model_Status_Transaksi_Investasi {
|
||||
}
|
||||
|
||||
export interface MODEL_INVOICE_INVESTASI {
|
||||
Profile: any;
|
||||
id: string;
|
||||
isActive: boolean;
|
||||
createdAt: Date;
|
||||
|
||||
@@ -12,4 +12,5 @@ export const RouterAdminInvestasi = {
|
||||
detail_review: "/dev/admin/investasi/detail/review/",
|
||||
detail_reject: "/dev/admin/investasi/detail/reject/",
|
||||
bukti_transfer: "/dev/admin/investasi/bukti-transfer/",
|
||||
detail_transaksi: "/dev/admin/investasi/detail/transaksi/",
|
||||
};
|
||||
|
||||
@@ -35,6 +35,7 @@ const middlewareConfig: MiddlewareConfig = {
|
||||
// ADMIN API
|
||||
// >> buat dibawah sini <<
|
||||
"/api/admin/donasi/*",
|
||||
"/api/admin/investasi/*",
|
||||
|
||||
|
||||
// Akses awal
|
||||
|
||||
Reference in New Issue
Block a user