show state in the escrow list

This commit is contained in:
Jonathan Rainville 2019-05-16 14:55:48 -04:00
parent 10e4183055
commit e347ef23f6
No known key found for this signature in database
GPG Key ID: 5F4630B759727D9C
6 changed files with 30 additions and 11 deletions

View File

@ -62,6 +62,7 @@
"i18next-browser-languagedetector": "^2.2.4",
"identicon.js": "^2.3.3",
"lodash": "^4.17.11",
"merge": "^1.2.1",
"moment": "^2.23.0",
"number-to-bn": "^1.7.0",
"qrcode.react": "^0.9.3",

View File

@ -13,6 +13,7 @@ import {
import { States } from '../../utils/transaction';
import { escrowStatus } from './helpers';
import {RESET_STATE} from "../network/constants";
import merge from 'merge';
const DEFAULT_STATE = {
createEscrowStatus: States.none,
@ -21,7 +22,6 @@ const DEFAULT_STATE = {
payStatus: States.none,
cancelStatus: States.none,
rateStatus: States.none,
escrows: {},
fee: '0'
};
@ -61,15 +61,14 @@ function reducer(state = DEFAULT_STATE, action) {
case RATE_TRANSACTION_PRE_SUCCESS:
case RELEASE_ESCROW_PRE_SUCCESS:
case FUND_ESCROW_PRE_SUCCESS: {
const newEscrows = [...state.escrows];
newEscrows[escrowId] = {
escrowsClone[escrowId] = {
...state.escrows[escrowId],
mining: true,
txHash: action.txHash
};
return {
...state,
escrows: newEscrows
escrows: escrowsClone
};
}
case RELEASE_ESCROW:
@ -147,7 +146,7 @@ function reducer(state = DEFAULT_STATE, action) {
}
return {
...state,
escrows: Object.assign({}, state.escrows, action.escrows)
escrows: merge.recursive(state.escrows, action.escrows)
};
case GET_FEE_SUCCEEDED:
return {

View File

@ -2,7 +2,9 @@
import moment from 'moment';
import { fromTokenDecimals } from '../../utils/numbers';
import { getTradeStatus } from './helpers';
import { getTradeStatus, tradeStates } from './helpers';
const unimportantStates = [tradeStates.canceled, tradeStates.expired, tradeStates.released];
export const getCreateEscrowStatus = state => state.escrow.createEscrowStatus;
@ -29,7 +31,19 @@ export const getTrades = (state, userAddress, offers) => {
status: getTradeStatus(escrow),
tokenAmount: fromTokenDecimals(escrow.tradeAmount, token.decimals)
};
});
})
.sort((a, b) => {
if (unimportantStates.includes(a.status)) {
if (unimportantStates.includes(b.status)) {
return (parseInt(a.escrowId, 10) < parseInt(b.escrowId, 10)) ? 1 : -1;
}
return 1;
}
if (unimportantStates.includes(b.status)) {
return -1;
}
return (parseInt(a.escrowId, 10) < parseInt(b.escrowId, 10)) ? 1 : -1;
});
};
export const getEscrowById = (state, escrowId) => {

View File

@ -10,6 +10,9 @@ import {formatBalance} from "../../../utils/numbers";
import {tradeStates} from "../../../features/escrow/helpers";
const getTradeStyle = (trade) => {
if (trade.mining) {
return {text: 'Mining', className: 'bg-info'};
}
if(trade.arbitration){
if(trade.arbitration.open){
trade.status = tradeStates.arbitration_open;
@ -22,11 +25,13 @@ const getTradeStyle = (trade) => {
switch(trade.status){
case tradeStates.waiting:
return {text: 'Open', className: 'bg-primary'};
case tradeStates.funded:
return {text: 'Funded', className: 'bg-primary'};
case tradeStates.paid:
return {text: 'Open', className: 'bg-success'};
return {text: 'Paid', className: 'bg-primary'};
case tradeStates.released:
return {text: 'Closed', className: 'bg-primary'};
return {text: 'Done', className: 'bg-success'};
case tradeStates.canceled:
return {text: 'Canceled', className: 'bg-secondary'};
case tradeStates.expired:

View File

@ -22,7 +22,7 @@ const persistConfig = {
key: 'teller-network-store',
storage,
stateReconciler: autoMergeLevel2,
blacklist: ['network', 'escrow', 'approval', 'router']
blacklist: ['network', 'approval', 'router']
};
function *root() {

View File

@ -11569,7 +11569,7 @@ merge2@^1.2.3:
resolved "https://registry.yarnpkg.com/merge2/-/merge2-1.2.3.tgz#7ee99dbd69bb6481689253f018488a1b902b0ed5"
integrity sha512-gdUU1Fwj5ep4kplwcmftruWofEFt6lfpkkr3h860CXbAB9c3hGb55EOL2ali0Td5oebvW0E1+3Sr+Ur7XfKpRA==
merge@1.2.1, merge@^1.2.0:
merge@1.2.1, merge@^1.2.0, merge@^1.2.1:
version "1.2.1"
resolved "https://registry.yarnpkg.com/merge/-/merge-1.2.1.tgz#38bebf80c3220a8a487b6fcfb3941bb11720c145"
integrity sha512-VjFo4P5Whtj4vsLzsYBu5ayHhoHJ0UqNm7ibvShmbmoz7tGi0vXaoJbGdB+GmDMLUdg8DpQXEIeVDAe8MaABvQ==