"use client"; import { IRealtimeData } from "@/app/lib/global_state"; import { RouterEvent } from "@/app/lib/router_hipmi/router_event"; 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 { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global/notifikasi_peringatan"; import UIGlobal_Modal from "@/app_modules/_global/ui/ui_modal"; import notifikasiToAdmin_funCreate from "@/app_modules/notifikasi/fun/create/create_notif_to_admin"; import { Button, Group, Stack } from "@mantine/core"; import moment from "moment"; import { useRouter } from "next/navigation"; import { useState } from "react"; import { WibuRealtime } from "wibu-pkg"; import { Event_ComponentSkeletonDetailData } from "../../component"; import ComponentEvent_DetailData from "../../component/detail/detail_data"; import { Event_funDeleteById } from "../../fun/delete/fun_delete"; import { Event_funEditStatusById } from "../../fun/edit/fun_edit_status_by_id"; import { MODEL_EVENT } from "../../_lib/interface"; import { AccentColor, MainColor } from "@/app_modules/_global/color"; import { clientLogger } from "@/util/clientLogger"; export default function Event_DetailDraft({ dataEvent, eventId, }: { dataEvent: MODEL_EVENT; eventId: string; }) { const [data, setData] = useState(dataEvent); if (!data) { return ( <> ); } return ( <> {/*
{JSON.stringify(dataEvent.tanggal)}
*/} {data?.catatan ? ( ) : ( "" )} ); } function ButtonAction({ eventId, tanggalSelesai, }: { eventId: string; tanggalSelesai?: any; }) { const router = useRouter(); const [isLoadingDelete, setLoadingDelete] = useState(false); const [isLoadingAjukan, setLoadingAjukan] = useState(false); const [openModal1, setOpenModal1] = useState(false); const [openModal2, setOpenModal2] = useState(false); async function onDelete() { const res = await Event_funDeleteById(eventId); try { setLoadingDelete(true); if (res.status === 200) { router.back(); ComponentGlobal_NotifikasiBerhasil(res.message, 2000); } else { setLoadingDelete(false); ComponentGlobal_NotifikasiGagal(res.message); } } catch (error) { setLoadingDelete(false); clientLogger.error("Error delete event", error); } } async function onAjukan() { if ( moment(tanggalSelesai.toISOString().toString()).diff( moment(), "minutes" ) < 0 ) return ComponentGlobal_NotifikasiPeringatan("Waktu acara telah lewat"); const res = await Event_funEditStatusById("2", eventId); 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: "Mengajukan review", }; const notif = await notifikasiToAdmin_funCreate({ data: dataNotifikasi as any, }); if (notif.status === 201) { WibuRealtime.setData({ type: "notification", pushNotificationTo: "ADMIN", }); WibuRealtime.setData({ type: "trigger", pushNotificationTo: "ADMIN", dataMessage: dataNotifikasi, }); } ComponentGlobal_NotifikasiBerhasil(res.message, 2000); setLoadingAjukan(true); router.replace(RouterEvent.status({ id: "2" })); } else { ComponentGlobal_NotifikasiGagal(res.message); } } return ( <> {/* MODAL AJUKAN */} setOpenModal1(false)} buttonKiri={ } buttonKanan={ } /> {/* MODAL HAPUS */} setOpenModal2(false)} buttonKiri={ } buttonKanan={ } /> ); }