"use client";
import { RouterProfile } from "@/app/lib/router_hipmi/router_katalog";
import ComponentAdminGlobal_HeaderTamplate from "@/app_modules/admin/component/header_tamplate";
import { AdminEvent_getListPesertaById } from "@/app_modules/admin/event/fun/get/get_list_peserta_by_id";
import { MODEL_VOTING } from "@/app_modules/vote/model/interface";
import {
Avatar,
Box,
Button,
Center,
Divider,
Grid,
Group,
Modal,
Paper,
ScrollArea,
Spoiler,
Stack,
Table,
Text,
Textarea,
Title,
} from "@mantine/core";
import { useDisclosure } from "@mantine/hooks";
import { IconBan } from "@tabler/icons-react";
import { IconEyeShare } from "@tabler/icons-react";
import _ from "lodash";
import { useRouter } from "next/navigation";
import { useState } from "react";
import { AdminVote_funEditStatusPublishById } from "../../fun/edit/fun_edit_status_publish_by_id";
import toast from "react-simple-toasts";
import { AdminVote_getListTableByStatusId } from "../../fun/get/get_list_table_by_status_id";
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/component_global/notif_global/notifikasi_berhasil";
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/component_global/notif_global/notifikasi_gagal";
import { AdminEvent_funEditCatatanById } from "../../fun/edit/fun_edit_status_reject_by_id";
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/component_global/notif_global/notifikasi_peringatan";
export default function AdminVote_TableReview({
listVote,
}: {
listVote: MODEL_VOTING[];
}) {
return (
<>
>
);
}
function TableStatus({ listData }: { listData: MODEL_VOTING[] }) {
const router = useRouter();
const [opened, { open, close }] = useDisclosure(false);
const [data, setData] = useState(listData);
const [votingId, setVotingId] = useState("");
const [catatan, setCatatan] = useState("");
const TableRows = data.map((e, i) => (
|
{e.title}
|
{e.deskripsi}
|
{e.Voting_DaftarNamaVote.map((v) => (
- {v.value}
))}
|
{e.awalVote.toLocaleDateString("id-ID", { dateStyle: "long" })}
|
{e.akhirVote.toLocaleDateString("id-ID", { dateStyle: "long" })}
|
}
radius={"xl"}
onClick={() => onPublish(e.id, setData, e.awalVote)}
>
Publish
}
radius={"xl"}
onClick={() => {
open();
setVotingId(e.id);
}}
>
Reject
|
));
return (
<>
REVIEW
|
Judul
|
Deskripsi
|
Pilihan
|
Mulai Vote
|
Selesai Vote
|
Aksi
|
{TableRows}
{_.isEmpty(TableRows) ? (
Tidak Ada Data
) : (
""
)}
>
);
}
async function onPublish(voteId: string, setData: any, awalVote: Date) {
const hariIni = new Date();
if (awalVote < hariIni)
return ComponentGlobal_NotifikasiPeringatan(
"Tanggal Mulai Votig Lewat, Edit Kembali",
1500
);
await AdminVote_funEditStatusPublishById(voteId).then(async (res) => {
if (res.status === 200) {
await AdminVote_getListTableByStatusId("2").then((val) => {
setData(val);
ComponentGlobal_NotifikasiBerhasil(res.message);
});
} else {
ComponentGlobal_NotifikasiGagal(res.message);
}
});
}
async function onReject(
voteId: string,
setData: any,
catatan: string,
close: any
) {
const data = {
id: voteId,
catatan: catatan,
};
await AdminEvent_funEditCatatanById(data as any).then(async (res) => {
if (res.status === 200) {
await AdminVote_getListTableByStatusId("2").then((val) => {
setData(val);
ComponentGlobal_NotifikasiBerhasil(res.message);
close();
});
} else {
ComponentGlobal_NotifikasiGagal(res.message);
}
});
}