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

export function createColumns(onSuccess?: () => void): ColumnDef<Location>[] {
    return [
        {
            accessorKey: 'location_code',
            header: 'Código',
        },
        {
            accessorKey: 'location_description',
            header: 'Descripción',
            cell: ({ row }) => row.original.location_description || '—'
        },
        {
            id: 'actions',
            header: 'Acciones',
            cell: ({ row }) => renderComponent(DataTableActions, {
                item: row.original,
                onSuccess
            })
        }
    ];
}
