1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-25 11:28:51 +01:00
metamask-extension/ui/components/multichain/menu-items/account-details-menu-item.js
David Walsh 46b2290822
Fix #20006 - Add Address Details and View on Explorer to Global Menu (#20013)
* Fix #20006 - Add Address Details and View on Explorer to Global Menu

* Fix tests
2023-07-18 17:01:07 -05:00

55 lines
1.5 KiB
JavaScript

import React, { useContext } from 'react';
import PropTypes from 'prop-types';
import { useDispatch } from 'react-redux';
import { setAccountDetailsAddress } from '../../../store/actions';
import { MenuItem } from '../../ui/menu';
import { useI18nContext } from '../../../hooks/useI18nContext';
import { MetaMetricsContext } from '../../../contexts/metametrics';
import {
MetaMetricsEventCategory,
MetaMetricsEventName,
} from '../../../../shared/constants/metametrics';
import { IconName, Text } from '../../component-library';
export const AccountDetailsMenuItem = ({
metricsLocation,
closeMenu,
address,
textProps,
}) => {
const t = useI18nContext();
const dispatch = useDispatch();
const trackEvent = useContext(MetaMetricsContext);
const LABEL = t('accountDetails');
return (
<MenuItem
onClick={() => {
dispatch(setAccountDetailsAddress(address));
trackEvent({
event: MetaMetricsEventName.NavAccountDetailsOpened,
category: MetaMetricsEventCategory.Navigation,
properties: {
location: metricsLocation,
},
});
closeMenu?.();
}}
iconName={IconName.ScanBarcode}
data-testid="account-list-menu-details"
>
{textProps ? <Text {...textProps}>{LABEL}</Text> : LABEL}
</MenuItem>
);
};
AccountDetailsMenuItem.propTypes = {
metricsLocation: PropTypes.string.isRequired,
closeMenu: PropTypes.func,
address: PropTypes.string.isRequired,
textProps: PropTypes.object,
};