fix: add function download

This commit is contained in:
riefive
2025-11-18 14:54:00 +07:00
parent 2ccdb14999
commit 96c561e86e
+10 -1
View File
@@ -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() {