UI – Voting (User) - app/(application)/(user)/voting/(tabs)/index.tsx - app/(application)/(user)/voting/(tabs)/history.tsx - app/(application)/(user)/voting/(tabs)/contribution.tsx - app/(application)/(user)/voting/create.tsx - app/(application)/(user)/voting/[id]/edit.tsx - app/(application)/(user)/voting/[id]/[status]/detail.tsx - app/(application)/(user)/voting/[id]/list-of-contributor.tsx UI – Event - app/(application)/(user)/event/[id]/edit.tsx - screens/Event/ScreenStatus.tsx UI – Voting Screens (New) - screens/Voting/ScreenBeranda.tsx - screens/Voting/ScreenContribution.tsx - screens/Voting/ScreenHistory.tsx - screens/Voting/ScreenListOfContributor.tsx - screens/Voting/ScreenStatus.tsx - screens/Voting/ButtonStatusSection.tsx UI – Job - screens/Job/ButtonStatusSection.tsx - screens/Job/MainViewStatus2.tsx API Client - service/api-client/api-voting.ts Docs - docs/prompt-for-qwen-code.md ### No Issue
71 lines
2.1 KiB
TypeScript
71 lines
2.1 KiB
TypeScript
/* eslint-disable react-hooks/exhaustive-deps */
|
|
import NewWrapper from "@/components/_ShareComponent/NewWrapper";
|
|
import { createPaginationComponents } from "@/helpers/paginationHelpers";
|
|
import { useAuth } from "@/hooks/use-auth";
|
|
import { usePagination } from "@/hooks/use-pagination";
|
|
import Voting_BoxPublishSection from "@/screens/Voting/BoxPublishSection";
|
|
import { apiVotingGetAll } from "@/service/api-client/api-voting";
|
|
import { useMemo } from "react";
|
|
import { RefreshControl } from "react-native";
|
|
|
|
export default function Voting_ScreenContribution() {
|
|
const { user } = useAuth();
|
|
|
|
const pagination = usePagination({
|
|
fetchFunction: async (page) => {
|
|
return await apiVotingGetAll({
|
|
category: "contribution",
|
|
authorId: user?.id as string,
|
|
page: String(page),
|
|
});
|
|
},
|
|
pageSize: 4,
|
|
dependencies: [user?.id],
|
|
onError: (error) => console.error("[ERROR] Fetch contribution:", error),
|
|
});
|
|
|
|
// Gunakan helper untuk membuat komponen-komponen pagination
|
|
const { ListEmptyComponent, ListFooterComponent } =
|
|
createPaginationComponents({
|
|
loading: pagination.loading,
|
|
refreshing: pagination.refreshing,
|
|
listData: pagination.listData,
|
|
emptyMessage: "Tidak ada kontribusi",
|
|
emptySearchMessage: "Tidak ada hasil pencarian",
|
|
skeletonCount: 5,
|
|
skeletonHeight: 200,
|
|
isInitialLoad: pagination.isInitialLoad,
|
|
});
|
|
|
|
// Render item untuk FlatList
|
|
const renderItem = useMemo(
|
|
() =>
|
|
({ item }: { item: any }) =>
|
|
(
|
|
<Voting_BoxPublishSection
|
|
data={item}
|
|
key={item.id}
|
|
href={`/voting/${item.id}/contribution`}
|
|
/>
|
|
),
|
|
[],
|
|
);
|
|
|
|
return (
|
|
<NewWrapper
|
|
listData={pagination.listData}
|
|
renderItem={renderItem}
|
|
ListEmptyComponent={ListEmptyComponent}
|
|
ListFooterComponent={ListFooterComponent}
|
|
onEndReached={pagination.loadMore}
|
|
refreshControl={
|
|
<RefreshControl
|
|
refreshing={pagination.refreshing}
|
|
onRefresh={pagination.onRefresh}
|
|
/>
|
|
}
|
|
hideFooter
|
|
/>
|
|
);
|
|
}
|