import { ActionIcon, Group, Tooltip } from '@mantine/core';
import { IconEdit, IconTrash } from '@tabler/icons-react';
import type { TFunction } from 'i18next';
import type { AdvancedColumn } from '@ema-platform/ui';
import type { LocationType } from '../../types/location';

export function locationTypeColumnActions(
  t: TFunction,
  handlers: {
    onEdit: (type: LocationType) => void;
    onDelete: (type: LocationType) => void;
  },
): AdvancedColumn<LocationType> {
  return {
    header: '',
    label: t('location.actions', 'Actions'),
    align: 'right',
    cell: ({ row }) => (
      <Group gap="xs" wrap="nowrap" justify="flex-end">
        <Tooltip label={t('location.edit')}>
          <ActionIcon
            color="blue"
            variant="subtle"
            aria-label={t('location.edit')}
            onClick={() => handlers.onEdit(row.original)}
          >
            <IconEdit size={14} />
          </ActionIcon>
        </Tooltip>
        <Tooltip label={t('location.delete')}>
          <ActionIcon
            color="red"
            variant="subtle"
            aria-label={t('location.delete')}
            onClick={() => handlers.onDelete(row.original)}
          >
            <IconTrash size={14} />
          </ActionIcon>
        </Tooltip>
      </Group>
    ),
  };
}
