/* 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 Collaboration_BoxPublishSection from "@/screens/Collaboration/BoxPublishSection"; import { apiCollaborationGetAll } from "@/service/api-client/api-collaboration"; import { useFocusEffect } from "expo-router"; import _ from "lodash"; import { useCallback, useState } from "react"; import { View } from "react-native"; export default function CollaborationParticipans() { const [activeCategory, setActiveCategory] = useState< "participant" | "my-project" >("participant"); const { user } = useAuth(); const [listData, setListData] = useState(); const [loadingGetData, setLoadingGetData] = useState(false); useFocusEffect( useCallback(() => { onLoadData(); }, [activeCategory]) ); const onLoadData = async () => { try { setLoadingGetData(true); const response = await apiCollaborationGetAll({ category: activeCategory === "participant" ? "participant" : "my-project", authorId: user?.id, }); setListData(response.data); } catch (error) { console.log("[ERROR]", error); } finally { setLoadingGetData(false); } }; const handlePress = (item: any) => { setActiveCategory(item); // tambahkan logika lain seperti filter dsb. }; const headerComponent = ( handlePress("participant")} > Partisipasi Proyek handlePress("my-project")} > Proyek Saya ); return ( {loadingGetData ? ( ) : _.isEmpty(listData) ? ( Tidak ada data ) : activeCategory === "participant" ? ( listData?.map((item: any, index: number) => ( )) ) : ( listData?.map((item: any, index: number) => ( )) )} ); }