API Voting & Belum di Integrasikan ke UInya
This commit is contained in:
@@ -1,14 +1,15 @@
|
||||
export {
|
||||
apiGetVoteStatusCountDashboard,
|
||||
apiGetVoteRiwayatCount
|
||||
apiGetAdminVoteStatusCountDashboard,
|
||||
apiGetAdminVoteRiwayatCount,
|
||||
apiGetAdminVotingByStatus
|
||||
}
|
||||
const apiGetVoteStatusCountDashboard = async ({ name }: {
|
||||
const apiGetAdminVoteStatusCountDashboard = 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/voting/dashboard/${name}`, {
|
||||
const response = await fetch(`/api/admin/vote/dashboard/${name}`, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
@@ -19,11 +20,11 @@ const apiGetVoteStatusCountDashboard = async ({ name }: {
|
||||
});
|
||||
return await response.json().catch(() => null);
|
||||
}
|
||||
const apiGetVoteRiwayatCount = async () => {
|
||||
const apiGetAdminVoteRiwayatCount = async () => {
|
||||
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/voting/dashboard/riwayat`, {
|
||||
const response = await fetch(`/api/admin/vote/dashboard/riwayat`, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
@@ -33,4 +34,31 @@ const apiGetVoteRiwayatCount = async () => {
|
||||
}
|
||||
});
|
||||
return await response.json().catch(() => null);
|
||||
}
|
||||
|
||||
const apiGetAdminVotingByStatus = async ({
|
||||
name,
|
||||
page,
|
||||
search }: {
|
||||
name: "Publish" | "Review" | "Reject";
|
||||
page: string;
|
||||
search: string;
|
||||
}) => {
|
||||
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
|
||||
if (!token) return await token.json().catch(() => null);
|
||||
|
||||
const isPage = page ? `?page=${page}` : "";
|
||||
const isSearch = search ? `&search=${search}` : "";
|
||||
const response = await fetch(
|
||||
`/api/admin/vote/status/${name}${isPage}${isSearch}`,
|
||||
{
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Accept: "application/json",
|
||||
"Access-Control-Allow-Origin": "*",
|
||||
Authorization: `Bearer ${token}`
|
||||
}
|
||||
}
|
||||
)
|
||||
return await response.json().catch(() => null);
|
||||
}
|
||||
Reference in New Issue
Block a user