1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-29 15:50:28 +01:00
metamask-extension/ui/components/app/confirm-subtitle/confirm-subtitle.js
rohit kerkar deabc3ed5f
Part of #18714: Replacing deprecated constants in confirm-subtitle folder (#19699)
* repalcing deprecated constants

* resolve issue

* lint fixes

---------

Co-authored-by: georgewrmarshall <george.marshall@consensys.net>
2023-06-26 19:35:45 -07:00

55 lines
1.5 KiB
JavaScript

import React from 'react';
import PropTypes from 'prop-types';
import { useSelector } from 'react-redux';
import { SECONDARY } from '../../../helpers/constants/common';
import { Color, TextVariant } from '../../../helpers/constants/design-system';
import { isNFTAssetStandard } from '../../../helpers/utils/transactions.util';
import { getShouldShowFiat } from '../../../selectors';
import { useTransactionInfo } from '../../../hooks/useTransactionInfo';
import { Text } from '../../component-library';
import UserPreferencedCurrencyDisplay from '../user-preferenced-currency-display';
const ConfirmSubTitle = ({
txData,
hexTransactionAmount,
subtitleComponent,
assetStandard,
}) => {
const shouldShowFiat = useSelector(getShouldShowFiat);
const { isNftTransfer } = useTransactionInfo(txData);
if (!shouldShowFiat && !isNftTransfer && !isNFTAssetStandard(assetStandard)) {
return null;
}
if (subtitleComponent) {
return subtitleComponent;
}
return (
<Text
as="h5"
ellipsis
variant={TextVariant.bodyMd}
color={Color.textAlternative}
>
<UserPreferencedCurrencyDisplay
value={hexTransactionAmount}
type={SECONDARY}
showEthLogo
hideLabel
/>
</Text>
);
};
ConfirmSubTitle.propTypes = {
assetStandard: PropTypes.string,
hexTransactionAmount: PropTypes.string,
subtitleComponent: PropTypes.element,
txData: PropTypes.object.isRequired,
};
export default ConfirmSubTitle;