diff --git a/js/src/modals/SMSVerification/CheckIfCertified/checkIfCertified.css b/js/src/modals/SMSVerification/CheckIfCertified/checkIfCertified.css deleted file mode 100644 index 13779b8f4..000000000 --- a/js/src/modals/SMSVerification/CheckIfCertified/checkIfCertified.css +++ /dev/null @@ -1,27 +0,0 @@ -/* Copyright 2015, 2016 Ethcore (UK) Ltd. -/* This file is part of Parity. -/* -/* Parity is free software: you can redistribute it and/or modify -/* it under the terms of the GNU General Public License as published by -/* the Free Software Foundation, either version 3 of the License, or -/* (at your option) any later version. -/* -/* Parity is distributed in the hope that it will be useful, -/* but WITHOUT ANY WARRANTY; without even the implied warranty of -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -/* GNU General Public License for more details. -/* -/* You should have received a copy of the GNU General Public License -/* along with Parity. If not, see . -*/ - -.container { - display: flex; - align-items: center; -} - -.message { - margin-top: 0; - margin-bottom: 0; - margin-left: .5em; -} diff --git a/js/src/modals/SMSVerification/CheckIfCertified/checkIfCertified.js b/js/src/modals/SMSVerification/CheckIfCertified/checkIfCertified.js deleted file mode 100644 index b9048f6e7..000000000 --- a/js/src/modals/SMSVerification/CheckIfCertified/checkIfCertified.js +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright 2015, 2016 Ethcore (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -import React, { Component, PropTypes } from 'react'; -import SuccessIcon from 'material-ui/svg-icons/navigation/check'; -import ErrorIcon from 'material-ui/svg-icons/alert/error-outline'; - -import styles from './checkIfCertified.css'; - -export default class CheckIfCertified extends Component { - static contextTypes = { - api: PropTypes.object.isRequired - } - - static propTypes = { - account: PropTypes.string.isRequired, - contract: PropTypes.object.isRequired, - onIsCertified: PropTypes.func.isRequired, - onIsNotCertified: PropTypes.func.isRequired - } - - state = { - pending: false, - isCertified: null - }; - - componentWillMount () { - const { pending } = this.state; - if (pending) { - return; - } - this.setState({ pending: true }); - - const { account, contract, onIsCertified, onIsNotCertified } = this.props; - - contract.instance.certified.call({}, [account]) - .then((isCertified) => { - this.setState({ isCertified, pending: false }); - if (isCertified) { - onIsCertified(); - } else { - onIsNotCertified(); - } - }) - .catch((err) => { - console.error('error checking if certified', err); - }); - } - - render () { - const { pending, isCertified } = this.state; - - if (pending) { - return (

Checking if your account is verified…

); - } - - if (isCertified) { - return ( -
- -

Your account is already verified.

-
- ); - } - return ( -
- -

Your account is not verified yet.

-
- ); - } -} diff --git a/js/src/modals/SMSVerification/CheckIfCertified/index.js b/js/src/modals/SMSVerification/CheckIfCertified/index.js deleted file mode 100644 index 2577505e2..000000000 --- a/js/src/modals/SMSVerification/CheckIfCertified/index.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2015, 2016 Ethcore (UK) Ltd. -// This file is part of Parity. - -// Parity is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Parity is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Parity. If not, see . - -export default from './checkIfCertified'; diff --git a/js/src/modals/SMSVerification/GatherData/gatherData.css b/js/src/modals/SMSVerification/GatherData/gatherData.css index ac956063c..4bd7697fb 100644 --- a/js/src/modals/SMSVerification/GatherData/gatherData.css +++ b/js/src/modals/SMSVerification/GatherData/gatherData.css @@ -17,3 +17,14 @@ .spacing { margin-top: 1.5em; } + +.container { + margin-top: .5em; + display: flex; + align-items: center; +} +.message { + margin-top: 0; + margin-bottom: 0; + margin-left: .5em; +} diff --git a/js/src/modals/SMSVerification/GatherData/gatherData.js b/js/src/modals/SMSVerification/GatherData/gatherData.js index fd5d00791..44f0d5340 100644 --- a/js/src/modals/SMSVerification/GatherData/gatherData.js +++ b/js/src/modals/SMSVerification/GatherData/gatherData.js @@ -16,6 +16,9 @@ import React, { Component, PropTypes } from 'react'; import { Checkbox } from 'material-ui'; +import SuccessIcon from 'material-ui/svg-icons/navigation/check'; +import ErrorIcon from 'material-ui/svg-icons/alert/error-outline'; + import phone from 'phoneformat.js'; import { fromWei } from '../../../api/util/wei'; @@ -24,7 +27,12 @@ import { Form, Input } from '../../../ui'; import styles from './gatherData.css'; export default class GatherData extends Component { + static contextTypes = { + api: PropTypes.object.isRequired + } + static propTypes = { + account: PropTypes.string.isRequired, contract: PropTypes.object.isRequired, data: PropTypes.object.isRequired, onData: PropTypes.func.isRequired, @@ -34,6 +42,7 @@ export default class GatherData extends Component { state = { init: true, + isCertified: null, numberIsValid: null, consentGiven: false }; @@ -41,8 +50,9 @@ export default class GatherData extends Component { componentWillMount () { const { init } = this.state; if (init) { - this.queryFee(); this.setState({ init: false }); + this.queryFee(); + this.checkIfCertified(); } } @@ -53,6 +63,7 @@ export default class GatherData extends Component { return (

{ fee ? `The fee is ${fromWei(fee).toFixed(3)} ETH.` : 'Fetching the fee…' }

+ { this.renderCertified() } + +

Your account is already verified.

+ + ); + } + if (isCertified === false) { + return ( +
+ +

Your account is not verified yet.

+
+ ); + } + return (

Checking if your account is verified…

); + } + queryFee = () => { const { contract, onData } = this.props; @@ -83,6 +116,19 @@ export default class GatherData extends Component { }); } + checkIfCertified = () => { + const { account, contract, onData } = this.props; + + contract.instance.certified.call({}, [account]) + .then((isCertified) => { + onData({ isCertified }); + this.onChange(); + }) + .catch((err) => { + console.error('error checking if certified', err); + }); + } + numberOnSubmit = (value) => { this.numberOnChange(null, value); this.props.onData({ number: value }); @@ -102,10 +148,10 @@ export default class GatherData extends Component { } onChange = () => { - const { fee } = this.props.data; + const { fee, isCertified } = this.props.data; const { numberIsValid, consentGiven } = this.state; - if (fee && numberIsValid && consentGiven) { + if (fee && numberIsValid && consentGiven && isCertified === false) { this.props.onDataIsValid(); } else { this.props.onDataIsInvalid(); diff --git a/js/src/modals/SMSVerification/SMSVerification.js b/js/src/modals/SMSVerification/SMSVerification.js index af3153fb9..e685c2c21 100644 --- a/js/src/modals/SMSVerification/SMSVerification.js +++ b/js/src/modals/SMSVerification/SMSVerification.js @@ -24,7 +24,6 @@ import { validateAddress, validateUint } from '../../util/validation'; import ABI from '../../contracts/abi/sms-verification.json'; const contract = '0xcE381B876A85A72303f7cA7b3a012f58F4CEEEeB'; -import CheckIfCertified from './CheckIfCertified'; import GatherData from './GatherData'; import SendRequest from './SendRequest'; import QueryCode from './QueryCode'; @@ -64,7 +63,7 @@ export default class SMSVerification extends Component { title='verify your account via SMS' visible scroll current={ step } - steps={ ['Preparations', 'Enter Data', 'Request', 'Enter Code', 'Confirm'] } + steps={ ['Enter Data', 'Request', 'Enter Code', 'Confirm'] } > { this.renderStep() } @@ -83,7 +82,7 @@ export default class SMSVerification extends Component { /> ); - if (step === 4) { + if (step === 3) { return (
{ cancel } @@ -117,9 +116,7 @@ export default class SMSVerification extends Component { } const { step } = this.state; - if (step === 4) { - return this.renderFifthStep(); - } else if (step === 3) { + if (step === 3) { return this.renderFourthStep(); } else if (step === 2) { return this.renderThirdStep(); @@ -148,23 +145,11 @@ export default class SMSVerification extends Component { renderFirstStep () { const { account } = this.props; - const { contract } = this.state; - - return ( - - ); - } - - renderSecondStep () { const { contract, data } = this.state; return (