2023-03-23 19:21:33 +01:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import { useSelector } from 'react-redux';
|
|
|
|
|
|
|
|
import { SECONDARY } from '../../../helpers/constants/common';
|
2023-06-27 04:35:45 +02:00
|
|
|
import { Color, TextVariant } from '../../../helpers/constants/design-system';
|
2023-06-02 15:03:10 +02:00
|
|
|
import { isNFTAssetStandard } from '../../../helpers/utils/transactions.util';
|
2023-03-23 19:21:33 +01:00
|
|
|
import { getShouldShowFiat } from '../../../selectors';
|
|
|
|
import { useTransactionInfo } from '../../../hooks/useTransactionInfo';
|
2023-06-02 15:03:10 +02:00
|
|
|
import { Text } from '../../component-library';
|
|
|
|
import UserPreferencedCurrencyDisplay from '../user-preferenced-currency-display';
|
2023-03-23 19:21:33 +01:00
|
|
|
|
|
|
|
const ConfirmSubTitle = ({
|
|
|
|
txData,
|
|
|
|
hexTransactionAmount,
|
|
|
|
subtitleComponent,
|
2023-06-02 15:03:10 +02:00
|
|
|
assetStandard,
|
2023-03-23 19:21:33 +01:00
|
|
|
}) => {
|
|
|
|
const shouldShowFiat = useSelector(getShouldShowFiat);
|
|
|
|
const { isNftTransfer } = useTransactionInfo(txData);
|
|
|
|
|
2023-06-02 15:03:10 +02:00
|
|
|
if (!shouldShowFiat && !isNftTransfer && !isNFTAssetStandard(assetStandard)) {
|
2023-03-23 19:21:33 +01:00
|
|
|
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 = {
|
2023-06-02 15:03:10 +02:00
|
|
|
assetStandard: PropTypes.string,
|
2023-03-23 19:21:33 +01:00
|
|
|
hexTransactionAmount: PropTypes.string,
|
|
|
|
subtitleComponent: PropTypes.element,
|
|
|
|
txData: PropTypes.object.isRequired,
|
|
|
|
};
|
|
|
|
|
|
|
|
export default ConfirmSubTitle;
|