diff --git a/src/components/ValidateCode/ExpiredValidateCodeModal.js b/src/components/ValidateCode/ExpiredValidateCodeModal.js index 57d6f2cf2b98..449462e88130 100644 --- a/src/components/ValidateCode/ExpiredValidateCodeModal.js +++ b/src/components/ValidateCode/ExpiredValidateCodeModal.js @@ -1,8 +1,4 @@ -import React, {PureComponent} from 'react'; -import {withOnyx} from 'react-native-onyx'; -import PropTypes from 'prop-types'; -import _, {compose} from 'underscore'; -import lodashGet from 'lodash/get'; +import React from 'react'; import {View} from 'react-native'; import colors from '../../styles/colors'; import styles from '../../styles/styles'; @@ -12,114 +8,39 @@ import Text from '../Text'; import * as Expensicons from '../Icon/Expensicons'; import * as Illustrations from '../Icon/Illustrations'; import variables from '../../styles/variables'; -import TextLink from '../TextLink'; -import ONYXKEYS from '../../ONYXKEYS'; -import * as ErrorUtils from '../../libs/ErrorUtils'; -import * as Session from '../../libs/actions/Session'; const propTypes = { - /** The details about the account that the user is signing in with */ - account: PropTypes.shape({ - /** An error message to display to the user */ - errors: PropTypes.objectOf(PropTypes.string), - - /** The message to be displayed when code requested */ - message: PropTypes.string, - }), - - /** The credentials of the logged in person */ - credentials: PropTypes.shape({ - /** The email the user logged in with */ - login: PropTypes.string, - }), - ...withLocalizePropTypes, }; -const defaultProps = { - account: {}, - credentials: {}, -}; - -class ExpiredValidateCodeModal extends PureComponent { - constructor(props) { - super(props); - - this.requestNewCode = this.requestNewCode.bind(this); - } - - shouldShowRequestCodeLink() { - return Boolean(lodashGet(this.props, 'credentials.login', null)); - } - - requestNewCode() { - Session.resendValidateCode(); - } - - render() { - const codeRequestedMessage = lodashGet(this.props, 'account.message', null); - const accountErrors = lodashGet(this.props, 'account.errors', {}); - let codeRequestedErrors; - if (_.keys(accountErrors).length > 1) { - codeRequestedErrors = ErrorUtils.getLatestErrorMessage(this.props.account); - } - return ( - - - - - - {this.props.translate('validateCodeModal.expiredCodeTitle')} - - - {this.props.translate('validateCodeModal.expiredCodeDescription')} - {this.shouldShowRequestCodeLink() && !codeRequestedMessage && ( - <> -
- {this.props.translate('validateCodeModal.requestNewCode')}{' '} - {this.props.translate('validateCodeModal.requestNewCodeLink')}! - - )} -
- {this.shouldShowRequestCodeLink() && Boolean(codeRequestedErrors) && ( - -
-
- {codeRequestedErrors} -
- )} - {this.shouldShowRequestCodeLink() && Boolean(codeRequestedMessage) && ( - -
-
- {this.props.translate(codeRequestedMessage)} -
- )} -
-
- +function ExpiredValidateCodeModal(props) { + return ( + + + + {props.translate('validateCodeModal.expiredCodeTitle')} + + {props.translate('validateCodeModal.expiredCodeDescription')} + + + + - ); - } + + ); } ExpiredValidateCodeModal.propTypes = propTypes; -ExpiredValidateCodeModal.defaultProps = defaultProps; -export default compose( - withLocalize, - withOnyx({ - account: {key: ONYXKEYS.ACCOUNT}, - credentials: {key: ONYXKEYS.CREDENTIALS}, - }), -)(ExpiredValidateCodeModal); +ExpiredValidateCodeModal.displayName = 'ExpiredValidateCodeModal'; +export default withLocalize(ExpiredValidateCodeModal); diff --git a/src/languages/en.js b/src/languages/en.js index 7f8b96990b26..0dca451b0701 100755 --- a/src/languages/en.js +++ b/src/languages/en.js @@ -195,8 +195,6 @@ export default { signInHere: 'just sign in here', expiredCodeTitle: 'Magic code expired', expiredCodeDescription: 'Go back to the original device and request a new code.', - requestNewCode: 'You can also', - requestNewCodeLink: 'request a new code here', successfulNewCodeRequest: 'Code requested. Please check your device.', tfaRequiredTitle: 'Two-factor authentication\nrequired', tfaRequiredDescription: 'Please enter the two-factor authentication code\nwhere you are trying to sign in.', diff --git a/src/languages/es.js b/src/languages/es.js index 1267a59b7043..10e31f7225e1 100644 --- a/src/languages/es.js +++ b/src/languages/es.js @@ -194,8 +194,6 @@ export default { signInHere: 'simplemente inicia sesión aquí', expiredCodeTitle: 'Código mágico caducado', expiredCodeDescription: 'Vuelve al dispositivo original y solicita un código nuevo.', - requestNewCode: '¡También puedes', - requestNewCodeLink: 'solicitar un nuevo código aquí', successfulNewCodeRequest: 'Código solicitado. Por favor, comprueba tu dispositivo.', tfaRequiredTitle: 'Se requiere autenticación\nde dos factores', tfaRequiredDescription: 'Por favor, introduce el código de autenticación de dos factores\ndonde estás intentando iniciar sesión.',