diff --git a/src/routes/safe/component/Balances/Tokens/actions.js b/src/routes/safe/component/Balances/Tokens/actions.js new file mode 100644 index 00000000..5184fdcc --- /dev/null +++ b/src/routes/safe/component/Balances/Tokens/actions.js @@ -0,0 +1,13 @@ +// @flow +import enableToken from '~/routes/tokens/store/actions/enableToken' +import disableToken from '~/routes/tokens/store/actions/disableToken' + +export type Actions = { + enableToken: typeof enableToken, + disableToken: typeof disableToken, +} + +export default { + enableToken, + disableToken, +} diff --git a/src/routes/safe/component/Balances/Tokens/index.jsx b/src/routes/safe/component/Balances/Tokens/index.jsx index 0b4c30c4..24b9cbfe 100644 --- a/src/routes/safe/component/Balances/Tokens/index.jsx +++ b/src/routes/safe/component/Balances/Tokens/index.jsx @@ -1,5 +1,6 @@ // @flow import * as React from 'react' +import { connect } from 'react-redux' import { List } from 'immutable' import classNames from 'classnames/bind' import SearchBar from 'material-ui-search-bar' @@ -23,6 +24,7 @@ import Spacer from '~/components/Spacer' import Row from '~/components/layout/Row' import { lg, md, sm, xs, mediumFontSize, border } from '~/theme/variables' import { type Token } from '~/routes/tokens/store/model/token' +import actions, { type Actions } from './actions' const styles = () => ({ root: { @@ -96,10 +98,11 @@ const styles = () => ({ }, }) -type Props = { +type Props = Actions & { onClose: () => void, classes: Object, tokens: List, + safeAddress: string, } type State = { @@ -122,6 +125,19 @@ class Tokens extends React.Component { this.setState(() => ({ filter: value })) } + onSwitch = (token: Token) => (e: SyntheticInputEvent) => { + const { checked } = e.target + const { safeAddress, enableToken, disableToken } = this.props + + if (checked) { + enableToken(safeAddress, token) + + return + } + + disableToken(safeAddress, token) + } + render() { const { onClose, classes, tokens } = this.props const searchClasses = { @@ -170,8 +186,8 @@ class Tokens extends React.Component { @@ -182,4 +198,7 @@ class Tokens extends React.Component { } } -export default withStyles(styles)(Tokens) +const TokenComponent = withStyles(styles)(Tokens) + +export default connect(undefined, actions)(TokenComponent) + diff --git a/src/routes/safe/component/Balances/index.jsx b/src/routes/safe/component/Balances/index.jsx index 70ed19fb..977b7b36 100644 --- a/src/routes/safe/component/Balances/index.jsx +++ b/src/routes/safe/component/Balances/index.jsx @@ -33,6 +33,7 @@ type Props = { classes: Object, granted: boolean, tokens: List, + safeAddress: string, } type Action = 'Token' | 'Send' | 'Receive' @@ -63,7 +64,9 @@ class Balances extends React.Component { const { hideZero, showToken, showReceive, showSend, } = this.state - const { classes, granted, tokens } = this.props + const { + classes, granted, tokens, safeAddress, + } = this.props const columns = generateColumns() const autoColumns = columns.filter(c => !c.custom) @@ -96,7 +99,7 @@ class Balances extends React.Component { handleClose={this.onHide('Token')} open={showToken} > - + diff --git a/src/routes/safe/component/Layout.jsx b/src/routes/safe/component/Layout.jsx index b8c2ca53..d2c04821 100644 --- a/src/routes/safe/component/Layout.jsx +++ b/src/routes/safe/component/Layout.jsx @@ -122,7 +122,13 @@ class Layout extends React.Component { - {value === 0 && } + {value === 0 && + } ) }