"use client"; import { AccentColor, MainColor } from "@/app_modules/_global/color"; import ComponentGlobal_BoxInformation from "@/app_modules/_global/component/box_information"; import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil"; import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal"; import UIGlobal_Modal from "@/app_modules/_global/ui/ui_modal"; import CustomSkeleton from "@/app_modules/components/CustomSkeleton"; import { RouterVote } from "@/lib/router_hipmi/router_vote"; import { clientLogger } from "@/util/clientLogger"; import { Button, SimpleGrid, Stack } from "@mantine/core"; import { useShallowEffect } from "@mantine/hooks"; import { useParams, useRouter } from "next/navigation"; import { useState } from "react"; import { apiGetOneVotingById } from "../../_lib/api_voting"; import ComponentVote_DetailDataSebelumPublish from "../../component/detail/detail_data_sebelum_publish"; import { Vote_funDeleteById } from "../../fun/delete/fun_delete_by_id"; import { Vote_funEditStatusByStatusId } from "../../fun/edit/fun_edit_status_by_id"; import { MODEL_VOTING } from "../../model/interface"; export default function Vote_DetailReject() { const { id } = useParams(); const [data, setData] = useState(); useShallowEffect(() => { onLoadData(); }, []); async function onLoadData() { try { const response = await apiGetOneVotingById({ id: id as string }); if (response) { setData(response.data); } else { setData(null); } } catch (error) { console.log(error); } } if (!data) return ; return ( <> ); } function ButtonAction({ voteId }: { voteId: string }) { const router = useRouter(); const [openModal1, setOpenModal1] = useState(false); const [openModal2, setOpenModal2] = useState(false); const [isLoading, setIsLoading] = useState(false); async function onUpdate() { await Vote_funEditStatusByStatusId(voteId, "3").then((res) => { try { setIsLoading(true); if (res.status === 200) { ComponentGlobal_NotifikasiBerhasil("Berhasil Masuk Draft", 2000); router.replace(RouterVote.status({ id: "3" })); } else { setIsLoading(false); ComponentGlobal_NotifikasiGagal(res.message); } } catch (error) { setIsLoading(false); clientLogger.error("Error update voting", error); } }); } async function onDelete() { await Vote_funDeleteById(voteId).then((res) => { try { setIsLoading(true); if (res.status === 200) { setOpenModal2(false); ComponentGlobal_NotifikasiBerhasil("Berhasil Hapus Vote", 2000); router.replace(RouterVote.status({ id: "4" })); } else { setIsLoading(false); ComponentGlobal_NotifikasiGagal(res.message); } } catch (error) { setIsLoading(false); clientLogger.error("Error delete vote", error); } }); } return ( <> {" "} setOpenModal1(false)} buttonKiri={ } buttonKanan={ } /> {/* MODAL HAPUS */} setOpenModal2(false)} buttonKiri={ } buttonKanan={ } /> ); }