fix admin voting
- fix detail publish voting
This commit is contained in:
@@ -3,6 +3,8 @@ export {
|
||||
apiGetAdminVoteRiwayatCount,
|
||||
apiGetAdminVotingByStatus,
|
||||
apiGetAdminVotingRiwayat,
|
||||
apiGetOneAdminVotingById as apiGetOneVotingById,
|
||||
apiGetAdminKontibutorVotingById,
|
||||
};
|
||||
const apiGetAdminVoteStatusCountDashboard = async ({
|
||||
name,
|
||||
@@ -87,7 +89,6 @@ const apiGetAdminVotingByStatus = async ({
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
const apiGetAdminVotingRiwayat = async ({
|
||||
page,
|
||||
search,
|
||||
@@ -133,3 +134,68 @@ const apiGetAdminVotingRiwayat = async ({
|
||||
}
|
||||
};
|
||||
|
||||
const apiGetOneAdminVotingById = async ({ id }: { id: string }) => {
|
||||
try {
|
||||
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/admin/vote/${id}`, {
|
||||
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 one data voting admin",
|
||||
errorData?.message || "Unknown error"
|
||||
);
|
||||
return null;
|
||||
}
|
||||
|
||||
return response.json();
|
||||
} catch (error) {
|
||||
console.log("Error get one data voting admin", error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
const apiGetAdminKontibutorVotingById = async ({ id }: { id: string }) => {
|
||||
try {
|
||||
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/admin/vote/${id}/kontributor`, {
|
||||
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 one data voting admin",
|
||||
errorData?.message || "Unknown error"
|
||||
);
|
||||
return null;
|
||||
}
|
||||
|
||||
return response.json();
|
||||
} catch (error) {
|
||||
console.log("Error get one data voting admin", error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user