Styles on the Owner Page
This commit is contained in:
parent
9f27f408a2
commit
af0930a02f
|
@ -3,75 +3,157 @@ import * as React from 'react'
|
||||||
import { withStyles } from '@material-ui/core/styles'
|
import { withStyles } from '@material-ui/core/styles'
|
||||||
import Field from '~/components/forms/Field'
|
import Field from '~/components/forms/Field'
|
||||||
import TextField from '~/components/forms/TextField'
|
import TextField from '~/components/forms/TextField'
|
||||||
import { required } from '~/components/forms/validator'
|
import { required, composeValidators, uniqueAddress, mustBeEthereumAddress } from '~/components/forms/validator'
|
||||||
import Block from '~/components/layout/Block'
|
import Block from '~/components/layout/Block'
|
||||||
|
import Button from '~/components/layout/Button'
|
||||||
import Row from '~/components/layout/Row'
|
import Row from '~/components/layout/Row'
|
||||||
import Col from '~/components/layout/Col'
|
import Col from '~/components/layout/Col'
|
||||||
import { FIELD_NAME } from '~/routes/open/components/fields'
|
import IconButton from '@material-ui/core/IconButton'
|
||||||
|
import Delete from '@material-ui/icons/Delete'
|
||||||
|
import InputAdornment from '@material-ui/core/InputAdornment'
|
||||||
|
import CheckCircle from '@material-ui/icons/CheckCircle'
|
||||||
|
import { getOwnerNameBy, getOwnerAddressBy } from '~/routes/open/components/fields'
|
||||||
import Paragraph from '~/components/layout/Paragraph'
|
import Paragraph from '~/components/layout/Paragraph'
|
||||||
import OpenPaper from '~/components/Stepper/OpenPaper'
|
import OpenPaper from '~/components/Stepper/OpenPaper'
|
||||||
import { getAccountsFrom } from '~/routes/open/utils/safeDataExtractor'
|
import { getAccountsFrom } from '~/routes/open/utils/safeDataExtractor'
|
||||||
import Hairline from '~/components/layout/Hairline'
|
import Hairline from '~/components/layout/Hairline'
|
||||||
import { lg } from '~/theme/variables'
|
import { md, lg, sm } from '~/theme/variables'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
classes: Object,
|
classes: Object,
|
||||||
|
otherAccounts: string[],
|
||||||
|
errors: Object,
|
||||||
|
}
|
||||||
|
|
||||||
|
type State = {
|
||||||
|
numOwners: number,
|
||||||
}
|
}
|
||||||
|
|
||||||
const styles = () => ({
|
const styles = () => ({
|
||||||
root: {
|
root: {
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
},
|
},
|
||||||
padding: {
|
title: {
|
||||||
padding: lg,
|
padding: `${md} ${lg}`,
|
||||||
|
},
|
||||||
|
owner: {
|
||||||
|
padding: `${sm} ${lg}`,
|
||||||
|
},
|
||||||
|
name: {
|
||||||
|
marginRight: `${sm}`,
|
||||||
|
},
|
||||||
|
trash: {
|
||||||
|
top: '5px',
|
||||||
|
},
|
||||||
|
add: {
|
||||||
|
justifyContent: 'center',
|
||||||
|
},
|
||||||
|
check: {
|
||||||
|
color: '#03AE60',
|
||||||
|
height: '20px',
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const SafeOwners = ({ classes }: Props) => (
|
const getAddressValidators = (addresses: string[], position: number) => {
|
||||||
<React.Fragment>
|
const copy = addresses.slice()
|
||||||
<Block className={classes.padding}>
|
copy.splice(position, 1)
|
||||||
<Paragraph noMargin size="md" color="primary" weight="light">
|
|
||||||
Specify the owners of the Safe.
|
return composeValidators(required, mustBeEthereumAddress, uniqueAddress(copy))
|
||||||
</Paragraph>
|
}
|
||||||
</Block>
|
|
||||||
<Block margin="md">
|
const noErrorsOn = (name: string, errors: Object) => errors[name] === undefined
|
||||||
<Hairline margin="sm" />
|
|
||||||
<Row className={classes.padding}>
|
class SafeOwners extends React.Component<Props, State> {
|
||||||
<Col xs={4}>
|
state = {
|
||||||
NAME
|
numOwners: 3,
|
||||||
</Col>
|
}
|
||||||
<Col xs={8}>
|
|
||||||
ADDRESS
|
render() {
|
||||||
</Col>
|
const { classes, errors, otherAccounts } = this.props
|
||||||
</Row>
|
const { numOwners } = this.state
|
||||||
<Hairline margin="sm" />
|
|
||||||
</Block>
|
return (
|
||||||
<Block margin="md">
|
<React.Fragment>
|
||||||
<Paragraph size="md" color="primary" weight="bolder">
|
<Block className={classes.title}>
|
||||||
● My Safe is a smart contract on the Ethereum blockchain.
|
<Paragraph noMargin size="md" color="primary" weight="light">
|
||||||
</Paragraph>
|
Specify the owners of the Safe.
|
||||||
</Block>
|
</Paragraph>
|
||||||
<Block margin="lg" className={classes.root}>
|
</Block>
|
||||||
<Field
|
<Hairline />
|
||||||
name={FIELD_NAME}
|
<Row className={classes.owner}>
|
||||||
component={TextField}
|
<Col xs={4}>
|
||||||
type="text"
|
NAME
|
||||||
validate={required}
|
</Col>
|
||||||
placeholder="Name of the new Safe"
|
<Col xs={8}>
|
||||||
text="Safe name"
|
ADDRESS
|
||||||
/>
|
</Col>
|
||||||
</Block>
|
</Row>
|
||||||
</React.Fragment>
|
<Hairline />
|
||||||
)
|
{ [...Array(Number(numOwners))].map((x, index) => {
|
||||||
|
const addressName = getOwnerAddressBy(index)
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Row key={`owner${(index)}`} className={classes.owner}>
|
||||||
|
<Col xs={4}>
|
||||||
|
<Field
|
||||||
|
className={classes.name}
|
||||||
|
name={getOwnerNameBy(index)}
|
||||||
|
component={TextField}
|
||||||
|
type="text"
|
||||||
|
validate={required}
|
||||||
|
placeholder="Owner Name*"
|
||||||
|
text="Owner Name"
|
||||||
|
/>
|
||||||
|
</Col>
|
||||||
|
<Col xs={7}>
|
||||||
|
<Field
|
||||||
|
name={addressName}
|
||||||
|
component={TextField}
|
||||||
|
inputAdornment={noErrorsOn(addressName, errors) && {
|
||||||
|
endAdornment: (
|
||||||
|
<InputAdornment position="end">
|
||||||
|
<CheckCircle className={classes.check} />
|
||||||
|
</InputAdornment>
|
||||||
|
),
|
||||||
|
}}
|
||||||
|
type="text"
|
||||||
|
validate={getAddressValidators(otherAccounts, index)}
|
||||||
|
placeholder="Owner Address*"
|
||||||
|
text="Owner Address"
|
||||||
|
/>
|
||||||
|
</Col>
|
||||||
|
<Col xs={1} center="xs" middle="xs">
|
||||||
|
{ index > 0 &&
|
||||||
|
<IconButton aria-label="Delete" onClick={undefined} className={classes.trash}>
|
||||||
|
<Delete />
|
||||||
|
</IconButton>
|
||||||
|
}
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
)
|
||||||
|
}) }
|
||||||
|
<Row align="center" grow className={classes.add} margin="xl">
|
||||||
|
<Button color="secondary">
|
||||||
|
+ ADD ANOTHER OWNER
|
||||||
|
</Button>
|
||||||
|
</Row>
|
||||||
|
</React.Fragment>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const SafeOwnersForm = withStyles(styles)(SafeOwners)
|
const SafeOwnersForm = withStyles(styles)(SafeOwners)
|
||||||
|
|
||||||
const SafeOwnersPage = () => (controls: React$Node, { values }: Object) => (
|
const SafeOwnersPage = () => (controls: React$Node, moe: Object) => {
|
||||||
<React.Fragment>
|
const { values, errors } = moe
|
||||||
<OpenPaper controls={controls} padding={false}>
|
|
||||||
<SafeOwnersForm numOwners={values.owners} otherAccounts={getAccountsFrom(values)} />
|
return (
|
||||||
</OpenPaper>
|
<React.Fragment>
|
||||||
</React.Fragment>
|
<OpenPaper controls={controls} padding={false}>
|
||||||
)
|
<SafeOwnersForm otherAccounts={getAccountsFrom(values)} errors={errors} />
|
||||||
|
</OpenPaper>
|
||||||
|
</React.Fragment>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
export default SafeOwnersPage
|
export default SafeOwnersPage
|
||||||
|
|
Loading…
Reference in New Issue