2021-11-18 18:54:58 +01:00
|
|
|
import React from 'react';
|
|
|
|
|
2021-11-18 20:08:29 +01:00
|
|
|
import { PRIORITY_LEVELS } from '../../../../shared/constants/gas';
|
2021-11-18 18:54:58 +01:00
|
|
|
import { useI18nContext } from '../../../hooks/useI18nContext';
|
2021-11-23 18:46:33 +01:00
|
|
|
import { useTransactionModalContext } from '../../../contexts/transaction-modal';
|
2021-11-23 19:18:44 +01:00
|
|
|
import ErrorMessage from '../../ui/error-message';
|
2021-11-18 18:54:58 +01:00
|
|
|
import I18nValue from '../../ui/i18n-value';
|
|
|
|
import LoadingHeartBeat from '../../ui/loading-heartbeat';
|
2021-11-23 17:52:50 +01:00
|
|
|
import Popover from '../../ui/popover';
|
|
|
|
import Typography from '../../ui/typography/typography';
|
2021-11-18 18:54:58 +01:00
|
|
|
|
2021-12-03 16:59:48 +01:00
|
|
|
import { COLORS, TYPOGRAPHY } from '../../../helpers/constants/design-system';
|
2021-11-23 19:18:44 +01:00
|
|
|
import { INSUFFICIENT_FUNDS_ERROR_KEY } from '../../../helpers/constants/error-keys';
|
|
|
|
import { useGasFeeContext } from '../../../contexts/gasFee';
|
2021-11-18 18:54:58 +01:00
|
|
|
import EditGasItem from './edit-gas-item';
|
2021-12-06 17:02:23 +01:00
|
|
|
import NetworkStatistics from './network-statistics';
|
2021-11-18 18:54:58 +01:00
|
|
|
|
2021-11-23 18:46:33 +01:00
|
|
|
const EditGasFeePopover = () => {
|
2021-11-23 19:18:44 +01:00
|
|
|
const { balanceError } = useGasFeeContext();
|
2021-11-18 18:54:58 +01:00
|
|
|
const t = useI18nContext();
|
2021-11-23 18:46:33 +01:00
|
|
|
const { closeModal, currentModal } = useTransactionModalContext();
|
|
|
|
|
|
|
|
if (currentModal !== 'editGasFee') return null;
|
2021-11-18 18:54:58 +01:00
|
|
|
|
|
|
|
return (
|
|
|
|
<Popover
|
|
|
|
title={t('editGasFeeModalTitle')}
|
2021-11-23 18:46:33 +01:00
|
|
|
onClose={() => closeModal('editGasFee')}
|
2021-11-18 18:54:58 +01:00
|
|
|
className="edit-gas-fee-popover"
|
|
|
|
>
|
|
|
|
<>
|
2021-12-02 19:16:46 +01:00
|
|
|
{process.env.IN_TEST ? null : <LoadingHeartBeat />}
|
2021-11-18 18:54:58 +01:00
|
|
|
<div className="edit-gas-fee-popover__wrapper">
|
|
|
|
<div className="edit-gas-fee-popover__content">
|
2021-11-23 19:18:44 +01:00
|
|
|
{balanceError && (
|
|
|
|
<ErrorMessage errorKey={INSUFFICIENT_FUNDS_ERROR_KEY} />
|
|
|
|
)}
|
2021-11-18 18:54:58 +01:00
|
|
|
<div className="edit-gas-fee-popover__content__header">
|
|
|
|
<span className="edit-gas-fee-popover__content__header-option">
|
|
|
|
<I18nValue messageKey="gasOption" />
|
|
|
|
</span>
|
|
|
|
<span className="edit-gas-fee-popover__content__header-time">
|
|
|
|
<I18nValue messageKey="time" />
|
|
|
|
</span>
|
|
|
|
<span className="edit-gas-fee-popover__content__header-max-fee">
|
|
|
|
<I18nValue messageKey="maxFee" />
|
|
|
|
</span>
|
|
|
|
</div>
|
2021-11-23 18:46:33 +01:00
|
|
|
<EditGasItem priorityLevel={PRIORITY_LEVELS.LOW} />
|
|
|
|
<EditGasItem priorityLevel={PRIORITY_LEVELS.MEDIUM} />
|
|
|
|
<EditGasItem priorityLevel={PRIORITY_LEVELS.HIGH} />
|
2021-11-18 20:08:29 +01:00
|
|
|
<div className="edit-gas-fee-popover__content__separator" />
|
2021-11-23 18:46:33 +01:00
|
|
|
<EditGasItem priorityLevel={PRIORITY_LEVELS.DAPP_SUGGESTED} />
|
|
|
|
<EditGasItem priorityLevel={PRIORITY_LEVELS.CUSTOM} />
|
2021-12-06 17:02:23 +01:00
|
|
|
<NetworkStatistics />
|
2021-11-23 17:52:50 +01:00
|
|
|
<Typography
|
|
|
|
className="edit-gas-fee-popover__know-more"
|
|
|
|
align="center"
|
|
|
|
color={COLORS.UI4}
|
2021-12-03 16:59:48 +01:00
|
|
|
tag={TYPOGRAPHY.Paragraph}
|
|
|
|
variant={TYPOGRAPHY.H7}
|
2021-11-23 17:52:50 +01:00
|
|
|
>
|
|
|
|
<I18nValue
|
|
|
|
messageKey="learmMoreAboutGas"
|
|
|
|
options={[
|
|
|
|
<a
|
|
|
|
key="learnMoreLink"
|
|
|
|
target="_blank"
|
|
|
|
rel="noopener noreferrer"
|
|
|
|
href="https://metamask.zendesk.com/hc/en-us/articles/4404600179227-User-Guide-Gas"
|
|
|
|
>
|
|
|
|
<I18nValue messageKey="learnMore" />
|
|
|
|
</a>,
|
|
|
|
]}
|
|
|
|
/>
|
|
|
|
</Typography>
|
2021-11-18 18:54:58 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</>
|
|
|
|
</Popover>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default EditGasFeePopover;
|