fix : donasi
deksripsi: - mengant use server menjadi api src/app/api/donasi/[id]/invoice/count/route.ts src/app/api/donasi/[id]/invoice/route.ts src/app/api/donasi/kabar/[id]/route.ts src/app/dev/(user)/donasi/cerita_penggalang/[id]/layout.tsx src/app/dev/(user)/donasi/cerita_penggalang/[id]/page.tsx src/app/dev/(user)/donasi/detail/donasi_saya/[id]/page.tsx src/app/dev/(user)/donasi/detail/kabar/[id]/page.tsx src/app/dev/(user)/donasi/proses_donasi/invoice/[id]/page.tsx src/app_modules/admin/donasi/detail/publish/detail_list_donatur.tsx src/app_modules/admin/donasi/fun/update/fun_update_status_dan_total.ts src/app_modules/donasi/detail/detail_donasi_saya/index.tsx src/app_modules/donasi/detail/detail_kabar/index.tsx src/app_modules/donasi/detail/detail_main/cerita_penggalang/layout.tsx src/app_modules/donasi/lib/api_donasi.ts src/app_modules/donasi/proses_donasi/invoice/index.tsx No Issue
This commit is contained in:
@@ -119,12 +119,12 @@ export const apiGetTemporaryCreate = async ({ id }: { id: string }) => {
|
||||
if (!response.ok) {
|
||||
const errorData = await response.json().catch(() => null);
|
||||
console.error(
|
||||
"Failed to get donasi cerita penggalang",
|
||||
"Failed to get donasi temporary create",
|
||||
response.statusText,
|
||||
errorData
|
||||
);
|
||||
throw new Error(
|
||||
errorData?.message || "Failed to get donasi cerita penggalang"
|
||||
errorData?.message || "Failed to get donasi temporary create"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -132,7 +132,120 @@ export const apiGetTemporaryCreate = async ({ id }: { id: string }) => {
|
||||
const data = await response.json();
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.error("Error get donasi cerita penggalang", error);
|
||||
console.error("Error get donasi temporary create", error);
|
||||
throw error; // Re-throw the error to handle it in the calling function
|
||||
}
|
||||
};
|
||||
|
||||
export const apiGetDonasiInvoiceById = async ({ id }: { id: string }) => {
|
||||
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}/invoice`, {
|
||||
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 invoice",
|
||||
response.statusText,
|
||||
errorData
|
||||
);
|
||||
throw new Error(errorData?.message || "Failed to get donasi invoice");
|
||||
}
|
||||
|
||||
// Return the JSON response
|
||||
const data = await response.json();
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.error("Error get donasi invoice", error);
|
||||
throw error; // Re-throw the error to handle it in the calling function
|
||||
}
|
||||
};
|
||||
|
||||
export const apiGetCountDonatur = async ({ id }: { id: string }) => {
|
||||
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}/invoice/count`, {
|
||||
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 invoice count",
|
||||
response.statusText,
|
||||
errorData
|
||||
);
|
||||
throw new Error(
|
||||
errorData?.message || "Failed to get donasi invoice count"
|
||||
);
|
||||
}
|
||||
|
||||
// Return the JSON response
|
||||
const data = await response.json();
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.error("Error get donasi invoice count", error);
|
||||
throw error; // Re-throw the error to handle it in the calling function
|
||||
}
|
||||
};
|
||||
|
||||
export const apiGetDonasiKabarById = async ({ id }: { id: string }) => {
|
||||
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}`, {
|
||||
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 kabar",
|
||||
response.statusText,
|
||||
errorData
|
||||
);
|
||||
throw new Error(errorData?.message || "Failed to get donasi kabar");
|
||||
}
|
||||
|
||||
// Return the JSON response
|
||||
const data = await response.json();
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.error("Error get donasi kabar", error);
|
||||
throw error; // Re-throw the error to handle it in the calling function
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user