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 { 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, maxBaseFee, maxPriorityFeePerGas, } = useAdvancedGasFeePopoverContext(); const advancedGasFeeValues = useSelector(getAdvancedGasFeeValues); const updateDefaultSettings = (value) => { if (value) { dispatch( setAdvancedGasFee({ maxBaseFee, priorityFee: maxPriorityFeePerGas, }), ); } else { dispatch(setAdvancedGasFee(null)); } }; const isDefaultSettingsSelected = Boolean(advancedGasFeeValues) && advancedGasFeeValues.maxBaseFee === maxBaseFee && advancedGasFeeValues.priorityFee === maxPriorityFeePerGas; const handleUpdateDefaultSettings = () => updateDefaultSettings(!isDefaultSettingsSelected); return ( {!isDefaultSettingsSelected && Boolean(advancedGasFeeValues) ? t('advancedGasFeeDefaultOptIn', [ {t('newValues')}, ]) : t('advancedGasFeeDefaultOptOut')} ); }; export default AdvancedGasFeeDefaults;