From c0ddf22e97594ddb5e24866996552ad209531086 Mon Sep 17 00:00:00 2001 From: Nikki Wines Date: Thu, 9 Mar 2023 17:05:43 -0800 Subject: [PATCH 01/19] add unlinkLoginForm --- src/languages/en.js | 5 ++ src/pages/signin/UnlinkLoginForm.js | 117 ++++++++++++++++++++++++++++ 2 files changed, 122 insertions(+) create mode 100644 src/pages/signin/UnlinkLoginForm.js diff --git a/src/languages/en.js b/src/languages/en.js index 44ce40366d71..c66e656ef98b 100755 --- a/src/languages/en.js +++ b/src/languages/en.js @@ -629,6 +629,11 @@ export default { resendLink: 'Resend link', validationCodeFailedMessage: 'It looks like there was an error with your validation link or it has expired.', }, + unlinkLoginForm: { + toValidateLogin: ({primaryLogin, secondaryLogin}) => `To validate ${secondaryLogin}, please resend the magic code from the Account Settings of ${primaryLogin}.`, + noLongerHaveAccess: ({primaryLogin}) => `If you no longer have access to ${primaryLogin}, please unlink your accounts.`, + unlink: 'Unlink', + }, detailsPage: { localTime: 'Local time', }, diff --git a/src/pages/signin/UnlinkLoginForm.js b/src/pages/signin/UnlinkLoginForm.js new file mode 100644 index 000000000000..ea4349f27bd8 --- /dev/null +++ b/src/pages/signin/UnlinkLoginForm.js @@ -0,0 +1,117 @@ +import React from 'react'; +import _ from 'underscore'; +import {TouchableOpacity, View} from 'react-native'; +import {withOnyx} from 'react-native-onyx'; +import PropTypes from 'prop-types'; +import Str from 'expensify-common/lib/str'; +import styles from '../../styles/styles'; +import Button from '../../components/Button'; +import Text from '../../components/Text'; +import * as Session from '../../libs/actions/Session'; +import ONYXKEYS from '../../ONYXKEYS'; +import withLocalize, {withLocalizePropTypes} from '../../components/withLocalize'; +import compose from '../../libs/compose'; +import redirectToSignIn from '../../libs/actions/SignInRedirect'; +import Avatar from '../../components/Avatar'; +import * as ReportUtils from '../../libs/ReportUtils'; +import networkPropTypes from '../../components/networkPropTypes'; +import {withNetwork} from '../../components/OnyxProvider'; +import DotIndicatorMessage from '../../components/DotIndicatorMessage'; + +const propTypes = { + /* Onyx Props */ + + /** The credentials of the logged in person */ + credentials: PropTypes.shape({ + /** The email/phone the user logged in with */ + login: PropTypes.string, + }).isRequired, + + /** The details about the account that the user is signing in with */ + account: PropTypes.shape({ + /** Whether or not a sign on form is loading (being submitted) */ + loading: PropTypes.bool, + + /** Whether or not the account is validated */ + validated: PropTypes.bool, + + /** The primaryLogin associated with the account */ + primaryLogin: PropTypes.string, + }), + + /** Information about the network */ + network: networkPropTypes.isRequired, + + ...withLocalizePropTypes, +}; + +const defaultProps = { + account: {}, +}; + +const UnlinkLoginForm = (props) => { + const primaryLogin = Str.isSMSLogin(props.account.primaryLogin) ? Str.removeSMSDomain(props.account.primaryLogin) : props.account.primaryLogin; + const secondaryLogin = Str.isSMSLogin(props.credentials.login) ? Str.removeSMSDomain(props.credentials.login) : props.credentials.login; + + return ( + <> + + + + + {secondaryLogin} + + + + + + {props.translate('unlinkLoginForm.toValidateLogin', {primaryLogin, secondaryLogin})} + + + + + {props.translate('unlinkLoginForm.noLongerHaveAccess', {primaryLogin})} + + + {!_.isEmpty(props.account.message) && ( + + // DotIndicatorMessage mostly expects onyxData errors so we need to mock an object so that the messages looks similar to prop.account.errors + + )} + {!_.isEmpty(props.account.errors) && ( + + )} + + redirectToSignIn()}> + + {props.translate('common.back')} + + +