diff --git a/src/components/pages/report/sale/tab/HppPerKandangTab.tsx b/src/components/pages/report/sale/tab/HppPerKandangTab.tsx index 38ac1649..fa0e2df1 100644 --- a/src/components/pages/report/sale/tab/HppPerKandangTab.tsx +++ b/src/components/pages/report/sale/tab/HppPerKandangTab.tsx @@ -165,7 +165,7 @@ const HppPerKandangTab = () => { }, [tableFilterState.period]); // ===== DATA FETCHING ===== - const { data: hppPerKandangResponse, isLoading } = useSWR( + const { data: hppPerKandang, isLoading } = useSWR( isSubmitted ? () => { const params = { @@ -207,27 +207,24 @@ const HppPerKandangTab = () => { const data: HppPerKandangReport['rows'] = useMemo( () => - isResponseSuccess(hppPerKandangResponse) - ? (hppPerKandangResponse?.data?.rows as HppPerKandangReport['rows']) || - [] + isResponseSuccess(hppPerKandang) + ? (hppPerKandang?.data?.rows as HppPerKandangReport['rows']) || [] : [], - [hppPerKandangResponse] + [hppPerKandang] ); const summary = - isResponseSuccess(hppPerKandangResponse) && - hppPerKandangResponse?.data?.summary - ? hppPerKandangResponse.data.summary + isResponseSuccess(hppPerKandang) && hppPerKandang?.data?.summary + ? hppPerKandang.data.summary : undefined; const period = - isResponseSuccess(hppPerKandangResponse) && - hppPerKandangResponse?.data?.period - ? hppPerKandangResponse.data.period + isResponseSuccess(hppPerKandang) && hppPerKandang?.data?.period + ? hppPerKandang.data.period : undefined; // ===== EXPORT DATA FETCHER ===== - const fetchAllExportData = + const hppPerKandangExport = useCallback(async (): Promise => { const params = { area_id: tableFilterState.area_id @@ -270,7 +267,7 @@ const HppPerKandangTab = () => { const handleExportExcel = useCallback(async () => { setIsExcelExportLoading(true); try { - const allDataForExport = await fetchAllExportData(); + const allDataForExport = await hppPerKandangExport(); if ( !allDataForExport ||