import type { ClassificationConcept } from '$lib/api/dashboard/a76/general_catalogs/classification-concepts';
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,
    permissions: { canEdit: boolean; canDelete: boolean } = { canEdit: true, canDelete: true }
): ColumnDef<ClassificationConcept>[] {
    return [
        {
            accessorKey: 'classification',
            header: 'Clasificación',
            cell: ({ row }) => row.original.classification || '-'
        },
        {
            id: 'actions',
            header: 'Acciones',
            cell: ({ row }) => {
                return renderComponent(DataTableActions, {
                    item: row.original,
                    onSuccess,
                    canEdit: permissions.canEdit,
                    canDelete: permissions.canDelete
                });
            }
        }
    ];
}
