import { ActionIcon, Group, Tooltip } from '@mantine/core';
import { IconTrash } from '@tabler/icons-react';
import type { AdvancedColumn } from '@ema-platform/ui';
import type { Item } from '../../api/item-api';

export function itemActionsColumn(handlers: {
  onDelete: (item: Item) => void;
}): AdvancedColumn<Item> {
  return {
    header: '',
    label: 'Actions',
    align: 'right',
    cell: ({ row }) => (
      <Group gap="xs" wrap="nowrap" justify="flex-end">
        <Tooltip label="Delete">
          <ActionIcon
            color="red"
            variant="subtle"
            aria-label="Delete"
            onClick={() => handlers.onDelete(row.original)}
          >
            <IconTrash size={16} />
          </ActionIcon>
        </Tooltip>
      </Group>
    ),
  };
}
