import type { ColumnDef } from '@tanstack/vue-table';
import { h } from 'vue';
import { DataTableColumnHeader } from '@/components/data-table';
import type { CategoryListItem } from '@/types/category';
import DataTableActions from './data-table-actions.vue';

export function createColumns(onEdit: (category: CategoryListItem) => void): ColumnDef<CategoryListItem>[] {
    return [
        {
            accessorKey: 'name',
            enableSorting: true,
            header: () => h(DataTableColumnHeader, { title: 'Nama', column: 'name' }),
        },
        {
            id: 'actions',
            enableSorting: false,
            enableHiding: false,
            cell: ({ row }) => h(DataTableActions, {
                category: row.original,
                onEdit: () => onEdit(row.original),
            }),
        },
    ];
}
