/* eslint-disable react-hooks/exhaustive-deps */ import { AvatarUsernameAndOtherComponent, BadgeCustom, BaseBox, LoaderCustom, TextCustom, ViewWrapper, } from "@/components"; import { apiEventGetOne, apiEventListOfParticipants, } from "@/service/api-client/api-event"; import dayjs, { Dayjs } from "dayjs"; import { useFocusEffect, useLocalSearchParams } from "expo-router"; import _ from "lodash"; import { useCallback, useState } from "react"; import { View } from "react-native"; export default function EventListOfParticipants() { const { id } = useLocalSearchParams(); const [startDate, setStartDate] = useState(); const [listData, setListData] = useState(null); const [loadtData, setLoadData] = useState(false); useFocusEffect( useCallback(() => { handlerLoadData(); }, [id]) ); const handlerLoadData = () => { try { onLoadData(); onLoadList(); } catch (error) { console.log("[ERROR]", error); } }; const onLoadData = async () => { try { const response = await apiEventGetOne({ id: id as string }); if (response.success) { const date = dayjs(response.data.tanggal); setStartDate(date); } } catch (error) { console.log("[ERROR]", error); } }; const onLoadList = async () => { try { setLoadData(true); const response = await apiEventListOfParticipants({ id: id as string }); if (response.success) { setListData(response.data); } } catch (error) { console.log("[ERROR]", error); } finally { setLoadData(false); } }; return ( {loadtData && !listData ? ( ) : _.isEmpty(listData) ? ( Belum ada peserta ) : ( listData?.map((item: any, index: number) => ( {item?.isPresent ? "Hadir" : "Tidak Hadir"} ) : ( - ) } /> )) )} ); }