import { useAuth } from 'components/easyUse';
import { modules } from 'constants/authority';
import React from 'react';
import styles from './ContextMenu.less';

export default function ContextMenu({ visible, position, onCopy, onDelete }) {
  const { checkAuth } = useAuth();

  return (
    <div className={styles.menu} style={{ display: visible ? 'block' : 'none', left: position.x + 10, top: position.y }}>
      {checkAuth(modules.componentAdd) && (
        <div className={styles.item} onClick={onCopy}>
          <i className="icon iconfont icon-icon_right_copy" />
          <span>复制</span>
        </div>
      )}
      <div className={styles.item} onClick={onDelete}>
        <i className="icon iconfont icon-icon_right_delete" />
        <span>删除</span>
      </div>
    </div>
  );
}
