import React from 'react';
import { HiPencil, HiTrash } from 'react-icons/hi';
import { ActionsTd, ActionsTh, IconButton, TableActionGroup } from '@/shared/components/ui';

interface AdminRowActionsProps {
  editLabel: string;
  deleteLabel: string;
  confirmDelete: string;
  onEdit: () => void;
  onDelete: () => void;
  showEdit?: boolean;
}

export const AdminRowActions: React.FC<AdminRowActionsProps> = ({
  editLabel,
  deleteLabel,
  confirmDelete,
  onEdit,
  onDelete,
  showEdit = true,
}) => (
  <ActionsTd>
    <TableActionGroup>
      {showEdit ? (
        <IconButton tone="primary" label={editLabel} size="sm" onClick={onEdit}>
          <HiPencil aria-hidden />
        </IconButton>
      ) : null}
      <IconButton
        tone="danger"
        size="sm"
        label={deleteLabel}
        onClick={() => {
          if (window.confirm(confirmDelete)) {
            onDelete();
          }
        }}
      >
        <HiTrash aria-hidden />
      </IconButton>
    </TableActionGroup>
  </ActionsTd>
);

export { ActionsTh as AdminActionsHeader };
