diff --git a/bun.lockb b/bun.lockb index 6ecc0fa0..8d2a8fec 100755 Binary files a/bun.lockb and b/bun.lockb differ 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={ - }