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

View File

@ -158,8 +158,8 @@ export default class Verification extends Component {
return (<p>{ error }</p>); return (<p>{ error }</p>);
} }
if (phase === 0) {
const { method } = this.state; const { method } = this.state;
if (phase === 0) {
const values = Object.values(methods); const values = Object.values(methods);
const value = values.findIndex((v) => v.value === method); const value = values.findIndex((v) => v.value === method);
return ( return (
@ -185,7 +185,6 @@ export default class Verification extends Component {
); );
case 2: case 2:
const { method } = this.state;
const { setConsentGiven } = this.props.store; const { setConsentGiven } = this.props.store;
const fields = [] const fields = []
@ -221,9 +220,19 @@ export default class Verification extends Component {
); );
case 4: 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 ( return (
<QueryCode <QueryCode
number={ number } fee={ fee } isCodeValid={ isCodeValid } receiver={ receiver }
hint={ hint }
isCodeValid={ isCodeValid }
setCode={ setCode } setCode={ setCode }
/> />
); );