pass fields to query into QueryCode

This commit is contained in:
Jannis R 2016-12-07 19:21:29 +01:00
parent 052f9258a5
commit 0e0f602d5e
No known key found for this signature in database
GPG Key ID: 0FE83946296A88A5
2 changed files with 21 additions and 7 deletions

View File

@ -20,20 +20,25 @@ import { Form, Input } from '~/ui';
export default class QueryCode extends Component {
static propTypes = {
number: PropTypes.string.isRequired,
receiver: PropTypes.string.isRequired,
hint: PropTypes.string,
isCodeValid: PropTypes.bool.isRequired,
setCode: PropTypes.func.isRequired
}
static defaultProps = {
hint: 'Enter the code you received.'
}
render () {
const { number, isCodeValid } = this.props;
const { receiver, hint, isCodeValid } = this.props;
return (
<Form>
<p>The verification code has been sent to { number }.</p>
<p>The verification code has been sent to { receiver }.</p>
<Input
label={ 'verification code' }
hint={ 'Enter the code you received via SMS.' }
hint={ hint }
error={ isCodeValid ? null : 'invalid code' }
onChange={ this.onChange }
onSubmit={ this.onSubmit }

View File

@ -158,8 +158,8 @@ export default class Verification extends Component {
return (<p>{ error }</p>);
}
const { method } = this.state;
if (phase === 0) {
const { method } = this.state;
const values = Object.values(methods);
const value = values.findIndex((v) => v.value === method);
return (
@ -185,7 +185,6 @@ export default class Verification extends Component {
);
case 2:
const { method } = this.state;
const { setConsentGiven } = this.props.store;
const fields = []
@ -221,9 +220,19 @@ export default class Verification extends Component {
);
case 4:
let receiver, hint;
if (method === 'sms') {
receiver = this.props.store.number;
hint = 'Enter the code you received via SMS.';
} else if (method === 'email') {
receiver = this.props.store.email;
hint = 'Enter the code you received via e-mail.';
}
return (
<QueryCode
number={ number } fee={ fee } isCodeValid={ isCodeValid }
receiver={ receiver }
hint={ hint }
isCodeValid={ isCodeValid }
setCode={ setCode }
/>
);