mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-22 14:25:47 +00:00
feat(FE): adding export xlsx for report expense, change report data fetching, adding progress bar
This commit is contained in:
@@ -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>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user