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
7 changes: 4 additions & 3 deletions src/components/TestDrive/Modal/EmployeeTestDriveModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
} from '@libs/actions/IOU';
import {verifyTestDriveRecipient} from '@libs/actions/Onboarding';
import setTestReceipt from '@libs/actions/setTestReceipt';
import type AccountExistsError from '@libs/Errors/AccountExistsError';
import Navigation from '@libs/Navigation/Navigation';
import type {PlatformStackRouteProp} from '@libs/Navigation/PlatformStackNavigation/types';
import type {TestDriveModalNavigatorParamList} from '@libs/Navigation/types';
Expand Down Expand Up @@ -93,13 +94,13 @@ function EmployeeTestDriveModal() {
},
() => {
setIsLoading(false);
setFormError(translate('testDrive.modal.employee.error'));
setFormError(translate('common.genericErrorMessage'));
},
);
})
.catch(() => {
.catch((e: AccountExistsError) => {
setIsLoading(false);
setFormError(translate('testDrive.modal.employee.error'));
setFormError(e.translationKey ? translate(e.translationKey) : 'common.genericErrorMessage');
});
};

Expand Down
1 change: 1 addition & 0 deletions src/languages/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,7 @@ const translations = {
getTheApp: 'Hole dir die App',
scanReceiptsOnTheGo: 'Scannen Sie Belege von Ihrem Telefon aus',
headsUp: 'Achtung!',
unstableInternetConnection: 'Instabile Internetverbindung. Bitte überprüfe dein Netzwerk und versuche es erneut.',
},
supportalNoAccess: {
title: 'Nicht so schnell',
Expand Down
1 change: 1 addition & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,7 @@ const translations = {
getTheApp: 'Get the app',
scanReceiptsOnTheGo: 'Scan receipts from your phone',
headsUp: 'Heads up!',
unstableInternetConnection: 'Unstable internet connection. Please check your network and try again.',
},
supportalNoAccess: {
title: 'Not so fast',
Expand Down
1 change: 1 addition & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,7 @@ const translations = {
getTheApp: 'Descarga la app',
scanReceiptsOnTheGo: 'Escanea recibos desde tu teléfono',
headsUp: '¡Atención!',
unstableInternetConnection: 'Conexión a internet inestable. Por favor, revisa tu red e inténtalo de nuevo.',
},
supportalNoAccess: {
title: 'No tan rápido',
Expand Down
1 change: 1 addition & 0 deletions src/languages/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,7 @@ const translations = {
getTheApp: "Obtenez l'application",
scanReceiptsOnTheGo: 'Numérisez les reçus depuis votre téléphone',
headsUp: 'Attention !',
unstableInternetConnection: 'Connexion Internet instable. Veuillez vérifier votre réseau et réessayer.',
},
supportalNoAccess: {
title: 'Pas si vite',
Expand Down
1 change: 1 addition & 0 deletions src/languages/it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,7 @@ const translations = {
getTheApp: "Scarica l'app",
scanReceiptsOnTheGo: 'Scansiona le ricevute dal tuo telefono',
headsUp: 'Attenzione!',
unstableInternetConnection: 'Connessione Internet instabile. Controlla la tua rete e riprova.',
},
supportalNoAccess: {
title: 'Non così in fretta',
Expand Down
1 change: 1 addition & 0 deletions src/languages/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,7 @@ const translations = {
getTheApp: 'アプリを入手',
scanReceiptsOnTheGo: '携帯電話から領収書をスキャンする',
headsUp: 'ご注意ください!',
unstableInternetConnection: 'インターネット接続が不安定です。ネットワークを確認してもう一度お試しください。',
},
supportalNoAccess: {
title: 'ちょっと待ってください',
Expand Down
1 change: 1 addition & 0 deletions src/languages/nl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,7 @@ const translations = {
getTheApp: 'Download de app',
scanReceiptsOnTheGo: 'Scan bonnetjes vanaf je telefoon',
headsUp: 'Let op!',
unstableInternetConnection: 'Onstabiele internetverbinding. Controleer je netwerk en probeer het opnieuw.',
},
supportalNoAccess: {
title: 'Niet zo snel',
Expand Down
1 change: 1 addition & 0 deletions src/languages/pl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,7 @@ const translations = {
getTheApp: 'Pobierz aplikację',
scanReceiptsOnTheGo: 'Skanuj paragony za pomocą telefonu',
headsUp: 'Uwaga!',
unstableInternetConnection: 'Niestabilne połączenie internetowe. Sprawdź swoją sieć i spróbuj ponownie.',
},
supportalNoAccess: {
title: 'Nie tak szybko',
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 @@ -626,6 +626,7 @@ const translations = {
getTheApp: 'Obtenha o aplicativo',
scanReceiptsOnTheGo: 'Digitalize recibos com seu celular',
headsUp: 'Atenção!',
unstableInternetConnection: 'Conexão de internet instável. Verifique sua rede e tente novamente.',
},
supportalNoAccess: {
title: 'Não tão rápido',
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 @@ -626,6 +626,7 @@ const translations = {
getTheApp: '获取应用程序',
scanReceiptsOnTheGo: '用手机扫描收据',
headsUp: '\u6CE8\u610F\uFF01',
unstableInternetConnection: '互联网连接不稳定。请检查你的网络,然后重试。',
},
supportalNoAccess: {
title: '慢一点',
Expand Down
13 changes: 13 additions & 0 deletions src/libs/Errors/AccountExistsError.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import type {TranslationPaths} from '@src/languages/types';

class AccountExistsError extends Error {
translationKey: TranslationPaths;

constructor(accountExists: boolean | undefined) {
super();
// If accountExists is undefined, it means we couldn't determine the account status due to an unstable internet connection.
this.translationKey = accountExists === undefined ? 'common.unstableInternetConnection' : 'testDrive.modal.employee.error';
}
}

export default AccountExistsError;
6 changes: 4 additions & 2 deletions src/libs/actions/Onboarding.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Onyx from 'react-native-onyx';
import * as API from '@libs/API';
import {SIDE_EFFECT_REQUEST_COMMANDS} from '@libs/API/types';
import AccountExistsError from '@libs/Errors/AccountExistsError';
import ONYXKEYS from '@src/ONYXKEYS';

/**
Expand Down Expand Up @@ -34,12 +35,13 @@ function setWorkspaceCurrency(currency: string) {
function verifyTestDriveRecipient(email: string) {
// eslint-disable-next-line rulesdir/no-api-side-effects-method
return API.makeRequestWithSideEffects(SIDE_EFFECT_REQUEST_COMMANDS.VERIFY_TEST_DRIVE_RECIPIENT, {email}).then((response) => {
if (!response?.accountExists) {
// If accountExists is undefined, it means we couldn't determine the account status due to an unstable internet connection.
if (response?.accountExists === false) {
// We can invite this user since they do not have an account yet
return;
}

throw new Error(response?.message);
throw new AccountExistsError(response?.accountExists);
});
}

Expand Down
Loading