# Fix
- Loading card
- Create : saat memilih jam sesuai dengan batas jam di hari itu
## No isuuee
This commit is contained in:
2024-05-23 17:17:40 +08:00
parent 10cf9c3a46
commit 166b1349f5
22 changed files with 484 additions and 400 deletions

View File

@@ -1,6 +1,6 @@
"use client";
import { Button, Group, Stack } from "@mantine/core";
import { Button, Group, Modal, Stack, Title } from "@mantine/core";
import ComponentEvent_DetailData from "../../component/detail/detail_data";
import { AppRouterInstance } from "next/dist/shared/lib/app-router-context.shared-runtime";
@@ -13,6 +13,10 @@ import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/component_global/
import React, { useState } from "react";
import ComponentEvent_CatatanReject from "../../component/catatan_reject";
import { useRouter } from "next/navigation";
import moment from "moment";
import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/component_global/notif_global/notifikasi_peringatan";
import { Event_funDeleteById } from "../../fun/delete/fun_delete";
import { useDisclosure } from "@mantine/hooks";
export default function Event_DetailDraft({
dataEvent,
@@ -29,25 +33,42 @@ export default function Event_DetailDraft({
""
)}
<ComponentEvent_DetailData data={dataEvent} />
<ButtonAction eventId={dataEvent?.id} />
<ButtonAction eventId={dataEvent?.id} tanggal={dataEvent.tanggal} />
</Stack>
</>
);
}
function ButtonAction({ eventId }: { eventId: string }) {
function ButtonAction({ eventId, tanggal }: { eventId: string; tanggal: any }) {
const router = useRouter();
const [isLoadingDelete, setLoadingDelete] = useState(false);
const [isLoadingAjukan, setLoadingAjukan] = useState(false);
const [tabsStatus, setTabsStatus] = useAtom(gs_event_status);
const [opened, { open, close }] = useDisclosure(false);
async function onDelete() {
console.log(eventId);
await Event_funDeleteById(eventId).then((res) => {
if (res.status === 200) {
ComponentGlobal_NotifikasiBerhasil(res.message, 2000);
setLoadingDelete(true);
setTabsStatus("Draft");
close();
router.back();
} else {
ComponentGlobal_NotifikasiGagal(res.message);
}
});
}
async function onAjukan() {
if (moment(tanggal.toISOString().toString()).diff(moment(), "minutes") < 0)
return ComponentGlobal_NotifikasiPeringatan("Waktu acara telah lewat");
await Event_funEditStatusById("2", eventId).then((res) => {
if (res.status === 200) {
ComponentGlobal_NotifikasiBerhasil(res.message, 2000);
setTabsStatus("Review");
setLoadingAjukan(true);
router.back();
} else {
ComponentGlobal_NotifikasiGagal(res.message);
@@ -57,8 +78,32 @@ function ButtonAction({ eventId }: { eventId: string }) {
return (
<>
<Modal opened={opened} onClose={close} centered withCloseButton={false}>
<Stack>
<Title order={6}>Yakin akan menghapus event ini?</Title>
<Group position="center">
<Button radius={"xl"} onClick={close}>
Batal
</Button>
<Button
loaderPosition="center"
loading={isLoadingDelete ? true : false}
radius={"xl"}
onClick={() => {
onDelete();
}}
color="red"
>
Hapus
</Button>
</Group>
</Stack>
</Modal>
<Group grow>
<Button
loaderPosition="center"
loading={isLoadingAjukan ? true : false}
radius={"xl"}
color="yellow"
onClick={() => {
@@ -71,7 +116,7 @@ function ButtonAction({ eventId }: { eventId: string }) {
radius={"xl"}
color="red"
onClick={() => {
// onClick(router, setTabsStatus, dataEvent.id);
open();
}}
>
Hapus