"use client"; import { Stack, Group, Title, Paper, ScrollArea, Table, Center, Text, Badge, Spoiler, Pagination, Button, Modal, TextInput, Textarea, Box, } from "@mantine/core"; import ComponentAdminGlobal_HeaderTamplate from "../../_admin_global/header_tamplate"; import { MODEL_COLLABORATION } from "@/app_modules/colab/model/interface"; import { useState } from "react"; import { useDisclosure, useShallowEffect } from "@mantine/hooks"; import adminColab_getListAllPublish from "../fun/get/get_list_all_publish"; import ComponentAdminColab_DetailData from "../component/detail_data"; import adminColab_getOneByColabId from "../fun/get/get_one_by_colab_id"; import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global/notifikasi_peringatan"; import _ from "lodash"; import { IconBan, IconCheck, IconEye } from "@tabler/icons-react"; import adminColab_funReportProjectById from "../fun/edit/fun_report_project_by_id"; import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil"; export default function AdminColab_TablePublish({ listData, }: { listData: any; }) { return ( <> {/*
{JSON.stringify(listData.nPage, null, 2)}
*/}
); } function TableMenu({ listData }: { listData: any }) { const [data, setData] = useState(listData.data); const [isNPage, setNPage] = useState(listData.nPage); const [activePage, setActivePage] = useState(1); const [idProject, setIdProject] = useState(""); const [openDetail, setOpenDetail] = useState(false); const [loadingDetail, setLoadingDetail] = useState(false); const [detailData, setDetailData] = useState(); const [openReject, setOpenReject] = useState(false); const [report, setReport] = useState(""); const [loadingReject, setLoadingReject] = useState(false); const [loadingReport, setLoadingReport] = useState(false); // PAGINATION dan No awal data di tampilkan let noAwal = activePage * 5 - 4; async function onLoad(pindahPage: any) { const load = await adminColab_getListAllPublish({ page: pindahPage }); setActivePage(pindahPage); setData(load.data as any); setNPage(load.nPage); } // Table Body const tableRow = data.map((e, i) => (
{noAwal++}
{e?.Author?.Profile?.name}
{e?.title}
{e?.ProjectCollaborationMaster_Industri.name}
{e?.ProjectCollaboration_Partisipasi.length}
)); // Menampilkan Detail Data async function getDetailData(colabId: any) { setLoadingDetail(true); setIdProject(colabId); await adminColab_getOneByColabId({ id: colabId }).then((res) => { if (res.status === 200) { setDetailData(res.data as any); setOpenDetail(true); setLoadingDetail(false); } else { ComponentGlobal_NotifikasiPeringatan("Gagal Load"); } }); } // Menampilkan Data Title yang akan di REJECT async function onRejected(colabId: string) { setLoadingReject(true); setIdProject(colabId); await adminColab_getOneByColabId({ id: colabId }).then((res) => { if (res.status === 200) { const selectedData = _.omit(res.data, [ "Author", "ProjectCollaborationMaster_Industri", "ProjectCollaboration_Partisipasi", "benefit", "createdAt", "purpose", "lokasi", ]); setDetailData(selectedData as any); setOpenReject(true); setLoadingReject(false); } else { ComponentGlobal_NotifikasiPeringatan("Gagal Load"); } }); } // Update status report pada project async function onReport() { if (report === "") return ComponentGlobal_NotifikasiPeringatan("Lengkapi Alasan Report"); await adminColab_funReportProjectById({ colabId: idProject, report: report, }).then(async (res) => { if (res.status === 200) { const newData = await adminColab_getListAllPublish({ page: activePage, }); setActivePage(activePage); setData(newData.data as any); setNPage(newData.nPage); setOpenReject(false); ComponentGlobal_NotifikasiBerhasil(res.message); } else { ComponentGlobal_NotifikasiPeringatan(res.message); } }); } return ( <> Publish {tableRow}
No
Username
Title
Industri
Jumlah Partisipan
Aksi
{ onLoad(val); }} />
{/* Detail Data */} setOpenDetail(false)} centered withCloseButton={false} size={"lg"} > {/* Reject Project */} setOpenReject(false)} centered withCloseButton={false} size={"lg"} > Apakah anda yakin ingin mereport project{" "} {detailData?.title} ? {" "}