A Metamask fork with Infura removed and default networks editable
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ciphermask/ui/pages/send/send-content/send-amount-row/send-amount-row.component.js

63 lines
1.6 KiB

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';
7 years ago
export default class SendAmountRow extends Component {
static propTypes = {
amount: PropTypes.string,
inError: PropTypes.bool,
asset: PropTypes.object,
7 years ago
updateSendAmount: PropTypes.func,
};
static contextTypes = {
t: PropTypes.func,
};
7 years ago
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}
hexValue={amount}
/>
);
}
render() {
const { inError, asset } = this.props;
if (asset.type === ASSET_TYPES.COLLECTIBLE) {
return null;
}
7 years ago
return (
<SendRowWrapper
label={`${this.context.t('amount')}:`}
showError={inError}
errorType="amount"
7 years ago
>
<AmountMaxButton inError={inError} />
{this.renderInput()}
7 years ago
</SendRowWrapper>
);
7 years ago
}
}