import type { ColumnDef } from '@tanstack/vue-table';
import { h } from 'vue';
import { DataTableColumnHeader } from '@/components/data-table';
import type { CustomerListItem } from '@/types/customer';
import DataTableActions from './data-table-actions.vue';

export function createColumns(onEdit: (customer: CustomerListItem) => void): ColumnDef<CustomerListItem>[] {
    return [
        {
            accessorKey: 'name',
            enableSorting: true,
            header: () => h(DataTableColumnHeader, { title: 'Nama', column: 'name' }),
        },
        {
            accessorKey: 'phone_number',
            enableSorting: false,
            header: () => h(DataTableColumnHeader, { title: 'Telepon', column: 'phone_number' }),
        },
        {
            accessorKey: 'address',
            enableSorting: false,
            header: () => h(DataTableColumnHeader, { title: 'Alamat', column: 'address' }),
        },
        {
            id: 'actions',
            enableSorting: false,
            enableHiding: false,
            cell: ({ row }) => h(DataTableActions, {
                customer: row.original,
                onEdit: () => onEdit(row.original),
            }),
        },
    ];
}
