From 43e02e157472c27635d3fae355d431285bb47613 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Wed, 14 Feb 2018 14:59:00 +0100 Subject: [PATCH] Apply suggestions --- client/coral-admin/src/containers/SignIn.js | 2 +- client/coral-framework/hocs/withForgotPassword.js | 2 +- .../hocs/withResendEmailConfirmation.js | 2 +- client/coral-framework/hocs/withSetUsername.js | 4 ++-- client/coral-framework/hocs/withSignIn.js | 2 +- client/coral-framework/hocs/withSignUp.js | 8 ++++---- .../client/login/containers/SignIn.js | 2 +- .../client/login/containers/SignUp.js | 12 +++++++----- .../client/stream/containers/SetUsernameDialog.js | 2 +- 9 files changed, 19 insertions(+), 17 deletions(-) diff --git a/client/coral-admin/src/containers/SignIn.js b/client/coral-admin/src/containers/SignIn.js index 02dc8ba01..a48b15ce7 100644 --- a/client/coral-admin/src/containers/SignIn.js +++ b/client/coral-admin/src/containers/SignIn.js @@ -8,7 +8,7 @@ class SignInContainer extends Component { state = { email: '', password: '', - recaptchaResponse: '', + recaptchaResponse: null, }; handleSubmit = () => { diff --git a/client/coral-framework/hocs/withForgotPassword.js b/client/coral-framework/hocs/withForgotPassword.js index 85af3a6f9..9ef4b59e1 100644 --- a/client/coral-framework/hocs/withForgotPassword.js +++ b/client/coral-framework/hocs/withForgotPassword.js @@ -46,7 +46,7 @@ export default hoistStatics(WrappedComponent => { getErrorMessage() { if (!this.state.error) { - return ''; + return null; } return translateError(this.state.error); } diff --git a/client/coral-framework/hocs/withResendEmailConfirmation.js b/client/coral-framework/hocs/withResendEmailConfirmation.js index 80182ca5c..64f5ed69f 100644 --- a/client/coral-framework/hocs/withResendEmailConfirmation.js +++ b/client/coral-framework/hocs/withResendEmailConfirmation.js @@ -47,7 +47,7 @@ export default hoistStatics(WrappedComponent => { getErrorMessage() { if (!this.state.error) { - return ''; + return null; } return translateError(this.state.error); } diff --git a/client/coral-framework/hocs/withSetUsername.js b/client/coral-framework/hocs/withSetUsername.js index b0c8ea1eb..05323efa1 100644 --- a/client/coral-framework/hocs/withSetUsername.js +++ b/client/coral-framework/hocs/withSetUsername.js @@ -40,7 +40,7 @@ const withSetUsername = hoistStatics(WrappedComponent => { if (!value) { return t('error.required_field'); } - return validate.username(value) ? '' : errorMsg.username; + return validate.username(value) ? null : errorMsg.username; }; setUsername = async username => { @@ -64,7 +64,7 @@ const withSetUsername = hoistStatics(WrappedComponent => { getErrorMessage() { if (!this.state.error) { - return ''; + return null; } return getErrorMessages(this.state.error).join(', '); } diff --git a/client/coral-framework/hocs/withSignIn.js b/client/coral-framework/hocs/withSignIn.js index 53c3ab6d1..d377d8ada 100644 --- a/client/coral-framework/hocs/withSignIn.js +++ b/client/coral-framework/hocs/withSignIn.js @@ -67,7 +67,7 @@ export default hoistStatics(WrappedComponent => { getErrorMessage() { if (!this.state.error) { - return ''; + return null; } return this.state.error.translation_key === 'NOT_AUTHORIZED' ? t('error.email_password') diff --git a/client/coral-framework/hocs/withSignUp.js b/client/coral-framework/hocs/withSignUp.js index 860e4b7c1..8c35e1cc9 100644 --- a/client/coral-framework/hocs/withSignUp.js +++ b/client/coral-framework/hocs/withSignUp.js @@ -51,7 +51,7 @@ const withSignUp = hoistStatics(WrappedComponent => { validate = (field, value) => { if (!allFields.includes(field)) { - return ''; + return null; } if (requiredFields.includes(field) && !value) { @@ -59,10 +59,10 @@ const withSignUp = hoistStatics(WrappedComponent => { } if (field in validate) { - return validate[field](value) ? '' : errorMsg[field]; + return validate[field](value) ? null : errorMsg[field]; } - return ''; + return null; }; signUp = ({ username, email, password }, redirectUri) => { @@ -96,7 +96,7 @@ const withSignUp = hoistStatics(WrappedComponent => { getErrorMessage() { if (!this.state.error) { - return ''; + return null; } return translateError(this.state.error); } diff --git a/plugins/talk-plugin-auth/client/login/containers/SignIn.js b/plugins/talk-plugin-auth/client/login/containers/SignIn.js index ac887d7d2..ed797aed3 100644 --- a/plugins/talk-plugin-auth/client/login/containers/SignIn.js +++ b/plugins/talk-plugin-auth/client/login/containers/SignIn.js @@ -9,7 +9,7 @@ import { setView, setEmail, setPassword } from '../actions'; class SignInContainer extends Component { state = { - recaptchaResponse: '', + recaptchaResponse: null, }; handleSubmit = () => { diff --git a/plugins/talk-plugin-auth/client/login/containers/SignUp.js b/plugins/talk-plugin-auth/client/login/containers/SignUp.js index d1629db1c..cadca6f86 100644 --- a/plugins/talk-plugin-auth/client/login/containers/SignUp.js +++ b/plugins/talk-plugin-auth/client/login/containers/SignUp.js @@ -12,10 +12,10 @@ class SignUpContainer extends Component { state = { username: '', passwordRepeat: '', - usernameError: '', - emailError: '', - passwordError: '', - passwordRepeatError: '', + usernameError: null, + emailError: null, + passwordError: null, + passwordRepeatError: null, }; validate = data => { @@ -30,7 +30,9 @@ class SignUpContainer extends Component { }); if (data.password !== data.passwordRepeat) { - changes['passwordRepeatError'] = t('sign_in.passwords_dont_match'); + changes['passwordRepeatError'] = t( + 'talk-plugin-auth.login.passwords_dont_match' + ); valid = false; } diff --git a/plugins/talk-plugin-auth/client/stream/containers/SetUsernameDialog.js b/plugins/talk-plugin-auth/client/stream/containers/SetUsernameDialog.js index 16ba5cac0..ae89b9fac 100644 --- a/plugins/talk-plugin-auth/client/stream/containers/SetUsernameDialog.js +++ b/plugins/talk-plugin-auth/client/stream/containers/SetUsernameDialog.js @@ -11,7 +11,7 @@ import SetUsernameDialog from '../components/SetUsernameDialog'; class SetUsernameDialogContainer extends Component { state = { username: this.props.username, - usernameError: '', + usernameError: null, }; handleSubmit = () => {