API Table Investasi Admin

This commit is contained in:
2025-02-04 22:35:44 +08:00
parent 257c1ebaad
commit c53ca6d355
40 changed files with 1737 additions and 378 deletions

View File

@@ -0,0 +1,51 @@
export {
apiGetAdminInvestasiCountDashboard,
apiGetAdminInvestasiByStatus,
}
const apiGetAdminInvestasiCountDashboard = async ({ name }:
{ name: "Publish" | "Review" | "Reject" }) => {
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/investasi/dashboard/${name}`, {
method: "GET",
headers: {
"Content-Type": "application/json",
Accept: "application/json",
"Access-Control-Allow-Origin": "*",
Authorization: `Bearer ${token}`,
},
})
return await response.json().catch(() => null);
};
const apiGetAdminInvestasiByStatus = async ({ status, page, search }: {
status: "Publish" | "Review" | "Reject",
page: string,
search: string
}) => {
console.log("dgsdg")
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
if (!token) return await token.json().catch(() => null);
console.log("Ini token", token)
console.log("Ini Page", page)
console.log("Ini Search", search)
const isPage = page ? `?page=${page}` : "";
const isSearch = search ? `&search=${search}` : "";
const response = await fetch(`/api/admin/investasi/${status}${isPage}${isSearch}`, {
headers: {
"Content-Type": "application/json",
Accept: "application/json",
"Access-Control-Allow-Origin": "*",
Authorization: `Bearer ${token}`,
},
})
console.log("Ini response", response)
return await response.json().catch(() => null);
}

View File

@@ -1,22 +0,0 @@
const apiGetInvestasiCountDashboard = async ({ name }:
{ name: "Publish" | "Review" | "Reject" }) => {
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/investasi/dashboard/${name}`, {
method: "GET",
headers: {
"Content-Type": "application/json",
Accept: "application/json",
"Access-Control-Allow-Origin": "*",
Authorization: `Bearer ${token}`,
},
})
return await response.json().catch(() => null);
};
export default apiGetInvestasiCountDashboard;