From 3ee32351e208f5c93b829d1dd218fabf778434da Mon Sep 17 00:00:00 2001 From: Bagasbanuna02 Date: Wed, 17 Jul 2024 11:28:07 +0800 Subject: [PATCH] #style: Deskripsi: - UI Voting: bagian kontribusi dan riwayat ## No issue --- .../vote/detail/kontribusi/[id]/loading.tsx | 9 -- src/app/dev/vote/detail/main/[id]/page.tsx | 5 +- .../vote/detail/riwayat_saya/[id]/loading.tsx | 9 -- .../detail/semua_riwayat/[id]/loading.tsx | 9 -- src/app/dev/vote/main/kontribusi/page.tsx | 5 +- src/app/dev/vote/main/riwayat/page.tsx | 8 +- src/app_modules/home/component/ui_home.tsx | 6 +- .../vote/component/card_view_publish.tsx | 46 +++------- .../vote/detail/kontribusi/index.tsx | 2 +- .../vote/detail/kontribusi/layout.tsx | 8 +- src/app_modules/vote/detail/main/index.tsx | 2 +- src/app_modules/vote/detail/publish/index.tsx | 2 +- src/app_modules/vote/detail/reject/index.tsx | 29 +++---- .../vote/detail/riwayat_saya/index.tsx | 2 +- .../vote/detail/riwayat_saya/layout.tsx | 11 ++- .../vote/detail/semua_riwayat/index.tsx | 8 +- .../vote/detail/semua_riwayat/layout.tsx | 11 ++- .../vote/fun/get/get_all_list_riwayat.ts | 86 ++++++++++--------- .../vote/fun/get/get_all_list_riwayat_saya.ts | 9 +- .../get/get_list_kontribusi_by_author_id.ts | 11 ++- src/app_modules/vote/main/beranda.tsx | 2 +- src/app_modules/vote/main/kontribusi.tsx | 67 +++++++++------ src/app_modules/vote/main/riwayat/index.tsx | 29 ++++++- src/app_modules/vote/main/riwayat/saya.tsx | 72 +++++++++------- src/app_modules/vote/main/riwayat/semua.tsx | 66 +++++++------- src/app_modules/vote/main/status/publish.tsx | 12 +-- 26 files changed, 269 insertions(+), 257 deletions(-) delete mode 100644 src/app/dev/vote/detail/kontribusi/[id]/loading.tsx delete mode 100644 src/app/dev/vote/detail/riwayat_saya/[id]/loading.tsx delete mode 100644 src/app/dev/vote/detail/semua_riwayat/[id]/loading.tsx diff --git a/src/app/dev/vote/detail/kontribusi/[id]/loading.tsx b/src/app/dev/vote/detail/kontribusi/[id]/loading.tsx deleted file mode 100644 index 380b3fcd..00000000 --- a/src/app/dev/vote/detail/kontribusi/[id]/loading.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import ComponentGlobal_V2_LoadingPage from "@/app_modules/_global/loading_page_v2"; - -export default async function Page() { - return ( - <> - - - ); -} diff --git a/src/app/dev/vote/detail/main/[id]/page.tsx b/src/app/dev/vote/detail/main/[id]/page.tsx index 197f4b7e..cbdfffe3 100644 --- a/src/app/dev/vote/detail/main/[id]/page.tsx +++ b/src/app/dev/vote/detail/main/[id]/page.tsx @@ -1,10 +1,9 @@ -import prisma from "@/app/lib/prisma"; import { Vote_MainDetail } from "@/app_modules/vote"; -import { Vote_getHasilVoteById } from "@/app_modules/vote/fun/get/get_list_hasil_by_id"; import { Vote_cekKontributorById } from "@/app_modules/vote/fun/get/cek_kontributor_by_id"; +import { Vote_getHasilVoteById } from "@/app_modules/vote/fun/get/get_list_hasil_by_id"; +import { Vote_getListKontributorById } from "@/app_modules/vote/fun/get/get_list_kontributor_by_id"; import { Vote_getOnebyId } from "@/app_modules/vote/fun/get/get_one_by_id"; import { Vote_getOnePilihanVotingByUserId } from "@/app_modules/vote/fun/get/get_one_pilihan_voting_by_user_id"; -import { Vote_getListKontributorById } from "@/app_modules/vote/fun/get/get_list_kontributor_by_id"; export default async function Page({ params }: { params: { id: string } }) { const voteId = params.id; diff --git a/src/app/dev/vote/detail/riwayat_saya/[id]/loading.tsx b/src/app/dev/vote/detail/riwayat_saya/[id]/loading.tsx deleted file mode 100644 index 380b3fcd..00000000 --- a/src/app/dev/vote/detail/riwayat_saya/[id]/loading.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import ComponentGlobal_V2_LoadingPage from "@/app_modules/_global/loading_page_v2"; - -export default async function Page() { - return ( - <> - - - ); -} diff --git a/src/app/dev/vote/detail/semua_riwayat/[id]/loading.tsx b/src/app/dev/vote/detail/semua_riwayat/[id]/loading.tsx deleted file mode 100644 index 380b3fcd..00000000 --- a/src/app/dev/vote/detail/semua_riwayat/[id]/loading.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import ComponentGlobal_V2_LoadingPage from "@/app_modules/_global/loading_page_v2"; - -export default async function Page() { - return ( - <> - - - ); -} diff --git a/src/app/dev/vote/main/kontribusi/page.tsx b/src/app/dev/vote/main/kontribusi/page.tsx index fa11c1b2..31e1f35f 100644 --- a/src/app/dev/vote/main/kontribusi/page.tsx +++ b/src/app/dev/vote/main/kontribusi/page.tsx @@ -1,9 +1,8 @@ import { Vote_Kontribusi } from "@/app_modules/vote"; -import { Vote_getAllListKontribusiByAuthorId } from "@/app_modules/vote/fun/get/get_list_kontribusi_by_author_id"; - +import { vote_getAllListKontribusiByAuthorId } from "@/app_modules/vote/fun/get/get_list_kontribusi_by_author_id"; export default async function Page() { - const dataKontribusi = await Vote_getAllListKontribusiByAuthorId() + const dataKontribusi = await vote_getAllListKontribusiByAuthorId({ page: 1 }); return ( <> diff --git a/src/app/dev/vote/main/riwayat/page.tsx b/src/app/dev/vote/main/riwayat/page.tsx index 76593fd8..067bdb85 100644 --- a/src/app/dev/vote/main/riwayat/page.tsx +++ b/src/app/dev/vote/main/riwayat/page.tsx @@ -1,10 +1,10 @@ import { Vote_Riwayat } from "@/app_modules/vote"; -import { Vote_getAllListRiwayat } from "@/app_modules/vote/fun/get/get_all_list_riwayat"; -import { Vote_getAllListRiwayatSaya } from "@/app_modules/vote/fun/get/get_all_list_riwayat_saya"; +import { vote_getAllListRiwayat } from "@/app_modules/vote/fun/get/get_all_list_riwayat"; +import { Vote_getAllListRiwayatSaya as vote_getAllListRiwayatSaya } from "@/app_modules/vote/fun/get/get_all_list_riwayat_saya"; export default async function Page() { - const listRiwayat = await Vote_getAllListRiwayat(); - const listRiwayatSaya = await Vote_getAllListRiwayatSaya() + const listRiwayat = await vote_getAllListRiwayat({ page: 1 }); + const listRiwayatSaya = await vote_getAllListRiwayatSaya({ page: 1 }); return ( <> diff --git a/src/app_modules/home/component/ui_home.tsx b/src/app_modules/home/component/ui_home.tsx index 9652211e..19faf8ed 100644 --- a/src/app_modules/home/component/ui_home.tsx +++ b/src/app_modules/home/component/ui_home.tsx @@ -274,11 +274,11 @@ export function Home_UiFooter({ dataUser }: { dataUser: MODEL_USER }) { }} w={"100%"} bottom={0} - h={"10vh"} + h={"9vh"} > {listHalamanFooter.map((e, i) => ( -
+
))} -
+
{data?.Voting_DaftarNamaVote.map((v, i) => ( - {v.value} - + + {v.value} + {v.jumlah} + + - // - // - // - // {v.value} - // - - // - // {v.jumlah} - // - // - // ))} ) : ( - - - - - Voting A - - 2 - - - - - - Voting B - - 3 - - - - - + "" )} {pilihanSaya ? ( diff --git a/src/app_modules/vote/detail/kontribusi/index.tsx b/src/app_modules/vote/detail/kontribusi/index.tsx index 16854181..32dcbe75 100644 --- a/src/app_modules/vote/detail/kontribusi/index.tsx +++ b/src/app_modules/vote/detail/kontribusi/index.tsx @@ -26,7 +26,7 @@ export default function Vote_DetailKontribusi({ }) { return ( <> - + - } + } > {children} - + ); } diff --git a/src/app_modules/vote/detail/main/index.tsx b/src/app_modules/vote/detail/main/index.tsx index e5ecd3a2..716d51e4 100644 --- a/src/app_modules/vote/detail/main/index.tsx +++ b/src/app_modules/vote/detail/main/index.tsx @@ -48,7 +48,7 @@ export default function Vote_MainDetail({ const [data, setData] = useState(dataVote); return ( <> - + - + {/* */} diff --git a/src/app_modules/vote/detail/reject/index.tsx b/src/app_modules/vote/detail/reject/index.tsx index a00089cb..f53b1aa1 100644 --- a/src/app_modules/vote/detail/reject/index.tsx +++ b/src/app_modules/vote/detail/reject/index.tsx @@ -1,29 +1,22 @@ "use client"; +import ComponentGlobal_BoxInformation from "@/app_modules/_global/component/box_information"; +import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil"; +import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal"; +import UIGlobal_Modal from "@/app_modules/_global/ui/ui_modal"; import { Button, - Group, - Modal, SimpleGrid, - Stack, - Text, - Title, + Stack } from "@mantine/core"; -import ComponentVote_DetailDataSebelumPublish from "../../component/detail/detail_data_sebelum_publish"; -import { useRouter } from "next/navigation"; -import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil"; import { useAtom } from "jotai"; -import { gs_vote_status } from "../../global_state"; -import { useDisclosure } from "@mantine/hooks"; -import { MODEL_VOTING } from "../../model/interface"; -import { Vote_funDeleteById } from "../../fun/delete/fun_delete_by_id"; -import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal"; -import { Vote_funEditStatusByStatusId } from "../../fun/edit/fun_edit_status_by_id"; -import ComponentVote_NotedBox from "../../component/noted_box"; -import ComponentGlobal_BoxInformation from "@/app_modules/_global/component/box_information"; +import { useRouter } from "next/navigation"; import { useState } from "react"; -import UIGlobal_Modal from "@/app_modules/_global/ui/ui_modal"; -import { MainColor } from "@/app_modules/_global/color/color_pallet"; +import ComponentVote_DetailDataSebelumPublish from "../../component/detail/detail_data_sebelum_publish"; +import { Vote_funDeleteById } from "../../fun/delete/fun_delete_by_id"; +import { Vote_funEditStatusByStatusId } from "../../fun/edit/fun_edit_status_by_id"; +import { gs_vote_status } from "../../global_state"; +import { MODEL_VOTING } from "../../model/interface"; export default function Vote_DetailReject({ dataVote, diff --git a/src/app_modules/vote/detail/riwayat_saya/index.tsx b/src/app_modules/vote/detail/riwayat_saya/index.tsx index 2f1bbb48..b5c5ec86 100644 --- a/src/app_modules/vote/detail/riwayat_saya/index.tsx +++ b/src/app_modules/vote/detail/riwayat_saya/index.tsx @@ -15,7 +15,7 @@ export default function Vote_DetailRiwayatSaya({ }) { return ( <> - + - } + } > {children} - + ); } diff --git a/src/app_modules/vote/detail/semua_riwayat/index.tsx b/src/app_modules/vote/detail/semua_riwayat/index.tsx index ed83c15b..06cb5091 100644 --- a/src/app_modules/vote/detail/semua_riwayat/index.tsx +++ b/src/app_modules/vote/detail/semua_riwayat/index.tsx @@ -12,17 +12,19 @@ export default function Vote_DetailSemuaRiwayat({ listKontributor, }: { dataVote: MODEL_VOTING; - listKontributor:MODEL_VOTE_KONTRIBUTOR[] + listKontributor: MODEL_VOTE_KONTRIBUTOR[]; }) { return ( <> - + - + ); diff --git a/src/app_modules/vote/detail/semua_riwayat/layout.tsx b/src/app_modules/vote/detail/semua_riwayat/layout.tsx index 0ca2e154..ae50be53 100644 --- a/src/app_modules/vote/detail/semua_riwayat/layout.tsx +++ b/src/app_modules/vote/detail/semua_riwayat/layout.tsx @@ -1,9 +1,8 @@ "use client"; -import { AppShell } from "@mantine/core"; +import UIGlobal_LayoutHeaderTamplate from "@/app_modules/_global/ui/ui_header_tamplate"; +import UIGlobal_LayoutTamplate from "@/app_modules/_global/ui/ui_layout_tamplate"; import React from "react"; -import ComponentVote_HeaderTamplate from "../../component/header_tamplate"; -import AppComponentGlobal_LayoutTamplate from "@/app_modules/_global/component_layout_tamplate"; export default function LayoutVote_DetailSemuaRiwayat({ children, @@ -12,11 +11,11 @@ export default function LayoutVote_DetailSemuaRiwayat({ }) { return ( <> - } + } > {children} - + ); } diff --git a/src/app_modules/vote/fun/get/get_all_list_riwayat.ts b/src/app_modules/vote/fun/get/get_all_list_riwayat.ts index b92fa6f5..ca69b3c7 100644 --- a/src/app_modules/vote/fun/get/get_all_list_riwayat.ts +++ b/src/app_modules/vote/fun/get/get_all_list_riwayat.ts @@ -2,45 +2,51 @@ import prisma from "@/app/lib/prisma" -export async function Vote_getAllListRiwayat() { - const data = await prisma.voting.findMany({ - orderBy: { - createdAt: "asc", - }, - where: { - voting_StatusId: "1", - isActive: true, - akhirVote: { - lte: new Date(), - }, - }, - select: { - id: true, - title: true, - isActive: true, - createdAt: true, - updatedAt: true, - deskripsi: true, - awalVote: true, - akhirVote: true, - catatan: true, - authorId: true, - voting_StatusId: true, - Voting_DaftarNamaVote: { - orderBy: { - createdAt: "asc", - }, - }, - Author: { - select: { - id: true, - username: true, - nomor: true, - Profile: true, - }, - }, - }, - }); +export async function vote_getAllListRiwayat({ page }: { page: number }) { + const takeData = 5; + const skipData = page * takeData - takeData; - return data + const data = await prisma.voting.findMany({ + take: takeData, + skip: skipData, + + orderBy: { + createdAt: "asc", + }, + where: { + voting_StatusId: "1", + isActive: true, + akhirVote: { + lte: new Date(), + }, + }, + select: { + id: true, + title: true, + isActive: true, + createdAt: true, + updatedAt: true, + deskripsi: true, + awalVote: true, + akhirVote: true, + catatan: true, + authorId: true, + voting_StatusId: true, + Voting_DaftarNamaVote: { + orderBy: { + createdAt: "asc", + }, + }, + Author: { + select: { + id: true, + username: true, + nomor: true, + Profile: true, + }, + }, + }, + }); + + return data; } \ No newline at end of file diff --git a/src/app_modules/vote/fun/get/get_all_list_riwayat_saya.ts b/src/app_modules/vote/fun/get/get_all_list_riwayat_saya.ts index 792e81db..7a06720c 100644 --- a/src/app_modules/vote/fun/get/get_all_list_riwayat_saya.ts +++ b/src/app_modules/vote/fun/get/get_all_list_riwayat_saya.ts @@ -3,9 +3,16 @@ import { user_getOneUserId } from "@/app_modules/fun_global/get_user_token"; import prisma from "@/app/lib/prisma"; -export async function Vote_getAllListRiwayatSaya() { +export async function Vote_getAllListRiwayatSaya({ page }: { page: number }) { const authorId = await user_getOneUserId(); + const takeData = 5; + const skipData = page * takeData - takeData; + + const data = await prisma.voting.findMany({ + take: takeData, + skip: skipData, + orderBy: { createdAt: "asc", }, diff --git a/src/app_modules/vote/fun/get/get_list_kontribusi_by_author_id.ts b/src/app_modules/vote/fun/get/get_list_kontribusi_by_author_id.ts index 05110f60..ce4dc19a 100644 --- a/src/app_modules/vote/fun/get/get_list_kontribusi_by_author_id.ts +++ b/src/app_modules/vote/fun/get/get_list_kontribusi_by_author_id.ts @@ -3,9 +3,18 @@ import prisma from "@/app/lib/prisma"; import { user_getOneUserId } from "@/app_modules/fun_global/get_user_token"; -export async function Vote_getAllListKontribusiByAuthorId() { +export async function vote_getAllListKontribusiByAuthorId({ + page, +}: { + page: number; +}) { + const takeData = 5; + const skipData = page * takeData - takeData; + const authorId = await user_getOneUserId(); const data = await prisma.voting_Kontributor.findMany({ + take: takeData, + skip: skipData, orderBy: { createdAt: "asc", }, diff --git a/src/app_modules/vote/main/beranda.tsx b/src/app_modules/vote/main/beranda.tsx index 96425afe..db7bf23d 100644 --- a/src/app_modules/vote/main/beranda.tsx +++ b/src/app_modules/vote/main/beranda.tsx @@ -53,7 +53,7 @@ export default function Vote_Beranda({ ) : ( // --- Main component --- // (
diff --git a/src/app_modules/vote/main/kontribusi.tsx b/src/app_modules/vote/main/kontribusi.tsx index 44d9850f..dadbae4d 100644 --- a/src/app_modules/vote/main/kontribusi.tsx +++ b/src/app_modules/vote/main/kontribusi.tsx @@ -1,51 +1,62 @@ "use client"; import { RouterVote } from "@/app/lib/router_hipmi/router_vote"; -import { - Avatar, - Badge, - Box, - Card, - Center, - Divider, - Grid, - Group, - Radio, - Stack, - Text, - Title, -} from "@mantine/core"; -import moment from "moment"; -import { useRouter } from "next/navigation"; -import ComponentVote_CardViewPublish from "../component/card_view_publish"; -import { MODEL_VOTE_KONTRIBUTOR } from "../model/interface"; +import { Box, Center, Loader, Stack } from "@mantine/core"; import _ from "lodash"; +import ComponentVote_CardViewPublish from "../component/card_view_publish"; import ComponentVote_IsEmptyData from "../component/is_empty_data"; +import { MODEL_VOTE_KONTRIBUTOR } from "../model/interface"; +import ComponentGlobal_IsEmptyData from "@/app_modules/_global/component/is_empty_data"; +import { data } from "autoprefixer"; +import { ScrollOnly } from "next-scroll-loader"; +import { vote_getAllListPublish } from "../fun/get/get_all_list_publish"; +import { useState } from "react"; +import { vote_getAllListKontribusiByAuthorId } from "../fun/get/get_list_kontribusi_by_author_id"; export default function Vote_Kontribusi({ dataKontribusi, }: { dataKontribusi: MODEL_VOTE_KONTRIBUTOR[]; }) { - const router = useRouter(); + const [data, setData] = useState(dataKontribusi); + const [activePage, setActivePage] = useState(1); + return ( <> {_.isEmpty(dataKontribusi) ? ( - + ) : ( - - {dataKontribusi.map((e, i) => ( - + + ( +
+ +
+ )} + data={data} + setData={setData} + moreData={async () => { + const loadData = await vote_getAllListKontribusiByAuthorId({ + page: activePage + 1, + }); + + setActivePage((val) => val + 1); + + return loadData; + }} + > + {(item) => ( -
- ))} -
+ )} + + )} {/*
{JSON.stringify(dataKontribusi, null, 2)}
*/} diff --git a/src/app_modules/vote/main/riwayat/index.tsx b/src/app_modules/vote/main/riwayat/index.tsx index 0efbb358..e8c4e1ac 100644 --- a/src/app_modules/vote/main/riwayat/index.tsx +++ b/src/app_modules/vote/main/riwayat/index.tsx @@ -7,13 +7,14 @@ import Vote_RiwayatSaya from "./saya"; import { useAtom } from "jotai"; import { gs_vote_riwayat } from "../../global_state"; import { MODEL_VOTING } from "../../model/interface"; +import { AccentColor, MainColor } from "@/app_modules/_global/color/color_pallet"; export default function Vote_Riwayat({ listRiwayat, listRiwayatSaya, }: { listRiwayat: MODEL_VOTING[]; - listRiwayatSaya: MODEL_VOTING[] + listRiwayatSaya: MODEL_VOTING[]; }) { const [tabsRiwayat, setTabsRiwayat] = useAtom(gs_vote_riwayat); const listTabs = [ @@ -34,12 +35,23 @@ export default function Vote_Riwayat({ return ( <> @@ -47,8 +59,17 @@ export default function Vote_Riwayat({ {e.label} diff --git a/src/app_modules/vote/main/riwayat/saya.tsx b/src/app_modules/vote/main/riwayat/saya.tsx index 6f9e46d1..c1f46d43 100644 --- a/src/app_modules/vote/main/riwayat/saya.tsx +++ b/src/app_modules/vote/main/riwayat/saya.tsx @@ -1,49 +1,59 @@ "use client"; import { RouterVote } from "@/app/lib/router_hipmi/router_vote"; -import { - Stack, - Card, - Grid, - Avatar, - Divider, - Title, - Badge, - Group, - Radio, - Center, - Text, - Box, -} from "@mantine/core"; -import moment from "moment"; +import { Box, Center, Loader, Stack } from "@mantine/core"; +import _ from "lodash"; import { useRouter } from "next/navigation"; import ComponentVote_CardViewPublish from "../../component/card_view_publish"; -import { MODEL_VOTING } from "../../model/interface"; -import _ from "lodash"; 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 { ScrollOnly } from "next-scroll-loader"; +import { Vote_getAllListRiwayatSaya } from "../../fun/get/get_all_list_riwayat_saya"; export default function Vote_RiwayatSaya({ listRiwayatSaya, }: { listRiwayatSaya: MODEL_VOTING[]; }) { - const router = useRouter(); + const [data, setData] = useState(listRiwayatSaya); + const [activePage, setActivePage] = useState(1); + return ( <> - {_.isEmpty(listRiwayatSaya) ? ( - + {_.isEmpty(data) ? ( + ) : ( - - {listRiwayatSaya.map((e, i) => ( - - - - ))} - + // --- Main component --- // + + ( +
+ +
+ )} + data={data} + setData={setData} + moreData={async () => { + const loadData = await Vote_getAllListRiwayatSaya({ + page: activePage + 1, + }); + setActivePage((val) => val + 1); + + return loadData; + }} + > + {(item) => ( + + )} +
+
)} ); diff --git a/src/app_modules/vote/main/riwayat/semua.tsx b/src/app_modules/vote/main/riwayat/semua.tsx index 537980e2..6e3a027d 100644 --- a/src/app_modules/vote/main/riwayat/semua.tsx +++ b/src/app_modules/vote/main/riwayat/semua.tsx @@ -1,49 +1,57 @@ "use client"; import { RouterVote } from "@/app/lib/router_hipmi/router_vote"; -import { - Stack, - Card, - Grid, - Avatar, - Divider, - Title, - Badge, - Group, - Radio, - Center, - Text, - Box, -} from "@mantine/core"; -import moment from "moment"; -import { useRouter } from "next/navigation"; -import ComponentVote_CardViewPublish from "../../component/card_view_publish"; -import { MODEL_VOTING } from "../../model/interface"; +import ComponentGlobal_IsEmptyData from "@/app_modules/_global/component/is_empty_data"; +import { Box, Center, Loader } from "@mantine/core"; import _ from "lodash"; -import ComponentVote_IsEmptyData from "../../component/is_empty_data"; +import { ScrollOnly } from "next-scroll-loader"; +import { useState } from "react"; +import ComponentVote_CardViewPublish from "../../component/card_view_publish"; +import { vote_getAllListRiwayat } from "../../fun/get/get_all_list_riwayat"; +import { MODEL_VOTING } from "../../model/interface"; export default function Vote_SemuaRiwayat({ listRiwayat, }: { listRiwayat: MODEL_VOTING[]; }) { - const router = useRouter(); + const [data, setData] = useState(listRiwayat); + const [activePage, setActivePage] = useState(1); + return ( <> - {_.isEmpty(listRiwayat) ? ( - + {_.isEmpty(data) ? ( + ) : ( - - {listRiwayat.map((e, i) => ( - + // --- Main component --- // + + ( +
+ +
+ )} + data={data} + setData={setData} + moreData={async () => { + const loadData = await vote_getAllListRiwayat({ + page: activePage + 1, + }); + setActivePage((val) => val + 1); + + return loadData; + }} + > + {(item) => ( -
- ))} -
+ )} + + )} ); diff --git a/src/app_modules/vote/main/status/publish.tsx b/src/app_modules/vote/main/status/publish.tsx index ea2f9f42..9c82b6f3 100644 --- a/src/app_modules/vote/main/status/publish.tsx +++ b/src/app_modules/vote/main/status/publish.tsx @@ -1,18 +1,14 @@ "use client"; import { RouterVote } from "@/app/lib/router_hipmi/router_vote"; -import { Box, Center, Loader, Stack } from "@mantine/core"; -import _ from "lodash"; -import { useRouter } from "next/navigation"; -import ComponentVote_CardViewPublish from "../../component/card_view_publish"; -import ComponentVote_IsEmptyData from "../../component/is_empty_data"; -import { MODEL_VOTING } from "../../model/interface"; -import { RouterJob } from "@/app/lib/router_hipmi/router_job"; import ComponentGlobal_IsEmptyData from "@/app_modules/_global/component/is_empty_data"; -import ComponentJob_CardStatus from "@/app_modules/job/component/card/card_view"; import job_getAllStatusPublish from "@/app_modules/job/fun/get/status/get_list_publish"; +import { Center, Loader } from "@mantine/core"; +import _ from "lodash"; import { ScrollOnly } from "next-scroll-loader"; import { useState } from "react"; +import ComponentVote_CardViewPublish from "../../component/card_view_publish"; +import { MODEL_VOTING } from "../../model/interface"; export default function Vote_StatusPublish({ listPublish,