Fix: Event

Deskripsi:
- Fix database event
- Fix style detal
This commit is contained in:
2024-11-29 16:15:54 +08:00
parent 517b2bb9b0
commit 45279cd37f
36 changed files with 714 additions and 611 deletions

View File

@@ -13,6 +13,10 @@ import { useState } from "react";
import ComponentEvent_DetailData from "../../component/detail/detail_data";
import { Event_funEditStatusById } from "../../fun/edit/fun_edit_status_by_id";
import { MODEL_EVENT } from "../../model/interface";
import { IRealtimeData } from "@/app/lib/global_state";
import { WibuRealtime } from "wibu-pkg";
import { event_checkStatus } from "../../fun/get/fun_check_status_by_id";
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/notif_global";
export default function Event_DetailReview({
dataEvent,
@@ -35,11 +39,7 @@ function ButtonAction({ eventId }: { eventId: string }) {
const [openModal, setOpenModal] = useState(false);
return (
<>
<Button
radius={"xl"}
color={"orange"}
onClick={() => setOpenModal(true)}
>
<Button radius={"xl"} color={"orange"} onClick={() => setOpenModal(true)}>
Batalkan Review
</Button>
@@ -73,34 +73,44 @@ async function onClick(
eventId: string,
setLoading: any
) {
const res = await Event_funEditStatusById("3", eventId);
if (res.status === 200) {
const dataNotif: any = {
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: "Membatalkan review",
};
const checkStatus = await event_checkStatus({ id: eventId });
const notif = await notifikasiToAdmin_funCreate({
data: dataNotif as any,
});
if (checkStatus) {
const res = await Event_funEditStatusById("3", 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: "Membatalkan review",
};
if (notif.status === 201) {
mqtt_client.publish(
"ADMIN",
JSON.stringify({
count: 1,
})
);
const notif = await notifikasiToAdmin_funCreate({
data: dataNotifikasi as any,
});
ComponentGlobal_NotifikasiBerhasil(res.message, 1500);
setLoading(true);
router.replace(RouterEvent.status({ id: "3" }));
if (notif.status === 201) {
WibuRealtime.setData({
type: "notification",
pushNotificationTo: "ADMIN",
});
WibuRealtime.setData({
type: "trigger",
pushNotificationTo: "ADMIN",
dataMessage: dataNotifikasi,
});
ComponentGlobal_NotifikasiBerhasil(res.message, 1500);
setLoading(true);
router.replace(RouterEvent.status({ id: "3" }));
}
} else {
ComponentGlobal_NotifikasiGagal(res.message);
}
} else {
ComponentGlobal_NotifikasiGagal(res.message);
ComponentGlobal_NotifikasiPeringatan("Event telah direview admin");
}
}