From fae75d75992d4b1135470e56f66907648b0fa72f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germ=C3=A1n=20Mart=C3=ADnez?= Date: Fri, 14 Jun 2019 17:51:09 +0200 Subject: [PATCH] Add update Safe name component --- src/routes/safe/components/Layout.jsx | 3 +- .../Settings/UpdateSafeName/index.jsx | 88 +++++++++++++------ src/routes/safe/components/Settings/index.jsx | 19 +++- 3 files changed, 79 insertions(+), 31 deletions(-) diff --git a/src/routes/safe/components/Layout.jsx b/src/routes/safe/components/Layout.jsx index fe148dca..187f6a49 100644 --- a/src/routes/safe/components/Layout.jsx +++ b/src/routes/safe/components/Layout.jsx @@ -90,7 +90,7 @@ class Layout extends React.Component { render() { const { - safe, provider, network, classes, granted, tokens, activeTokens, createTransaction, + safe, provider, network, classes, granted, tokens, activeTokens, createTransaction, updateSafeName, } = this.props const { tabIndex } = this.state @@ -148,6 +148,7 @@ class Layout extends React.Component { safeAddress={address} safeName={name} etherScanLink={etherScanLink} + updateSafeName={updateSafeName} /> )} diff --git a/src/routes/safe/components/Settings/UpdateSafeName/index.jsx b/src/routes/safe/components/Settings/UpdateSafeName/index.jsx index 24980f6b..f0ebeeb3 100644 --- a/src/routes/safe/components/Settings/UpdateSafeName/index.jsx +++ b/src/routes/safe/components/Settings/UpdateSafeName/index.jsx @@ -1,10 +1,17 @@ // @flow -import * as React from 'react' +import React, { useState } from 'react' import { withStyles } from '@material-ui/core/styles' import Block from '~/components/layout/Block' import Col from '~/components/layout/Col' +import Field from '~/components/forms/Field' +import { + composeValidators, required, minMaxLength, +} from '~/components/forms/validator' +import TextField from '~/components/forms/TextField' +import GnoForm from '~/components/forms/GnoForm' import Row from '~/components/layout/Row' import Paragraph from '~/components/layout/Paragraph' +import Hairline from '~/components/layout/Hairline' import Button from '~/components/layout/Button' import { sm, boldFont } from '~/theme/variables' import { styles } from './style' @@ -21,36 +28,63 @@ const saveButtonStyle = { type Props = { classes: Object, + safeAddress: string, + safeName: string, + updateSafe: Funtion } -class UpdateSafeName extends React.Component { - render() { - const { classes } = this.props +const UpdateSafeName = (props: Props) => { + const { + classes, + safeAddress, + safeName, + updateSafeName, + } = props - return ( - - - - Details - - - - - - - - - ) + const handleSubmit = (values) => { + updateSafeName(safeAddress, values.safeName) } + + return ( + + + {() => ( + + + + Modify Safe name + + + + + + + + + + + + + )} + + + ) } export default withStyles(styles)(UpdateSafeName) diff --git a/src/routes/safe/components/Settings/index.jsx b/src/routes/safe/components/Settings/index.jsx index 0b1360e8..3895ffe6 100644 --- a/src/routes/safe/components/Settings/index.jsx +++ b/src/routes/safe/components/Settings/index.jsx @@ -1,5 +1,6 @@ // @flow import * as React from 'react' +import { connect } from 'react-redux' import { withStyles } from '@material-ui/core/styles' import Block from '~/components/layout/Block' import Col from '~/components/layout/Col' @@ -7,13 +8,15 @@ import Row from '~/components/layout/Row' import RemoveSafeModal from './RemoveSafeModal' import Paragraph from '~/components/layout/Paragraph' import Hairline from '~/components/layout/Hairline' +import UpdateSafeName from './UpdateSafeName' +import actions, { type Actions } from './actions' import { styles } from './style' type State = { showRemoveSafe: boolean, } -type Props = { +type Props = Actions & { classes: Object, granted: boolean, etherScanLink: string, @@ -49,6 +52,7 @@ class Settings extends React.Component { etherScanLink, safeAddress, safeName, + updateSafeName, } = this.props return ( @@ -98,7 +102,11 @@ class Settings extends React.Component { {menuOptionIndex === 1 && ( -

To be done

+ )} {granted && menuOptionIndex === 2 && (

To be done

@@ -117,4 +125,9 @@ class Settings extends React.Component { } } -export default withStyles(styles)(Settings) +const settingsComponent = withStyles(styles)(Settings) + +export default connect( + undefined, + actions, +)(settingsComponent)