Skip to content

Commit 2202cc2

Browse files
authored
Merge pull request #5116 from Expensify/monil-resendLinkCopy
Refactor resend link page
2 parents 357af46 + 58b278b commit 2202cc2

File tree

8 files changed

+93
-22
lines changed

8 files changed

+93
-22
lines changed

src/languages/en.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export default {
2626
continue: 'Continue',
2727
firstName: 'First name',
2828
lastName: 'Last name',
29+
phone: 'Phone',
2930
phoneNumber: 'Phone number',
3031
email: 'Email',
3132
and: 'and',
@@ -376,8 +377,10 @@ export default {
376377
},
377378
resendValidationForm: {
378379
linkHasBeenResent: 'Link has been re-sent',
379-
weSentYouMagicSignInLink: ({loginType}) => `We've sent a magic sign in link to your ${loginType}.`,
380+
weSentYouMagicSignInLink: ({login}) => `We've sent a magic sign in link to ${login}. Check your Inbox and your Spam folder and wait 5-10 minutes before trying again.`,
380381
resendLink: 'Resend link',
382+
unvalidatedAccount: 'This account exists but isn\'t validated, please check your inbox for your magic link.',
383+
newAccount: ({login, loginType}) => `Welcome ${login}, it's always great to see a new face around here! Please check your ${loginType} for a magic link to validate your account.`,
381384
},
382385
detailsPage: {
383386
localTime: 'Local time',

src/languages/es.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export default {
2626
continue: 'Continuar',
2727
firstName: 'Primer nombre',
2828
lastName: 'Apellido',
29+
phone: 'teléfono',
2930
phoneNumber: 'Número de teléfono',
3031
email: 'Email',
3132
and: 'y',
@@ -376,8 +377,10 @@ export default {
376377
},
377378
resendValidationForm: {
378379
linkHasBeenResent: 'El enlace se ha reenviado',
379-
weSentYouMagicSignInLink: ({loginType}) => `Hemos enviado un enlace mágico de inicio de sesión a tu ${loginType}.`,
380+
weSentYouMagicSignInLink: ({login}) => `Hemos enviado un enlace mágico de inicio de sesión a ${login}. Verifica tu bandeja de entrada y tu carpeta de correo no deseado y espera de 5 a 10 minutos antes de intentarlo de nuevo.`,
380381
resendLink: 'Reenviar enlace',
382+
unvalidatedAccount: 'Esta cuenta existe pero no está validada, por favor busca el enlace mágico en tu bandeja de entrada',
383+
newAccount: ({login, loginType}) => `¡Bienvenido ${login}, es genial ver una cara nueva por aquí! En tu ${loginType} encontrarás un enlace para validar tu cuenta, por favor, revísalo`,
381384
},
382385
detailsPage: {
383386
localTime: 'Hora local',

src/pages/SetPasswordPage.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,10 @@ class SetPasswordPage extends Component {
113113
const error = this.state.error || this.props.account.error;
114114
return (
115115
<SafeAreaView style={[styles.signInPage]}>
116-
<SignInPageLayout welcomeText={this.props.translate('setPasswordPage.passwordFormTitle')}>
116+
<SignInPageLayout
117+
shouldShowWelcomeText
118+
welcomeText={this.props.translate('setPasswordPage.passwordFormTitle')}
119+
>
117120
<View style={[styles.mb4]}>
118121
<NewPasswordForm
119122
password={this.state.password}

src/pages/signin/ResendValidationForm.js

Lines changed: 44 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import {View} from 'react-native';
2+
import {TouchableOpacity, View} from 'react-native';
33
import {withOnyx} from 'react-native-onyx';
44
import PropTypes from 'prop-types';
55
import _ from 'underscore';
@@ -9,9 +9,11 @@ import Button from '../../components/Button';
99
import Text from '../../components/Text';
1010
import {reopenAccount, resendValidationLink, resetPassword} from '../../libs/actions/Session';
1111
import ONYXKEYS from '../../ONYXKEYS';
12-
import ChangeExpensifyLoginLink from './ChangeExpensifyLoginLink';
1312
import withLocalize, {withLocalizePropTypes} from '../../components/withLocalize';
1413
import compose from '../../libs/compose';
14+
import redirectToSignIn from '../../libs/actions/SignInRedirect';
15+
import Avatar from '../../components/Avatar';
16+
import {getDefaultAvatar} from '../../libs/OptionsListUtils';
1517

1618
const propTypes = {
1719
/* Onyx Props */
@@ -32,6 +34,9 @@ const propTypes = {
3234

3335
/** Whether or not the account is closed */
3436
closed: PropTypes.bool,
37+
38+
/** Whether or not the account already exists */
39+
accountExists: PropTypes.bool,
3540
}),
3641

3742
...withLocalizePropTypes,
@@ -80,31 +85,59 @@ class ResendValidationForm extends React.Component {
8085
}
8186

8287
render() {
88+
const isNewAccount = !this.props.account.accountExists;
89+
const isOldUnvalidatedAccount = this.props.account.accountExists && !this.props.account.validated;
90+
const isSMSLogin = Str.isSMSLogin(this.props.credentials.login);
91+
const login = isSMSLogin ? this.props.toLocalPhone(Str.removeSMSDomain(this.props.credentials.login)) : this.props.credentials.login;
92+
const loginType = (isSMSLogin ? this.props.translate('common.phone') : this.props.translate('common.email')).toLowerCase();
93+
let message = '';
94+
95+
if (isNewAccount) {
96+
message = this.props.translate('resendValidationForm.newAccount', {
97+
login,
98+
loginType,
99+
});
100+
} else if (isOldUnvalidatedAccount) {
101+
message = this.props.translate('resendValidationForm.unvalidatedAccount');
102+
} else {
103+
message = this.props.translate('resendValidationForm.weSentYouMagicSignInLink', {
104+
login,
105+
});
106+
}
107+
83108
return (
84109
<>
85-
<View>
110+
<View style={[styles.mt3, styles.flexRow, styles.alignItemsCenter, styles.justifyContentStart]}>
111+
<Avatar
112+
source={getDefaultAvatar(this.props.credentials.login)}
113+
imageStyles={[styles.mr2]}
114+
/>
115+
<Text style={[styles.textStrong]}>
116+
{login}
117+
</Text>
118+
</View>
119+
<View style={[styles.mv5]}>
86120
<Text>
87-
{this.props.translate('resendValidationForm.weSentYouMagicSignInLink', {
88-
loginType: (Str.isSMSLogin(this.props.credentials.login)
89-
? this.props.translate('common.phoneNumber').toLowerCase()
90-
: this.props.translate('common.email')).toLowerCase(),
91-
})}
121+
{message}
92122
</Text>
93123
</View>
94124
{!_.isEmpty(this.state.formSuccess) && (
95125
<Text style={[styles.formSuccess]}>
96126
{this.state.formSuccess}
97127
</Text>
98128
)}
99-
<View style={[styles.mt4]}>
129+
<View style={[styles.mb4, styles.flexRow, styles.justifyContentBetween, styles.alignItemsCenter]}>
130+
<TouchableOpacity onPress={() => redirectToSignIn()}>
131+
<Text>
132+
{this.props.translate('common.back')}
133+
</Text>
134+
</TouchableOpacity>
100135
<Button
101136
success
102-
style={[styles.mb2]}
103137
text={this.props.translate('resendValidationForm.resendLink')}
104138
isLoading={this.props.account.loading}
105139
onPress={this.validateAndSubmitForm}
106140
/>
107-
<ChangeExpensifyLoginLink />
108141
</View>
109142
</>
110143
);

src/pages/signin/SignInPage.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class SignInPage extends Component {
9292
<SafeAreaView style={[styles.signInPage]}>
9393
<SignInPageLayout
9494
welcomeText={welcomeText}
95-
shouldShowWelcomeText={showLoginForm}
95+
shouldShowWelcomeText={showLoginForm || showPasswordForm || !showResendValidationLinkForm}
9696
shouldShowWelcomeScreenshot={showLoginForm}
9797
>
9898
{showLoginForm && <LoginForm />}

src/pages/signin/SignInPageLayout/SignInPageLayoutNarrow.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ const propTypes = {
1616
* on form type (set password, sign in, etc.) */
1717
welcomeText: PropTypes.string.isRequired,
1818

19+
/** Whether to show welcome text on a particular page */
20+
shouldShowWelcomeText: PropTypes.bool.isRequired,
21+
1922
...withLocalizePropTypes,
2023
};
2124

@@ -47,9 +50,11 @@ const SignInPageLayoutNarrow = props => (
4750
height={variables.componentSizeLarge}
4851
/>
4952
</View>
50-
<Text style={[styles.mv5, styles.textLabel, styles.h3]}>
51-
{props.welcomeText}
52-
</Text>
53+
{props.shouldShowWelcomeText && (
54+
<Text style={[styles.mv5, styles.textLabel, styles.h3]}>
55+
{props.welcomeText}
56+
</Text>
57+
)}
5358
{props.children}
5459
</View>
5560
</View>

src/pages/signin/SignInPageLayout/SignInPageLayoutWide.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ const propTypes = {
2222
/* Flag to check medium screen with device */
2323
isMediumScreenWidth: PropTypes.bool.isRequired,
2424

25+
/** Whether to show welcome text on a particular page */
26+
shouldShowWelcomeText: PropTypes.bool.isRequired,
27+
2528
...withLocalizePropTypes,
2629
};
2730

@@ -45,9 +48,11 @@ const SignInPageLayoutWide = props => (
4548
height={variables.componentSizeLarge}
4649
/>
4750
</View>
48-
<Text style={[styles.mv5, styles.textLabel, styles.h3]}>
49-
{props.welcomeText}
50-
</Text>
51+
{props.shouldShowWelcomeText && (
52+
<Text style={[styles.mv5, styles.textLabel, styles.h3]}>
53+
{props.welcomeText}
54+
</Text>
55+
)}
5156
<View>
5257
{props.children}
5358
</View>

src/pages/signin/SignInPageLayout/index.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
11
import React from 'react';
2+
import PropTypes from 'prop-types';
23
import SignInPageLayoutNarrow from './SignInPageLayoutNarrow';
34
import SignInPageLayoutWide from './SignInPageLayoutWide';
45
import withWindowDimensions, {windowDimensionsPropTypes} from '../../../components/withWindowDimensions';
56

67
const propTypes = {
8+
/** The children to show inside the layout */
9+
children: PropTypes.node.isRequired,
10+
11+
/** Welcome text to show in the header of the form, changes depending
12+
* on form type (set password, sign in, etc.) */
13+
welcomeText: PropTypes.string.isRequired,
14+
15+
/** Whether to show welcome text on a particular page */
16+
shouldShowWelcomeText: PropTypes.bool.isRequired,
17+
718
...windowDimensionsPropTypes,
819
};
920

@@ -13,11 +24,19 @@ const SignInPageLayout = props => (
1324
<SignInPageLayoutWide
1425
welcomeText={props.welcomeText}
1526
isMediumScreenWidth={props.isMediumScreenWidth}
27+
shouldShowWelcomeText={props.shouldShowWelcomeText}
1628
>
1729
{props.children}
1830
</SignInPageLayoutWide>
1931
)
20-
: <SignInPageLayoutNarrow welcomeText={props.welcomeText}>{props.children}</SignInPageLayoutNarrow>
32+
: (
33+
<SignInPageLayoutNarrow
34+
welcomeText={props.welcomeText}
35+
shouldShowWelcomeText={props.shouldShowWelcomeText}
36+
>
37+
{props.children}
38+
</SignInPageLayoutNarrow>
39+
)
2140
);
2241

2342
SignInPageLayout.propTypes = propTypes;

0 commit comments

Comments
 (0)