/* eslint-disable react-hooks/exhaustive-deps */ import { BackButton, BaseBox, DotButton, DrawerCustom, LoaderCustom, MenuDrawerDynamicGrid, Spacing, TextCustom, } from "@/components"; import AppHeader from "@/components/_ShareComponent/AppHeader"; import { IconPlus } from "@/components/_Icon"; import NewWrapper from "@/components/_ShareComponent/NewWrapper"; import { usePagination } from "@/hooks/use-pagination"; import { apiInvestmentGetNews } from "@/service/api-client/api-investment"; import { router, Stack, useFocusEffect } from "expo-router"; import { useCallback, useState } from "react"; import { RefreshControl } from "react-native"; import { createPaginationComponents } from "@/helpers/paginationHelpers"; import { PAGINATION_DEFAULT_TAKE } from "@/constants/constans-value"; import Investment_BoxNews from "./BoxNews"; interface InvestmentRecapOfNewsProps { investmentId: string; } export default function Investment_ScreenRecapOfNews({ investmentId, }: InvestmentRecapOfNewsProps) { const [openDrawer, setOpenDrawer] = useState(false); const pagination = usePagination({ fetchFunction: async (page) => { return await apiInvestmentGetNews({ id: investmentId, category: "all-news", page: String(page), }); }, pageSize: PAGINATION_DEFAULT_TAKE, // Sesuaikan dengan jumlah item per halaman dari API dependencies: [investmentId], }); useFocusEffect( useCallback(() => { pagination.onRefresh(); }, [investmentId]), ); const renderItem = ({ item, index }: { item: any; index: number }) => ( ); const { ListEmptyComponent, ListFooterComponent } = createPaginationComponents({ loading: pagination.loading, refreshing: pagination.refreshing, listData: pagination.listData, isInitialLoad: pagination.isInitialLoad, emptyMessage: "Tidak ada berita", skeletonCount: PAGINATION_DEFAULT_TAKE, skeletonHeight: 80, }); return ( <> ( } right={ setOpenDrawer(true)} />} /> ), }} /> } /> setOpenDrawer(false)} height={"auto"} > , }, ]} onPressItem={(item) => { router.push(item.path as any); setOpenDrawer(false); }} /> ); }