fix crash on transactions page because of breaking change in date-fns
This commit is contained in:
parent
7b921e84de
commit
8eab1898f4
|
@ -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,
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -32,8 +32,8 @@ type TxServiceModel = {
|
|||
data: string,
|
||||
operation: number,
|
||||
nonce: number,
|
||||
submissionDate: Date,
|
||||
executionDate: Date,
|
||||
submissionDate: string,
|
||||
executionDate: string,
|
||||
confirmations: ConfirmationServiceModel[],
|
||||
isExecuted: boolean,
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -67,6 +67,9 @@ export default createMuiTheme({
|
|||
},
|
||||
outlinedPrimary: {
|
||||
border: `2px solid ${primary}`,
|
||||
'&:hover': {
|
||||
border: `2px solid ${primary}`,
|
||||
},
|
||||
},
|
||||
sizeLarge: {
|
||||
padding: `${md} ${lg}`,
|
||||
|
|
Loading…
Reference in New Issue