mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 13:32:00 +00:00
feat(FE-363): Add Excel export loading and combine export state
This commit is contained in:
@@ -46,6 +46,8 @@ interface GroupedSupplierData {
|
||||
const PurchasesPerSupplierTab = () => {
|
||||
// ===== STATE MANAGEMENT =====
|
||||
const [isPdfExportLoading, setIsPdfExportLoading] = useState(false);
|
||||
const [isExcelExportLoading, setIsExcelExportLoading] = useState(false);
|
||||
const isAnyExportLoading = isPdfExportLoading || isExcelExportLoading;
|
||||
|
||||
// ===== PAGINATION STATE =====
|
||||
const [currentPage, setCurrentPage] = useState(1);
|
||||
@@ -256,9 +258,9 @@ const PurchasesPerSupplierTab = () => {
|
||||
);
|
||||
|
||||
const meta =
|
||||
isResponseSuccess(purchasePerSupplier) && 'meta' in purchasePerSupplier
|
||||
isResponseSuccess(purchasePerSupplier) && purchasePerSupplier?.meta
|
||||
? purchasePerSupplier.meta
|
||||
: undefined;
|
||||
: null;
|
||||
|
||||
const { data: allDataForExport } = useSWR(
|
||||
isSubmitted
|
||||
@@ -327,6 +329,7 @@ const PurchasesPerSupplierTab = () => {
|
||||
toast.error('Tidak ada data untuk diekspor.');
|
||||
return;
|
||||
}
|
||||
setIsExcelExportLoading(true);
|
||||
|
||||
try {
|
||||
const groupedBySupplier: { [key: string]: typeof allExportData } = {};
|
||||
@@ -453,6 +456,8 @@ const PurchasesPerSupplierTab = () => {
|
||||
toast.success('Excel berhasil dibuat dan diunduh.');
|
||||
} catch {
|
||||
toast.error('Gagal membuat Excel. Silakan coba lagi.');
|
||||
} finally {
|
||||
setIsExcelExportLoading(false);
|
||||
}
|
||||
}, [allExportData, tableFilterState, areaOptions, supplierOptions]);
|
||||
|
||||
@@ -727,7 +732,7 @@ const PurchasesPerSupplierTab = () => {
|
||||
</Button>
|
||||
<Dropdown
|
||||
trigger={
|
||||
<Button color='success' isLoading={isPdfExportLoading}>
|
||||
<Button color='success' isLoading={isAnyExportLoading}>
|
||||
Export
|
||||
</Button>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user