From 925a5a157c71d07b6fb251ff1f6b2db4a72123df Mon Sep 17 00:00:00 2001 From: Vivek Kumar Date: Fri, 31 May 2024 05:37:53 +0530 Subject: [PATCH 01/13] added translation --- src/languages/en.ts | 6 ++++-- src/languages/es.ts | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index 8d1b24211583..e6c04e5691d9 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -428,8 +428,7 @@ export default { phrase2: "Money talks. And now that chat and payments are in one place, it's also easy.", phrase3: 'Your payments get to you as fast as you can get your point across.', enterPassword: 'Please enter your password', - newFaceEnterMagicCode: ({login}: NewFaceEnterMagicCodeParams) => - `It's always great to see a new face around here! Please enter the magic code sent to ${login}. It should arrive within a minute or two.`, + welcomeNewFace: ({login}: NewFaceEnterMagicCodeParams) => `Welcome ${login}, it's always great to see a new face around here!`, welcomeEnterMagicCode: ({login}: WelcomeEnterMagicCodeParams) => `Please enter the magic code sent to ${login}. It should arrive within a minute or two.`, }, login: { @@ -1423,6 +1422,9 @@ export default { onceTheAbove: 'Once the above steps are completed, please reach out to ', toUnblock: ' to unblock your login.', }, + welcomeSignUpForm: { + join: 'Join', + }, detailsPage: { localTime: 'Local time', }, diff --git a/src/languages/es.ts b/src/languages/es.ts index 29f85edfc93e..af7b0946202f 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -419,8 +419,7 @@ export default { phrase2: 'El dinero habla. Y ahora que chat y pagos están en un mismo lugar, es también fácil.', phrase3: 'Tus pagos llegan tan rápido como tus mensajes.', enterPassword: 'Por favor, introduce tu contraseña', - newFaceEnterMagicCode: ({login}: NewFaceEnterMagicCodeParams) => - `¡Siempre es genial ver una cara nueva por aquí! Por favor ingresa el código mágico enviado a ${login}. Debería llegar en un par de minutos.`, + welcomeNewFace: ({login}: NewFaceEnterMagicCodeParams) => `Bienvenido ${login}, ¡siempre es genial ver una cara nueva por aquí!`, welcomeEnterMagicCode: ({login}: WelcomeEnterMagicCodeParams) => `Por favor, introduce el código mágico enviado a ${login}. Debería llegar en un par de minutos.`, }, login: { @@ -1424,6 +1423,9 @@ export default { onceTheAbove: 'Una vez completados los pasos anteriores, ponte en contacto con ', toUnblock: ' para desbloquear el inicio de sesión.', }, + welcomeSignUpForm: { + join: 'Unirse', + }, detailsPage: { localTime: 'Hora local', }, From 90ea20e9ea17dbb4d6eb2a8f3255f8329a0d0eda Mon Sep 17 00:00:00 2001 From: Vivek Kumar Date: Fri, 31 May 2024 05:38:21 +0530 Subject: [PATCH 02/13] updatd API call --- src/libs/API/parameters/BeginSignInParams.ts | 1 + src/libs/actions/Session/index.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libs/API/parameters/BeginSignInParams.ts b/src/libs/API/parameters/BeginSignInParams.ts index 2f85a3335c62..0dec2587ed14 100644 --- a/src/libs/API/parameters/BeginSignInParams.ts +++ b/src/libs/API/parameters/BeginSignInParams.ts @@ -1,5 +1,6 @@ type BeginSignInParams = { email: string; + useNewBeginSignIn: boolean; }; export default BeginSignInParams; diff --git a/src/libs/actions/Session/index.ts b/src/libs/actions/Session/index.ts index 303517558206..a1d56e8ad12f 100644 --- a/src/libs/actions/Session/index.ts +++ b/src/libs/actions/Session/index.ts @@ -405,7 +405,7 @@ function signInAttemptState(): OnyxData { function beginSignIn(email: string) { const {optimisticData, successData, failureData} = signInAttemptState(); - const params: BeginSignInParams = {email}; + const params: BeginSignInParams = {email, useNewBeginSignIn: true}; API.read(READ_COMMANDS.BEGIN_SIGNIN, params, {optimisticData, successData, failureData}); } From efb056f6149020f64e7e129f36468d3ef3800baa Mon Sep 17 00:00:00 2001 From: Vivek Kumar Date: Fri, 31 May 2024 05:53:31 +0530 Subject: [PATCH 03/13] signs up an user --- src/libs/API/parameters/SignUpUserParams.ts | 6 +++ src/libs/API/parameters/index.ts | 1 + src/libs/API/types.ts | 2 + src/libs/actions/Session/index.ts | 44 +++++++++++++++++++++ 4 files changed, 53 insertions(+) create mode 100644 src/libs/API/parameters/SignUpUserParams.ts diff --git a/src/libs/API/parameters/SignUpUserParams.ts b/src/libs/API/parameters/SignUpUserParams.ts new file mode 100644 index 000000000000..81f97b965f33 --- /dev/null +++ b/src/libs/API/parameters/SignUpUserParams.ts @@ -0,0 +1,6 @@ +type SignUpUserParams = { + email?: string; + preferredLocale: string; +}; + +export default SignUpUserParams; diff --git a/src/libs/API/parameters/index.ts b/src/libs/API/parameters/index.ts index c9e2e342c5ae..7e1554948e3c 100644 --- a/src/libs/API/parameters/index.ts +++ b/src/libs/API/parameters/index.ts @@ -223,3 +223,4 @@ export type {default as OpenPolicyAccountingPageParams} from './OpenPolicyAccoun export type {default as SearchParams} from './Search'; export type {default as SendInvoiceParams} from './SendInvoiceParams'; export type {default as MarkAsCashParams} from './MarkAsCashParams'; +export type {default as SignUpUserParams} from './SignUpUserParams'; \ No newline at end of file diff --git a/src/libs/API/types.ts b/src/libs/API/types.ts index 40deec85bc47..91fa07fb84d4 100644 --- a/src/libs/API/types.ts +++ b/src/libs/API/types.ts @@ -218,6 +218,7 @@ const WRITE_COMMANDS = { ACCEPT_SPOTNANA_TERMS: 'AcceptSpotnanaTerms', SEND_INVOICE: 'SendInvoice', MARK_AS_CASH: 'MarkAsCash', + SIGN_UP_USER: 'SignUpUser', } as const; type WriteCommand = ValueOf; @@ -436,6 +437,7 @@ type WriteCommandParameters = { [WRITE_COMMANDS.ACCEPT_SPOTNANA_TERMS]: EmptyObject; [WRITE_COMMANDS.SEND_INVOICE]: Parameters.SendInvoiceParams; [WRITE_COMMANDS.MARK_AS_CASH]: Parameters.MarkAsCashParams; + [WRITE_COMMANDS.SIGN_UP_USER]: Parameters.SignUpUserParams; }; const READ_COMMANDS = { diff --git a/src/libs/actions/Session/index.ts b/src/libs/actions/Session/index.ts index a1d56e8ad12f..ceb351724b89 100644 --- a/src/libs/actions/Session/index.ts +++ b/src/libs/actions/Session/index.ts @@ -18,6 +18,7 @@ import type { SignInUserWithLinkParams, UnlinkLoginParams, ValidateTwoFactorAuthParams, + SignUpUserParams } from '@libs/API/parameters'; import type SignInUserParams from '@libs/API/parameters/SignInUserParams'; import {READ_COMMANDS, SIDE_EFFECT_REQUEST_COMMANDS, WRITE_COMMANDS} from '@libs/API/types'; @@ -410,6 +411,48 @@ function beginSignIn(email: string) { API.read(READ_COMMANDS.BEGIN_SIGNIN, params, {optimisticData, successData, failureData}); } +/** + * Creates an account for the new user and signs them into the application with the newly created account. + * + * @param {String} [preferredLocale] Indicates which language to use when the user lands in the app + */ +function signUpUser(preferredLocale: string = CONST.LOCALES.DEFAULT) { + const optimisticData: OnyxUpdate[] = [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: ONYXKEYS.ACCOUNT, + value: { + ...CONST.DEFAULT_ACCOUNT_DATA, + isLoading: true, + }, + }, + ]; + + const successData:OnyxUpdate[] = [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: ONYXKEYS.ACCOUNT, + value: { + isLoading: false, + }, + }, + ]; + + const failureData:OnyxUpdate[] = [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: ONYXKEYS.ACCOUNT, + value: { + isLoading: false, + }, + }, + ]; + + const params: SignUpUserParams = {email: credentials.login, preferredLocale}; + + API.write(WRITE_COMMANDS.SIGN_UP_USER, params, {optimisticData, successData, failureData}); +} + /** * Given an idToken from Sign in with Apple, checks the API to see if an account * exists for that email address and signs the user in if so. @@ -1004,4 +1047,5 @@ export { signInWithSupportAuthToken, isSupportAuthToken, hasStashedSession, + signUpUser, }; From 6bff5d3aef185e28ebea8fbd27a4a41d09b59294 Mon Sep 17 00:00:00 2001 From: Vivek Kumar Date: Fri, 31 May 2024 07:10:28 +0530 Subject: [PATCH 04/13] add new user signup page --- src/languages/en.ts | 4 +- src/languages/es.ts | 4 +- src/languages/types.ts | 4 +- src/pages/signin/SignInPage.tsx | 4 +- src/pages/signin/SignUpWelcomeForm.tsx | 58 ++++++++++++++++++++++++++ 5 files changed, 66 insertions(+), 8 deletions(-) create mode 100644 src/pages/signin/SignUpWelcomeForm.tsx diff --git a/src/languages/en.ts b/src/languages/en.ts index e6c04e5691d9..595de7e59fc2 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -33,7 +33,7 @@ import type { LogSizeParams, ManagerApprovedAmountParams, ManagerApprovedParams, - NewFaceEnterMagicCodeParams, + SignUpNewFaceCodeParams, NoLongerHaveAccessParams, NotAllowedExtensionParams, NotYouParams, @@ -428,7 +428,7 @@ export default { phrase2: "Money talks. And now that chat and payments are in one place, it's also easy.", phrase3: 'Your payments get to you as fast as you can get your point across.', enterPassword: 'Please enter your password', - welcomeNewFace: ({login}: NewFaceEnterMagicCodeParams) => `Welcome ${login}, it's always great to see a new face around here!`, + welcomeNewFace: ({login}: SignUpNewFaceCodeParams) => `${login}, it's always great to see a new face around here!`, welcomeEnterMagicCode: ({login}: WelcomeEnterMagicCodeParams) => `Please enter the magic code sent to ${login}. It should arrive within a minute or two.`, }, login: { diff --git a/src/languages/es.ts b/src/languages/es.ts index af7b0946202f..1d7d0124779c 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -32,7 +32,7 @@ import type { LogSizeParams, ManagerApprovedAmountParams, ManagerApprovedParams, - NewFaceEnterMagicCodeParams, + SignUpNewFaceCodeParams, NoLongerHaveAccessParams, NotAllowedExtensionParams, NotYouParams, @@ -419,7 +419,7 @@ export default { phrase2: 'El dinero habla. Y ahora que chat y pagos están en un mismo lugar, es también fácil.', phrase3: 'Tus pagos llegan tan rápido como tus mensajes.', enterPassword: 'Por favor, introduce tu contraseña', - welcomeNewFace: ({login}: NewFaceEnterMagicCodeParams) => `Bienvenido ${login}, ¡siempre es genial ver una cara nueva por aquí!`, + welcomeNewFace: ({login}: SignUpNewFaceCodeParams) => `${login}, ¡siempre es genial ver una cara nueva por aquí!`, welcomeEnterMagicCode: ({login}: WelcomeEnterMagicCodeParams) => `Por favor, introduce el código mágico enviado a ${login}. Debería llegar en un par de minutos.`, }, login: { diff --git a/src/languages/types.ts b/src/languages/types.ts index e2e7e26e696b..5f0fc761e2de 100644 --- a/src/languages/types.ts +++ b/src/languages/types.ts @@ -18,7 +18,7 @@ type LoggedInAsParams = { email: string; }; -type NewFaceEnterMagicCodeParams = { +type SignUpNewFaceCodeParams = { login: string; }; @@ -329,7 +329,7 @@ export type { LoggedInAsParams, ManagerApprovedAmountParams, ManagerApprovedParams, - NewFaceEnterMagicCodeParams, + SignUpNewFaceCodeParams, NoLongerHaveAccessParams, NotAllowedExtensionParams, NotYouParams, diff --git a/src/pages/signin/SignInPage.tsx b/src/pages/signin/SignInPage.tsx index 16aeb7053726..8e863655910d 100644 --- a/src/pages/signin/SignInPage.tsx +++ b/src/pages/signin/SignInPage.tsx @@ -224,8 +224,8 @@ function SignInPageInner({credentials, account, activeClients = [], preferredLoc } else { welcomeHeader = shouldUseNarrowLayout ? '' : translate('welcomeText.welcome'); welcomeText = shouldUseNarrowLayout - ? `${translate('welcomeText.welcome')} ${translate('welcomeText.newFaceEnterMagicCode', {login: userLoginToDisplay})}` - : translate('welcomeText.newFaceEnterMagicCode', {login: userLoginToDisplay}); + ? `${translate('welcomeText.welcome')} ${translate('welcomeText.welcomeNewFace', {login: userLoginToDisplay})}` + : translate('welcomeText.welcomeNewFace', {login: userLoginToDisplay}); } } } else if (shouldShowUnlinkLoginForm || shouldShowEmailDeliveryFailurePage || shouldShowChooseSSOOrMagicCode) { diff --git a/src/pages/signin/SignUpWelcomeForm.tsx b/src/pages/signin/SignUpWelcomeForm.tsx new file mode 100644 index 000000000000..866c867e7f50 --- /dev/null +++ b/src/pages/signin/SignUpWelcomeForm.tsx @@ -0,0 +1,58 @@ +import React from 'react'; +import { TouchableOpacity, View } from 'react-native'; +import { withOnyx } from 'react-native-onyx'; +import Button from '../../components/Button'; +import Text from '../../components/Text'; +import * as Session from '../../libs/actions/Session'; +import ONYXKEYS from '../../ONYXKEYS'; +import redirectToSignIn from '../../libs/actions/SignInRedirect'; +import Terms from './Terms'; +import useThemeStyles from '@hooks/useThemeStyles'; +import useLocalize from '@hooks/useLocalize'; +import useNetwork from '@hooks/useNetwork'; +import type {OnyxEntry} from 'react-native-onyx'; +import type {Account, Locale} from '@src/types/onyx'; + +type SignUpWelcomeFormOnyxProps = { + /** State for the account */ + account: OnyxEntry; + + /** The user's preferred locale */ + preferredLocale: OnyxEntry; +}; + +type SignUpWelcomeFormProps = SignUpWelcomeFormOnyxProps; + +function SignUpWelcomeForm({account, preferredLocale}: SignUpWelcomeFormProps) { + const network = useNetwork(); + const styles = useThemeStyles(); + const {translate} = useLocalize(); + + return <> + + redirectToSignIn()}> + {translate('common.back')} + +