mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 13:32:00 +00:00
feat(FE-357): Add loading state for export
This commit is contained in:
@@ -33,6 +33,11 @@ interface Totals {
|
||||
}
|
||||
|
||||
const HppPerKandangTab = () => {
|
||||
// ===== STATE MANAGEMENT =====
|
||||
const [isPdfExportLoading, setIsPdfExportLoading] = useState(false);
|
||||
const [isExcelExportLoading, setIsExcelExportLoading] = useState(false);
|
||||
const isAnyExportLoading = isPdfExportLoading || isExcelExportLoading;
|
||||
|
||||
// ===== SUBMISSION STATE =====
|
||||
const [isSubmitted, setIsSubmitted] = useState(false);
|
||||
|
||||
@@ -273,6 +278,7 @@ const HppPerKandangTab = () => {
|
||||
return;
|
||||
}
|
||||
|
||||
setIsExcelExportLoading(true);
|
||||
try {
|
||||
const totals = allExportData.reduce(
|
||||
(acc, item) => ({
|
||||
@@ -400,6 +406,8 @@ const HppPerKandangTab = () => {
|
||||
toast.success('Excel berhasil dibuat dan diunduh.');
|
||||
} catch {
|
||||
toast.error('Gagal membuat Excel. Silakan coba lagi.');
|
||||
} finally {
|
||||
setIsExcelExportLoading(false);
|
||||
}
|
||||
}, [
|
||||
allExportData,
|
||||
@@ -415,6 +423,7 @@ const HppPerKandangTab = () => {
|
||||
return;
|
||||
}
|
||||
|
||||
setIsPdfExportLoading(true);
|
||||
try {
|
||||
const areaName = tableFilterState.area_id
|
||||
? areaOptions.find(
|
||||
@@ -448,6 +457,8 @@ const HppPerKandangTab = () => {
|
||||
toast.success('PDF berhasil dibuat dan diunduh.');
|
||||
} catch {
|
||||
toast.error('Gagal membuat PDF. Silakan coba lagi.');
|
||||
} finally {
|
||||
setIsPdfExportLoading(false);
|
||||
}
|
||||
}, [
|
||||
hppPerKandang,
|
||||
@@ -652,7 +663,11 @@ const HppPerKandangTab = () => {
|
||||
Reset
|
||||
</Button>
|
||||
<Dropdown
|
||||
trigger={<Button color='success'>Export</Button>}
|
||||
trigger={
|
||||
<Button color='success' isLoading={isAnyExportLoading}>
|
||||
Export
|
||||
</Button>
|
||||
}
|
||||
align='end'
|
||||
>
|
||||
<Menu className='w-32'>
|
||||
|
||||
Reference in New Issue
Block a user