chore: move cancelStatus to escrow object

This commit is contained in:
Jonathan Rainville 2019-05-31 15:05:49 -04:00
parent 55d57c170d
commit 692560e17a
No known key found for this signature in database
GPG Key ID: 5F4630B759727D9C
3 changed files with 18 additions and 22 deletions

View File

@ -19,7 +19,6 @@ import merge from 'merge';
const DEFAULT_STATE = {
escrows: {},
createEscrowStatus: States.none,
cancelStatus: States.none,
rateStatus: States.none,
fee: '0',
newEscrow: null,
@ -164,23 +163,23 @@ function reducer(state = DEFAULT_STATE, action) {
fee: action.fee
};
case CANCEL_ESCROW:
escrowsClone[escrowId].cancelStatus = States.pending;
return {
...state,
cancelStatus: States.pending
escrows: escrowsClone
};
case CANCEL_ESCROW_SUCCEEDED:
{
escrowsClone[escrowId].status = escrowStatus.CANCELED;
return {
...state,
escrows: escrowsClone,
cancelStatus: States.success
};
}
case CANCEL_ESCROW_FAILED:
case CANCEL_ESCROW_SUCCEEDED: {
escrowsClone[escrowId].cancelStatus = States.success;
escrowsClone[escrowId].status = escrowStatus.CANCELED;
return {
...state,
escrows: escrowsClone
};
}
case CANCEL_ESCROW_FAILED:
escrowsClone[escrowId].cancelStatus = States.failed;
return {
...state,
cancelStatus: States.failed,
escrows: escrowsClone
};
case RATE_TRANSACTION:
@ -255,7 +254,8 @@ function reducer(state = DEFAULT_STATE, action) {
createEscrowStatus: States.none,
payStatus: States.none,
releaseStatus: States.none,
rateStatus: States.none
rateStatus: States.none,
cancelStatus: States.none
};
return {
...state,

View File

@ -7,8 +7,6 @@ const unimportantStates = [tradeStates.canceled, tradeStates.expired, tradeState
export const getCreateEscrowStatus = state => state.escrow.createEscrowStatus;
export const getCancelEscrowStatus = state => state.escrow.cancelStatus;
export const getCreateEscrowId = state => state.escrow.createEscrowId;
export const getRatingStatus = state => state.escrow.rateStatus;

View File

@ -205,7 +205,6 @@ Escrow.propTypes = {
releaseEscrow: PropTypes.func,
rateStatus: PropTypes.string,
payEscrow: PropTypes.func,
cancelStatus: PropTypes.string,
approvalTxHash: PropTypes.string,
cancelEscrow: PropTypes.func,
cancelDispute: PropTypes.func,
@ -218,16 +217,16 @@ Escrow.propTypes = {
};
const mapStateToProps = (state, props) => {
const cancelStatus = escrow.selectors.getCancelEscrowStatus(state);
const approvalLoading = approval.selectors.isLoading(state);
const arbitrationLoading = arbitration.selectors.isLoading(state);
const ratingStatus = escrow.selectors.getRatingStatus(state);
const escrowId = props.match.params.id.toString();
const theEscrow = escrow.selectors.getEscrowById(state, escrowId);
return {
address: network.selectors.getAddress(state) || "",
escrowId: escrowId,
escrow: escrow.selectors.getEscrowById(state, escrowId),
escrow: theEscrow,
arbitration: arbitration.selectors.getArbitration(state) || {},
fee: escrow.selectors.getFee(state),
sntAllowance: approval.selectors.getSNTAllowance(state),
@ -235,10 +234,9 @@ const mapStateToProps = (state, props) => {
approvalTxHash: approval.selectors.txHash(state),
approvalError: approval.selectors.error(state),
tokens: network.selectors.getTokens(state),
loading: cancelStatus === States.pending || ratingStatus === States.pending || approvalLoading || arbitrationLoading,
loading: (theEscrow && theEscrow.cancelStatus === States.pending) || ratingStatus === States.pending || approvalLoading || arbitrationLoading,
rateStatus: escrow.selectors.getRatingStatus(state),
escrowEvents: events.selectors.getEscrowEvents(state),
cancelStatus
escrowEvents: events.selectors.getEscrowEvents(state)
};
};