Linting/address ()

* 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
src/renderer/component
address
shapeShift
walletAddress

View file

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

View file

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

View file

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

View file

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

View file

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