import React from 'react';
import { Button, Space, Popconfirm } from 'antd';
import { EditOutlined, DeleteOutlined, SaveOutlined, CloseOutlined } from '@ant-design/icons';

export const TeamActions = ({
  record,
  editable,
  editingKey,
  onEdit,
  onSave,
  onCancel,
  onDelete,
}) => {
  if (editable) {
    return (
      <Space>
        <Button
          icon={<SaveOutlined />}
          onClick={() => onSave(record.id)}
          type="link"
        >
          保存
        </Button>
        <Button
          icon={<CloseOutlined />}
          onClick={onCancel}
          type="link"
        >
          取消
        </Button>
      </Space>
    );
  }

  return (
    <Space>
      <Button
        disabled={editingKey !== ''}
        icon={<EditOutlined />}
        onClick={() => onEdit(record)}
        type="link"
      >
        编辑
      </Button>
      <Popconfirm
        title="确定要删除该团队吗？"
        onConfirm={() => onDelete(record.id)}
      >
        <Button
          icon={<DeleteOutlined />}
          type="link"
          danger
        >
          删除
        </Button>
      </Popconfirm>
    </Space>
  );
};