From 377c16cf7893fd0ebc5a723caa647f38d65dda69 Mon Sep 17 00:00:00 2001 From: Jannis R Date: Tue, 15 Nov 2016 13:39:10 +0100 Subject: [PATCH] sms verification: make QueryCode component dumb --- .../SMSVerification/QueryCode/queryCode.js | 24 ++++++------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/js/src/modals/SMSVerification/QueryCode/queryCode.js b/js/src/modals/SMSVerification/QueryCode/queryCode.js index f06a8ace6..b4da6c8f4 100644 --- a/js/src/modals/SMSVerification/QueryCode/queryCode.js +++ b/js/src/modals/SMSVerification/QueryCode/queryCode.js @@ -18,18 +18,15 @@ import React, { Component, PropTypes } from 'react'; import { Form, Input } from '../../../ui'; -const isValidCode = /^[A-Z0-9_-]{7,14}$/i; - export default class QueryCode extends Component { static propTypes = { - data: PropTypes.object.isRequired, - onData: PropTypes.func.isRequired, - onDataIsValid: PropTypes.func.isRequired, - onDataIsInvalid: PropTypes.func.isRequired + number: PropTypes.string.isRequired, + isCodeValid: PropTypes.bool.isRequired, + setCode: PropTypes.func.isRequired } render () { - const { number, code } = this.props.data; + const { number, isCodeValid } = this.props; return (
@@ -37,7 +34,7 @@ export default class QueryCode extends Component { @@ -46,16 +43,9 @@ export default class QueryCode extends Component { } onChange = (_, code) => { - code = code.trim(); - this.props.onData({ code }); - - if (isValidCode.test(code)) { - this.props.onDataIsValid(); - } else { - this.props.onDataIsInvalid(); - } + this.props.setCode(code.trim()); } onSubmit = (code) => { - this.onChange(null, code); + this.props.setCode(code.trim()); } }