/* eslint-disable react-hooks/exhaustive-deps */ import { BackButton, BoxButtonOnFooter, ButtonCustom, DotButton, DrawerCustom, MenuDrawerDynamicGrid, StackCustom, ViewWrapper, } from "@/components"; import { IconNews } from "@/components/_Icon"; import { useAuth } from "@/hooks/use-auth"; import Donation_ComponentBoxDetailData from "@/screens/Donation/ComponentBoxDetailData"; import Donation_ComponentInfoFundrising from "@/screens/Donation/ComponentInfoFundrising"; import Donation_ComponentStoryFunrising from "@/screens/Donation/ComponentStoryFunrising"; import Donation_ProgressSection from "@/screens/Donation/ProgressSection"; import { apiDonationGetOne } from "@/service/api-client/api-donation"; import { countDownAndCondition } from "@/utils/countDownAndCondition"; import { router, Stack, useFocusEffect, useLocalSearchParams, } from "expo-router"; import { useCallback, useEffect, useState } from "react"; export default function DonasiDetailBeranda() { const { user } = useAuth(); const { id } = useLocalSearchParams(); const [openDrawer, setOpenDrawer] = useState(false); const [data, setData] = useState(); useFocusEffect( useCallback(() => { onLoadData(); }, [id]) ); const onLoadData = async () => { try { const response = await apiDonationGetOne({ id: id as string, category: "permanent", }); setData(response.data); } catch (error) { console.log("[ERROR]", error); } }; const [value, setValue] = useState({ sisa: 0, reminder: false, }); useEffect(() => { updateCountDown(); }, [data]); const updateCountDown = () => { const countDown = countDownAndCondition({ duration: data?.DonasiMaster_Durasi?.name, publishTime: data?.publishTime, }); setValue({ sisa: countDown.durationDay, reminder: countDown.reminder, }); }; const buttonSection = ( <> router.navigate(`/donation/${id}/(transaction-flow)`)} > {value?.reminder ? "Waktu berakhir" : "Donasi"} ); return ( <> , headerRight: () => user?.id === data?.Author?.id ? ( setOpenDrawer(true)} /> ) : null, }} /> } /> setOpenDrawer(false)} height={"auto"} > , label: "Rekap Kabar", path: `/donation/${id}/(news)/recap-of-news`, }, ]} onPressItem={(item) => { console.log("PATH ", item.path); router.navigate(item.path as any); setOpenDrawer(false); }} /> ); }