Fix: Event
Deksripsi - Fix notifikasi - Fix load beranda - Fix reload button di admin
This commit is contained in:
@@ -0,0 +1,91 @@
|
||||
import { IRealtimeData } from "@/app/lib/global_state";
|
||||
import { RouterEvent } from "@/app/lib/router_hipmi/router_event";
|
||||
import { MainColor } from "@/app_modules/_global/color";
|
||||
import {
|
||||
ComponentGlobal_NotifikasiBerhasil,
|
||||
ComponentGlobal_NotifikasiGagal,
|
||||
} from "@/app_modules/_global/notif_global";
|
||||
import { notifikasiToAdmin_funCreate } from "@/app_modules/notifikasi/fun";
|
||||
import { Button } from "@mantine/core";
|
||||
import { useAtom } from "jotai";
|
||||
import moment from "moment";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import { WibuRealtime } from "wibu-pkg";
|
||||
import { Event_funCreate } from "../../fun/create/fun_create";
|
||||
import { gs_event_hotMenu } from "../../global_state";
|
||||
|
||||
export default function Event_ComponentCreateButton({ value }: { value: any }) {
|
||||
const router = useRouter();
|
||||
const [hotMenu, setHotMenu] = useAtom(gs_event_hotMenu);
|
||||
const [isLoading, setLoading] = useState(false);
|
||||
|
||||
async function onSave() {
|
||||
const res = await Event_funCreate(value);
|
||||
|
||||
if (res.status === 201) {
|
||||
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: "Event baru",
|
||||
};
|
||||
|
||||
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);
|
||||
setHotMenu(1);
|
||||
setLoading(true);
|
||||
router.push(RouterEvent.status({ id: "2" }), { scroll: false });
|
||||
}
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Button
|
||||
style={{
|
||||
transition: "0.5s",
|
||||
}}
|
||||
disabled={
|
||||
value.title === "" ||
|
||||
value.lokasi === "" ||
|
||||
value.deskripsi === "" ||
|
||||
value.eventMaster_TipeAcaraId === 0 ||
|
||||
value.tanggal === "function Date() { [native code] }" ||
|
||||
moment(value.tanggal).diff(moment(), "minutes") < 0
|
||||
}
|
||||
loaderPosition="center"
|
||||
loading={isLoading ? true : false}
|
||||
radius={"xl"}
|
||||
mt={"xl"}
|
||||
onClick={() => {
|
||||
onSave();
|
||||
}}
|
||||
bg={MainColor.yellow}
|
||||
color="yellow"
|
||||
c={"black"}
|
||||
>
|
||||
Simpan
|
||||
</Button>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
import Event_ComponentCreateButton from "./button/button_create_event";
|
||||
import { Event_ComponentSkeletonDetailData } from "./skeleton/comp_skeleton_detail_data";
|
||||
|
||||
export { Event_ComponentSkeletonDetailData };
|
||||
export { Event_ComponentCreateButton };
|
||||
|
||||
Reference in New Issue
Block a user