Fix voting

Deksripsi:
- Fix user server to API di tampilan utama voting
This commit is contained in:
2024-12-27 11:04:55 +08:00
parent 5f8a1c38d0
commit 924e994236
34 changed files with 1039 additions and 468 deletions

View File

@@ -2,25 +2,46 @@
import { RouterVote } from "@/app/lib/router_hipmi/router_vote";
import ComponentGlobal_IsEmptyData from "@/app_modules/_global/component/is_empty_data";
import { clientLogger } from "@/util/clientLogger";
import { Box, Center, Loader } from "@mantine/core";
import { useShallowEffect } from "@mantine/hooks";
import _ from "lodash";
import { ScrollOnly } from "next-scroll-loader";
import { useState } from "react";
import { apiGetAllVoting } from "../../_lib/api_voting";
import { Voting_ComponentSkeletonViewStatus } from "../../component";
import ComponentVote_CardViewStatus from "../../component/card_view_status";
import { vote_getAllReject } from "../../fun/get/status/get_all_reject";
import { MODEL_VOTING } from "../../model/interface";
export default function Vote_StatusReject({
listReject,
}: {
listReject: MODEL_VOTING[];
}) {
const [data, setData] = useState(listReject);
export default function Vote_StatusReject() {
const [data, setData] = useState<MODEL_VOTING[] | null>(null);
const [activePage, setActivePage] = useState(1);
useShallowEffect(() => {
onLoad();
}, []);
async function onLoad() {
try {
const respone = await apiGetAllVoting({
kategori: "status",
page: "1",
status: "4",
});
if (respone) {
setData(respone.data);
}
} catch (error) {
clientLogger.error("Error get data review", error);
}
}
return (
<>
{_.isEmpty(data) ? (
{_.isNull(data) ? (
<Voting_ComponentSkeletonViewStatus />
) : _.isEmpty(data) ? (
<ComponentGlobal_IsEmptyData />
) : (
// --- Main component --- //
@@ -33,20 +54,22 @@ export default function Vote_StatusReject({
</Center>
)}
data={data}
setData={setData}
setData={setData as any}
moreData={async () => {
const loadData = await vote_getAllReject({
page: activePage + 1,
const respone = await apiGetAllVoting({
kategori: "status",
page: `${activePage + 1}`,
status: "4",
});
setActivePage((val) => val + 1);
return loadData;
return respone.data;
}}
>
{(item) => (
<ComponentVote_CardViewStatus
data={item}
path={RouterVote.detail_reject}
path={RouterVote.detail_review}
/>
)}
</ScrollOnly>