refactor(FE-364): Timestamp purchases-per-supplier export filenames

This commit is contained in:
rstubryan
2025-12-18 13:39:05 +07:00
parent 915e68f755
commit 85fddcb19a
2 changed files with 2 additions and 27 deletions
@@ -421,7 +421,7 @@ export const generatePurchasesPerSupplierPDF = async (
const url = URL.createObjectURL(blob);
const link = document.createElement('a');
link.href = url;
link.download = `laporan-pembelian-per-supplier-${formatDate(new Date(), 'YYYY-MM-DD-HHmm')}.pdf`;
link.download = `laporan-pembelian-per-supplier-dicetak-pada${formatDate(new Date(), 'YYYY-MM-DD-HHmm')}.pdf`;
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
@@ -361,31 +361,6 @@ const PurchasesPerSupplierTab = () => {
const workbook = XLSX.utils.book_new();
const areaName =
tableFilterState.area_id.length > 0
? tableFilterState.area_id
.map(
(id) =>
areaOptions.find((opt) => opt.value === Number(id))?.label
)
.filter(Boolean)
.join(', ') || 'Semua Area'
: 'Semua Area';
const supplierName =
tableFilterState.supplier_id.length > 0
? tableFilterState.supplier_id
.map(
(id) =>
supplierOptions.find((opt) => opt.value === Number(id))?.label
)
.filter(Boolean)
.join(', ') || 'Semua Supplier'
: 'Semua Supplier';
const startDate = tableFilterState.start_date || 'all';
const endDate = tableFilterState.end_date || 'all';
Object.entries(groupedBySupplier).forEach(
([supplierName, supplierData]) => {
const totals = supplierData.reduce(
@@ -477,7 +452,7 @@ const PurchasesPerSupplierTab = () => {
}
);
const filename = `Laporan_Pembelian_Per_Supplier_${areaName}_${supplierName}_${startDate}_to_${endDate}.xlsx`;
const filename = `laporan-pembelian-per-supplier-dicetak-pada${formatDate(new Date(), 'YYYY-MM-DD-HHmm')}.xlsx`;
XLSX.writeFile(workbook, filename);
toast.success('Excel berhasil dibuat dan diunduh.');