add reviewtx component, state variable for tx info

This commit is contained in:
mmv 2019-05-23 17:16:54 +04:00
parent 46e96c7026
commit 8afb646d9b
3 changed files with 42 additions and 3 deletions

View File

@ -7,6 +7,7 @@ import { withStyles } from '@material-ui/core/styles'
import Modal from '~/components/Modal' import Modal from '~/components/Modal'
import ChooseTxType from './screens/ChooseTxType' import ChooseTxType from './screens/ChooseTxType'
import SendFunds from './screens/SendFunds' import SendFunds from './screens/SendFunds'
import ReviewTx from './screens/ReviewTx'
type Props = { type Props = {
onClose: () => void, onClose: () => void,
@ -19,7 +20,15 @@ type Props = {
tokens: List<Token>, tokens: List<Token>,
selectedToken: string, selectedToken: string,
} }
type ActiveScreen = 'chooseTxType' | 'sendFunds' type ActiveScreen = 'chooseTxType' | 'sendFunds' | 'reviewTx'
type TxStateType =
| {
token: Token,
recipientAddress: string,
amount: string,
}
| Object
const styles = () => ({ const styles = () => ({
smallerModalWindow: { smallerModalWindow: {
@ -29,10 +38,23 @@ const styles = () => ({
}) })
const Send = ({ const Send = ({
onClose, isOpen, classes, safeAddress, etherScanLink, safeName, ethBalance, tokens, selectedToken, onClose,
isOpen,
classes,
safeAddress,
etherScanLink,
safeName,
ethBalance,
tokens,
selectedToken,
}: Props) => { }: Props) => {
const [activeScreen, setActiveScreen] = useState<ActiveScreen>('sendFunds') const [activeScreen, setActiveScreen] = useState<ActiveScreen>('sendFunds')
const [tx, setTx] = useState<TxStateType>({})
const smallerModalSize = activeScreen === 'chooseTxType' const smallerModalSize = activeScreen === 'chooseTxType'
const handleTxCreation = (txInfo) => {
setActiveScreen('reviewTx')
setTx(txInfo)
}
// Uncomment when we add custom txs // Uncomment when we add custom txs
// useEffect( // useEffect(
@ -62,8 +84,10 @@ const Send = ({
ethBalance={ethBalance} ethBalance={ethBalance}
tokens={tokens} tokens={tokens}
selectedToken={selectedToken} selectedToken={selectedToken}
onSubmit={handleTxCreation}
/> />
)} )}
{activeScreen === 'reviewTx' && <ReviewTx tx={tx} />}
</React.Fragment> </React.Fragment>
</Modal> </Modal>
) )

View File

@ -0,0 +1,12 @@
// @flow
import React from 'react'
const ReviewTx = () => {
return (
<div>
YO! Wanna review tx?
</div>
)
}
export default ReviewTx

View File

@ -39,6 +39,7 @@ type Props = {
ethBalance: string, ethBalance: string,
selectedToken: string, selectedToken: string,
tokens: List<Token>, tokens: List<Token>,
onSubmit: Function,
} }
const SendFunds = ({ const SendFunds = ({
@ -50,10 +51,12 @@ const SendFunds = ({
ethBalance, ethBalance,
tokens, tokens,
selectedToken, selectedToken,
onSubmit,
}: Props) => { }: Props) => {
const handleSubmit = (values) => { const handleSubmit = (values) => {
console.log(values) onSubmit(values)
} }
const formMutators = { const formMutators = {
setMax: (args, state, utils) => { setMax: (args, state, utils) => {
const { token } = state.formState.values const { token } = state.formState.values