fix: donasi
deskripsi: - fix perubahan use server menjadi API src/app/api/donasi/kabar/[id]/list/route.ts src/app/dev/(user)/donasi/kabar/daftar/[id]/page.tsx src/app/dev/(user)/donasi/kabar/rekap/[id]/page.tsx src/app_modules/donasi/_ui/kabar/ui_daftar_kabar.tsx src/app_modules/donasi/_ui/kabar/ui_rekap_kabar.tsx src/app_modules/donasi/_view/kabar/view_daftar_kabar.tsx src/app_modules/donasi/_view/kabar/view_rekap_kabar.tsx src/app_modules/donasi/component/card_view/ui_card_kabar.tsx src/app_modules/donasi/lib/api_donasi.ts No issue
This commit is contained in:
@@ -366,4 +366,42 @@ export const apiGetDonasiListDonaturById = async ({ id, page }: { id: string, pa
|
||||
throw error; // Re-throw the error to handle it in the calling function
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const apiGetDonasiListKabarById = 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/kabar/${id}/list?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 kabar",
|
||||
response.statusText,
|
||||
errorData
|
||||
);
|
||||
throw new Error(
|
||||
errorData?.message || "Failed to get donasi list kabar"
|
||||
);
|
||||
}
|
||||
|
||||
// Return the JSON response
|
||||
const data = await response.json();
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.error("Error get donasi list kabar", error);
|
||||
throw error; // Re-throw the error to handle it in the calling function
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user