import type { ColumnDef } from "@tanstack/table-core";
import type { UnitOfMeasureCustoms } 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<UnitOfMeasureCustoms>[] {
    return [
        {
            accessorKey: "code",
            header: "Código",
        },
        {
            accessorKey: "description",
            header: "Descripción",
        },
        {
            accessorKey: "a76_unit_code",
            header: "Código A76 / SCAII",
        },
        {
            id: "actions",
            header: "Acciones",
            cell: ({ row }) =>
                renderComponent(DataTableActions, {
                    unit: row.original,
                    onSuccess
                }),
        },
    ];
}
