Fix voting
Deksripsi: - Fix user server to API di tampilan utama voting
This commit is contained in:
@@ -1,28 +1,47 @@
|
||||
"use client";
|
||||
|
||||
import { RouterVote } from "@/app/lib/router_hipmi/router_vote";
|
||||
import { Box, Center, Loader, Stack } from "@mantine/core";
|
||||
import _ from "lodash";
|
||||
import ComponentVote_CardViewStatus from "../../component/card_view_status";
|
||||
import ComponentVote_IsEmptyData from "../../component/is_empty_data";
|
||||
import { MODEL_VOTING } from "../../model/interface";
|
||||
import { useState } from "react";
|
||||
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 { vote_getAllReview } from "../../fun/get/status/get_all_review";
|
||||
import { vote_getAllDraft } from "../../fun/get/status/get_all_draft";
|
||||
import { useState } from "react";
|
||||
import { apiGetAllVoting } from "../../_lib/api_voting";
|
||||
import { Voting_ComponentSkeletonViewStatus } from "../../component";
|
||||
import ComponentVote_CardViewStatus from "../../component/card_view_status";
|
||||
import { MODEL_VOTING } from "../../model/interface";
|
||||
|
||||
export default function Vote_StatusDraft({
|
||||
listDraft,
|
||||
}: {
|
||||
listDraft: MODEL_VOTING[];
|
||||
}) {
|
||||
const [data, setData] = useState(listDraft);
|
||||
export default function Vote_StatusDraft() {
|
||||
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: "3",
|
||||
});
|
||||
|
||||
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 --- //
|
||||
@@ -35,20 +54,22 @@ export default function Vote_StatusDraft({
|
||||
</Center>
|
||||
)}
|
||||
data={data}
|
||||
setData={setData}
|
||||
setData={setData as any}
|
||||
moreData={async () => {
|
||||
const loadData = await vote_getAllDraft({
|
||||
page: activePage + 1,
|
||||
const respone = await apiGetAllVoting({
|
||||
kategori: "status",
|
||||
page: `${activePage + 1}`,
|
||||
status: "3",
|
||||
});
|
||||
setActivePage((val) => val + 1);
|
||||
|
||||
return loadData;
|
||||
return respone.data;
|
||||
}}
|
||||
>
|
||||
{(item) => (
|
||||
<ComponentVote_CardViewStatus
|
||||
data={item}
|
||||
path={RouterVote.detail_draft}
|
||||
path={RouterVote.detail_review}
|
||||
/>
|
||||
)}
|
||||
</ScrollOnly>
|
||||
|
||||
Reference in New Issue
Block a user