import type { ColumnDef } from '@tanstack/vue-table'; import { h } from 'vue'; import { Badge } from '@/components/ui/badge'; import { DataTableColumnHeader } from '@/components/data-table'; import type { OwnerVerificationItem } from '@/types/owner-verification'; import DataTableActions from './data-table-actions.vue'; function statusBadgeVariant(status: string): 'default' | 'destructive' | 'outline' | 'secondary' { if (status === 'approved') { return 'default'; } if (status === 'rejected') { return 'destructive'; } return 'outline'; } export function createColumns( onView: (item: OwnerVerificationItem) => void, ): ColumnDef[] { return [ { accessorKey: 'created_at_formatted', enableSorting: true, header: () => h(DataTableColumnHeader, { title: 'Waktu', column: 'created_at' }), cell: ({ row }) => row.original.created_at_formatted ?? '-', }, { accessorKey: 'submitted_by_name', enableSorting: false, header: 'Diajukan Oleh', }, { accessorKey: 'action_label', enableSorting: true, header: () => h(DataTableColumnHeader, { title: 'Aksi', column: 'action' }), }, { accessorKey: 'subject_label', enableSorting: false, header: 'Modul', }, { accessorKey: 'title', enableSorting: false, header: 'Item', }, { accessorKey: 'status_label', enableSorting: true, header: () => h(DataTableColumnHeader, { title: 'Status', column: 'status' }), cell: ({ row }) => h( Badge, { variant: statusBadgeVariant(row.original.status) }, () => row.original.status_label, ), }, { id: 'actions', enableSorting: false, enableHiding: false, cell: ({ row }) => h(DataTableActions, { item: row.original, onView: () => onView(row.original), }), }, ]; }