import React from 'react'; import { useSelector, useDispatch } from 'react-redux'; import Box from '../../../ui/box'; import Typography from '../../../ui/typography'; import CheckBox from '../../../ui/check-box'; import I18nValue from '../../../ui/i18n-value'; import { COLORS, DISPLAY, FLEX_DIRECTION, TYPOGRAPHY, } from '../../../../helpers/constants/design-system'; import { getAdvancedGasFeeValues } from '../../../../selectors'; import { setAdvancedGasFee } from '../../../../store/actions'; import { useAdvancedGasFeePopoverContext } from '../context'; import { useI18nContext } from '../../../../hooks/useI18nContext'; const AdvancedGasFeeDefaults = () => { const t = useI18nContext(); const dispatch = useDispatch(); const { hasErrors, baseFeeMultiplier, maxPriorityFeePerGas, } = useAdvancedGasFeePopoverContext(); const advancedGasFeeValues = useSelector(getAdvancedGasFeeValues); const updateDefaultSettings = (value) => { if (value) { dispatch( setAdvancedGasFee({ maxBaseFee: baseFeeMultiplier, priorityFee: maxPriorityFeePerGas, }), ); } else { dispatch(setAdvancedGasFee(null)); } }; const isDefaultSettingsSelected = Boolean(advancedGasFeeValues) && advancedGasFeeValues.maxBaseFee === baseFeeMultiplier && advancedGasFeeValues.priorityFee === maxPriorityFeePerGas; const handleUpdateDefaultSettings = () => updateDefaultSettings(!isDefaultSettingsSelected); return ( {!isDefaultSettingsSelected && Boolean(advancedGasFeeValues) ? ( {t('newValues')}, ]} /> ) : ( )} ); }; export default AdvancedGasFeeDefaults;