mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 05:22:02 +00:00
refactor(FE-357): Rename API response and export fetch vars
This commit is contained in:
@@ -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 ||
|
||||
|
||||
Reference in New Issue
Block a user