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() {