fix admin voting

deksripsi:
- fix table reject, review dan riwayat
This commit is contained in:
2025-02-25 10:41:45 +08:00
parent 03471c2a3a
commit 38e04ff27f
7 changed files with 365 additions and 176 deletions

View File

@@ -2,6 +2,7 @@ export {
apiGetAdminVoteStatusCountDashboard,
apiGetAdminVoteRiwayatCount,
apiGetAdminVotingByStatus,
apiGetAdminVotingRiwayat,
};
const apiGetAdminVoteStatusCountDashboard = async ({
name,
@@ -85,3 +86,50 @@ const apiGetAdminVotingByStatus = async ({
throw error;
}
};
const apiGetAdminVotingRiwayat = async ({
page,
search,
}: {
page: string;
search: 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 isPage = page ? `?page=${page}` : "";
const isSearch = search ? `&search=${search}` : "";
const response = await fetch(
`/api/admin/vote/status/riwayat${isPage}${isSearch}`,
{
headers: {
"Content-Type": "application/json",
Accept: "application/json",
Authorization: `Bearer ${token}`,
},
}
);
// Check if the response is OK
if (!response.ok) {
const errorData = await response.json().catch(() => null);
console.error(
"Error get data voting admin",
errorData?.message || "Unknown error"
);
return null;
}
return response.json();
} catch (error) {
console.log("Error get data voting admin", error);
throw error;
}
};