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