mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-29 23:58:06 +01:00
78f4684b2a
* MetaMetrics: add EVENT.CATEGORIES const * MetaMetrics: add EVENT.CATEGORIES.INPAGE_PROVIDER * MetaMetrics: add EVENT.CATEGORIES.AUTH * MetaMetrics: add EVENT.CATEGORIES.ACCOUNTS pt. 1 * MetaMetrics: add EVENT.CATEGORIES.ACCOUNTS pt. 2 confirm we want to use 'Accounts' instead of 'Account' * MetaMetrics: add EVENT.CATEGORIES.MESSAGES * MetaMetrics: add EVENT.CATEGORIES.RETENTION const * MetaMetrics: add EVENT.CATEGORIES.SETTINGS * MetaMask: add missing EVENT.CATEGORIES.SNAPS * MetaMetrics: add EVENT.CATEGORIES.WALLET const * MetaMetrics: add EVENT.CATEGORIES.ONBOARDING const * MetaMetrics: add EVENT.CATEGORIES.ONBOARDING & EVENT.CATEGORIES.TRANSACTIONS consts * MetaMetrics: use EVENT.CATEGORIES * ducks/swaps: revert slice name * MetaMetrics: add missing EVENT.CATEGORIES.NETWORK
51 lines
1.4 KiB
JavaScript
51 lines
1.4 KiB
JavaScript
import React, { useContext } 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 { MetaMetricsContext } from '../../../../../contexts/metametrics';
|
|
import { EVENT } from '../../../../../../shared/constants/metametrics';
|
|
|
|
export default function AmountMaxButton() {
|
|
const isDraftTransactionInvalid = useSelector(isSendFormInvalid);
|
|
const maxModeOn = useSelector(getSendMaxModeState);
|
|
const dispatch = useDispatch();
|
|
const trackEvent = useContext(MetaMetricsContext);
|
|
const t = useI18nContext();
|
|
|
|
const onMaxClick = () => {
|
|
trackEvent({
|
|
event: 'Clicked "Amount Max"',
|
|
category: EVENT.CATEGORIES.TRANSACTIONS,
|
|
properties: {
|
|
action: 'Edit Screen',
|
|
legacy_event: true,
|
|
},
|
|
});
|
|
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>
|
|
);
|
|
}
|