From ba8ca9a883dbc74fabbfc425fb525e85ccbae201 Mon Sep 17 00:00:00 2001 From: nico Date: Fri, 10 Jan 2025 17:15:14 +0800 Subject: [PATCH] Fix Button Loading All Menu Execpt Joba vacancy --- bun.lockb | Bin 716700 -> 716700 bytes src/app/dev/donasi/detail/draft/[id]/page.tsx | 1 + .../comp_button_delete_donasi_by_id.tsx | 54 +++++--- .../donasi/detail/detail_draft/index.tsx | 24 +++- .../donasi/detail/detail_reject/index.tsx | 9 +- .../donasi/detail/detail_review/index.tsx | 3 +- src/app_modules/event/detail/draft/index.tsx | 7 +- src/app_modules/event/detail/reject/index.tsx | 8 +- src/app_modules/event/detail/review/index.tsx | 2 +- .../detail/portofolio/view_detail_draft.tsx | 126 ++++++++++-------- .../detail/portofolio/view_detail_reject.tsx | 73 +++++++--- .../detail/portofolio/view_detail_review.tsx | 54 ++++---- .../investasi/fun/fun_delete_donasi.ts | 22 +++ src/app_modules/vote/detail/draft/index.tsx | 3 +- src/app_modules/vote/detail/reject/index.tsx | 3 + src/app_modules/vote/detail/review/index.tsx | 2 +- 16 files changed, 251 insertions(+), 140 deletions(-) create mode 100644 src/app_modules/investasi/fun/fun_delete_donasi.ts diff --git a/bun.lockb b/bun.lockb index 6ecc0fa08c2a033c3e569ae708ad7dd24b6c44f8..8d2a8fec559e000218fcaad39579b9876212f6c0 100755 GIT binary patch delta 8341 zcmZA62Y63+-^cOu7db*=#!7;Sh)5zxA_*c0iqzga#9py?=${HotBPBHZH?Bf_U=-v zMkrbp9o;%K4qo`JFxd&)2GJA*-&1%uaEn6iRVPDV*ZE z&F+}$jIynQA&{|ymN$H~T~o(CWEHeukY<(0N^2I(*oEoJD5F`Z_NzixO0(M9&zJ0y zD}OA@oJzG1#P^b=85-+C!L)m8)^**t;^YkdwOcgp zHy#C%HGs^;Y~OF!iA^l}HX5qkVwmip*)Ulf(~Zzwvk}@amaMDs`_;ZwF3ycM!(^Qm zPrIopeZa2Z@G?OMY=6g8)9!%1)lttl4%(iMF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#A}R0V$XL@3Kvp{*v8|WlSqb4Xqxou=(o diff --git a/src/app/dev/donasi/detail/draft/[id]/page.tsx b/src/app/dev/donasi/detail/draft/[id]/page.tsx index f15353f6..c251cc42 100644 --- a/src/app/dev/donasi/detail/draft/[id]/page.tsx +++ b/src/app/dev/donasi/detail/draft/[id]/page.tsx @@ -4,6 +4,7 @@ import { Donasi_getOneById } from "@/app_modules/donasi/fun/get/get_one_donasi_b export default async function Page({ params }: { params: { id: string } }) { const donasiId = params.id const dataDonasi = await Donasi_getOneById(donasiId); + return ( <> diff --git a/src/app_modules/donasi/component/button/comp_button_delete_donasi_by_id.tsx b/src/app_modules/donasi/component/button/comp_button_delete_donasi_by_id.tsx index 62005ea4..572eb3d1 100644 --- a/src/app_modules/donasi/component/button/comp_button_delete_donasi_by_id.tsx +++ b/src/app_modules/donasi/component/button/comp_button_delete_donasi_by_id.tsx @@ -14,6 +14,7 @@ import { useAtom } from "jotai"; import { gs_donasi_tabs_posting } from "../../global_state"; import { useRouter } from "next/navigation"; import { AccentColor, MainColor } from "@/app_modules/_global/color"; +import { clientLogger } from "@/util/clientLogger"; export function Donasi_ComponentButtonDeleteDonasiById({ donasiId, @@ -25,6 +26,7 @@ export function Donasi_ComponentButtonDeleteDonasiById({ imageId: string; }) { const router = useRouter(); + const [isLoading, setLoading] = useState(false); const [openModal, setOpenModal] = useState(false); const [tabsPostingDonasi, setTabsPostingDonasi] = useAtom( gs_donasi_tabs_posting @@ -32,28 +34,35 @@ export function Donasi_ComponentButtonDeleteDonasiById({ async function onDelete() { const del = await Donasi_funDeleteDonasiById(donasiId); - if (del.status === 200) { - const deleteImageDonasi = await funGlobal_DeleteFileById({ - fileId: imageId as any, - }); + try { + setLoading(true); + if (del.status === 200) { + const deleteImageDonasi = await funGlobal_DeleteFileById({ + fileId: imageId as any, + }); - if (!deleteImageDonasi.success) { - ComponentGlobal_NotifikasiPeringatan("Gagal hapus gambar "); + if (!deleteImageDonasi.success) { + ComponentGlobal_NotifikasiPeringatan("Gagal hapus gambar "); + } + + const deleteImageCerita = await funGlobal_DeleteFileById({ + fileId: imageCeritaId as any, + }); + + if (!deleteImageCerita.success) { + ComponentGlobal_NotifikasiPeringatan("Gagal hapus gambar "); + } + + router.replace(RouterDonasi.status_galang_dana({ id: "3" })); + setTabsPostingDonasi("Draft"); + ComponentGlobal_NotifikasiBerhasil(del.message); + } else { + setLoading(false); + ComponentGlobal_NotifikasiGagal(del.message); } - - const deleteImageCerita = await funGlobal_DeleteFileById({ - fileId: imageCeritaId as any, - }); - - if (!deleteImageCerita.success) { - ComponentGlobal_NotifikasiPeringatan("Gagal hapus gambar "); - } - - router.replace(RouterDonasi.status_galang_dana({ id: "3" })); - setTabsPostingDonasi("Draft"); - ComponentGlobal_NotifikasiBerhasil(del.message); - } else { - ComponentGlobal_NotifikasiGagal(del.message); + } catch (error) { + setLoading(false); + clientLogger.error("Error delete donasi", error); } } @@ -75,12 +84,13 @@ export function Donasi_ComponentButtonDeleteDonasiById({ opened={openModal} close={() => setOpenModal(false)} buttonKiri={ - } buttonKanan={ - } diff --git a/src/app_modules/donasi/detail/detail_draft/index.tsx b/src/app_modules/donasi/detail/detail_draft/index.tsx index 7b9f9466..91b45293 100644 --- a/src/app_modules/donasi/detail/detail_draft/index.tsx +++ b/src/app_modules/donasi/detail/detail_draft/index.tsx @@ -17,11 +17,15 @@ import { MODEL_DONASI } from "../../model/interface"; import { IRealtimeData } from "@/app/lib/global_state"; import { WibuRealtime } from "wibu-pkg"; import { AccentColor, MainColor } from "@/app_modules/_global/color"; +import funDeleteDonasi from "@/app_modules/investasi/fun/fun_delete_donasi"; +import { clientLogger } from "@/util/clientLogger"; +import { funGlobal_DeleteFileById } from "@/app_modules/_global/fun"; +import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global"; export default function DetailDraftDonasi({ dataDonasi, }: { - dataDonasi: MODEL_DONASI; + dataDonasi: MODEL_DONASI; }) { const [data, setData] = useState(dataDonasi); @@ -45,15 +49,19 @@ export default function DetailDraftDonasi({ function ButtonAjukanPenggalangan({ dataDonasi, + }: { dataDonasi: MODEL_DONASI; + }) { const router = useRouter(); - const [isLoading, setLoading] = useState(false); + const [isLoadingAjukan, setLoadingAjukan] = useState(false); + const [isLoadingDelete, setLoadingDelete] = useState(false); const [openModal, setOpenModal] = useState(false); async function onChangeStatus() { const res = await Donasi_funGantiStatus(dataDonasi.id, "2"); + try { if (res.status === 200) { const dataNotifikasi: IRealtimeData = { @@ -81,13 +89,18 @@ function ButtonAjukanPenggalangan({ dataMessage: dataNotifikasi, }); - setLoading(true); + setLoadingAjukan(true); ComponentGlobal_NotifikasiBerhasil("Berhasil Diajukan"); router.push(RouterDonasi.status_galang_dana({ id: "2" })); } } else { + setLoadingAjukan(false); ComponentGlobal_NotifikasiPeringatan(res.message); } + } catch (error) { + setLoadingAjukan(false); + clientLogger.error("Error ajukan donasi", error); + } } return ( <> @@ -107,7 +120,8 @@ function ButtonAjukanPenggalangan({ opened={openModal} close={() => setOpenModal(false)} buttonKiri={ - } @@ -117,7 +131,7 @@ function ButtonAjukanPenggalangan({ backgroundColor: AccentColor.yellow }} loaderPosition="center" - loading={isLoading} + loading={isLoadingAjukan} radius={"xl"} c={MainColor.darkblue} onClick={() => onChangeStatus()} diff --git a/src/app_modules/donasi/detail/detail_reject/index.tsx b/src/app_modules/donasi/detail/detail_reject/index.tsx index 3c8dd1da..459dadb5 100644 --- a/src/app_modules/donasi/detail/detail_reject/index.tsx +++ b/src/app_modules/donasi/detail/detail_reject/index.tsx @@ -127,7 +127,8 @@ function ButtonAction({ opened={openModaEdit} close={() => setOpenModalEdit(false)} buttonKiri={ - } @@ -151,7 +152,8 @@ function ButtonAction({ opened={openModalDelete} close={() => setOpenModalDelete(false)} buttonKiri={ - } @@ -160,7 +162,8 @@ function ButtonAction({ loaderPosition="center" loading={isLoadingDelete} radius={"xl"} - color="red" + style={{ backgroundColor: MainColor.red }} + c={AccentColor.white} onClick={() => onDelete()} > Hapus diff --git a/src/app_modules/donasi/detail/detail_review/index.tsx b/src/app_modules/donasi/detail/detail_review/index.tsx index f44269a4..94c4fa6a 100644 --- a/src/app_modules/donasi/detail/detail_review/index.tsx +++ b/src/app_modules/donasi/detail/detail_review/index.tsx @@ -111,7 +111,8 @@ function ButtonBatalReview({ donasi }: { donasi: MODEL_DONASI }) { opened={openModal} close={() => setOpenModal(false)} buttonKiri={ - } diff --git a/src/app_modules/event/detail/draft/index.tsx b/src/app_modules/event/detail/draft/index.tsx index a17357a2..bdf8f4b5 100644 --- a/src/app_modules/event/detail/draft/index.tsx +++ b/src/app_modules/event/detail/draft/index.tsx @@ -159,7 +159,7 @@ function ButtonAction({ opened={openModal1} close={() => setOpenModal1(false)} buttonKiri={ - } @@ -185,7 +185,7 @@ function ButtonAction({ opened={openModal2} close={() => setOpenModal2(false)} buttonKiri={ - } @@ -197,7 +197,8 @@ function ButtonAction({ onClick={() => { onDelete(); }} - color="red" + style={{ backgroundColor: MainColor.red }} + c={AccentColor.white} > Hapus diff --git a/src/app_modules/event/detail/reject/index.tsx b/src/app_modules/event/detail/reject/index.tsx index 46667743..1df2f049 100644 --- a/src/app_modules/event/detail/reject/index.tsx +++ b/src/app_modules/event/detail/reject/index.tsx @@ -109,7 +109,7 @@ function ButtonAction({ eventId, }: { eventId: string }) { opened={openModal1} close={() => setOpenModal1(false)} buttonKiri={ - } @@ -135,7 +135,7 @@ function ButtonAction({ eventId, }: { eventId: string }) { opened={openModal2} close={() => setOpenModal2(false)} buttonKiri={ - } @@ -143,9 +143,9 @@ function ButtonAction({ eventId, }: { eventId: string }) { } diff --git a/src/app_modules/investasi/_view/detail/portofolio/view_detail_draft.tsx b/src/app_modules/investasi/_view/detail/portofolio/view_detail_draft.tsx index fcb47f15..fe2a4285 100644 --- a/src/app_modules/investasi/_view/detail/portofolio/view_detail_draft.tsx +++ b/src/app_modules/investasi/_view/detail/portofolio/view_detail_draft.tsx @@ -13,6 +13,7 @@ import { MODEL_INVESTASI } from "@/app_modules/investasi/_lib/interface"; import { investasi_funEditStatusById } from "@/app_modules/investasi/fun/edit/fun_edit_status_by_id"; import funDeleteInvestasi from "@/app_modules/investasi/fun/fun_delete_investasi"; import notifikasiToAdmin_funCreate from "@/app_modules/notifikasi/fun/create/create_notif_to_admin"; +import { clientLogger } from "@/util/clientLogger"; import mqtt_client from "@/util/mqtt_client"; import { Button, Group, Stack } from "@mantine/core"; import _ from "lodash"; @@ -39,72 +40,83 @@ export default function Investasi_ViewDetailDraft({ statusId: "2", }); - if (res.status === 200) { + try { setIsLoading(true); - ComponentGlobal_NotifikasiBerhasil("Review Berhasil Diajukan"); - router.replace(NEW_RouterInvestasi.portofolio({ id: "2" })); - - const dataNotif = { - appId: res.data?.id, - userId: res.data?.authorId, - pesan: res.data?.title, - status: res.data?.MasterStatusInvestasi?.name, - kategoriApp: "INVESTASI", - title: "Mengajukan review", - }; - - const notif = await notifikasiToAdmin_funCreate({ - data: dataNotif as any, - }); - - if (notif.status === 201) { - mqtt_client.publish("ADMIN", JSON.stringify({ count: 1 })); + if (res.status === 200) { + ComponentGlobal_NotifikasiBerhasil("Review Berhasil Diajukan"); + router.replace(NEW_RouterInvestasi.portofolio({ id: "2" })); + + const dataNotif = { + appId: res.data?.id, + userId: res.data?.authorId, + pesan: res.data?.title, + status: res.data?.MasterStatusInvestasi?.name, + kategoriApp: "INVESTASI", + title: "Mengajukan review", + }; + + const notif = await notifikasiToAdmin_funCreate({ + data: dataNotif as any, + }); + + if (notif.status === 201) { + mqtt_client.publish("ADMIN", JSON.stringify({ count: 1 })); + } + } else { + setIsLoading(false); + ComponentGlobal_NotifikasiGagal(res.message); } - } else { - ComponentGlobal_NotifikasiGagal(res.message); + } catch (error) { + setIsLoading(false); + clientLogger.error("Error update investasi", error); } } async function onDelete() { const res = await funDeleteInvestasi(data.id); - if (res.status === 200) { + try { setIsLoadingDelete(true); - - const delImage = await funGlobal_DeleteFileById({ - fileId: data.imageId, - }); - if (!delImage.success) { - ComponentAdminGlobal_NotifikasiPeringatan("Gagal hapus image "); - } - - const delFileProspektus = await funGlobal_DeleteFileById({ - fileId: data.prospektusFileId, - }); - if (!delFileProspektus.success) { - ComponentAdminGlobal_NotifikasiPeringatan("Gagal hapus prospektus "); - } - - if (!_.isEmpty(data.DokumenInvestasi)) { - for (let i of data.DokumenInvestasi) { - const delFileDokumen = await funGlobal_DeleteFileById({ - fileId: i.fileId, - }); - - if (!delFileDokumen.success) { - ComponentAdminGlobal_NotifikasiPeringatan( - "Gagal hapus prospektus " - ); + if (res.status === 200) { + + const delImage = await funGlobal_DeleteFileById({ + fileId: data.imageId, + }); + if (!delImage.success) { + ComponentAdminGlobal_NotifikasiPeringatan("Gagal hapus image "); + } + + const delFileProspektus = await funGlobal_DeleteFileById({ + fileId: data.prospektusFileId, + }); + if (!delFileProspektus.success) { + ComponentAdminGlobal_NotifikasiPeringatan("Gagal hapus prospektus "); + } + + if (!_.isEmpty(data.DokumenInvestasi)) { + for (let i of data.DokumenInvestasi) { + const delFileDokumen = await funGlobal_DeleteFileById({ + fileId: i.fileId, + }); + + if (!delFileDokumen.success) { + ComponentAdminGlobal_NotifikasiPeringatan( + "Gagal hapus prospektus " + ); + } } } + + ComponentGlobal_NotifikasiBerhasil(res.message); + setOpenModal(false); + router.replace(NEW_RouterInvestasi.portofolio({ id: "3" })); + setIsLoadingDelete(false); + } else { + ComponentGlobal_NotifikasiGagal(res.message); + setIsLoadingDelete(false); } - - ComponentGlobal_NotifikasiBerhasil(res.message); - setOpenModal(false); - router.replace(NEW_RouterInvestasi.portofolio({ id: "3" })); - setIsLoadingDelete(false); - } else { - ComponentGlobal_NotifikasiGagal(res.message); + } catch (error) { setIsLoadingDelete(false); + clientLogger.error("Error delete investasi", error); } } @@ -143,7 +155,8 @@ export default function Investasi_ViewDetailDraft({ close={() => setOpenModal(false)} title={"Anda yakin ingin mengajukan review ?"} buttonKiri={ - } @@ -170,7 +183,8 @@ export default function Investasi_ViewDetailDraft({ close={() => setOpenModalDelete(false)} title={"Anda yakin ingin menghapus ?"} buttonKiri={ - } diff --git a/src/app_modules/investasi/_view/detail/portofolio/view_detail_reject.tsx b/src/app_modules/investasi/_view/detail/portofolio/view_detail_reject.tsx index 8bf2df0c..450695df 100644 --- a/src/app_modules/investasi/_view/detail/portofolio/view_detail_reject.tsx +++ b/src/app_modules/investasi/_view/detail/portofolio/view_detail_reject.tsx @@ -12,6 +12,7 @@ import { Investasi_ComponentDetailDataNonPublish } from "@/app_modules/investasi import { MODEL_INVESTASI } from "@/app_modules/investasi/_lib/interface"; import { investasi_funEditStatusById } from "@/app_modules/investasi/fun/edit/fun_edit_status_by_id"; import funDeleteInvestasi from "@/app_modules/investasi/fun/fun_delete_investasi"; +import { clientLogger } from "@/util/clientLogger"; import { Button, Group, Stack } from "@mantine/core"; import _ from "lodash"; import { useRouter } from "next/navigation"; @@ -24,8 +25,10 @@ export default function Investasi_ViewDetailReject({ }) { const router = useRouter(); const [data, setData] = useState(dataInvestasi); - const [openModal, setOpenModal] = useState(false); - const [isLoading, setLoading] = useState(false); + const [openModalDel, setOpenModalDel] = useState(false); + const [openModalEdit, setOpenModalEdit] = useState(false); + const [isLoadingDel, setLoadingDel] = useState(false); + const [isLoadingEdit, setLoadingEdit] = useState(false); async function onAjukan() { const res = await investasi_funEditStatusById({ @@ -33,18 +36,25 @@ export default function Investasi_ViewDetailReject({ statusId: "3", }); - if (res.status === 200) { - ComponentGlobal_NotifikasiBerhasil("Project Diajukan Kembali"); - router.replace(NEW_RouterInvestasi.portofolio({ id: "3" })); - } else { - ComponentGlobal_NotifikasiGagal("Gagal Pengajuan"); + try { + setLoadingEdit(true); + if (res.status === 200) { + ComponentGlobal_NotifikasiBerhasil("Project Diajukan Kembali"); + router.replace(NEW_RouterInvestasi.portofolio({ id: "3" })); + } else { + setLoadingEdit(false); + ComponentGlobal_NotifikasiGagal("Gagal Pengajuan"); + } + } catch (error) { + setLoadingEdit(false); + clientLogger.error("Error ajukan kembali", error); } } async function onDelete() { const res = await funDeleteInvestasi(data.id); if (res.status === 200) { - setLoading(true); + setLoadingDel(true); const delImage = await funGlobal_DeleteFileById({ fileId: data.imageId, @@ -75,12 +85,12 @@ export default function Investasi_ViewDetailReject({ } ComponentGlobal_NotifikasiBerhasil(res.message); - setOpenModal(false); + setOpenModalDel(false); router.replace(NEW_RouterInvestasi.portofolio({ id: "4" })); - setLoading(false); + setLoadingDel(false); } else { ComponentGlobal_NotifikasiGagal(res.message); - setLoading(false); + setLoadingDel(false); } } @@ -89,19 +99,20 @@ export default function Investasi_ViewDetailReject({ {/* Pop up */} setOpenModal(false)} + opened={openModalDel} + close={() => setOpenModalDel(false)} buttonKiri={ - } buttonKanan={ + } + buttonKanan={ + + } + /> + {/* Alasan */} @@ -121,7 +156,7 @@ export default function Investasi_ViewDetailReject({ diff --git a/src/app_modules/investasi/_view/detail/portofolio/view_detail_review.tsx b/src/app_modules/investasi/_view/detail/portofolio/view_detail_review.tsx index 600c9492..9a3d75e4 100644 --- a/src/app_modules/investasi/_view/detail/portofolio/view_detail_review.tsx +++ b/src/app_modules/investasi/_view/detail/portofolio/view_detail_review.tsx @@ -9,6 +9,7 @@ import { Investasi_ComponentDetailDataNonPublish } from "@/app_modules/investasi import { MODEL_INVESTASI } from "@/app_modules/investasi/_lib/interface"; import { investasi_funEditStatusById } from "@/app_modules/investasi/fun/edit/fun_edit_status_by_id"; import notifikasiToAdmin_funCreate from "@/app_modules/notifikasi/fun/create/create_notif_to_admin"; +import { clientLogger } from "@/util/clientLogger"; import mqtt_client from "@/util/mqtt_client"; import { Button, Stack } from "@mantine/core"; import { useRouter } from "next/navigation"; @@ -29,31 +30,36 @@ export default function Investasi_ViewDetailReview({ investasiId: data.id, statusId: "3", }); - if (res.status === 200) { + try { setLoading(true); - ComponentGlobal_NotifikasiBerhasil("Review Dibatalkan"); - router.replace(NEW_RouterInvestasi.portofolio({ id: "3" })); - - const dataNotif = { - appId: res.data?.id, - userId: res.data?.authorId, - pesan: res.data?.title, - status: res.data?.MasterStatusInvestasi?.name, - kategoriApp: "INVESTASI", - title: "Membatalkan review", - }; - - const notif = await notifikasiToAdmin_funCreate({ - data: dataNotif as any, - }); - - if (notif.status === 201) { - mqtt_client.publish("ADMIN", JSON.stringify({ count: 1 })); + if (res.status === 200) { + ComponentGlobal_NotifikasiBerhasil("Review Dibatalkan"); + router.replace(NEW_RouterInvestasi.portofolio({ id: "3" })); + + const dataNotif = { + appId: res.data?.id, + userId: res.data?.authorId, + pesan: res.data?.title, + status: res.data?.MasterStatusInvestasi?.name, + kategoriApp: "INVESTASI", + title: "Membatalkan review", + }; + + const notif = await notifikasiToAdmin_funCreate({ + data: dataNotif as any, + }); + + if (notif.status === 201) { + mqtt_client.publish("ADMIN", JSON.stringify({ count: 1 })); + } + setLoading(false); + } else { + ComponentGlobal_NotifikasiPeringatan(res.message); + setLoading(false); } + } catch (error) { setLoading(false); - } else { - ComponentGlobal_NotifikasiPeringatan(res.message); - setLoading(false); + clientLogger.error("Error ajukan kembali", error); } } @@ -82,13 +88,13 @@ export default function Investasi_ViewDetailReview({ close={() => setOpenModal(false)} title={"Anda yakin ingin batalkan review?"} buttonKiri={ - } buttonKanan={ @@ -190,7 +191,7 @@ function ButtonAction({ close={() => setOpenModal2(false)} buttonKiri={ diff --git a/src/app_modules/vote/detail/review/index.tsx b/src/app_modules/vote/detail/review/index.tsx index b8bf7dad..d32326e4 100644 --- a/src/app_modules/vote/detail/review/index.tsx +++ b/src/app_modules/vote/detail/review/index.tsx @@ -105,7 +105,7 @@ function ButtonAction({ opened={openModal} close={() => setOpenModal(false)} buttonKiri={ - }