sms verification: check if certified
This commit is contained in:
parent
435d3c24db
commit
14da2d2805
@ -0,0 +1,27 @@
|
||||
/* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
.container {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.message {
|
||||
margin-top: 0;
|
||||
margin-bottom: 0;
|
||||
margin-left: .5em;
|
||||
}
|
@ -0,0 +1,88 @@
|
||||
// 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
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 { Form, Input } from '../../../ui';
|
||||
|
||||
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 (<p className={ styles.message }>Checking if your account is verified…</p>);
|
||||
}
|
||||
|
||||
if (isCertified) {
|
||||
return (
|
||||
<div className={ styles.container }>
|
||||
<ErrorIcon />
|
||||
<p className={ styles.message }>Your account is already verified.</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<div className={ styles.container }>
|
||||
<SuccessIcon />
|
||||
<p className={ styles.message }>Your account is not verified yet.</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
17
js/src/modals/SMSVerification/CheckIfCertified/index.js
Normal file
17
js/src/modals/SMSVerification/CheckIfCertified/index.js
Normal file
@ -0,0 +1,17 @@
|
||||
// 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
export default from './checkIfCertified';
|
@ -24,6 +24,7 @@ import { validateAddress, validateUint } from '../../util/validation';
|
||||
import ABI from '../../contracts/abi/sms-verification.json';
|
||||
const contract = '0x7B3F58965439b22ef1dA4BB78f16191d11ab80B0';
|
||||
|
||||
import CheckIfCertified from './CheckIfCertified';
|
||||
import GatherData from './GatherData';
|
||||
|
||||
export default class SMSVerification extends Component {
|
||||
@ -119,16 +120,28 @@ export default class SMSVerification extends Component {
|
||||
onDataIsValid = () => {
|
||||
this.setState({ stepIsValid: true });
|
||||
}
|
||||
|
||||
onDataIsInvalid = () => {
|
||||
this.setState({ stepIsValid: false });
|
||||
}
|
||||
|
||||
next = () => {
|
||||
this.setState({ step: this.state.step + 1 });
|
||||
this.setState({ step: this.state.step + 1, stepIsValid: false });
|
||||
}
|
||||
|
||||
renderFirstStep () {
|
||||
const { account } = this.props;
|
||||
const { contract } = this.state;
|
||||
|
||||
return (
|
||||
<CheckIfCertified
|
||||
account={ account } contract={ contract }
|
||||
onIsCertified={ this.onDataIsInvalid }
|
||||
onIsNotCertified={ this.onDataIsValid }
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
renderSecondStep () {
|
||||
return (
|
||||
<GatherData
|
||||
onDataIsValid={ this.onDataIsValid }
|
||||
|
Loading…
Reference in New Issue
Block a user