fix: donasi
deskrispi: - fix metode pengambilan data dari use server menjadi API src/app/api/donasi/[id]/donatur/route.ts src/app/api/donasi/[id]/pencairan-dana/route.ts src/app/dev/(user)/donasi/donatur/[id]/page.tsx src/app_modules/donasi/component/card_view/ui_card_donatur.tsx src/app_modules/donasi/detail/detail_main/donatur/index.tsx src/app_modules/donasi/lib/api_donasi.ts No Issue
This commit is contained in:
@@ -327,4 +327,43 @@ export const apiGetDonasiPencairanDanaById = async ({ id, page }: { id: string,
|
||||
throw error; // Re-throw the error to handle it in the calling function
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const apiGetDonasiListDonaturById = async ({ id, page }: { id: string, page: number }) => {
|
||||
try {
|
||||
// Fetch token from cookie
|
||||
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
|
||||
if (!token) {
|
||||
console.error("No token found");
|
||||
return null;
|
||||
}
|
||||
|
||||
const response = await fetch(`/api/donasi/${id}/donatur?page=${page}`, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Accept: "application/json",
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const errorData = await response.json().catch(() => null);
|
||||
console.error(
|
||||
"Failed to get donasi list donatur",
|
||||
response.statusText,
|
||||
errorData
|
||||
);
|
||||
throw new Error(
|
||||
errorData?.message || "Failed to get donasi list donatur"
|
||||
);
|
||||
}
|
||||
|
||||
// Return the JSON response
|
||||
const data = await response.json();
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.error("Error get donasi list donatur", error);
|
||||
throw error; // Re-throw the error to handle it in the calling function
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user