API Voting & Belum di Integrasikan ke UInya
This commit is contained in:
@@ -129,7 +129,7 @@ function TableStatus({ listData }: { listData: any }) {
|
||||
<Center c={AccentColor.white}>{e.title}</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center>
|
||||
<Center c={AccentColor.white}>
|
||||
<Spoiler
|
||||
hideLabel="sembunyikan"
|
||||
maw={400}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
@@ -7,10 +7,11 @@ import { IconAlertTriangle, IconBookmark, IconHistory, IconUpload } from "@table
|
||||
import { AccentColor, AdminColor } from "@/app_modules/_global/color/color_pallet";
|
||||
import { useState } from "react";
|
||||
import { clientLogger } from "@/util/clientLogger";
|
||||
import { apiGetVoteRiwayatCount, apiGetVoteStatusCountDashboard } from "../lib/api_fetch_admin_voting";
|
||||
|
||||
import global_limit from "@/lib/limit";
|
||||
import { useShallowEffect } from "@mantine/hooks";
|
||||
import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
|
||||
import { apiGetAdminVoteRiwayatCount, apiGetAdminVoteStatusCountDashboard } from "../lib/api_fetch_admin_voting";
|
||||
|
||||
export default function AdminVote_Main() {
|
||||
const [countPublish, setCountPublish] = useState<number | null>(null);
|
||||
@@ -36,7 +37,7 @@ export default function AdminVote_Main() {
|
||||
}
|
||||
async function onLoadCountPublish() {
|
||||
try {
|
||||
const response = await apiGetVoteStatusCountDashboard({
|
||||
const response = await apiGetAdminVoteStatusCountDashboard({
|
||||
name: "Publish",
|
||||
})
|
||||
if (response) {
|
||||
@@ -48,7 +49,7 @@ export default function AdminVote_Main() {
|
||||
}
|
||||
async function onLoadCountReview() {
|
||||
try {
|
||||
const response = await apiGetVoteStatusCountDashboard({
|
||||
const response = await apiGetAdminVoteStatusCountDashboard({
|
||||
name: "Review",
|
||||
})
|
||||
|
||||
@@ -61,7 +62,7 @@ export default function AdminVote_Main() {
|
||||
}
|
||||
async function onLoadCountReject() {
|
||||
try {
|
||||
const response = await apiGetVoteStatusCountDashboard({
|
||||
const response = await apiGetAdminVoteStatusCountDashboard({
|
||||
name: "Reject",
|
||||
})
|
||||
if (response) {
|
||||
@@ -73,7 +74,7 @@ export default function AdminVote_Main() {
|
||||
}
|
||||
async function onLoadCountRiwayat() {
|
||||
try {
|
||||
const response = await apiGetVoteRiwayatCount()
|
||||
const response = await apiGetAdminVoteRiwayatCount()
|
||||
if (response) {
|
||||
setCountRiwayat(response.data);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user