import React from 'react';
import { Menu, Dropdown } from '@arco-design/web-react';
import { Node } from '@xyflow/react';

interface NodeContextMenuProps {
  node: Node;
  onRename?: (node: Node) => void;
  onDelete?: (node: Node) => void;
  onCopy?: (node: Node) => void;
  onEdit?: (node: Node) => void;
}

const NodeContextMenu: React.FC<NodeContextMenuProps> = ({
                                                           node,
                                                           onDelete,
                                                           onCopy,
                                                           onEdit
                                                         }) => {
  const handleDelete = () => {
    onDelete && onDelete(node);
  };

  const handleCopy = () => {
    onCopy && onCopy(node);
  };

  const handleEdit = () => {
    onEdit && onEdit(node);
  };

  return (
    <Menu>
      <Menu.Item key="edit" onClick={handleEdit}>
        编辑节点
      </Menu.Item>

      {(!['start', 'end'].includes(node.type)) && (
        <>
          <Menu.Item key="copy" onClick={handleCopy}>
            复制节点
          </Menu.Item>
          <Menu.Item key="delete" onClick={handleDelete}>
            删除节点
          </Menu.Item>
        </>
      )}
    </Menu>
  );
};

export default NodeContextMenu;