/**
 * Definición de columnas para la tabla de Transportistas
 */
import type { Transporter } from '$lib/api/dashboard/a76/transporters';
import type { ColumnDef } from '@tanstack/table-core';
import { renderComponent } from '$lib/components/ui/data-table';
import DataTableActions from './data-table-actions.svelte';

export function createColumns(onSuccess?: () => void): ColumnDef<Transporter>[] {
    return [
        {
            accessorKey: 'transporter_key',
            header: 'Clave',
            cell: ({ row }) => {
                return row.original.transporter_key;
            }
        },
        {
            accessorKey: 'name',
            header: 'Nombre',
            cell: ({ row }) => {
                return row.original.name || '-';
            }
        },
        {
            accessorKey: 'short_name',
            header: 'Nombre Corto',
            cell: ({ row }) => {
                return row.original.short_name || '-';
            }
        },
        {
            accessorKey: 'rfc',
            header: 'RFC',
            cell: ({ row }) => {
                return row.original.rfc || '-';
            }
        },
        {
            accessorKey: 'caat_code',
            header: 'CAAT',
            cell: ({ row }) => {
                return row.original.caat_code || '-';
            }
        },
        {
            accessorKey: 'transport_code',
            header: 'Código Transporte',
            cell: ({ row }) => {
                return row.original.transport_code || '-';
            }
        },
        {
            id: 'actions',
            header: 'Acciones',
            cell: ({ row }) => {
                return renderComponent(DataTableActions, {
                    item: row.original,
                    onSuccess
                });
            }
        }
    ];
}
