mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 13:32:00 +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]);
|
}, [tableFilterState.period]);
|
||||||
|
|
||||||
// ===== DATA FETCHING =====
|
// ===== DATA FETCHING =====
|
||||||
const { data: hppPerKandangResponse, isLoading } = useSWR(
|
const { data: hppPerKandang, isLoading } = useSWR(
|
||||||
isSubmitted
|
isSubmitted
|
||||||
? () => {
|
? () => {
|
||||||
const params = {
|
const params = {
|
||||||
@@ -207,27 +207,24 @@ const HppPerKandangTab = () => {
|
|||||||
|
|
||||||
const data: HppPerKandangReport['rows'] = useMemo(
|
const data: HppPerKandangReport['rows'] = useMemo(
|
||||||
() =>
|
() =>
|
||||||
isResponseSuccess(hppPerKandangResponse)
|
isResponseSuccess(hppPerKandang)
|
||||||
? (hppPerKandangResponse?.data?.rows as HppPerKandangReport['rows']) ||
|
? (hppPerKandang?.data?.rows as HppPerKandangReport['rows']) || []
|
||||||
[]
|
|
||||||
: [],
|
: [],
|
||||||
[hppPerKandangResponse]
|
[hppPerKandang]
|
||||||
);
|
);
|
||||||
|
|
||||||
const summary =
|
const summary =
|
||||||
isResponseSuccess(hppPerKandangResponse) &&
|
isResponseSuccess(hppPerKandang) && hppPerKandang?.data?.summary
|
||||||
hppPerKandangResponse?.data?.summary
|
? hppPerKandang.data.summary
|
||||||
? hppPerKandangResponse.data.summary
|
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
const period =
|
const period =
|
||||||
isResponseSuccess(hppPerKandangResponse) &&
|
isResponseSuccess(hppPerKandang) && hppPerKandang?.data?.period
|
||||||
hppPerKandangResponse?.data?.period
|
? hppPerKandang.data.period
|
||||||
? hppPerKandangResponse.data.period
|
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
// ===== EXPORT DATA FETCHER =====
|
// ===== EXPORT DATA FETCHER =====
|
||||||
const fetchAllExportData =
|
const hppPerKandangExport =
|
||||||
useCallback(async (): Promise<HppPerKandangReport | null> => {
|
useCallback(async (): Promise<HppPerKandangReport | null> => {
|
||||||
const params = {
|
const params = {
|
||||||
area_id: tableFilterState.area_id
|
area_id: tableFilterState.area_id
|
||||||
@@ -270,7 +267,7 @@ const HppPerKandangTab = () => {
|
|||||||
const handleExportExcel = useCallback(async () => {
|
const handleExportExcel = useCallback(async () => {
|
||||||
setIsExcelExportLoading(true);
|
setIsExcelExportLoading(true);
|
||||||
try {
|
try {
|
||||||
const allDataForExport = await fetchAllExportData();
|
const allDataForExport = await hppPerKandangExport();
|
||||||
|
|
||||||
if (
|
if (
|
||||||
!allDataForExport ||
|
!allDataForExport ||
|
||||||
|
|||||||
Reference in New Issue
Block a user