/* eslint-disable react-hooks/exhaustive-deps */ import { ButtonCustom, LoaderCustom, Spacing, TextCustom } from "@/components"; import ViewWrapper from "@/components/_ShareComponent/ViewWrapper"; import { AccentColor, MainColor } from "@/constants/color-palet"; import { useAuth } from "@/hooks/use-auth"; import Event_BoxPublishSection from "@/screens/Event/BoxPublishSection"; import { apiEventGetAll } from "@/service/api-client/api-event"; import { dateTimeView } from "@/utils/dateTimeView"; import _ from "lodash"; import { useEffect, useState } from "react"; import { View } from "react-native"; export default function EventHistory() { const [activeCategory, setActiveCategory] = useState("all"); const { user } = useAuth(); const [listData, setListData] = useState([]); const [isLoadList, setIsLoadList] = useState(false); useEffect(() => { onLoadData({ userId: user?.id }); }, [user?.id, activeCategory]); async function onLoadData({ userId }: { userId?: string }) { try { setIsLoadList(true); const response = await apiEventGetAll({ category: activeCategory === "all" ? "all-history" : "my-history", userId: userId, }); if (response.success) { setListData(response.data); } } catch (error) { console.log("[ERROR]", error); } finally { setIsLoadList(false); } } const handlePress = (item: any) => { setActiveCategory(item); // tambahkan logika lain seperti filter dsb. }; const headerComponent = ( handlePress("all")} > Semua Riwayat handlePress("main")} > Riwayat Saya ); return ( {isLoadList ? ( ) : _.isEmpty(listData) ? ( Belum ada riwayat ) : ( listData.map((item: any, index: number) => ( {dateTimeView({ date: item?.tanggal, withoutTime: true })} } href={`/event/${item.id}/history`} /> )) )} ); }