import type { ColumnDef } from '@tanstack/table-core';
import type { INPC } from '$lib/api/dashboard/a76/general_catalogs/inpc';
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 }): ColumnDef<INPC>[] {
    return [
        {
            accessorKey: 'year',
            header: 'Año',
            cell: ({ row }) => row.original.year || 'N/A'
        },
        {
            accessorKey: 'month',
            header: 'Mes',
            cell: ({ row }) => row.original.month || 'N/A'
        },
        {
            accessorKey: 'value',
            header: 'Valor',
            cell: ({ row }) => row.original.value?.toString() || 'N/A'
        },
        {
            id: 'actions',
            header: 'Acciones',
            cell: ({ row }) => {
                return renderComponent(DataTableActions, {
                    item: row.original,
                    onSuccess
                });
            }
        }
    ];
}
