API Investasi By Id & Fetch API Investasi By Id

This commit is contained in:
2025-02-11 17:33:49 +08:00
parent 7c1d17079a
commit d9c6435044
3 changed files with 102 additions and 0 deletions

View File

@@ -1,6 +1,8 @@
export {
apiGetAdminInvestasiCountDashboard,
apiGetAdminInvestasiByStatus,
apiGetAdminInvestasiById,
}
const apiGetAdminInvestasiCountDashboard = async ({ name }:
{ name: "Publish" | "Review" | "Reject" }) => {
@@ -37,6 +39,7 @@ const apiGetAdminInvestasiByStatus = async ({ status, page, search }: {
const isPage = page ? `?page=${page}` : "";
const isSearch = search ? `&search=${search}` : "";
const response = await fetch(`/api/admin/investasi/${status}${isPage}${isSearch}`, {
method: "GET",
headers: {
"Content-Type": "application/json",
Accept: "application/json",
@@ -45,5 +48,24 @@ const apiGetAdminInvestasiByStatus = async ({ status, page, search }: {
},
})
return await response.json().catch(() => null);
}
const apiGetAdminInvestasiById = async ({id} : {id: string}) => {
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/detail/${id}`, {
method: "GET",
headers: {
"Content-Type": "application/json",
Accept: "application/json",
"Access-Control-Allow-Origin": "*",
Authorization: `Bearer ${token}`,
}
})
console.log("Ini data Response", await response.json())
return await response.json().catch(() => null);
}