import type { ColumnDef } from '@tanstack/table-core';
import type { EquivalencyItem } from '$lib/api/dashboard/a76/general_catalogs/equivalencies';
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<EquivalencyItem>[] {
    return [
        {
            accessorKey: 'original_field',
            header: 'Desde código',
            cell: ({ row }) => row.original.original_field || 'N/A'
        },
        {
            accessorKey: 'external_field',
            header: 'Hacia código',
            cell: ({ row }) => row.original.external_field || 'N/A'
        },
        {
            accessorKey: 'conversion_factor',
            header: 'Factor de conversión',
            cell: ({ row }) => (row.original.conversion_factor ?? 0).toString()
        },
        {
            id: 'actions',
            header: 'Acciones',
            cell: ({ row }) => {
                return renderComponent(DataTableActions, {
                    item: row.original,
                    onSuccess,
                    canEdit,
                    canDelete
                });
            }
        }
    ];
}
