Linting/address (#2066)

* Fix linting errors in address component

* Add type checking to address component and its consumers
This commit is contained in:
Anna Melzer 2018-10-28 19:32:52 +01:00 committed by Sean Yesmunt
parent 2465857a90
commit 389053218e
5 changed files with 45 additions and 24 deletions

View file

@ -1,7 +1,12 @@
// @flow
import { connect } from 'react-redux';
import { doNotify } from 'lbry-redux';
import Address from './view';
export default connect(null, {
doNotify,
})(Address);
export default connect(
null,
{
doNotify,
}
)(Address);

View file

@ -5,18 +5,20 @@ import { FormRow } from 'component/common/form';
import * as statuses from 'constants/shape_shift';
import Address from 'component/address';
import Button from 'component/button';
import type { Dispatch } from 'redux/actions/shape_shift';
import type { Dispatch, ThunkAction } from 'types/redux';
import type { Action } from 'redux/actions/shape_shift';
import ShiftMarketInfo from './market_info';
type Props = {
shiftState: ?string,
shiftCoinType: ?string,
shiftDepositAddress: ?string,
shiftDepositAddress: string,
shiftReturnAddress: ?string,
shiftOrderId: ?string,
originCoinDepositMax: ?number,
clearShapeShift: Dispatch,
getActiveShift: Dispatch,
clearShapeShift: () => (Dispatch<Action>) => ThunkAction<Action>,
getActiveShift: string => (Dispatch<Action>) => ThunkAction<Action>,
shapeShiftRate: ?number,
originCoinDepositMax: ?number,
originCoinDepositFee: ?number,

View file

@ -2,7 +2,8 @@
import React from 'react';
import { getExampleAddress } from 'util/shape_shift';
import { FormField, FormRow, Submit } from 'component/common/form';
import type { ShapeShiftFormValues, Dispatch } from 'redux/actions/shape_shift';
import type { ShapeShiftFormValues, Action } from 'redux/actions/shape_shift';
import type { Dispatch, ThunkAction } from 'types/redux';
import ShiftMarketInfo from './market_info';
type ShapeShiftFormErrors = {
@ -19,7 +20,7 @@ type Props = {
isSubmitting: boolean,
shiftSupportedCoins: Array<string>,
originCoin: string,
getCoinStats: Dispatch,
getCoinStats: string => (Dispatch<Action>) => ThunkAction<Action>,
originCoinDepositFee: number,
originCoinDepositMin: string,
originCoinDepositMax: number,

View file

@ -4,17 +4,23 @@ import { Formik } from 'formik';
import { validateShapeShiftForm } from 'util/shape_shift';
import Button from 'component/button';
import type { ShapeShiftState } from 'redux/reducers/shape_shift';
import type { Dispatch, ShapeShiftFormValues } from 'redux/actions/shape_shift';
import type { ShapeShiftFormValues, Action } from 'redux/actions/shape_shift';
import type { Dispatch, ThunkAction } from 'types/redux';
import type { FormikActions } from 'types/common';
import ShapeShiftForm from './internal/form';
import ActiveShapeShift from './internal/active-shift';
type Props = {
shapeShift: ShapeShiftState,
getCoinStats: Dispatch,
createShapeShift: Dispatch,
clearShapeShift: Dispatch,
getActiveShift: Dispatch,
shapeShiftInit: Dispatch,
getCoinStats: string => (Dispatch<Action>) => ThunkAction<Action>,
createShapeShift: (
ShapeShiftFormValues,
FormikActions
) => (Dispatch<Action>) => ThunkAction<Action>,
clearShapeShift: () => (Dispatch<Action>) => ThunkAction<Action>,
getActiveShift: string => (Dispatch<Action>) => ThunkAction<Action>,
shapeShiftInit: () => (Dispatch<Action>) => ThunkAction<Action>,
receiveAddress: string,
};
@ -42,7 +48,6 @@ class ShapeShift extends React.PureComponent<Props> {
} = this.props;
const {
loading,
updating,
error,
shiftSupportedCoins,
@ -104,7 +109,7 @@ class ShapeShift extends React.PureComponent<Props> {
getActiveShift={getActiveShift}
shiftCoinType={shiftCoinType}
shiftReturnAddress={shiftReturnAddress}
shiftDepositAddress={shiftDepositAddress}
shiftDepositAddress={shiftDepositAddress || ''}
shiftOrderId={shiftOrderId}
shiftState={shiftState}
clearShapeShift={clearShapeShift}

View file

@ -12,19 +12,19 @@ type Props = {
gettingNewAddress: boolean,
};
class WalletAddress extends React.PureComponent<Props> {
type State = {
showQR: boolean,
};
class WalletAddress extends React.PureComponent<Props, State> {
constructor(props: Props) {
super(props);
this.state = {
showQR: false,
};
}
toggleQR() {
this.setState({
showQR: !this.state.showQR,
});
this.toggleQR = this.toggleQR.bind(this);
}
componentWillMount() {
@ -36,6 +36,14 @@ class WalletAddress extends React.PureComponent<Props> {
}
}
toggleQR: Function;
toggleQR() {
this.setState({
showQR: !this.state.showQR,
});
}
render() {
const { receiveAddress, getNewAddress, gettingNewAddress } = this.props;
const { showQR } = this.state;
@ -62,7 +70,7 @@ class WalletAddress extends React.PureComponent<Props> {
<Button
button="link"
label={showQR ? __('Hide QR code') : __('Show QR code')}
onClick={this.toggleQR.bind(this)}
onClick={this.toggleQR}
/>
</div>