From 0b6be00632eb630e5274ca3a0743569aeaef28da Mon Sep 17 00:00:00 2001 From: mmv Date: Mon, 15 Apr 2019 17:59:31 +0400 Subject: [PATCH] fix checkbox displaying in manage tokens modal --- .../safe/component/Balances/Tokens/index.jsx | 37 +++++++++++-------- src/routes/safe/component/Balances/index.jsx | 7 +++- src/routes/safe/store/reducer/safe.js | 4 +- 3 files changed, 29 insertions(+), 19 deletions(-) diff --git a/src/routes/safe/component/Balances/Tokens/index.jsx b/src/routes/safe/component/Balances/Tokens/index.jsx index 15072199..1f46fbeb 100644 --- a/src/routes/safe/component/Balances/Tokens/index.jsx +++ b/src/routes/safe/component/Balances/Tokens/index.jsx @@ -65,8 +65,7 @@ class Tokens extends React.Component { this.setState(() => ({ filter: value })) } - onSwitch = (token: Token) => (e: SyntheticInputEvent) => { - const { checked } = e.target + onSwitch = (token: Token) => () => { const { safeAddress, updateActiveTokens } = this.props updateActiveTokens(safeAddress, token.address) @@ -78,7 +77,9 @@ class Tokens extends React.Component { } render() { - const { onClose, classes, tokens } = this.props + const { + onClose, classes, tokens, activeTokens, + } = this.props const { filter } = this.state const searchClasses = { input: classes.searchInput, @@ -120,19 +121,23 @@ class Tokens extends React.Component { - {filteredTokens.map((token: Token) => ( - - - {token.name} - - - {token.address !== ETH_ADDRESS && ( - - - - )} - - ))} + {filteredTokens.map((token: Token) => { + const isActive = activeTokens.findIndex(({ address }) => address === token.address) !== -1 + + return ( + + + {token.name} + + + {token.address !== ETH_ADDRESS && ( + + + + )} + + ) + })} ) diff --git a/src/routes/safe/component/Balances/index.jsx b/src/routes/safe/component/Balances/index.jsx index 9b1c66e7..f1c61517 100644 --- a/src/routes/safe/component/Balances/index.jsx +++ b/src/routes/safe/component/Balances/index.jsx @@ -102,7 +102,12 @@ class Balances extends React.Component { handleClose={this.onHide('Token')} open={showToken} > - + diff --git a/src/routes/safe/store/reducer/safe.js b/src/routes/safe/store/reducer/safe.js index ca0443fe..cdff553c 100644 --- a/src/routes/safe/store/reducer/safe.js +++ b/src/routes/safe/store/reducer/safe.js @@ -25,7 +25,7 @@ export const buildSafe = (storedSafe: SafeProps) => { owners, } - return SafeRecord(safe) + return safe } const buildSafesFrom = (loadedSafes: Object): Map => { @@ -36,7 +36,7 @@ const buildSafesFrom = (loadedSafes: Object): Map => { const safeRecords = keys.map((address: string) => buildSafe(loadedSafes[address])) return safes.withMutations(async (map) => { - safeRecords.forEach((safe: Safe) => map.set(safe.get('address'), safe)) + safeRecords.forEach((safe: SafeProps) => map.set(safe.address, safe)) }) } catch (err) { // eslint-disable-next-line