import type { ColumnDef } from "@tanstack/table-core";
import type { UnitOfMeasureOMA } from "$lib/api/dashboard/a76/general_catalogs/units-of-measure";
import { renderComponent } from "$lib/components/ui/data-table/index.js";
import DataTableActions from "./data-table-actions.svelte";

export function createColumns(onSuccess?: () => void): ColumnDef<UnitOfMeasureOMA>[] {
    return [
        {
            accessorKey: "code",
            header: "Código",
        },
        {
            accessorKey: "description",
            header: "Descripción",
        },
        {
            id: "actions",
            header: "Acciones",
            cell: ({ row }) =>
                renderComponent(DataTableActions, {
                    unit: row.original,
                    onSuccess
                }),
        },
    ];
}
