/* eslint-disable react-hooks/exhaustive-deps */ import { ButtonCustom, Spacing, TextCustom, OS_Wrapper } from "@/components"; import { AccentColor, MainColor } from "@/constants/color-palet"; import { PAGINATION_DEFAULT_TAKE, PADDING_INLINE } from "@/constants/constans-value"; import { createPaginationComponents } from "@/helpers/paginationHelpers"; import { useAuth } from "@/hooks/use-auth"; import { usePagination } from "@/hooks/use-pagination"; import Event_BoxPublishSection from "@/screens/Event/BoxPublishSection"; import { apiEventGetAll } from "@/service/api-client/api-event"; import { dateTimeView } from "@/utils/dateTimeView"; import _ from "lodash"; import { useState } from "react"; import { RefreshControl, View } from "react-native"; export default function Event_ScreenHistory() { const [activeCategory, setActiveCategory] = useState("all"); const { user } = useAuth(); // Setup pagination const pagination = usePagination({ fetchFunction: async (page) => { return await apiEventGetAll({ category: activeCategory === "all" ? "all-history" : "my-history", userId: user?.id, page: String(page), }); }, pageSize: PAGINATION_DEFAULT_TAKE, dependencies: [user?.id, activeCategory], onError: (error) => console.error("[ERROR] Fetch event history:", error), }); // Generate komponen const { ListEmptyComponent, ListFooterComponent } = createPaginationComponents({ loading: pagination.loading, refreshing: pagination.refreshing, listData: pagination.listData, emptyMessage: "Belum ada riwayat", skeletonCount: PAGINATION_DEFAULT_TAKE, skeletonHeight: 100, }); // Render item event const renderEventItem = ({ item }: { item: any }) => ( {dateTimeView({ date: item?.tanggal, withoutTime: true })} } href={`/event/${item.id}/history`} /> ); const handlePress = (item: any) => { setActiveCategory(item); // Reset pagination saat kategori berubah pagination.reset(); }; const headerComponent = ( handlePress("all")} > Semua Riwayat handlePress("main")} > Riwayat Saya ); return ( } onEndReached={pagination.loadMore} ListEmptyComponent={ListEmptyComponent} ListFooterComponent={ListFooterComponent} hideFooter /> ); }