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

export function createColumns(
    onSuccess: () => void,
    permissions: { canEdit: boolean; canDelete: boolean } = { canEdit: true, canDelete: true }
): ColumnDef<Seal>[] {
    return [
    
        {
            accessorKey: 'seal',
            header: 'Sello',
            cell: ({ row }) => row.original.seal,
        },
        {
            id: 'actions',
            header: 'Acciones',
            meta: {},
            cell: ({ row }) => renderComponent(DataTableActions, {
                item: row.original,
                onSuccess,
                canEdit: permissions.canEdit,
                canDelete: permissions.canDelete
            })
        }
    ];
}