Apply suggestions

This commit is contained in:
Chi Vinh Le
2018-02-14 14:59:00 +01:00
parent 8f7171b54e
commit 43e02e1574
9 changed files with 19 additions and 17 deletions
+1 -1
View File
@@ -8,7 +8,7 @@ class SignInContainer extends Component {
state = {
email: '',
password: '',
recaptchaResponse: '',
recaptchaResponse: null,
};
handleSubmit = () => {
@@ -46,7 +46,7 @@ export default hoistStatics(WrappedComponent => {
getErrorMessage() {
if (!this.state.error) {
return '';
return null;
}
return translateError(this.state.error);
}
@@ -47,7 +47,7 @@ export default hoistStatics(WrappedComponent => {
getErrorMessage() {
if (!this.state.error) {
return '';
return null;
}
return translateError(this.state.error);
}
@@ -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(', ');
}
+1 -1
View File
@@ -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')
+4 -4
View File
@@ -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);
}
@@ -9,7 +9,7 @@ import { setView, setEmail, setPassword } from '../actions';
class SignInContainer extends Component {
state = {
recaptchaResponse: '',
recaptchaResponse: null,
};
handleSubmit = () => {
@@ -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;
}
@@ -11,7 +11,7 @@ import SetUsernameDialog from '../components/SetUsernameDialog';
class SetUsernameDialogContainer extends Component {
state = {
username: this.props.username,
usernameError: '',
usernameError: null,
};
handleSubmit = () => {