Files
hipmi-mobile/screens/Admin/Event/ScreenEventListOfParticipants.tsx
bagasbanuna 6d4dc0f7f7 feat: Complete Admin Phase 1 Event screens migration
- Migrate 8 admin event screens to OS_Wrapper (dashboard, lists, detail, forms, utility)
- Add enableKeyboardHandling to 3 form screens (reject-input, type-create, type-update)
- Migrate ScreenEventTypeOfEvent from Voting to OS_Wrapper
- Update TASK-005 with Admin Phase 1 completion status
- Total: 140 files migrated (~83% complete)

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
2026-04-14 16:55:41 +08:00

85 lines
2.7 KiB
TypeScript

import { OS_Wrapper } from "@/components";
import AdminBackButtonAntTitle from "@/components/_ShareComponent/Admin/BackButtonAntTitle";
import { MainColor } from "@/constants/color-palet";
import { PADDING_INLINE, PAGINATION_DEFAULT_TAKE } from "@/constants/constans-value";
import { createPaginationComponents } from "@/helpers/paginationHelpers";
import { usePagination } from "@/hooks/use-pagination";
import { apiAdminEventListOfParticipants } from "@/service/api-admin/api-admin-event";
import dayjs from "dayjs";
import { useLocalSearchParams } from "expo-router";
import { useCallback } from "react";
import { RefreshControl } from "react-native";
import { Admin_BoxEventParticipant } from "./BoxEventParticipant";
export function Admin_ScreenEventListOfParticipants() {
const { id } = useLocalSearchParams();
// Gunakan hook pagination
const pagination = usePagination({
fetchFunction: async (page, searchQuery) => {
const response = await apiAdminEventListOfParticipants({
id: id as string,
page: String(page),
});
if (response.success) {
return { data: response.data };
} else {
return { data: [] };
}
},
pageSize: PAGINATION_DEFAULT_TAKE,
dependencies: [id],
onError: (error) => {
console.error("Error loading participants:", error);
},
});
// Render item untuk daftar peserta
const renderItem = useCallback(
({ item, index }: { item: any; index: number }) => (
<Admin_BoxEventParticipant
key={index}
item={item}
startDate={dayjs(item?.Event?.tanggal)}
/>
),
[],
);
// Buat komponen-komponen pagination
const { ListEmptyComponent, ListFooterComponent } =
createPaginationComponents({
loading: pagination.loading,
refreshing: pagination.refreshing,
listData: pagination.listData,
searchQuery: "",
emptyMessage: "Belum ada peserta",
emptySearchMessage: "Tidak ada hasil pencarian",
isInitialLoad: pagination.isInitialLoad,
skeletonCount: PAGINATION_DEFAULT_TAKE,
skeletonHeight: 60,
});
return (
<OS_Wrapper
contentPadding={PADDING_INLINE}
listData={pagination.listData}
renderItem={renderItem}
keyExtractor={(item: any) => item.id.toString()}
headerComponent={<AdminBackButtonAntTitle title="Daftar Peserta" />}
ListEmptyComponent={ListEmptyComponent}
ListFooterComponent={ListFooterComponent}
onEndReached={pagination.loadMore}
refreshControl={
<RefreshControl
refreshing={pagination.refreshing}
onRefresh={pagination.onRefresh}
tintColor={MainColor.yellow}
colors={[MainColor.yellow]}
/>
}
/>
);
}