(
+ donatur.data
+ );
+ const [isNPage, setNPage] = useState(donatur.nPage);
+ const [isActivePage, setActivePage] = useState(1);
+ const [isSelect, setSelect] = useState("");
+
+ async function onRelaod() {
+ const loadData = await adminDonasi_getListDonatur({
+ donasiId: dataDonasi?.id,
+ page: 1,
+ });
+ setSelect("");
+ setListDonatur(loadData.data as any);
+ setNPage(loadData.nPage);
+ }
+
+ async function onSelect(s: any) {
+ setSelect(s);
+ const loadData = await adminDonasi_getListDonatur({
+ donasiId: dataDonasi?.id,
+ page: 1,
+ selectStatusId: s,
+ });
+ setListDonatur(loadData.data as any);
+ setNPage(loadData.nPage);
+ setActivePage(1);
+ }
+
+ async function onPageClick(p: any) {
+ setActivePage(p);
+ const loadData = await adminDonasi_getListDonatur({
+ donasiId: dataDonasi?.id,
+ page: p,
+ selectStatusId: isSelect,
+ });
+ setListDonatur(loadData.data as any);
+ setNPage(loadData.nPage);
+ }
+
+ const tableRows = lisDonatur.map((e, i) => (
+
+ |
+ {e?.Author.username}
+ |
+
+ {e?.DonasiMaster_Bank?.name}
+ |
+
+
+
+
+ |
+
+
+ {new Intl.DateTimeFormat("id-ID", { dateStyle: "full" }).format(
+ e?.createdAt
+ )}
+
+ |
+
+
+
+ {e?.DonasiMaster_StatusInvoice?.name}
+
+
+ |
+
+
+ {e?.donasiMaster_StatusInvoiceId === "1" ||
+ e?.donasiMaster_StatusInvoiceId === "2" ? (
+
+ ) : (
+ "-"
+ )}
+
+ |
+
+
+ {e?.donasiMaster_StatusInvoiceId === "1" ? (
+
+ ) : e?.DonasiMaster_StatusInvoice?.id === "2" ? (
+ {
+ onSuccessDonasi(val);
+ }}
+ onSuccessDonatur={(val) => {
+ setListDonatur(val.data);
+ setNPage(val.nPage);
+ }}
+ />
+ ) : (
+ -
+ )}
+
+ |
+
+ ));
+
+ return (
+ <>
+
+ {/* {JSON.stringify(dataDonasi, null, 2)} */}
+
+ {
+ onRelaod();
+ }}
+ >
+
+
+
+ >
+ );
+}
+
+function ButtonAccept({
+ invoiceId,
+ donasiId,
+ nominal,
+ danaTerkumpul,
+ target,
+ onSuccessDonasi,
+ onSuccessDonatur,
+}: {
+ invoiceId: string;
+ donasiId: string;
+ nominal: number;
+ danaTerkumpul: number;
+ target: number;
+ onSuccessDonasi: (val: any) => void;
+ onSuccessDonatur: (val: any) => void;
+}) {
+ const [opened, { open, close }] = useDisclosure(false);
+ const [isLoading, setIsLoading] = useState(false);
+
+ async function onAccept() {
+ let nominalDonasi = nominal;
+ let jumlahTerkumpul = danaTerkumpul;
+
+ const updateStatus = await adminDonasi_funUpdateStatusDanTotal({
+ invoiceId: invoiceId,
+ donasiId: donasiId,
+ jumlahTerkumpul: jumlahTerkumpul,
+ nominal: nominalDonasi,
+ statusInvoiceId: "1",
+ target: target,
+ });
+ if (updateStatus.status == 200) {
+ setIsLoading(true);
+ const dataNotif = {
+ appId: updateStatus.data?.id,
+ userId: updateStatus.data?.authorId,
+ pesan: updateStatus.data?.Donasi?.title,
+ status: updateStatus.data?.DonasiMaster_StatusInvoice?.name,
+ kategoriApp: "DONASI",
+ title: "Terimakasih, Donasi anda telah diterima",
+ };
+
+ const notif = await adminNotifikasi_funCreateToUser({
+ data: dataNotif as any,
+ });
+
+ if (notif.status === 201) {
+ mqtt_client.publish(
+ "USER",
+ JSON.stringify({ userId: updateStatus?.data?.authorId, count: 1 })
+ );
+
+ mqtt_client.publish(
+ "donasi_invoice",
+ JSON.stringify({
+ invoiceId: invoiceId,
+ statusInvoiceId: "1",
+ })
+ );
+ }
+
+ const dataNotifToAuthorDonasi = {
+ appId: updateStatus.data?.Donasi?.id,
+ userId: updateStatus.data?.Donasi?.authorId,
+ pesan: updateStatus.data?.Donasi?.title,
+ status: "Donatur Baru",
+ kategoriApp: "DONASI",
+ title: "Ada donatur baru",
+ };
+
+ const notifToAuthorDonasi = await adminNotifikasi_funCreateToUser({
+ data: dataNotifToAuthorDonasi as any,
+ });
+
+ if (notifToAuthorDonasi.status === 201) {
+ mqtt_client.publish(
+ "USER",
+ JSON.stringify({
+ userId: updateStatus?.data?.Donasi?.authorId,
+ count: 1,
+ })
+ );
+ }
+
+ const updateData = await AdminDonasi_getOneById(donasiId);
+ onSuccessDonasi(updateData as any);
+ const updatelistDonatur = await adminDonasi_getListDonatur({
+ donasiId: donasiId,
+ page: 1,
+ });
+ onSuccessDonatur(updatelistDonatur);
+ ComponentAdminGlobal_NotifikasiBerhasil(updateStatus.message);
+ setIsLoading(false);
+ } else {
+ ComponentAdminGlobal_NotifikasiGagal(updateStatus.message);
+ setIsLoading(false);
+ }
+ close();
+ }
+
+ return (
+ <>
+
+
+
+
+
+ {`${"Anda sudah melihat bukti transfer dan yakin menerima donasi ini ?"}`}
+
+
+
+
+
+
+
+ >
+ );
+}
+
+//######################## LIST PENCAIRAN #####################//
+function TampilanListPencairan({
+ pencairan,
+}: {
+ pencairan: MODEL_DONASI_PENCAIRAN_DANA[];
+}) {
+ const router = useRouter();
+ const [data, setData] = useState(pencairan);
+ const [opened, { open, close }] = useDisclosure(false);
+ const [gambarId, setGambarId] = useState("");
+
+ const rowTable = data.map((e) => (
+
+ |
+
+
+
+ |
+
+ {moment(e.createdAt).format("ll")}
+ |
+
+
+ {e.title}
+
+ |
+
+
+
+ {e.deskripsi}
+
+
+ |
+
+
+
+
+
+
+ |
+
+ ));
+
+ return (
+ <>
+ {/*
+
+
+
+ */}
+
+ {/* {JSON.stringify(data, null, 2)} */}
+
+
+
+ {
+ // onRelaod();
+ }}
+ >
+
+
+ {/*
+
+ {/*
+ Rincian Pencairan Dana
+ {_.isEmpty(pencairan) ? (
+
+ BELUM ADA PENCAIRAN DANA
+
+ ) : (
+
+
+
+
+ | Nominal |
+ Tanggal |
+ Judul |
+
+ Deskripsi
+ |
+
+ Bukti Transfer
+ |
+
+
+ {rowTable}
+
+
+ )}
+ */}
+ >
+ );
+}
diff --git a/src/app_modules/admin/donasi/detail/publish/detail_publish_backup2.txt b/src/app_modules/admin/donasi/detail/publish/detail_publish_backup2.txt
new file mode 100644
index 00000000..36ac2f11
--- /dev/null
+++ b/src/app_modules/admin/donasi/detail/publish/detail_publish_backup2.txt
@@ -0,0 +1,871 @@
+"use client";
+
+import { AccentColor, AdminColor } from "@/app_modules/_global/color/color_pallet";
+import { ComponentGlobal_TampilanRupiah } from "@/app_modules/_global/component";
+import { apiGetMasterStatusTransaksi } from "@/app_modules/_global/lib/api_fetch_master";
+import { globalStatusTransaksi } from "@/app_modules/_global/lib/master_list_app";
+import { Admin_ComponentLoadImageLandscape } from "@/app_modules/admin/_admin_global";
+import { ComponentAdminGlobal_TitlePage } from "@/app_modules/admin/_admin_global/_component";
+import CustomSkeletonAdmin from "@/app_modules/admin/_admin_global/_component/skeleton/customSkeletonAdmin";
+import { ComponentAdminGlobal_NotifikasiBerhasil } from "@/app_modules/admin/_admin_global/admin_notifikasi/notifikasi_berhasil";
+import { ComponentAdminGlobal_NotifikasiGagal } from "@/app_modules/admin/_admin_global/admin_notifikasi/notifikasi_gagal";
+import AdminGlobal_ComponentBackButton from "@/app_modules/admin/_admin_global/back_button";
+import adminNotifikasi_funCreateToUser from "@/app_modules/admin/notifikasi/fun/create/fun_create_notif_user";
+import TampilanRupiahDonasi from "@/app_modules/donasi/component/tampilan_rupiah";
+import {
+ MODEL_DONASI,
+ MODEL_DONASI_PENCAIRAN_DANA
+} from "@/app_modules/donasi/model/interface";
+import { MODEL_NEW_DEFAULT_MASTER } from "@/app_modules/model_global/interface";
+import { RouterAdminGlobal } from "@/lib";
+import { RouterAdminDonasi } from "@/lib/router_admin/router_admin_donasi";
+import { RouterAdminDonasi_OLD } from "@/lib/router_hipmi/router_admin";
+import { clientLogger } from "@/util/clientLogger";
+import mqtt_client from "@/util/mqtt_client";
+import {
+ ActionIcon,
+ Badge,
+ Box,
+ Button,
+ Center,
+ Grid,
+ Group,
+ Modal,
+ Pagination,
+ Paper,
+ ScrollArea,
+ Select,
+ SimpleGrid,
+ Spoiler,
+ Stack,
+ Table,
+ Text,
+ TextInput,
+ Title,
+} from "@mantine/core";
+import { useDisclosure, useShallowEffect } from "@mantine/hooks";
+import { IconReload } from "@tabler/icons-react";
+import _, { toNumber } from "lodash";
+import moment from "moment";
+import { useParams, useRouter } from "next/navigation";
+import { useState } from "react";
+import SkeletonAdminDetailDonasiPublish from "../../component/skeleton_detail_donasi_publish";
+import { AdminDonasi_getOneById } from "../../fun/get/get_one_by_id";
+import adminDonasi_funUpdateStatusDanTotal from "../../fun/update/fun_update_status_dan_total";
+import { apiGetAdminAllDaftarDonatur, apiGetAdminDonasiById } from "../../lib/api_fetch_admin_donasi";
+
+export default function AdminDonasi_DetailPublish({
+ countDonatur,
+ listPencairan,
+}: {
+ countDonatur: number;
+ listPencairan: MODEL_DONASI_PENCAIRAN_DANA[];
+}) {
+ const [pencairan, setPencairan] = useState(listPencairan);
+ // const [isReload, setReload] = useState(false);
+
+ return (
+ <>
+ {/* {JSON.stringify(pencairan, null, 2)} */}
+
+ <>
+
+
+
+
+ >
+
+ >
+ );
+}
+
+function TampilanDetailDonasi({
+ countDonatur,
+}: {
+ countDonatur: number;
+}) {
+ const params = useParams<{ id: string }>();
+ const [data, setData] = useState(null);
+ const [isReload, setReload] = useState(false);
+
+
+ useShallowEffect(() => {
+
+ loadInitialData();
+ }, [isReload])
+ const loadInitialData = async () => {
+ try {
+ const response = await apiGetAdminDonasiById({
+ id: params.id,
+ })
+
+ if (response?.success && response?.data) {
+ setTimeout(() => {
+ setData(response.data)
+ }, 3000);
+ } else {
+ console.log("Invalid data format recieved:", response);
+ setData(null)
+ }
+ } catch (error) {
+ clientLogger.error("Invalid data format recieved:", error);
+ setData(null);
+ }
+ }
+ const [opened, { open, close }] = useDisclosure(false);
+ const router = useRouter();
+ const [isLoadingPencairanDana, setIsLoadingPencairanDana] = useState(false);
+
+
+ return (
+ <>
+ {!data ? () : (
+
+
+
+
+
+
+ Gambar Donasi
+
+
+
+
+
+
+
+ Detail Donasi
+
+
+ Judul
+
+ :
+
+
+ {data?.title}
+
+
+
+
+
+
+ Penggalang Dana
+
+ :
+
+
+ {data?.Author.username}
+
+
+
+
+
+
+ Durasi
+
+ :
+
+
+ {data?.DonasiMaster_Durasi.name} hari
+
+
+
+
+
+
+ Dana dibutuhkan
+
+ :
+
+
+
+
+
+
+
+ Kategori
+
+ :
+
+
+ {data?.DonasiMaster_Ketegori?.name}
+
+
+
+
+
+
+ Total donatur
+
+ :
+
+
+ {countDonatur}
+
+
+
+
+
+
+ Progres
+
+ :
+
+
+ {toNumber(data.progres).toFixed(2)} %
+
+
+
+
+
+
+ Dana terkumpul
+
+ :
+
+
+
+
+
+
+
+ {/* Pencairan Dana */}
+
+
+
+ Pencairan Dana
+
+
+
+
+ Total Dana Dicairkan
+
+
+
+
+
+ Bank Tujuan
+
+ {data?.namaBank}
+
+
+
+
+
+
+
+ Akumulasi Pencairan
+
+ {data?.akumulasiPencairan} Kali
+
+
+
+
+
+ Nomor Rekening
+
+ {data?.rekening}
+
+
+
+
+
+
+ Sisa Dana
+
+
+
+
+
+
+
+
+
+ )}
+
+
+
+ >
+ );
+}
+
+function PencairanDana() {
+ return (
+ <>
+
+
+
+ >
+ );
+}
+
+//######################## LIST DONATUR #####################//
+function TampilanListDonatur() {
+ const router = useRouter();
+ const params = useParams<{ id: string }>();
+ const donasiId = params.id;
+ const [isLoadingCek, setLoadingCek] = useState(false);
+ const [idData, setIdData] = useState("");
+ const [lisDonatur, setListDonatur] = useState(null);
+ const [listStatus, setListStatus] = useState(null);
+ const [isNPage, setNPage] = useState(1);
+ const [isActivePage, setActivePage] = useState(1);
+
+ const [selectStatus, setSelectStatus] = useState("");
+
+
+ useShallowEffect(() => {
+ handleLoadData();
+ }, [isActivePage, selectStatus]);
+
+ useShallowEffect(() => {
+ handleLoadStatus();
+ }, [])
+
+ const handleLoadData = async () => {
+ try {
+ const cek = globalStatusTransaksi.find((e) => e.id === selectStatus);
+ const response = await apiGetAdminAllDaftarDonatur({
+ id: donasiId,
+ page: `${isActivePage}`,
+ status: cek?.name,
+ });
+
+ if (response?.success && response?.data?.data) {
+ setListDonatur(response.data.data);
+ setNPage(response.data.nPage || 1);
+ } else {
+ console.error("Invalid data format received:", response);
+ setListDonatur([]);
+ }
+ } catch (error) {
+ clientLogger.error("Error get data daftar donatur", error);
+ setListDonatur([]);
+ }
+ }
+
+ const handleLoadStatus = async () => {
+ try {
+ const response = await apiGetMasterStatusTransaksi();
+
+
+ if (response?.success && response?.data) {
+ setListStatus(response.data);
+ } else {
+ console.error("Invalid data format received:", response);
+ setListStatus(null);
+ }
+ } catch (error) {
+ clientLogger.error("Error get status donatur", error);
+ setListStatus(null);
+ }
+ }
+ const onPageClick = async (page: number) => {
+ setActivePage(page);
+ }
+ async function onSelect(selectStatus: any) {
+ setSelectStatus(selectStatus);
+ }
+ async function onReload() {
+ setSelectStatus("");
+ handleLoadData();
+ }
+
+
+
+ const renderTableBody = () => {
+ if (!Array.isArray(lisDonatur) || lisDonatur.length === 0) {
+ return (
+
+ |
+
+ Tidak ada data
+
+ |
+
+ );
+ }
+ return lisDonatur?.map((e, i) => (
+
+ |
+ {e?.Author.username}
+ |
+
+ {e?.DonasiMaster_Bank?.name}
+ |
+
+
+
+
+ |
+
+
+ {new Intl.DateTimeFormat("id-ID", { dateStyle: "full" }).format(
+ new Date(e?.createdAt)
+ )}
+
+ |
+
+
+
+ {e?.DonasiMaster_StatusInvoice?.name}
+
+
+ |
+
+
+ {e?.donasiMaster_StatusInvoiceId === "1" ||
+ e?.donasiMaster_StatusInvoiceId === "2" ? (
+
+ ) : (
+ "-"
+ )}
+
+ |
+
+
+ {e?.donasiMaster_StatusInvoiceId === "1" ? (
+
+ ) : e?.DonasiMaster_StatusInvoice?.id === "2" ? (
+ {
+ onReload();
+ }}
+ onSuccessDonatur={(val) => {
+ setListDonatur(val.data);
+ setNPage(val.nPage);
+ }}
+ />
+ ) : (
+ -
+ )}
+
+ |
+
+ ));
+ }
+
+ if (!lisDonatur && !listStatus) return
+
+ return (
+ <>
+
+ {/* {JSON.stringify(dataDonasi, null, 2)} */}
+
+ {
+ onReload();
+ }}
+ >
+
+
+
+ >
+ );
+}
+
+function ButtonAccept({
+ invoiceId,
+ donasiId,
+ nominal,
+ danaTerkumpul,
+ target,
+ onSetDonasi: onSuccessDonasi,
+ onSuccessDonatur,
+}: {
+ invoiceId: string;
+ donasiId: string;
+ nominal: number;
+ danaTerkumpul: number;
+ target: number;
+ onSetDonasi: (val: boolean) => void;
+ onSuccessDonatur: (val: any) => void;
+}) {
+ const [opened, { open, close }] = useDisclosure(false);
+ const [isLoading, setIsLoading] = useState(false);
+
+ async function onAccept() {
+ let nominalDonasi = nominal;
+ let jumlahTerkumpul = danaTerkumpul;
+
+ const updateStatus = await adminDonasi_funUpdateStatusDanTotal({
+ invoiceId: invoiceId,
+ donasiId: donasiId,
+ jumlahTerkumpul: jumlahTerkumpul,
+ nominal: nominalDonasi,
+ statusInvoiceId: "1",
+ target: target,
+ });
+ if (updateStatus.status == 200) {
+ setIsLoading(true);
+ const dataNotif = {
+ appId: updateStatus.data?.id,
+ userId: updateStatus.data?.authorId,
+ pesan: updateStatus.data?.Donasi?.title,
+ status: updateStatus.data?.DonasiMaster_StatusInvoice?.name,
+ kategoriApp: "DONASI",
+ title: "Terimakasih, Donasi anda telah diterima",
+ };
+
+ const notif = await adminNotifikasi_funCreateToUser({
+ data: dataNotif as any,
+ });
+
+ if (notif.status === 201) {
+ mqtt_client.publish(
+ "USER",
+ JSON.stringify({ userId: updateStatus?.data?.authorId, count: 1 })
+ );
+
+ mqtt_client.publish(
+ "donasi_invoice",
+ JSON.stringify({
+ invoiceId: invoiceId,
+ statusInvoiceId: "1",
+ })
+ );
+ }
+
+ const dataNotifToAuthorDonasi = {
+ appId: updateStatus.data?.Donasi?.id,
+ userId: updateStatus.data?.Donasi?.authorId,
+ pesan: updateStatus.data?.Donasi?.title,
+ status: "Donatur Baru",
+ kategoriApp: "DONASI",
+ title: "Ada donatur baru",
+ };
+
+ const notifToAuthorDonasi = await adminNotifikasi_funCreateToUser({
+ data: dataNotifToAuthorDonasi as any,
+ });
+
+ if (notifToAuthorDonasi.status === 201) {
+ mqtt_client.publish(
+ "USER",
+ JSON.stringify({
+ userId: updateStatus?.data?.Donasi?.authorId,
+ count: 1,
+ })
+ );
+ }
+
+ const updateData = await AdminDonasi_getOneById(donasiId);
+ onSuccessDonasi(updateData as any);
+ // const updatelistDonatur = await adminDonasi_getListDonatur({
+ // donasiId: donasiId,
+ // page: 1,
+ // });
+ onSuccessDonatur(true);
+
+ ComponentAdminGlobal_NotifikasiBerhasil(updateStatus.message);
+ setIsLoading(false);
+ } else {
+ ComponentAdminGlobal_NotifikasiGagal(updateStatus.message);
+ setIsLoading(false);
+ }
+ close();
+ }
+
+ return (
+ <>
+
+
+
+
+
+ {`${"Anda sudah melihat bukti transfer dan yakin menerima donasi ini ?"}`}
+
+
+
+
+
+
+
+ >
+ );
+}
+
+//######################## LIST PENCAIRAN #####################//
+function TampilanListPencairan({
+ pencairan,
+}: {
+ pencairan: MODEL_DONASI_PENCAIRAN_DANA[];
+}) {
+ const router = useRouter();
+ const [data, setData] = useState(pencairan);
+ const [opened, { open, close }] = useDisclosure(false);
+ const [gambarId, setGambarId] = useState("");
+
+ const rowTable = data.map((e) => (
+
+ |
+
+
+
+ |
+
+ {moment(e.createdAt).format("ll")}
+ |
+
+
+ {e.title}
+
+ |
+
+
+
+ {e.deskripsi}
+
+
+ |
+
+
+
+
+
+
+ |
+
+ ));
+
+ return (
+ <>
+
+
+
+ {
+ // onRelaod();
+ }}
+ >
+
+
+ {/*
+
+
+ >
+ );
+}
diff --git a/src/app_modules/admin/donasi/fun/update/fun_update_status_dan_total.ts b/src/app_modules/admin/donasi/fun/update/fun_update_status_dan_total.ts
index 70c257a1..eae462eb 100644
--- a/src/app_modules/admin/donasi/fun/update/fun_update_status_dan_total.ts
+++ b/src/app_modules/admin/donasi/fun/update/fun_update_status_dan_total.ts
@@ -22,6 +22,11 @@ export default async function adminDonasi_funUpdateStatusDanTotal({
}) {
let totalNominal = nominal + jumlahTerkumpul;
const progres = (totalNominal / target) * 100;
+ console.log("Progres", progres)
+ console.log("Jumlah total nominal", typeof totalNominal)
+ console.log("Ini nominal", nominal)
+ console.log("Ini jumlah terkumpul", jumlahTerkumpul)
+ console.log("Ini target", target)
const updateInvoice = await prisma.donasi_Invoice.update({
where: {
@@ -48,6 +53,8 @@ export default async function adminDonasi_funUpdateStatusDanTotal({
},
},
});
+ console.log("Jumlah update invoice", updateInvoice)
+
if (!updateInvoice) return { status: 400, message: "Update invoice gagal" };
const updateDonasi = await prisma.donasi.update({
@@ -59,6 +66,7 @@ export default async function adminDonasi_funUpdateStatusDanTotal({
progres: "" + progres,
},
});
+ console.log("Jumlah update donasi", updateDonasi)
if (!updateDonasi) return { status: 400, message: "Update donasi gagal" };
revalidatePath(RouterAdminDonasi_OLD.detail_publish + donasiId);
diff --git a/src/app_modules/admin/donasi/lib/api_fetch_admin_donasi.ts b/src/app_modules/admin/donasi/lib/api_fetch_admin_donasi.ts
index baf8a5a7..10aa6dea 100644
--- a/src/app_modules/admin/donasi/lib/api_fetch_admin_donasi.ts
+++ b/src/app_modules/admin/donasi/lib/api_fetch_admin_donasi.ts
@@ -4,6 +4,8 @@ export {
apiGetAdminDonasiByStatus,
apiGetAdminDonasiKategori,
apiGetAdminDonasiById,
+ apiGetAdminAllDaftarDonatur,
+ apiGetAdminStatusDaftarDonatur
};
const apiGetAdminDonasiStatusCountDashboard = async ({ name }:
{ name: "Publish" | "Review" | "Reject" }) => {
@@ -49,7 +51,7 @@ const apiGetAdminDonasiByStatus = async ({
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
if (!token) return await token.json().catch(() => null);
-
+
const isPage = page ? `?page=${page}` : "";
const isSearch = search ? `&search=${search}` : "";
const response = await fetch(
@@ -63,14 +65,14 @@ const apiGetAdminDonasiByStatus = async ({
}
}
)
-
+
return await response.json().catch(() => null);
}
const apiGetAdminDonasiKategori = async () => {
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
if (!token) return await token.json().catch(() => null);
-
+
const response = await fetch(`/api/admin/donasi/kategori`, {
method: "GET",
headers: {
@@ -78,12 +80,12 @@ const apiGetAdminDonasiKategori = async () => {
Accept: "application/json",
"Access-Control-Allow-Origin": "*",
Authorization: `Bearer ${token}`
-
+
}
})
return await response.json().catch(() => null);
}
-const apiGetAdminDonasiById = async ({id} : {id: string}) => {
+const apiGetAdminDonasiById = async ({ id }: { id: string }) => {
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
if (!token) return await token.json().catch(() => null);
@@ -96,5 +98,67 @@ const apiGetAdminDonasiById = async ({id} : {id: string}) => {
Authorization: `Bearer ${token}`
}
})
- return await response.json().catch(() => null);
+ return await response.json().catch(() => null);
+}
+const apiGetAdminAllDaftarDonatur = async ({
+ id,
+ page,
+ status
+}: {
+ id: string,
+ page: string,
+ status?: string | undefined
+}) => {
+ try {
+ const { token } = await fetch("/api/get-cookie").then((res) => res.json());
+ if (!token) {
+ console.error("No token found");
+ return null;
+ }
+
+ const isStatus = status ? `&status=${status}` : "";
+ console.log("Ini status",isStatus);
+ const isPage = page ? `?page=${page}` : "";
+ const response = await fetch(
+ `/api/admin/donasi/${id}/donatur${isPage}${isStatus}`,
+ {
+ method: "GET",
+ headers: {
+ "Content-Type": "application/json",
+ Accept: "application/json",
+ "Access-Control-Allow-Origin": "*",
+ Authorization: `Bearer ${token}`,
+ },
+ }
+ );
+
+ if (!response.ok) {
+ const errorData = await response.json().catch(() => null);
+ console.error("Error get daftar donatur:",
+ errorData?.message || "Unknown error");
+ return null;
+ }
+
+ return response.json();
+ } catch (error) {
+ console.error("Error get daftar donatur:", error);
+ throw error;
+ }
+}
+
+const apiGetAdminStatusDaftarDonatur = async () => {
+ const { token } = await fetch("/api/get-cookie").then((res) => res.json());
+ if (!token) return await token.json().catch(() => null);
+
+ const response = await fetch(`/api/master/status_transaksi`, {
+ method: "GET",
+ headers: {
+ "Content-Type": "application/json",
+ Accept: "application/json",
+ "Access-Control-Allow-Origin": "*",
+ Authorization: `Bearer ${token}`
+ }
+ })
+
+ return await response.json().catch(() => null);
}
\ No newline at end of file
diff --git a/src/app_modules/admin/investasi/_lib/api_fetch_admin_investasi.ts b/src/app_modules/admin/investasi/_lib/api_fetch_admin_investasi.ts
index e2aacb27..7c5673b6 100644
--- a/src/app_modules/admin/investasi/_lib/api_fetch_admin_investasi.ts
+++ b/src/app_modules/admin/investasi/_lib/api_fetch_admin_investasi.ts
@@ -94,6 +94,7 @@ const apiGetAdminAllTransaksiById = async ({
// Fetch data
const isStatus = status ? `&status=${status}` : "";
+ console.log("Ini status",isStatus);
const isPage = page ? `?page=${page}` : "";
const response = await fetch(
`/api/admin/investasi/${id}/transaksi${isPage}${isStatus}`,
diff --git a/src/app_modules/forum/edit/posting/index.tsx b/src/app_modules/forum/edit/posting/index.tsx
index 5a7ae6f2..574dabb4 100644
--- a/src/app_modules/forum/edit/posting/index.tsx
+++ b/src/app_modules/forum/edit/posting/index.tsx
@@ -33,7 +33,7 @@ export default function Forum_EditPosting() {
const [reload, setReload] = useState(false);
useShallowEffect(() => {
if (window && window.document) setReload(true);
- }, []);
+ }, []);
useShallowEffect(() => {
handleLoadData();