1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-02 14:15:06 +01:00
metamask-extension/ui/pages/send/send-content/send-amount-row/amount-max-button/amount-max-button.js
Alex Donesky 8a42258e10
Remove the SHOW_EIP_1559_UI environment variable, replace with network detection where appropriate (#11694)
Fixing up tests and add back old custom gas modal for non-eip1559 compliant networks

Remove unnecessary props from send-gas-row.component

fix breaking test

Fix primary and secondary title overrides

fix rebase issue

Fix rebase conflict

Co-authored-by: David Walsh <davidwalsh83@gmail.com>
2021-07-30 22:59:21 -02:30

49 lines
1.3 KiB
JavaScript

import React from 'react';
import classnames from 'classnames';
import { useDispatch, useSelector } from 'react-redux';
import {
getSendMaxModeState,
isSendFormInvalid,
toggleSendMaxMode,
} from '../../../../../ducks/send';
import { useI18nContext } from '../../../../../hooks/useI18nContext';
import { useMetricEvent } from '../../../../../hooks/useMetricEvent';
export default function AmountMaxButton() {
const isDraftTransactionInvalid = useSelector(isSendFormInvalid);
const maxModeOn = useSelector(getSendMaxModeState);
const dispatch = useDispatch();
const trackClickedMax = useMetricEvent({
eventOpts: {
category: 'Transactions',
action: 'Edit Screen',
name: 'Clicked "Amount Max"',
},
});
const t = useI18nContext();
const onMaxClick = () => {
trackClickedMax();
dispatch(toggleSendMaxMode());
};
const disabled = isDraftTransactionInvalid;
return (
<button
className="send-v2__amount-max"
disabled={disabled}
onClick={onMaxClick}
>
<input type="checkbox" checked={maxModeOn} readOnly />
<div
className={classnames('send-v2__amount-max__button', {
'send-v2__amount-max__button__disabled': disabled,
})}
>
{t('max')}
</div>
</button>
);
}