Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: login page error #5864

Merged
merged 5 commits into from
Oct 19, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/languages/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ export default {
loginForm: {
phoneOrEmail: 'Phone or email',
error: {
invalidFormatLogin: 'The email or phone number entered is invalid. Please fix the format and try again.',
invalidFormatEmailLogin: 'The email entered is invalid. Please fix the format and try again.',
},
},
resendValidationForm: {
Expand Down Expand Up @@ -465,7 +465,8 @@ export default {
},
cameraPermissionsNotGranted: 'Camera permissions not granted',
messages: {
noPhoneNumber: 'Please enter a phone number including the country code e.g +447814266907',
noPhoneNumber: 'Please enter a phone number including the country code e.g +447814266907.',
errorMessageInvalidPhone: 'That doesn’t look like a valid phone number. Try again with the country code. e.g. +15005550006',
maxParticipantsReached: 'You\'ve reached the maximum number of participants for a group chat.',
},
onfidoStep: {
Expand Down Expand Up @@ -741,7 +742,6 @@ export default {
description: 'Our team of guides are on hand to help you each step of the way. Type in your name and phone number, and we’ll give you a call back.',
callMe: 'Call me',
growlMessageOnSave: 'Call requested.',
errorMessageInvalidPhone: 'That doesn’t look like a valid phone number. Try again with the country code. e.g. +15005550006',
growlMessageEmptyName: 'Please provide both a first and last name so our guides know how to address you!',
growlMessageNoPersonalPolicy: 'I wasn’t able to find a personal policy to associate this Guides call with, please check your connection and try again.',
callButton: 'Call',
Expand Down
6 changes: 3 additions & 3 deletions src/languages/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ export default {
loginForm: {
phoneOrEmail: 'Número de teléfono o email',
error: {
invalidFormatLogin: 'El email o número de teléfono que has introducido no es válido. Corrígelo e inténtalo de nuevo.',
invalidFormatEmailLogin: 'El email introducido no es válido. Corrígelo e inténtalo de nuevo.',
},
},
resendValidationForm: {
Expand Down Expand Up @@ -465,7 +465,8 @@ export default {
},
cameraPermissionsNotGranted: 'No has habilitado los permisos para acceder a la cámara',
messages: {
noPhoneNumber: 'Por favor escribe un número de teléfono que incluya el código de país e.g +447814266907',
noPhoneNumber: 'Por favor escribe un número de teléfono que incluya el código de país e.g +447814266907.',
errorMessageInvalidPhone: 'El teléfono no es valido. Inténtalo de nuevo agregando el código de país. P. ej.: +15005550006',
maxParticipantsReached: 'Has llegado al número máximo de participantes para un grupo.',
},
onfidoStep: {
Expand Down Expand Up @@ -743,7 +744,6 @@ export default {
description: '¿Necesitas ayuda configurando tu cuenta? Nuestro equipo de guías puede ayudarte. Escribe tu nombre y número de teléfono y te llamaremos.',
callMe: 'Llámame',
growlMessageOnSave: 'Llamada solicitada.',
errorMessageInvalidPhone: 'El teléfono no es valido. Inténtalo de nuevo agregando el código de país. P. ej.: +15005550006',
growlMessageEmptyName: 'Por favor ingresa tu nombre completo',
growlMessageNoPersonalPolicy: 'No he podido encontrar una póliza personal con la que asociar esta llamada a las Guías, compruebe su conexión e inténtelo de nuevo.',
callButton: 'Llamar',
Expand Down
6 changes: 5 additions & 1 deletion src/libs/actions/Session.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,11 @@ function fetchAccountDetails(login) {
resendValidationLink(login);
}
} else if (response.jsonCode === 402) {
Onyx.merge(ONYXKEYS.ACCOUNT, {error: translateLocal('loginForm.error.invalidFormatLogin')});
Onyx.merge(ONYXKEYS.ACCOUNT, {
error: CONST.REGEX.DIGITS_AND_PLUS.test(login)
? translateLocal('messages.errorMessageInvalidPhone')
: translateLocal('loginForm.error.invalidFormatEmailLogin'),
});
} else {
Onyx.merge(ONYXKEYS.ACCOUNT, {error: response.message});
}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/RequestCallPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ class RequestCallPage extends Component {
if (_.isEmpty(this.state.phoneNumber.trim())) {
this.setState({phoneNumberError: this.props.translate('messages.noPhoneNumber')});
} else if (!Str.isValidPhone(this.state.phoneNumber)) {
this.setState({phoneNumberError: this.props.translate('requestCallPage.errorMessageInvalidPhone')});
this.setState({phoneNumberError: this.props.translate('messages.errorMessageInvalidPhone')});
} else {
this.setState({phoneNumberError: ''});
}
Expand Down
13 changes: 11 additions & 2 deletions src/pages/signin/LoginForm.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import {View} from 'react-native';
import {withOnyx} from 'react-native-onyx';
import Onyx, {withOnyx} from 'react-native-onyx';
import PropTypes from 'prop-types';
import _ from 'underscore';
import Str from 'expensify-common/lib/str';
Expand All @@ -15,6 +15,7 @@ import canFocusInputOnScreenFocus from '../../libs/canFocusInputOnScreenFocus';
import withLocalize, {withLocalizePropTypes} from '../../components/withLocalize';
import getEmailKeyboardType from '../../libs/getEmailKeyboardType';
import ExpensiTextInput from '../../components/ExpensiTextInput';
import CONST from '../../CONST';

const propTypes = {
/* Onyx Props */
Expand Down Expand Up @@ -63,6 +64,10 @@ class LoginForm extends React.Component {
login: text,
formError: null,
});

if (this.props.account.error) {
Onyx.merge(ONYXKEYS.ACCOUNT, {error: ''});
}
}

/**
Expand All @@ -75,7 +80,11 @@ class LoginForm extends React.Component {
}

if (!Str.isValidEmail(this.state.login) && !Str.isValidPhone(this.state.login)) {
this.setState({formError: 'loginForm.error.invalidFormatLogin'});
if (CONST.REGEX.DIGITS_AND_PLUS.test(this.state.login)) {
this.setState({formError: 'messages.errorMessageInvalidPhone'});
} else {
this.setState({formError: 'loginForm.error.invalidFormatEmailLogin'});
}
return;
}

Expand Down