1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-28 23:06:37 +01:00
metamask-extension/ui/pages/send/send-content/send-amount-row/send-amount-row.component.js
Alex Donesky 4826c8c95e
Feat/collectibles send flow (#13048)
* Add collectibles send flow
2022-01-10 10:23:53 -06:00

63 lines
1.6 KiB
JavaScript

import React, { Component } from 'react';
import PropTypes from 'prop-types';
import SendRowWrapper from '../send-row-wrapper';
import UserPreferencedCurrencyInput from '../../../../components/app/user-preferenced-currency-input';
import UserPreferencedTokenInput from '../../../../components/app/user-preferenced-token-input';
import { ASSET_TYPES } from '../../../../ducks/send';
import AmountMaxButton from './amount-max-button';
export default class SendAmountRow extends Component {
static propTypes = {
amount: PropTypes.string,
inError: PropTypes.bool,
asset: PropTypes.object,
updateSendAmount: PropTypes.func,
};
static contextTypes = {
t: PropTypes.func,
};
handleChange = (newAmount) => {
this.props.updateSendAmount(newAmount);
};
renderInput() {
const { amount, inError, asset } = this.props;
return asset.type === ASSET_TYPES.TOKEN ? (
<UserPreferencedTokenInput
error={inError}
onChange={this.handleChange}
token={asset.details}
value={amount}
/>
) : (
<UserPreferencedCurrencyInput
error={inError}
onChange={this.handleChange}
value={amount}
/>
);
}
render() {
const { inError, asset } = this.props;
if (asset.type === ASSET_TYPES.COLLECTIBLE) {
return null;
}
return (
<SendRowWrapper
label={`${this.context.t('amount')}:`}
showError={inError}
errorType="amount"
>
<AmountMaxButton inError={inError} />
{this.renderInput()}
</SendRowWrapper>
);
}
}