James Prado c631f45ab7 Improve Gas Price UX (Part 2) (#850)
* Remove gas dropdown & Add gas sliders

* Update styles

* Revert changes made to requestpayment.tsx

* Update style & add custom labels to GasLimitField

* Update styles

* Update confirm transaction modal

* Revert "Update confirm transaction modal"

This reverts commit 743c9a505fe070feb55f7af550ad918a3d8899d1.

* Add transaction fee to tx confirmation modal

* Update styles

* Remove old gasPriceDropdown files & use network units in tx fee

* Add option to lock gaslimit data

* fix tslint errors

* Rename lockData to readOnly

* Add option to check if validAmount before generating transaction

* Add nonce field if gas slider is readonly

* Automatically set nonce in  <Send/>

* Update snapshot

* Move getNonceRequested to GasSlider component

* Add optional to check value for isValidAmount selector

* Add selector for transaction fee

* Update GasSlider component & Rename to Gas

* update snapshots

* Fix subtabs className

* Update styles

* Remove dataField on contract interact

* rename <Gas/> to <TXMetaDataPanel/>
2018-01-24 21:43:27 -06:00

109 lines
3.6 KiB
TypeScript

import React, { Component } from 'react';
import { AmountFieldFactory } from 'components/AmountFieldFactory';
import { AddressFieldFactory } from 'components/AddressFieldFactory';
import { connect } from 'react-redux';
import { AppState } from 'reducers';
import { GenerateTransaction, SendButton, SigningStatus, TXMetaDataPanel } from 'components';
import { resetWallet, TResetWallet } from 'actions/wallet';
import translate from 'translations';
import { getUnit } from 'selectors/transaction';
import { getCurrentBalance } from 'selectors/wallet';
import Spinner from 'components/ui/Spinner';
import { Wei, TokenValue } from 'libs/units';
interface StateProps {
unit: string;
resetWallet: TResetWallet;
currentBalance: Wei | TokenValue | null;
}
type Props = StateProps;
class FieldsClass extends Component<Props> {
public render() {
const { currentBalance } = this.props;
return (
<div className="Tab-content-pane">
<div className="row form-group">
<div className="col-xs-12">
<button
className="Deploy-field-reset btn btn-default btn-sm"
onClick={this.changeWallet}
>
<i className="fa fa-refresh" />
{translate('Change Wallet')}
</button>
</div>
<div className="col-xs-12">
<AddressFieldFactory
withProps={({ currentTo }) => (
<input className="form-control" type="text" value={currentTo.raw} readOnly={true} />
)}
/>
</div>
<div className="col-xs-1" />
</div>
<div className="row form-group">
<div className="col-xs-12">
<label>{translate('SEND_amount')}</label>
{currentBalance === null ? (
<div className="row text-center">
<Spinner />
</div>
) : (
<AmountFieldFactory
withProps={({ currentValue, isValid }) => (
<React.Fragment>
{!isValid && (
<h5 style={{ color: 'red' }}>
WARNING: Your ether or token balance is not high enough to complete this
transaction! Please send more funds or switch to a different wallet
</h5>
)}
{isValid && (
<input
className="form-control"
type="text"
value={`${currentValue.raw} ${this.props.unit}`}
readOnly={true}
/>
)}
</React.Fragment>
)}
/>
)}
</div>
</div>
<div className="row form-group">
<div className="col-xs-12">
<TXMetaDataPanel initialState={'simple'} disableToggle={true} />
</div>
</div>
<SigningStatus />
<div className="row form-group">
<div className="col-xs-12 clearfix">
{currentBalance === null ? (
<div className="row text-center">
<Spinner />
</div>
) : (
<GenerateTransaction />
)}
</div>
</div>
<div className="row form-group">
<SendButton />
</div>
</div>
);
}
private changeWallet = () => {
this.props.resetWallet();
};
}
export const Fields = connect(
(state: AppState) => ({ unit: getUnit(state), currentBalance: getCurrentBalance(state) }),
{ resetWallet }
)(FieldsClass);