pass whole tx to modals
This commit is contained in:
parent
f1b2df22e1
commit
7d3930cbc6
|
@ -1,5 +1,5 @@
|
||||||
// @flow
|
// @flow
|
||||||
import React from 'react'
|
import React, { useState } from 'react'
|
||||||
import Close from '@material-ui/icons/Close'
|
import Close from '@material-ui/icons/Close'
|
||||||
import IconButton from '@material-ui/core/IconButton'
|
import IconButton from '@material-ui/core/IconButton'
|
||||||
import { withStyles } from '@material-ui/core/styles'
|
import { withStyles } from '@material-ui/core/styles'
|
||||||
|
@ -12,6 +12,7 @@ import Row from '~/components/layout/Row'
|
||||||
import Bold from '~/components/layout/Bold'
|
import Bold from '~/components/layout/Bold'
|
||||||
import Block from '~/components/layout/Block'
|
import Block from '~/components/layout/Block'
|
||||||
import Paragraph from '~/components/layout/Paragraph'
|
import Paragraph from '~/components/layout/Paragraph'
|
||||||
|
import { type Transaction } from '~/routes/safe/store/models/transaction'
|
||||||
import { styles } from './style'
|
import { styles } from './style'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
|
@ -19,62 +20,72 @@ type Props = {
|
||||||
classes: Object,
|
classes: Object,
|
||||||
isOpen: boolean,
|
isOpen: boolean,
|
||||||
createTransaction: Function,
|
createTransaction: Function,
|
||||||
|
tx: Transaction,
|
||||||
nonce: string,
|
nonce: string,
|
||||||
}
|
}
|
||||||
|
|
||||||
const ApproveTxModal = ({
|
const ApproveTxModal = ({
|
||||||
onClose, isOpen, classes, createTransaction, nonce,
|
onClose, isOpen, classes, createTransaction, tx,
|
||||||
}: Props) => (
|
}: Props) => {
|
||||||
<Modal
|
const [shouldExecuteTx, setShouldExecuteTx] = useState<boolean>(false)
|
||||||
title="Approve Transaction"
|
|
||||||
description="Approve Transaction"
|
const handleExecuteCheckbox = () => setShouldExecuteTx(prevShouldExecute => !prevShouldExecute)
|
||||||
handleClose={onClose}
|
|
||||||
open={isOpen}
|
return (
|
||||||
// paperClassName={cn(smallerModalSize && classes.smallerModalWindow)}
|
<Modal
|
||||||
>
|
title="Approve Transaction"
|
||||||
<Row align="center" grow className={classes.heading}>
|
description="Approve Transaction"
|
||||||
<Paragraph weight="bolder" className={classes.headingText} noMargin>
|
handleClose={onClose}
|
||||||
Approve transaction
|
open={isOpen}
|
||||||
</Paragraph>
|
// paperClassName={cn(smallerModalSize && classes.smallerModalWindow)}
|
||||||
<IconButton onClick={onClose} disableRipple>
|
>
|
||||||
<Close className={classes.closeIcon} />
|
<Row align="center" grow className={classes.heading}>
|
||||||
</IconButton>
|
<Paragraph weight="bolder" className={classes.headingText} noMargin>
|
||||||
</Row>
|
Approve transaction
|
||||||
<Hairline />
|
|
||||||
<Block className={classes.container}>
|
|
||||||
<Row>
|
|
||||||
<Paragraph>
|
|
||||||
This action will approve this transaction. A separate transaction will be performed to submit the approval.
|
|
||||||
</Paragraph>
|
</Paragraph>
|
||||||
<Paragraph size="sm" color="medium">
|
<IconButton onClick={onClose} disableRipple>
|
||||||
Transaction nonce:
|
<Close className={classes.closeIcon} />
|
||||||
<br />
|
</IconButton>
|
||||||
<Bold className={classes.nonceNumber}>{nonce}</Bold>
|
|
||||||
</Paragraph>
|
|
||||||
<Paragraph color="error">
|
|
||||||
Approving transaction does not execute it immediately. If you want to approve and execute the transaction
|
|
||||||
right away, click on checkbox below.
|
|
||||||
</Paragraph>
|
|
||||||
<FormControlLabel control={<Checkbox checked={false} color="primary" />} label="Execute transaction" />
|
|
||||||
</Row>
|
</Row>
|
||||||
</Block>
|
<Hairline />
|
||||||
<Row align="center" className={classes.buttonRow}>
|
<Block className={classes.container}>
|
||||||
<Button className={classes.button} minWidth={140} minHeight={42} onClick={onClose}>
|
<Row>
|
||||||
Exit
|
<Paragraph>
|
||||||
</Button>
|
This action will approve this transaction. A separate transaction will be performed to submit the approval.
|
||||||
<Button
|
</Paragraph>
|
||||||
type="submit"
|
<Paragraph size="sm" color="medium">
|
||||||
className={classes.button}
|
Transaction nonce:
|
||||||
variant="contained"
|
<br />
|
||||||
minWidth={214}
|
<Bold className={classes.nonceNumber}>{tx.nonce}</Bold>
|
||||||
minHeight={42}
|
</Paragraph>
|
||||||
color="primary"
|
<Paragraph color="error">
|
||||||
data-testid="review-tx-btn"
|
Approving transaction does not execute it immediately. If you want to approve and execute the transaction
|
||||||
>
|
right away, click on checkbox below.
|
||||||
Approve Transaction
|
</Paragraph>
|
||||||
</Button>
|
<FormControlLabel
|
||||||
</Row>
|
control={<Checkbox onChange={handleExecuteCheckbox} checked={shouldExecuteTx} color="primary" />}
|
||||||
</Modal>
|
label="Execute transaction"
|
||||||
)
|
/>
|
||||||
|
</Row>
|
||||||
|
</Block>
|
||||||
|
<Row align="center" className={classes.buttonRow}>
|
||||||
|
<Button className={classes.button} minWidth={140} minHeight={42} onClick={onClose}>
|
||||||
|
Exit
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
type="submit"
|
||||||
|
className={classes.button}
|
||||||
|
variant="contained"
|
||||||
|
minWidth={214}
|
||||||
|
minHeight={42}
|
||||||
|
color="primary"
|
||||||
|
data-testid="review-tx-btn"
|
||||||
|
>
|
||||||
|
Approve Transaction
|
||||||
|
</Button>
|
||||||
|
</Row>
|
||||||
|
</Modal>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
export default withStyles(styles)(ApproveTxModal)
|
export default withStyles(styles)(ApproveTxModal)
|
||||||
|
|
|
@ -10,6 +10,7 @@ import Row from '~/components/layout/Row'
|
||||||
import Bold from '~/components/layout/Bold'
|
import Bold from '~/components/layout/Bold'
|
||||||
import Block from '~/components/layout/Block'
|
import Block from '~/components/layout/Block'
|
||||||
import Paragraph from '~/components/layout/Paragraph'
|
import Paragraph from '~/components/layout/Paragraph'
|
||||||
|
import { type Transaction } from '~/routes/safe/store/models/transaction'
|
||||||
import { styles } from './style'
|
import { styles } from './style'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
|
@ -17,11 +18,11 @@ type Props = {
|
||||||
classes: Object,
|
classes: Object,
|
||||||
isOpen: boolean,
|
isOpen: boolean,
|
||||||
createTransaction: Function,
|
createTransaction: Function,
|
||||||
nonce: string,
|
tx: Transaction,
|
||||||
}
|
}
|
||||||
|
|
||||||
const CancelTxModal = ({
|
const CancelTxModal = ({
|
||||||
onClose, isOpen, classes, createTransaction, nonce,
|
onClose, isOpen, classes, createTransaction, tx,
|
||||||
}: Props) => (
|
}: Props) => (
|
||||||
<Modal
|
<Modal
|
||||||
title="Cancel Transaction"
|
title="Cancel Transaction"
|
||||||
|
@ -47,7 +48,7 @@ const CancelTxModal = ({
|
||||||
<Paragraph size="sm" color="medium">
|
<Paragraph size="sm" color="medium">
|
||||||
Transaction nonce:
|
Transaction nonce:
|
||||||
<br />
|
<br />
|
||||||
<Bold className={classes.nonceNumber}>{nonce}</Bold>
|
<Bold className={classes.nonceNumber}>{tx.nonce}</Bold>
|
||||||
</Paragraph>
|
</Paragraph>
|
||||||
</Row>
|
</Row>
|
||||||
</Block>
|
</Block>
|
||||||
|
|
|
@ -117,7 +117,7 @@ const ExpandedTx = ({
|
||||||
{' '}
|
{' '}
|
||||||
{tx.symbol}
|
{tx.symbol}
|
||||||
{' '}
|
{' '}
|
||||||
to:
|
to:
|
||||||
</Bold>
|
</Bold>
|
||||||
<br />
|
<br />
|
||||||
<a href={getEtherScanLink(tx.recipient, 'rinkeby')} target="_blank" rel="noopener noreferrer">
|
<a href={getEtherScanLink(tx.recipient, 'rinkeby')} target="_blank" rel="noopener noreferrer">
|
||||||
|
@ -141,8 +141,8 @@ to:
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
</Block>
|
</Block>
|
||||||
<CancelTxModal isOpen={openModal === 'cancelTx'} onClose={closeModal} nonce={tx.nonce} />
|
<CancelTxModal isOpen={openModal === 'cancelTx'} onClose={closeModal} tx={tx} />
|
||||||
<ApproveTxModal isOpen={openModal === 'approveTx'} onClose={closeModal} nonce={tx.nonce} />
|
<ApproveTxModal isOpen={openModal === 'approveTx'} onClose={closeModal} tx={tx} />
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue