From 96c561e86e9fc2a1efa5abc1007ea496e4223666 Mon Sep 17 00:00:00 2001 From: riefive Date: Tue, 18 Nov 2025 14:54:00 +0700 Subject: [PATCH] fix: add function download --- app/components/content/sep/list.vue | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/components/content/sep/list.vue b/app/components/content/sep/list.vue index c4becc6b..e4f48873 100644 --- a/app/components/content/sep/list.vue +++ b/app/components/content/sep/list.vue @@ -26,6 +26,7 @@ import type { VclaimSepData } from '~/models/vclaim' // Libraries import { getFormatDateId } from '~/lib/date' +import { downloadCsv } from '~/lib/download' // Constants import { serviceTypes } from '~/lib/constants.vclaim' @@ -173,7 +174,15 @@ async function getSepList() { function exportCsv() { console.log('Ekspor CSV dipilih') - // tambahkan logic untuk generate CSV + if (!data.value || data.value.length === 0) { + toast({ title: 'Kosong', description: 'Tidak ada data untuk diekspor', variant: 'destructive' }) + return + } + + // build headers from first row keys and use data as array of objects + const headers = Object.keys(data.value[0] || {}) + const filename = `file-sep-${getFormatDateId(today)}.csv` + downloadCsv(headers, data.value, filename) } function exportExcel() {