Fix Button Loading All Menu Execpt Joba vacancy
This commit is contained in:
@@ -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={
|
||||
<Button radius={"xl"} onClick={() => setOpenModal(false)}>
|
||||
<Button style={{ backgroundColor: AccentColor.blue }}
|
||||
c={AccentColor.white} radius={"xl"} onClick={() => setOpenModal(false)}>
|
||||
Batal
|
||||
</Button>
|
||||
}
|
||||
buttonKanan={
|
||||
<Button radius={"xl"} color="red" onClick={() => onDelete()}>
|
||||
<Button c={AccentColor.white} loading={isLoading} loaderPosition="center" radius={"xl"} style={{ backgroundColor: MainColor.red}} onClick={() => onDelete()}>
|
||||
Hapus
|
||||
</Button>
|
||||
}
|
||||
|
||||
@@ -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={
|
||||
<Button c={AccentColor.white} radius={"xl"} onClick={() => setOpenModal(false)}>
|
||||
<Button style={{ backgroundColor: AccentColor.blue }}
|
||||
c={AccentColor.white} radius={"xl"} onClick={() => setOpenModal(false)}>
|
||||
Batal
|
||||
</Button>
|
||||
}
|
||||
@@ -117,7 +131,7 @@ function ButtonAjukanPenggalangan({
|
||||
backgroundColor: AccentColor.yellow
|
||||
}}
|
||||
loaderPosition="center"
|
||||
loading={isLoading}
|
||||
loading={isLoadingAjukan}
|
||||
radius={"xl"}
|
||||
c={MainColor.darkblue}
|
||||
onClick={() => onChangeStatus()}
|
||||
|
||||
@@ -127,7 +127,8 @@ function ButtonAction({
|
||||
opened={openModaEdit}
|
||||
close={() => setOpenModalEdit(false)}
|
||||
buttonKiri={
|
||||
<Button radius={"xl"} onClick={() => setOpenModalEdit(false)}>
|
||||
<Button style={{ backgroundColor: AccentColor.blue }}
|
||||
c={AccentColor.white} radius={"xl"} onClick={() => setOpenModalEdit(false)}>
|
||||
Batal
|
||||
</Button>
|
||||
}
|
||||
@@ -151,7 +152,8 @@ function ButtonAction({
|
||||
opened={openModalDelete}
|
||||
close={() => setOpenModalDelete(false)}
|
||||
buttonKiri={
|
||||
<Button radius={"xl"} onClick={() => setOpenModalDelete(false)}>
|
||||
<Button style={{ backgroundColor: AccentColor.blue }}
|
||||
c={AccentColor.white} radius={"xl"} onClick={() => setOpenModalDelete(false)}>
|
||||
Batal
|
||||
</Button>
|
||||
}
|
||||
@@ -160,7 +162,8 @@ function ButtonAction({
|
||||
loaderPosition="center"
|
||||
loading={isLoadingDelete}
|
||||
radius={"xl"}
|
||||
color="red"
|
||||
style={{ backgroundColor: MainColor.red }}
|
||||
c={AccentColor.white}
|
||||
onClick={() => onDelete()}
|
||||
>
|
||||
Hapus
|
||||
|
||||
@@ -111,7 +111,8 @@ function ButtonBatalReview({ donasi }: { donasi: MODEL_DONASI }) {
|
||||
opened={openModal}
|
||||
close={() => setOpenModal(false)}
|
||||
buttonKiri={
|
||||
<Button c={AccentColor.white} radius={"xl"} onClick={() => setOpenModal(false)}>
|
||||
<Button style={{ backgroundColor: AccentColor.blue }}
|
||||
c={AccentColor.white} radius={"xl"} onClick={() => setOpenModal(false)}>
|
||||
Batal
|
||||
</Button>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user