chore: move cancelStatus to escrow object
This commit is contained in:
parent
55d57c170d
commit
692560e17a
|
@ -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:
|
||||
{
|
||||
case CANCEL_ESCROW_SUCCEEDED: {
|
||||
escrowsClone[escrowId].cancelStatus = States.success;
|
||||
escrowsClone[escrowId].status = escrowStatus.CANCELED;
|
||||
return {
|
||||
...state,
|
||||
escrows: escrowsClone,
|
||||
cancelStatus: States.success
|
||||
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,
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
};
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue