refactor(FE-357): Rename API response and export fetch vars

This commit is contained in:
rstubryan
2025-12-17 14:14:27 +07:00
parent e1b562c175
commit 80fd75dfc1
@@ -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<HppPerKandangReport | null> => {
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 ||