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,56 +2,82 @@
import { RouterVote } from "@/app/lib/router_hipmi/router_vote";
import ComponentGlobal_IsEmptyData from "@/app_modules/_global/component/is_empty_data";
import job_getAllStatusPublish from "@/app_modules/job/fun/get/status/get_list_publish";
import { Center, Loader } from "@mantine/core";
import { clientLogger } from "@/util/clientLogger";
import { Box, Center, Loader, Stack } 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 ComponentVote_CardViewPublish from "../../component/card_view_publish";
import { MODEL_VOTING } from "../../model/interface";
import { Voting_ComponentSkeletonViewPublish } from "../../component";
export default function Vote_StatusPublish({
listPublish,
}: {
listPublish: MODEL_VOTING[];
}) {
const [data, setData] = useState(listPublish);
export default function Vote_StatusPublish() {
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: "1",
});
if (respone) {
setData(respone.data);
}
} catch (error) {
clientLogger.error("Error get data review", error);
}
}
return (
<>
{_.isEmpty(data) ? (
<ComponentGlobal_IsEmptyData />
) : (
// --- Main component --- //
<ScrollOnly
height="75vh"
renderLoading={() => (
<Center mt={"lg"}>
<Loader color={"yellow"} />
</Center>
)}
data={data}
setData={setData}
moreData={async () => {
const loadData = await job_getAllStatusPublish({
page: activePage + 1,
});
<Stack>
{_.isNull(data) ? (
<Voting_ComponentSkeletonViewPublish />
) : _.isEmpty(data) ? (
<ComponentGlobal_IsEmptyData />
) : (
// --- Main component --- //
<Box>
<ScrollOnly
height="75vh"
renderLoading={() => (
<Center mt={"lg"}>
<Loader color={"yellow"} />
</Center>
)}
data={data}
setData={setData as any}
moreData={async () => {
const respone = await apiGetAllVoting({
kategori: "status",
page: `${activePage + 1}`,
status: "1",
});
setActivePage((val) => val + 1);
setActivePage((val) => val + 1);
return loadData;
}}
>
{(item) => (
<ComponentVote_CardViewPublish
data={item}
path={RouterVote.detail_publish}
statusArsip
/>
)}
</ScrollOnly>
)}
return respone.data;
}}
>
{(item) => (
<ComponentVote_CardViewPublish
data={item}
path={RouterVote.detail_publish}
statusArsip
/>
)}
</ScrollOnly>
</Box>
)}
</Stack>
</>
);
}