1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-03 06:34:27 +01:00
metamask-extension/ui/components/app/nft-options/nft-options.js
Nidhi Kumari 3be1fc6d0c
converted collectibles files to nfts (#17658)
* converted collectibles files to nfts

* updated relative import for scss

* updated scss for pages
2023-02-08 20:04:56 +05:30

62 lines
1.8 KiB
JavaScript

import React, { useContext, useState } from 'react';
import PropTypes from 'prop-types';
import { I18nContext } from '../../../contexts/i18n';
import { Menu, MenuItem } from '../../ui/menu';
import { ICON_NAMES } from '../../component-library';
const CollectibleOptions = ({ onRemove, onViewOnOpensea }) => {
const t = useContext(I18nContext);
const [collectibleOptionsButtonElement, setCollectibleOptionsButtonElement] =
useState(null);
const [collectibleOptionsOpen, setCollectibleOptionsOpen] = useState(false);
return (
<>
<button
className="fas fa-ellipsis-v collectible-options__button"
data-testid="collectible-options__button"
onClick={() => setCollectibleOptionsOpen(true)}
ref={setCollectibleOptionsButtonElement}
/>
{collectibleOptionsOpen ? (
<Menu
anchorElement={collectibleOptionsButtonElement}
data-testid="close-collectible-options-menu"
onHide={() => setCollectibleOptionsOpen(false)}
>
{onViewOnOpensea ? (
<MenuItem
iconName={ICON_NAMES.EXPORT}
data-testid="collectible-options__view-on-opensea"
onClick={() => {
setCollectibleOptionsOpen(false);
onViewOnOpensea();
}}
>
{t('viewOnOpensea')}
</MenuItem>
) : null}
<MenuItem
iconName={ICON_NAMES.TRASH}
data-testid="collectible-item-remove"
onClick={() => {
setCollectibleOptionsOpen(false);
onRemove();
}}
>
{t('removeNFT')}
</MenuItem>
</Menu>
) : null}
</>
);
};
CollectibleOptions.propTypes = {
onRemove: PropTypes.func.isRequired,
onViewOnOpensea: PropTypes.func,
};
export default CollectibleOptions;