/* eslint-disable react-hooks/exhaustive-deps */ import { FloatingButton, LoaderCustom, SearchInput, TextCustom, ViewWrapper, } from "@/components"; import { useAuth } from "@/hooks/use-auth"; import Voting_BoxPublishSection from "@/screens/Voting/BoxPublishSection"; import { apiVotingGetAll } from "@/service/api-client/api-voting"; import { router, useFocusEffect } from "expo-router"; import _ from "lodash"; import { useCallback, useState } from "react"; export default function VotingBeranda() { const { user } = useAuth(); const [listData, setListData] = useState([]); const [loadingGetData, setLoadingGetData] = useState(false); const [search, setSearch] = useState(""); useFocusEffect( useCallback(() => { onLoadData(); }, [search]) ); const onLoadData = async () => { try { setLoadingGetData(true); const response = await apiVotingGetAll({ search, category: "beranda", userLoginId: user?.id, }); if (response.success) { setListData(response.data); } } catch (error) { console.log("[ERROR]", error); } finally { setLoadingGetData(false); } }; return ( router.push("/voting/create")} /> } headerComponent={ } > {loadingGetData ? ( ) : _.isEmpty(listData) ? ( Tidak ada data ) : ( listData.map((item: any, index: number) => ( )) )} ); }