From 9365320b03ef2e2c5693e425b4b717c253b7968f Mon Sep 17 00:00:00 2001 From: rstubryan Date: Wed, 17 Dec 2025 13:45:00 +0700 Subject: [PATCH] feat(FE-357): Add loading state for export --- .../pages/report/sale/tab/HppPerKandangTab.tsx | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/components/pages/report/sale/tab/HppPerKandangTab.tsx b/src/components/pages/report/sale/tab/HppPerKandangTab.tsx index e50667fd..620f41d6 100644 --- a/src/components/pages/report/sale/tab/HppPerKandangTab.tsx +++ b/src/components/pages/report/sale/tab/HppPerKandangTab.tsx @@ -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 Export} + trigger={ + + } align='end' >