diff --git a/src/routes/safe/components/Balances/SendModal/index.jsx b/src/routes/safe/components/Balances/SendModal/index.jsx index 4a4b2b67..a8b906cc 100644 --- a/src/routes/safe/components/Balances/SendModal/index.jsx +++ b/src/routes/safe/components/Balances/SendModal/index.jsx @@ -17,6 +17,7 @@ type Props = { safeName: string, ethBalance: string, tokens: List, + selectedToken: string, } type ActiveScreen = 'chooseTxType' | 'sendFunds' @@ -28,7 +29,7 @@ const styles = () => ({ }) const Send = ({ - onClose, isOpen, classes, safeAddress, etherScanLink, safeName, ethBalance, tokens, + onClose, isOpen, classes, safeAddress, etherScanLink, safeName, ethBalance, tokens, selectedToken, }: Props) => { const [activeScreen, setActiveScreen] = useState('sendFunds') const smallerModalSize = activeScreen === 'chooseTxType' @@ -60,6 +61,7 @@ const Send = ({ safeName={safeName} ethBalance={ethBalance} tokens={tokens} + selectedToken={selectedToken} /> )} diff --git a/src/routes/safe/components/Balances/SendModal/screens/SendFunds/TokenSelectField/index.jsx b/src/routes/safe/components/Balances/SendModal/screens/SendFunds/TokenSelectField/index.jsx index ccced862..fb186476 100644 --- a/src/routes/safe/components/Balances/SendModal/screens/SendFunds/TokenSelectField/index.jsx +++ b/src/routes/safe/components/Balances/SendModal/screens/SendFunds/TokenSelectField/index.jsx @@ -17,6 +17,7 @@ import { selectedTokenStyles, selectStyles } from './style' type SelectFieldProps = { tokens: List, classes: Object, + initialValue: string, } type SelectedTokenProps = { @@ -47,14 +48,14 @@ const SelectedToken = ({ token, classes }: SelectedTokenProps) => ( const SelectedTokenStyled = withStyles(selectedTokenStyles)(SelectedToken) -const TokenSelectField = ({ tokens, classes }: SelectFieldProps) => ( +const TokenSelectField = ({ tokens, classes, initialValue }: SelectFieldProps) => ( } - initialValue="" + initialValue={tokens.find(token => token.name === initialValue) || ''} displayEmpty > {tokens.map(token => ( diff --git a/src/routes/safe/components/Balances/SendModal/screens/SendFunds/index.jsx b/src/routes/safe/components/Balances/SendModal/screens/SendFunds/index.jsx index c3dfa150..b129c488 100644 --- a/src/routes/safe/components/Balances/SendModal/screens/SendFunds/index.jsx +++ b/src/routes/safe/components/Balances/SendModal/screens/SendFunds/index.jsx @@ -36,11 +36,12 @@ type Props = { etherScanLink: string, safeName: string, ethBalance: string, + selectedToken: string, tokens: List, } const SendFunds = ({ - classes, onClose, safeAddress, etherScanLink, safeName, ethBalance, tokens, + classes, onClose, safeAddress, etherScanLink, safeName, ethBalance, tokens, selectedToken, }: Props) => { const handleSubmit = () => {} const formMutators = { @@ -98,7 +99,7 @@ const SendFunds = ({ - + diff --git a/src/routes/safe/components/Balances/index.jsx b/src/routes/safe/components/Balances/index.jsx index e198f337..1ddfecb7 100644 --- a/src/routes/safe/components/Balances/index.jsx +++ b/src/routes/safe/components/Balances/index.jsx @@ -29,7 +29,7 @@ type State = { hideZero: boolean, showToken: boolean, showReceive: boolean, - showSend: boolean, + sendFunds: Object, } type Props = { @@ -49,7 +49,10 @@ class Balances extends React.Component { state = { hideZero: false, showToken: false, - showSend: false, + sendFunds: { + isOpen: false, + selectedToken: undefined, + }, showReceive: false, } @@ -61,6 +64,24 @@ class Balances extends React.Component { this.setState(() => ({ [`show${action}`]: false })) } + showSendFunds = (token: Token) => { + this.setState({ + sendFunds: { + isOpen: true, + selectedToken: token, + }, + }) + } + + hideSendFunds = () => { + this.setState({ + sendFunds: { + isOpen: false, + selectedToken: undefined, + }, + }) + } + handleChange = (e: SyntheticInputEvent) => { const { checked } = e.target @@ -69,7 +90,7 @@ class Balances extends React.Component { render() { const { - hideZero, showToken, showReceive, showSend, + hideZero, showToken, showReceive, sendFunds, } = this.state const { classes, granted, tokens, safeAddress, activeTokens, safeName, etherScanLink, ethBalance, @@ -138,7 +159,7 @@ class Balances extends React.Component { size="small" color="secondary" className={classes.send} - onClick={this.onShow('Send')} + onClick={() => this.showSendFunds(row.asset.name)} > Send @@ -161,13 +182,14 @@ class Balances extends React.Component { }