Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions src/languages/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2760,6 +2760,7 @@ ${amount} für ${merchant} – ${date}`,
},
workEmailValidationError: {
publicEmail: 'Bitte gib eine gültige geschäftliche E-Mail-Adresse von einer privaten Domain ein, z. B. mitch@company.com',
sameAsSignupEmail: 'Bitte geben Sie eine andere E-Mail-Adresse ein als die, mit der Sie sich registriert haben',
offline: 'Wir konnten deine geschäftliche E-Mail nicht hinzufügen, da du offenbar offline bist',
},
mergeBlockScreen: {
Expand Down
1 change: 1 addition & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2784,6 +2784,7 @@ const translations = {
},
workEmailValidationError: {
publicEmail: 'Please enter a valid work email from a private domain e.g. mitch@company.com',
sameAsSignupEmail: 'Please enter a different email than the one you signed up with',
offline: 'We couldn’t add your work email as you appear to be offline',
},
mergeBlockScreen: {
Expand Down
1 change: 1 addition & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2611,6 +2611,7 @@ ${amount} para ${merchant} - ${date}`,
},
workEmailValidationError: {
publicEmail: 'Por favor, introduce un correo electrónico laboral válido de un dominio privado, por ejemplo: mitch@company.com',
sameAsSignupEmail: 'Por favor, introduce un correo electrónico diferente al que utilizaste para registrarte',
offline: 'No pudimos añadir tu correo electrónico laboral porque parece que estás sin conexión.',
},
mergeBlockScreen: {
Expand Down
1 change: 1 addition & 0 deletions src/languages/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2765,6 +2765,7 @@ ${amount} pour ${merchant} - ${date}`,
},
workEmailValidationError: {
publicEmail: 'Veuillez saisir une adresse e-mail professionnelle valide provenant d’un domaine privé, par ex. mitch@company.com',
sameAsSignupEmail: 'Veuillez saisir une adresse e-mail différente de celle avec laquelle vous vous êtes inscrit',
offline: 'Nous n’avons pas pu ajouter votre adresse e-mail professionnelle, car vous semblez être hors ligne',
},
mergeBlockScreen: {
Expand Down
1 change: 1 addition & 0 deletions src/languages/it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2752,6 +2752,7 @@ ${amount} per ${merchant} - ${date}`,
},
workEmailValidationError: {
publicEmail: 'Inserisci un’email di lavoro valida con dominio privato, ad es. mitch@company.com',
sameAsSignupEmail: 'Inserisci un’email diversa da quella con cui ti sei registrato',
offline: 'Non è stato possibile aggiungere la tua email di lavoro perché sembri offline',
},
mergeBlockScreen: {
Expand Down
1 change: 1 addition & 0 deletions src/languages/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2733,6 +2733,7 @@ ${date} の ${merchant} への ${amount}`,
},
workEmailValidationError: {
publicEmail: 'プライベートドメインの有効な勤務先メールアドレスを入力してください(例:mitch@company.com)',
sameAsSignupEmail: 'サインアップ時に使用したものとは別のメールアドレスを入力してください',
offline: 'オフラインのため、勤務先のメールアドレスを追加できませんでした',
},
mergeBlockScreen: {
Expand Down
1 change: 1 addition & 0 deletions src/languages/nl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2752,6 +2752,7 @@ ${amount} voor ${merchant} - ${date}`,
},
workEmailValidationError: {
publicEmail: 'Voer een geldig zakelijk e-mailadres in van een privédomein, bijv. mitch@company.com',
sameAsSignupEmail: 'Voer een ander e-mailadres in dan het e-mailadres waarmee je je hebt aangemeld',
offline: 'We konden je werk-e-mailadres niet toevoegen omdat je offline lijkt te zijn',
},
mergeBlockScreen: {
Expand Down
1 change: 1 addition & 0 deletions src/languages/pl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2744,6 +2744,7 @@ ${amount} dla ${merchant} - ${date}`,
},
workEmailValidationError: {
publicEmail: 'Wpisz poprawny służbowy adres e‑mail z prywatnej domeny, np. mitch@company.com',
sameAsSignupEmail: 'Podaj inny adres e-mail niż ten, którego użyłeś przy rejestracji',
offline: 'Nie mogliśmy dodać Twojego służbowego adresu e‑mail, ponieważ wydajesz się być offline',
},
mergeBlockScreen: {
Expand Down
1 change: 1 addition & 0 deletions src/languages/pt-BR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2744,6 +2744,7 @@ ${amount} para ${merchant} - ${date}`,
},
workEmailValidationError: {
publicEmail: 'Insira um e-mail de trabalho válido de um domínio privado, por exemplo: mitch@company.com',
sameAsSignupEmail: 'Insira um e-mail diferente daquele com que você se cadastrou',
offline: 'Não foi possível adicionar seu e-mail profissional, pois você parece estar offline',
},
mergeBlockScreen: {
Expand Down
1 change: 1 addition & 0 deletions src/languages/zh-hans.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2692,6 +2692,7 @@ ${amount},商户:${merchant} - 日期:${date}`,
},
workEmailValidationError: {
publicEmail: '请输入来自私有域的有效工作邮箱,例如:mitch@company.com',
sameAsSignupEmail: '请输入与注册时不同的邮箱',
offline: '由于您似乎处于离线状态,我们无法添加您的工作邮箱',
},
mergeBlockScreen: {
Expand Down
11 changes: 7 additions & 4 deletions src/pages/OnboardingWorkEmail/BaseOnboardingWorkEmail.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {useIsFocused} from '@react-navigation/native';
import {Str} from 'expensify-common';
import {PUBLIC_DOMAINS_SET, Str} from 'expensify-common';
import React, {useCallback, useEffect, useMemo, useState} from 'react';
import {View} from 'react-native';
import AutoEmailLink from '@components/AutoEmailLink';
Expand Down Expand Up @@ -47,6 +47,7 @@ function BaseOnboardingWorkEmail({shouldUseNativeStyles}: BaseOnboardingWorkEmai
const {translate} = useLocalize();
const illustrations = useMemoizedLazyIllustrations(['EnvelopeReceipt', 'Gears', 'Profile']);
const [onboardingValues] = useOnyx(ONYXKEYS.NVP_ONBOARDING);
const [session] = useOnyx(ONYXKEYS.SESSION);
const [formValue] = useOnyx(ONYXKEYS.FORMS.ONBOARDING_WORK_EMAIL_FORM);
const workEmail = formValue?.[INPUT_IDS.ONBOARDING_WORK_EMAIL];
const [onboardingErrorMessage] = useOnyx(ONYXKEYS.ONBOARDING_ERROR_MESSAGE_TRANSLATION_KEY);
Expand Down Expand Up @@ -95,20 +96,22 @@ function BaseOnboardingWorkEmail({shouldUseNativeStyles}: BaseOnboardingWorkEmai
}, [onboardingValues?.shouldValidate, isVsb, isSmb, isFocused, onboardingValues?.isMergeAccountStepCompleted, onboardingValues?.isMergeAccountStepSkipped]);

const submitWorkEmail = useCallback((values: FormOnyxValues<typeof ONYXKEYS.FORMS.ONBOARDING_WORK_EMAIL_FORM>) => {
AddWorkEmail(values[INPUT_IDS.ONBOARDING_WORK_EMAIL]);
AddWorkEmail(values[INPUT_IDS.ONBOARDING_WORK_EMAIL].trim());
}, []);

const validate = (values: FormOnyxValues<typeof ONYXKEYS.FORMS.ONBOARDING_WORK_EMAIL_FORM>) => {
if (!shouldValidateOnChange) {
setShouldValidateOnChange(true);
}
const userEmail = values[INPUT_IDS.ONBOARDING_WORK_EMAIL];
const userEmail = values[INPUT_IDS.ONBOARDING_WORK_EMAIL].trim();

const errors = {};
const emailParts = userEmail.split('@');
const domain = emailParts.at(1) ?? '';

if (!Str.isValidEmail(userEmail) && !isOffline) {
if (session?.email && userEmail.toLowerCase() === session.email.toLowerCase() && !isOffline) {
Comment thread
blimpich marked this conversation as resolved.
Resolved
addErrorMessage(errors, INPUT_IDS.ONBOARDING_WORK_EMAIL, translate('onboarding.workEmailValidationError.sameAsSignupEmail'));
} else if ((!Str.isValidEmail(userEmail) || PUBLIC_DOMAINS_SET.has(domain.toLowerCase())) && !isOffline) {
Log.hmmm('User is trying to add an invalid work email', {userEmail, domain});
addErrorMessage(errors, INPUT_IDS.ONBOARDING_WORK_EMAIL, translate('onboarding.workEmailValidationError.publicEmail'));
}
Expand Down
Loading