import type { ColumnDef } from '@tanstack/table-core';
import type { Equivalency } from '$lib/api/dashboard/a76/general_catalogs/equivalencies';
import { renderComponent } from '$lib/components/ui/data-table';
import DataTableActions from './data-table-actions.svelte';
import { Header } from '$lib/components/ui/alert-dialog';

export function createColumns(onSuccess?: () => void): ColumnDef<Equivalency>[] {
    return [
        {
            accessorKey: 'fraccion_mex',
            header: 'Fracción MX',
            cell: ({ row }) => row.original.fraccion_mex || 'N/A'
        },
        {
            accessorKey: 'fraccion_us',
            header: 'Fracción US',
            cell: ({ row }) => row.original.fraccion_us || 'N/A'
        },
        {
            accessorKey: 'description',
            header: 'Descripción',
            cell: ({ row }) => row.original.description || 'N/A'
        },
        {
            id: 'actions',
            Header: 'Acciones',
            cell: ({ row }) => {
                return renderComponent(DataTableActions, {
                    item: row.original,
                    onSuccess
                });
            }
        }
    ];
}
