import type { ColumnDef } from '@tanstack/table-core';
import type { Prevalidator } from '$lib/api/dashboard/a76/general_catalogs/prevalidators';
import { renderComponent } from '$lib/components/ui/data-table';
import DataTableActions from './data-table-actions.svelte';
export function createColumns(
    onSuccess?: () => void,
    { canEdit = true, canDelete = true }: { canEdit?: boolean; canDelete?: boolean } = {}
): ColumnDef<Prevalidator>[] {
    return [
        {
            accessorKey: 'code',
            header: 'Código',
            cell: ({ row }) => row.original.code || 'N/A'
        },
        {
            accessorKey: 'description',
            header: 'Descripción',
            cell: ({ row }) => row.original.description || 'N/A'
        },
        {
            accessorKey: 'customs_prevalidator',
            header: 'Aduana',
            cell: ({ row }) => row.original.customs_prevalidator || 'N/A'
        },
        {
            accessorKey: 'patent_prevalidator',
            header: 'Patente',
            cell: ({ row }) => row.original.patent_prevalidator || 'N/A'
        },
        {
            id: 'actions',
            header: 'Acciones',
            cell: ({ row }) => {
                return renderComponent(DataTableActions, {
                    item: row.original,
                    onSuccess,
                    canEdit,
                    canDelete
                });
            }
        }
    ];
}
