(null);
- if (!data) {
- return (
- <>
-
- >
- );
- }
+ useShallowEffect(() => {
+ onLoadData();
+ }, []);
+
+ async function onLoadData() {
+ try {
+ const respone = await apiGetEventDetailById({
+ id: eventId,
+ });
+
+ if (respone) {
+ setData(respone.data);
+ }
+ } catch (error) {
+ clientLogger.error("Error get data detail event", error);
+ }
+ }
return (
<>
- {/* {JSON.stringify(dataEvent.tanggal)} */}
- {data?.catatan ? (
-
- ) : (
- ""
- )}
-
-
+
+
>
);
}
-function ButtonAction({
- eventId,
- tanggalSelesai,
-}: {
- eventId: string;
- tanggalSelesai?: any;
-}) {
+function ButtonAction({ eventId, endDate }: { eventId: string; endDate: 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 {
+ 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);
- ComponentGlobal_NotifikasiGagal(res.message);
+ clientLogger.error("Error delete event", error);
}
} catch (error) {
+ console.log("Error delete event", error);
setLoadingDelete(false);
- clientLogger.error("Error delete event", error);
}
}
async function onAjukan() {
- if (
- moment(tanggalSelesai.toISOString().toString()).diff(
- moment(),
- "minutes"
- ) < 0
- )
+ if (moment(endDate.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);
+ try {
setLoadingAjukan(true);
- router.replace(RouterEvent.status({ id: "2" }));
- } else {
- ComponentGlobal_NotifikasiGagal(res.message);
+ 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);
+ router.replace(RouterEvent.status({ id: "2" }));
+ } else {
+ setLoadingAjukan(false);
+ ComponentGlobal_NotifikasiGagal(res.message);
+ }
+ } catch (error) {
+ setLoadingAjukan(false);
+ clientLogger.error("Error ajukan event", error);
}
}
return (
<>
-
-
-
-
+ {!endDate ? (
+
+
+
+
+ ) : (
+
+
+
+
+ )}
{/* MODAL AJUKAN */}
setOpenModal1(false)}
buttonKiri={
-