Merge pull request #50 from andrerfneves/bugfix/send-addresses

feat(send): load addresses and zec price in Send View
This commit is contained in:
George Lima 2019-01-24 12:17:06 -02:00 committed by GitHub
commit 753bb9e1f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 18 deletions

View File

@ -3,10 +3,12 @@ import { connect } from 'react-redux';
import eres from 'eres';
import { BigNumber } from 'bignumber.js';
import store from '../../config/electron-store';
import rpc from '../../services/api';
import { SendView } from '../views/send';
import {
loadZECPrice,
sendTransaction,
sendTransactionSuccess,
sendTransactionError,
@ -33,10 +35,10 @@ export type SendTransactionInput = {
memo: string,
};
const mapStateToProps = ({ walletSummary, sendStatus }: AppState) => ({
const mapStateToProps = ({ walletSummary, sendStatus, receive }: AppState) => ({
balance: walletSummary.total,
zecPrice: walletSummary.zecPrice,
addresses: walletSummary.addresses,
zecPrice: sendStatus.zecPrice,
addresses: receive.addresses,
error: sendStatus.error,
isSending: sendStatus.isSending,
operationId: sendStatus.operationId,
@ -145,6 +147,11 @@ const mapDispatchToProps = (dispatch: Dispatch) => ({
}),
);
},
loadZECPrice: () => dispatch(
loadZECPrice({
value: store.get('ZEC_DOLLAR_PRICE'),
}),
),
});
// $FlowFixMe

View File

@ -7,6 +7,7 @@ export const SEND_TRANSACTION_ERROR = 'SEND_TRANSACTION_ERROR';
export const RESET_SEND_TRANSACTION = 'RESET_SEND_TRANSACTION';
export const VALIDATE_ADDRESS_SUCCESS = 'VALIDATE_ADDRESS_SUCCESS';
export const VALIDATE_ADDRESS_ERROR = 'VALIDATE_ADDRESS_SUCCESS';
export const LOAD_ZEC_PRICE = 'LOAD_ZEC_PRICE';
export const sendTransaction = () => ({
type: SEND_TRANSACTION,
@ -48,11 +49,19 @@ export const validateAddressError = () => ({
payload: {},
});
export const loadZECPrice = ({ value }: { value: number }) => ({
type: LOAD_ZEC_PRICE,
payload: {
value,
},
});
export type State = {
isSending: boolean,
isToAddressValid: boolean,
error: string | null,
operationId: string | null,
zecPrice: number,
};
const initialState: State = {
@ -60,6 +69,7 @@ const initialState: State = {
error: null,
operationId: null,
isToAddressValid: false,
zecPrice: 0,
};
export default (state: State = initialState, action: Action): State => {
@ -95,6 +105,8 @@ export default (state: State = initialState, action: Action): State => {
...state,
isToAddressValid: false,
};
case LOAD_ZEC_PRICE:
return { ...state, zecPrice: action.payload.value };
case RESET_SEND_TRANSACTION:
return initialState;
default:

View File

@ -75,19 +75,6 @@ const AmountInput = styled(InputComponent)`
padding-left: ${props => (props.isEmpty ? '15' : '50')}px;
`;
// const ShowFeeButton = styled.button`
// align-items: center;
// background: none;
// border: none;
// cursor: pointer;
// display: flex;
// width: 100%;
// color: ${props => props.theme.colors.text};
// outline: none;
// margin-bottom: 15px;
// margin-top: 15px;
// `;
const ShowFeeButton = styled.button`
background: none;
border: none;
@ -210,6 +197,8 @@ type Props = {
sendTransaction: SendTransactionInput => void,
resetSendView: () => void,
validateAddress: ({ address: string }) => void,
loadAddresses: () => void,
loadZECPrice: () => void,
};
type State = {
@ -236,9 +225,11 @@ export class SendView extends PureComponent<Props, State> {
state = initialState;
componentDidMount() {
const { resetSendView } = this.props;
const { resetSendView, loadAddresses, loadZECPrice } = this.props;
resetSendView();
loadAddresses();
loadZECPrice();
}
handleChange = (field: string) => (value: string) => {
@ -340,7 +331,7 @@ export class SendView extends PureComponent<Props, State> {
/* eslint-disable react/no-unused-prop-types */
valueSent: string,
valueSentInUsd: string,
toggle: () => void
toggle: () => void,
/* eslint-enable react/no-unused-prop-types */
}) => {
// eslint-disable-next-line react/prop-types