/* eslint-disable react-hooks/exhaustive-deps */ import { AvatarUsernameAndOtherComponent, BoxWithHeaderSection, LoaderCustom, Spacing, StackCustom, TextCustom, ViewWrapper } from "@/components"; import { useAuth } from "@/hooks/use-auth"; import { apiEventGetAll } from "@/service/api-client/api-event"; import { dateTimeView } from "@/utils/dateTimeView"; import { useFocusEffect } from "expo-router"; import _ from "lodash"; import React, { useCallback, useState } from "react"; export default function EventContribution() { const { user } = useAuth(); const [listData, setListData] = useState([]); const [isLoadList, setIsLoadList] = useState(false); useFocusEffect( useCallback(() => { onLoadData(); }, [user?.id]) ); async function onLoadData() { try { setIsLoadList(true); const response = await apiEventGetAll({ category: "contribution", userId: user?.id, }); console.log("[DATA] ", JSON.stringify(response.data, null, 2)); if (response.success) { setListData(response.data); // const responseListParticipants = await apiEventListOfParticipants({ // id: response?.data?.Event?.id, // }); // console.log( // "[LIST PARTICIPANTS]", // JSON.stringify(responseListParticipants.data, null, 2) // ); // if (responseListParticipants.success) { // setListParticipants(responseListParticipants.data); // } } } catch (error) { console.log("[ERROR]", error); } finally { setIsLoadList(false); } } return ( {isLoadList ? ( ) : _.isEmpty(listData) ? ( Belum ada kontribusi ) : ( listData.map((item: any, index: number) => ( {dateTimeView({ date: item?.Event?.tanggal, withoutTime: true, })} } /> {item?.Event?.title} {/* {item?.Event?.Event_Peserta?.map( (item2: any, index2: number) => ( ) )} */} )) )} ); }