fix: add function download
This commit is contained in:
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user