diff --git a/frontend/src/stores/fleetDashboardStore.js b/frontend/src/stores/fleetDashboardStore.js index 82d8bff..7e88851 100644 --- a/frontend/src/stores/fleetDashboardStore.js +++ b/frontend/src/stores/fleetDashboardStore.js @@ -1037,6 +1037,22 @@ export async function downloadGeneratedPdfByUrl(downloadUrl, filename = 'documen } } +export async function downloadGeneratedArchiveByUrl(downloadUrl, filename = 'archive.zip') { + if (!downloadUrl) { + showToast('Nedostaje URL za preuzimanje ZIP arhive.', 'error'); + throw new Error('Nedostaje URL za preuzimanje ZIP arhive.'); + } + try { + const blob = await api.get(downloadUrl, { responseType: 'blob' }); + saveBlobToFile(blob, filename); + return true; + } catch (err) { + const msg = err?.message || 'Preuzimanje ZIP arhive nije uspjelo.'; + showToast(msg, 'error'); + throw err; + } +} + export function openWorkOrderInvoicesPdfPage(workOrderId) { if (!isBrowser() || !workOrderId) { return;