feat(FE): adding export xlsx for report expense, change report data fetching, adding progress bar

This commit is contained in:
randy-ar
2025-12-18 18:13:27 +07:00
parent a935ffd9f5
commit c8a834f84a
9 changed files with 70194 additions and 300 deletions
+1 -38
View File
@@ -1,48 +1,11 @@
'use client';
import { useState } from 'react';
import useSWR from 'swr';
import ReportExpenseTable from '@/components/pages/report/expense/ReportExpenseTable';
import { ReportExpenseApi } from '@/services/api/report';
import { isResponseSuccess } from '@/lib/api-helper';
import { ReportExpenseSearchParams } from '@/types/api/report/report-expense';
const ReportExpense = () => {
const [params, setParams] = useState<ReportExpenseSearchParams>({
locationId: null,
supplierId: null,
kandangId: null,
nonstockId: null,
realizationDate: null,
category: null,
search: '',
});
const reportUrl = `${ReportExpenseApi.basePath}?${new URLSearchParams({
location_id: params.locationId ?? '',
supplier_id: params.supplierId ?? '',
kandang_id: params.kandangId ?? '',
nonstock_id: params.nonstockId ?? '',
realization_date: params.realizationDate ?? '',
category: params.category ?? '',
search: params.search,
})}`;
const { data: reportExpenses } = useSWR(reportUrl, () =>
ReportExpenseApi.getAllFetcher(reportUrl)
);
const onSearch = (searchParams: ReportExpenseSearchParams) => {
setParams(searchParams);
};
return (
<div className='w-full p-4'>
<ReportExpenseTable
reportExpenses={
isResponseSuccess(reportExpenses) ? reportExpenses.data : []
}
onSearch={onSearch}
/>
<ReportExpenseTable />
</div>
);
};