fix crash on transactions page because of breaking change in date-fns

This commit is contained in:
Mikhail Mikheev 2019-08-29 15:26:20 +04:00
parent 7b921e84de
commit 8eab1898f4
5 changed files with 14 additions and 10 deletions

View File

@ -1,5 +1,5 @@
// @flow
import { format, getTime } from 'date-fns'
import { format, getTime, parseISO } from 'date-fns'
import { List } from 'immutable'
import { type Transaction } from '~/routes/safe/store/models/transaction'
import { type SortRow, buildOrderFieldFrom } from '~/components/Table/sorting'
@ -23,7 +23,7 @@ type TxData = {
status?: string,
}
export const formatDate = (date: Date): string => format(date, 'MMM D, YYYY - HH:mm:ss')
export const formatDate = (date: string): string => format(parseISO(date), 'MMM d, yyyy - HH:mm:ss')
export const getTxAmount = (tx: Transaction) => {
const web3 = getWeb3()
@ -56,7 +56,7 @@ export const getTxTableData = (transactions: List<Transaction>): List<Transactio
[TX_TABLE_NONCE_ID]: tx.nonce,
[TX_TABLE_TYPE_ID]: txType,
[TX_TABLE_DATE_ID]: formatDate(tx.isExecuted ? tx.executionDate : tx.submissionDate),
[buildOrderFieldFrom(TX_TABLE_DATE_ID)]: getTime(txDate),
[buildOrderFieldFrom(TX_TABLE_DATE_ID)]: getTime(parseISO(txDate)),
[TX_TABLE_AMOUNT_ID]: getTxAmount(tx),
[TX_TABLE_STATUS_ID]: tx.status,
[TX_TABLE_RAW_TX_ID]: tx,

View File

@ -1,7 +1,7 @@
// @flow
import { List, Map } from 'immutable'
import { createSelector, createStructuredSelector, type Selector } from 'reselect'
import { isAfter } from 'date-fns'
import { isAfter, parseISO } from 'date-fns'
import {
safeSelector,
safeActiveTokensSelector,
@ -88,7 +88,7 @@ const extendedSafeTokensSelector: Selector<GlobalState, RouterProps, List<Token>
const extendedTokens = Map().withMutations((map) => {
safeTokens.forEach((tokenAddress: string) => {
const baseToken = tokensList.get(tokenAddress)
const tokenBalance = balances.find(tknBalance => tknBalance.address === tokenAddress)
const tokenBalance = balances.find((tknBalance) => tknBalance.address === tokenAddress)
if (baseToken) {
map.set(tokenAddress, baseToken.set('balance', tokenBalance ? tokenBalance.balance : '0'))
@ -116,7 +116,8 @@ const extendedTransactionsSelector: Selector<GlobalState, RouterProps, List<Tran
let replacementTransaction
if (!tx.isExecuted) {
replacementTransaction = transactions.findLast(
transaction => transaction.nonce === tx.nonce && isAfter(transaction.submissionDate, tx.submissionDate),
(transaction) => transaction.nonce === tx.nonce
&& isAfter(parseISO(transaction.submissionDate), parseISO(tx.submissionDate)),
)
if (replacementTransaction) {
extendedTx = tx.set('cancelled', true)

View File

@ -32,8 +32,8 @@ type TxServiceModel = {
data: string,
operation: number,
nonce: number,
submissionDate: Date,
executionDate: Date,
submissionDate: string,
executionDate: string,
confirmations: ConfirmationServiceModel[],
isExecuted: boolean,
}

View File

@ -13,8 +13,8 @@ export type TransactionProps = {
recipient: string,
data: string,
isExecuted: boolean,
submissionDate: Date,
executionDate: Date,
submissionDate: string,
executionDate: string,
symbol: string,
modifySettingsTx: boolean,
cancellationTx: boolean,

View File

@ -67,6 +67,9 @@ export default createMuiTheme({
},
outlinedPrimary: {
border: `2px solid ${primary}`,
'&:hover': {
border: `2px solid ${primary}`,
},
},
sizeLarge: {
padding: `${md} ${lg}`,