Browse Source

Reverse transactions in accounts reducers

master
Loëck Vézien 7 years ago
parent
commit
1e944daeda
No known key found for this signature in database GPG Key ID: CBCDCE384E853AC4
  1. 1
      .prettierignore
  2. 2
      src/components/AccountPage.js
  3. 16
      src/reducers/accounts.js

1
.prettierignore

@ -0,0 +1 @@
package.json

2
src/components/AccountPage.js

@ -43,7 +43,7 @@ class AccountPage extends PureComponent<Props> {
</Box>
</Box>
<Card title="Last operations">
{accountData.transactions.reverse().map(tr => (
{accountData.transactions.map(tr => (
<Box horizontal key={tr.hash}>
<Box grow>{'-'}</Box>
<Box>{format(tr.balance)}</Box>

16
src/reducers/accounts.js

@ -11,12 +11,20 @@ export type AccountsState = Accounts
const state: AccountsState = {}
function setAccount(account: Account) {
return {
...account,
data: {
...account.data,
transactions: get(account.data, 'transactions', []).reverse(),
},
}
}
const handlers: Object = {
ADD_ACCOUNT: (state: AccountsState, { payload: account }: { payload: Account }) => ({
...state,
[account.id]: {
...account,
},
[account.id]: setAccount(account),
}),
FETCH_ACCOUNTS: (state: AccountsState, { payload: accounts }: { payload: Accounts }) => accounts,
SET_ACCOUNT_DATA: (
@ -40,7 +48,7 @@ const handlers: Object = {
return {
...state,
[accountID]: account,
[accountID]: setAccount(account),
}
},
}

Loading…
Cancel
Save