import type { ColumnDef } from '@tanstack/table-core';
import type { UnitConversion } from '$lib/api/dashboard/a76/general_catalogs/unit-conversions';
import { renderComponent } from '$lib/components/ui/data-table';
import DataTableActions from './data-table-actions.svelte';
export function createColumns(
	onSuccess?: () => void,
	{ canEdit = true, canDelete = true }: { canEdit?: boolean; canDelete?: boolean } = {}
): ColumnDef<UnitConversion>[] {
	return [
		{
			accessorKey: 'from_unit_code',
			header: 'Desde código'
		},
		{
			accessorKey: 'to_unit_code',
			header: 'Hacia código'
		},
		{
			accessorKey: 'conversion_factor',
			header: 'Factor de conversión'
		},
		{
			id: 'actions',
			header: 'Acciones',
			cell: ({ row }) =>
				renderComponent(DataTableActions, {
					conversion: row.original,
					onSuccess,
					canEdit,
					canDelete
				})
		}
	];
}
