Fix Typescript Refactor (#229)

* Remove console logs.

* Fix undefined error by binding method.

* Show 0's in input field.

* Remove various unused imports.
This commit is contained in:
Daniel Ternyak 2017-09-24 20:29:49 -07:00 committed by GitHub
parent 7087950c10
commit 3660260efb
10 changed files with 37 additions and 63 deletions

View File

@ -14,16 +14,13 @@ interface State {
}
export default class QRCode extends React.Component<Props, State> {
public state: State = {}
public state: State = {};
public componentWillMount() {
console.error(this.props.data)
// Start generating QR codes immediately
this.generateQrCode(this.props.data);
}
public componentWillReceiveProps(nextProps: Props) {
console.error(this.props.data)
// Regenerate QR codes if props change
if (nextProps.data !== this.props.data) {
this.generateQrCode(nextProps.data);
@ -51,7 +48,6 @@ export default class QRCode extends React.Component<Props, State> {
this.setState({ qr: cache[value] });
return;
}
console.error(value, 'Value')
QRCodeLib.toDataURL(
value,
{

View File

@ -157,7 +157,7 @@ export default class DownloadWallet extends Component<Props, State> {
}
};
private handleDownloadKeystore(e): void {
private handleDownloadKeystore = (e): void => {
this.state.keystore ? this.markDownloaded() : e.preventDefault();
}
};
}

View File

@ -1,8 +1,8 @@
import Big, { BigNumber } from 'bignumber.js';
import Big from 'bignumber.js';
import Identicon from 'components/ui/Identicon';
import Modal, { IButton } from 'components/ui/Modal';
import Spinner from 'components/ui/Spinner';
import { NetworkConfig, NodeConfig, Token } from 'config/data';
import { NetworkConfig, NodeConfig } from 'config/data';
import EthTx from 'ethereumjs-tx';
import ERC20 from 'libs/erc20';
import {

View File

@ -4,12 +4,7 @@ import Big from 'bignumber.js';
import { BalanceSidebar } from 'components';
// COMPONENTS
import { UnlockHeader } from 'components/ui';
import {
donationAddressMap,
NetworkConfig,
NodeConfig,
Token
} from 'config/data';
import { donationAddressMap, NetworkConfig, NodeConfig } from 'config/data';
// CONFIG
import { TransactionWithoutGas } from 'libs/messages';
import { RPCNode } from 'libs/nodes';
@ -53,7 +48,6 @@ import {
ConfirmationModal,
CustomMessage,
DataField,
Donate,
GasField
} from './components';
// MISC
@ -357,24 +351,6 @@ export class SendTransaction extends React.Component<Props, State> {
}
}
// FIXME use mkTx instead or something that could take care of default gas/data and whatnot,
public onNewTx = (
address: string,
amount: string,
unit: UnitKey,
data: string = '',
gasLimit: string = '21000'
) => {
this.setState({
to: address,
value: amount,
unit,
data,
gasLimit,
gasChanged: false
});
};
public onAddressChange = (value: string) => {
this.setState({
to: value

View File

@ -35,9 +35,13 @@ export interface ActionProps {
interface State {
disabled: boolean;
showMinMaxError: boolean;
showedMinMaxError: boolean;
}
export default class CurrencySwap extends Component<StateProps & ActionProps> {
export default class CurrencySwap extends Component<
StateProps & ActionProps,
State
> {
public state = {
disabled: true,
showedMinMaxError: false
@ -186,7 +190,7 @@ export default class CurrencySwap extends Component<StateProps & ActionProps> {
: 'is-invalid'}`}
type="number"
placeholder="Amount"
value={originAmount ? originAmount : ''}
value={originAmount || originAmount === 0 ? originAmount : ''}
onChange={this.onChangeOriginAmount}
/>
@ -206,7 +210,11 @@ export default class CurrencySwap extends Component<StateProps & ActionProps> {
: 'is-invalid'}`}
type="number"
placeholder="Amount"
value={destinationAmount ? destinationAmount : ''}
value={
destinationAmount || destinationAmount === 0
? destinationAmount
: ''
}
onChange={this.onChangeDestinationAmount}
/>

View File

@ -22,7 +22,6 @@ export default class CurrentRates extends Component<Pairs, State> {
};
public onChange = (event: any) => {
const target = event.target;
const { value } = event.target;
const { name } = event.target;
this.setState({
@ -36,22 +35,24 @@ export default class CurrentRates extends Component<Pairs, State> {
const propsPair = this.props[pair];
return (
<div className="SwapRates-panel-rate">
{propsPair
? <div>
<input
className="SwapRates-panel-rate-input"
onChange={this.onChange}
value={statePair}
name={pair + 'Amount'}
/>
<span className="SwapRates-panel-rate-amount">
{` ${origin} = ${toFixedIfLarger(
statePair * propsPair,
6
)} ${destination}`}
</span>
</div>
: <Spinner />}
{propsPair ? (
<div>
<input
className="SwapRates-panel-rate-input"
onChange={this.onChange}
value={statePair}
name={pair + 'Amount'}
/>
<span className="SwapRates-panel-rate-amount">
{` ${origin} = ${toFixedIfLarger(
statePair * propsPair,
6
)} ${destination}`}
</span>
</div>
) : (
<Spinner />
)}
</div>
);
};
@ -59,9 +60,7 @@ export default class CurrentRates extends Component<Pairs, State> {
public render() {
return (
<article className="SwapRates">
<h3 className="SwapRates-title">
{translate('SWAP_rates')}
</h3>
<h3 className="SwapRates-title">{translate('SWAP_rates')}</h3>
<section className="SwapRates-panel row">
<div className="SwapRates-panel-side col-sm-6">

View File

@ -1,6 +1,4 @@
import { RestartSwapAction } from 'actions/swap';
import bityLogo from 'assets/images/logo-bity.svg';
import { bityReferralURL } from 'config/data';
import React, { Component } from 'react';
import translate from 'translations';
import { toFixedIfLarger } from 'utils/formatters';

View File

@ -3,7 +3,6 @@ import bityLogo from 'assets/images/logo-bity.svg';
import { bityReferralURL } from 'config/data';
import React, { Component } from 'react';
import translate from 'translations';
import { toFixedIfLarger } from 'utils/formatters';
import './SwapInfoHeader.scss';
export interface SwapInfoHeaderTitleProps {

View File

@ -32,7 +32,6 @@ import {
TStopOrderTimerSwap,
TStopPollBityOrderStatus
} from 'actions/swap';
import swapActions from 'actions/swap/actionCreators';
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { AppState } from 'reducers';

View File

@ -30,7 +30,6 @@ function* handleAccessContract(action: AccessContractAction): SagaIterator {
yield put(setInteractiveContract(contractFunctions));
} catch (err) {
console.error('Error parsing contract ABI JSON', err);
yield put(showNotification('danger', translate('ERROR_26'), 5000));
}
}