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/ONYXKEYS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type {OnyxUpdate} from 'react-native-onyx';
import type {ValueOf} from 'type-fest';
import type CONST from './CONST';
import type {OnboardingAccounting} from './CONST';
import type {TranslationPaths} from './languages/types';
import type {OnboardingCompanySize} from './libs/actions/Welcome/OnboardingFlow';
import type Platform from './libs/getPlatform/types';
import type * as FormTypes from './types/form';
Expand Down Expand Up @@ -389,8 +390,8 @@ const ONYXKEYS = {
/** Onboarding customized choices to display to the user based on their profile when signing up */
ONBOARDING_CUSTOM_CHOICES: 'onboardingCustomChoices',

/** Onboarding error message to be displayed to the user */
ONBOARDING_ERROR_MESSAGE: 'onboardingErrorMessage',
/** Onboarding error message translation key to be displayed to the user */
ONBOARDING_ERROR_MESSAGE_TRANSLATION_KEY: 'onboardingErrorMessageTranslationKey',

/** Onboarding policyID selected by the user during Onboarding flow */
ONBOARDING_POLICY_ID: 'onboardingPolicyID',
Expand Down Expand Up @@ -1213,7 +1214,7 @@ type OnyxValuesMapping = {
[ONYXKEYS.ONBOARDING_PURPOSE_SELECTED]: OnyxTypes.OnboardingPurpose;
[ONYXKEYS.ONBOARDING_COMPANY_SIZE]: OnboardingCompanySize;
[ONYXKEYS.ONBOARDING_CUSTOM_CHOICES]: OnyxTypes.OnboardingPurpose[] | [];
[ONYXKEYS.ONBOARDING_ERROR_MESSAGE]: string;
[ONYXKEYS.ONBOARDING_ERROR_MESSAGE_TRANSLATION_KEY]: TranslationPaths;
[ONYXKEYS.ONBOARDING_POLICY_ID]: string;
[ONYXKEYS.ONBOARDING_ADMINS_CHAT_REPORT_ID]: string;
[ONYXKEYS.ONBOARDING_LAST_VISITED_PATH]: string;
Expand Down
6 changes: 3 additions & 3 deletions src/components/OnboardingMergingAccountBlockedView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ type OnboardingMergingAccountBlockedViewProps = {
function OnboardingMergingAccountBlockedView({workEmail, isVsb}: OnboardingMergingAccountBlockedViewProps) {
const styles = useThemeStyles();
const {translate} = useLocalize();
const [onboardingErrorMessage] = useOnyx(ONYXKEYS.ONBOARDING_ERROR_MESSAGE, {canBeMissing: true});
const [onboardingErrorMessage] = useOnyx(ONYXKEYS.ONBOARDING_ERROR_MESSAGE_TRANSLATION_KEY, {canBeMissing: true});

const getErrorSubtitle = () => {
if (onboardingErrorMessage) {
return onboardingErrorMessage;
return translate(onboardingErrorMessage);
}
// Fallback to generic error message
return translate('onboarding.mergeBlockScreen.subtitle', {workEmail});
Expand All @@ -48,7 +48,7 @@ function OnboardingMergingAccountBlockedView({workEmail, isVsb}: OnboardingMergi
style={[styles.mb5]}
text={translate('common.buttonConfirm')}
onPress={() => {
setOnboardingErrorMessage('');
setOnboardingErrorMessage(null);
if (isVsb) {
Navigation.navigate(ROUTES.ONBOARDING_ACCOUNTING.getRoute());
return;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type {CommonActions, RouterConfigOptions, StackActionType, StackNavigationState} from '@react-navigation/native';
import {findFocusedRoute, StackRouter} from '@react-navigation/native';
import type {ParamListBase} from '@react-navigation/routers';
import type {LocalizedTranslate} from '@components/LocaleContextProvider';
import {isFullScreenName, isOnboardingFlowName} from '@libs/Navigation/helpers/isNavigatorName';
import isSideModalNavigator from '@libs/Navigation/helpers/isSideModalNavigator';
import * as Welcome from '@userActions/Welcome';
Expand Down Expand Up @@ -51,7 +50,7 @@ function isPreloadAction(action: RootStackNavigatorAction): action is PreloadAct
return action.type === CONST.NAVIGATION.ACTION_TYPE.PRELOAD;
}

function shouldPreventReset(state: StackNavigationState<ParamListBase>, action: CommonActions.Action | StackActionType, translate: LocalizedTranslate) {
function shouldPreventReset(state: StackNavigationState<ParamListBase>, action: CommonActions.Action | StackActionType) {
if (action.type !== CONST.NAVIGATION_ACTIONS.RESET || !action?.payload) {
return false;
}
Expand All @@ -60,7 +59,7 @@ function shouldPreventReset(state: StackNavigationState<ParamListBase>, action:

// We want to prevent the user from navigating back to a non-onboarding screen if they are currently on an onboarding screen
if (isOnboardingFlowName(currentFocusedRoute?.name) && !isOnboardingFlowName(targetFocusedRoute?.name)) {
Welcome.setOnboardingErrorMessage(translate('onboarding.purpose.errorBackButton'));
Welcome.setOnboardingErrorMessage('onboarding.purpose.errorBackButton');
return true;
}

Expand Down Expand Up @@ -113,7 +112,7 @@ function RootStackRouter(options: RootStackNavigatorRouterOptions) {
}

// Don't let the user navigate back to a non-onboarding screen if they are currently on an onboarding screen and it's not finished.
if (shouldPreventReset(state, action, options.translate)) {
if (shouldPreventReset(state, action)) {
syncBrowserHistory(state);
return state;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type {CommonActions, StackActionType, StackRouterOptions} from '@react-navigation/native';
import type {LocalizedTranslate} from '@components/LocaleContextProvider';
import type {WorkspaceScreenName} from '@libs/Navigation/types';
import type CONST from '@src/CONST';

Expand Down Expand Up @@ -49,7 +48,7 @@ type DismissModalActionType = RootStackNavigatorActionType & {
type: typeof CONST.NAVIGATION.ACTION_TYPE.DISMISS_MODAL;
};

type RootStackNavigatorRouterOptions = StackRouterOptions & {translate: LocalizedTranslate};
type RootStackNavigatorRouterOptions = StackRouterOptions;

type RootStackNavigatorAction = CommonActions.Action | StackActionType | RootStackNavigatorActionType;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {StackRouter, useNavigationBuilder} from '@react-navigation/native';
import type {StackNavigationEventMap, StackNavigationOptions} from '@react-navigation/stack';
import {StackView} from '@react-navigation/stack';
import React, {useMemo} from 'react';
import useLocalize from '@hooks/useLocalize';
import {addCustomHistoryRouterExtension} from '@libs/Navigation/AppNavigator/customHistory';
import convertToWebNavigationOptions from '@libs/Navigation/PlatformStackNavigation/navigationOptions/convertToWebNavigationOptions';
import type {
Expand Down Expand Up @@ -38,8 +37,6 @@ function createPlatformStackNavigatorComponent<RouterOptions extends PlatformSta
persistentScreens,
...props
}: PlatformStackNavigatorProps<ParamListBase>) {
const {translate} = useLocalize();

const {
navigation,
state: originalState,
Expand All @@ -65,7 +62,6 @@ function createPlatformStackNavigatorComponent<RouterOptions extends PlatformSta
sidebarScreen,
parentRoute,
persistentScreens,
translate,
},
convertToWebNavigationOptions,
);
Expand Down
3 changes: 1 addition & 2 deletions src/libs/actions/Report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3555,8 +3555,7 @@ function openReportFromDeepLink(
const currentFocusedRoute = findFocusedRoute(state);

if (isOnboardingFlowName(currentFocusedRoute?.name)) {
// eslint-disable-next-line @typescript-eslint/no-deprecated
setOnboardingErrorMessage(Localize.translateLocal('onboarding.purpose.errorBackButton'));
setOnboardingErrorMessage('onboarding.purpose.errorBackButton');
return;
}

Expand Down
13 changes: 5 additions & 8 deletions src/libs/actions/Session/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ import * as ErrorUtils from '@libs/ErrorUtils';
import FraudProtection from '@libs/FraudProtection';
import Fullstory from '@libs/Fullstory';
import HttpUtils from '@libs/HttpUtils';
// eslint-disable-next-line @typescript-eslint/no-deprecated
import {translateLocal} from '@libs/Localize';
Comment thread
shubham1206agra marked this conversation as resolved.
Resolved
import Log from '@libs/Log';
import Navigation from '@libs/Navigation/Navigation';
import navigationRef from '@libs/Navigation/navigationRef';
Expand Down Expand Up @@ -1348,8 +1346,8 @@ function MergeIntoAccountAndLogin(workEmail: string | undefined, validateCode: s
const optimisticData: OnyxUpdate[] = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.ONBOARDING_ERROR_MESSAGE,
value: '',
key: ONYXKEYS.ONBOARDING_ERROR_MESSAGE_TRANSLATION_KEY,
value: null,
},
{
onyxMethod: Onyx.METHOD.MERGE,
Expand All @@ -1364,8 +1362,8 @@ function MergeIntoAccountAndLogin(workEmail: string | undefined, validateCode: s
const successData: OnyxUpdate[] = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: ONYXKEYS.ONBOARDING_ERROR_MESSAGE,
value: '',
key: ONYXKEYS.ONBOARDING_ERROR_MESSAGE_TRANSLATION_KEY,
value: null,
},
{
onyxMethod: Onyx.METHOD.MERGE,
Expand Down Expand Up @@ -1408,8 +1406,7 @@ function MergeIntoAccountAndLogin(workEmail: string | undefined, validateCode: s
if (response?.jsonCode === CONST.JSON_CODE.EXP_ERROR) {
// If the error other than invalid code, we show a blocking screen
if (response?.message === CONST.MERGE_ACCOUNT_INVALID_CODE_ERROR || response?.title === CONST.MERGE_ACCOUNT_INVALID_CODE_ERROR) {
// eslint-disable-next-line @typescript-eslint/no-deprecated
Onyx.merge(ONYXKEYS.ONBOARDING_ERROR_MESSAGE, translateLocal('contacts.genericFailureMessages.validateSecondaryLogin'));
Onyx.merge(ONYXKEYS.ONBOARDING_ERROR_MESSAGE_TRANSLATION_KEY, 'contacts.genericFailureMessages.validateSecondaryLogin');
} else {
Onyx.merge(ONYXKEYS.NVP_ONBOARDING, {isMergingAccountBlocked: true});
}
Expand Down
5 changes: 3 additions & 2 deletions src/libs/actions/Welcome/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import Log from '@libs/Log';
import Navigation from '@libs/Navigation/Navigation';
import CONFIG from '@src/CONFIG';
import type {OnboardingAccounting} from '@src/CONST';
import type {TranslationPaths} from '@src/languages/types';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import type {Account, OnboardingPurpose} from '@src/types/onyx';
Expand Down Expand Up @@ -105,8 +106,8 @@ function setOnboardingUserReportedIntegration(value: OnboardingAccounting | null
Onyx.set(ONYXKEYS.ONBOARDING_USER_REPORTED_INTEGRATION, value);
}

function setOnboardingErrorMessage(value: string) {
Onyx.set(ONYXKEYS.ONBOARDING_ERROR_MESSAGE, value ?? null);
function setOnboardingErrorMessage(value: TranslationPaths | null) {
Onyx.set(ONYXKEYS.ONBOARDING_ERROR_MESSAGE_TRANSLATION_KEY, value);
}

function setOnboardingAdminsChatReportID(adminsChatReportID?: string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function BaseOnboardingPersonalDetails({currentUserPersonalDetails, shouldUseNat
const isSmb = onboardingValues?.signupQualifier === CONST.ONBOARDING_SIGNUP_QUALIFIERS.SMB;

useEffect(() => {
setOnboardingErrorMessage('');
setOnboardingErrorMessage(null);
}, []);

const completeOnboarding = useCallback(
Expand Down
10 changes: 5 additions & 5 deletions src/pages/OnboardingPurpose/BaseOnboardingPurpose.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function BaseOnboardingPurpose({shouldUseNativeStyles, shouldEnableMaxHeight, ro
const isPrivateDomainAndHasAccessiblePolicies = !account?.isFromPublicDomain && !!account?.hasAccessibleDomainPolicies;

const theme = useTheme();
const [onboardingErrorMessage, onboardingErrorMessageResult] = useOnyx(ONYXKEYS.ONBOARDING_ERROR_MESSAGE, {canBeMissing: true});
const [onboardingErrorMessage, onboardingErrorMessageResult] = useOnyx(ONYXKEYS.ONBOARDING_ERROR_MESSAGE_TRANSLATION_KEY, {canBeMissing: true});
const [onboardingPolicyID] = useOnyx(ONYXKEYS.ONBOARDING_POLICY_ID, {canBeMissing: true});
const [onboardingAdminsChatReportID] = useOnyx(ONYXKEYS.ONBOARDING_ADMINS_CHAT_REPORT_ID, {canBeMissing: true});
const [personalDetailsForm] = useOnyx(ONYXKEYS.FORMS.ONBOARDING_PERSONAL_DETAILS_FORM, {canBeMissing: true});
Expand All @@ -82,7 +82,7 @@ function BaseOnboardingPurpose({shouldUseNativeStyles, shouldEnableMaxHeight, ro
numberOfLinesTitle: 0,
onPress: () => {
setOnboardingPurposeSelected(choice);
setOnboardingErrorMessage('');
setOnboardingErrorMessage(null);
if (choice === CONST.ONBOARDING_CHOICES.MANAGE_TEAM) {
Navigation.navigate(ROUTES.ONBOARDING_EMPLOYEES.getRoute(route.params?.backTo));
return;
Expand Down Expand Up @@ -113,8 +113,8 @@ function BaseOnboardingPurpose({shouldUseNativeStyles, shouldEnableMaxHeight, ro
const isFocused = useIsFocused();

const handleOuterClick = useCallback(() => {
setOnboardingErrorMessage(translate('onboarding.errorSelection'));
}, [translate]);
setOnboardingErrorMessage('onboarding.errorSelection');
}, []);

const onboardingLocalRef = useRef<TOnboardingRef>(null);
useImperativeHandle(isFocused ? OnboardingRefManager.ref : onboardingLocalRef, () => ({handleOuterClick}), [handleOuterClick]);
Expand Down Expand Up @@ -148,7 +148,7 @@ function BaseOnboardingPurpose({shouldUseNativeStyles, shouldEnableMaxHeight, ro
</View>
</ScrollView>
<View style={[styles.w100, styles.mb5, styles.mh0, paddingHorizontal]}>
<FormHelpMessage message={onboardingErrorMessage} />
<FormHelpMessage message={onboardingErrorMessage ? translate(onboardingErrorMessage) : undefined} />
</View>
</ScreenWrapper>
);
Expand Down
12 changes: 6 additions & 6 deletions src/pages/OnboardingWorkEmail/BaseOnboardingWorkEmail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function BaseOnboardingWorkEmail({shouldUseNativeStyles}: BaseOnboardingWorkEmai
const [onboardingValues] = useOnyx(ONYXKEYS.NVP_ONBOARDING, {canBeMissing: true});
const [formValue] = useOnyx(ONYXKEYS.FORMS.ONBOARDING_WORK_EMAIL_FORM, {canBeMissing: true});
const workEmail = formValue?.[INPUT_IDS.ONBOARDING_WORK_EMAIL];
const [onboardingErrorMessage] = useOnyx(ONYXKEYS.ONBOARDING_ERROR_MESSAGE, {canBeMissing: true});
const [onboardingErrorMessage] = useOnyx(ONYXKEYS.ONBOARDING_ERROR_MESSAGE_TRANSLATION_KEY, {canBeMissing: true});
const isVsb = onboardingValues && 'signupQualifier' in onboardingValues && onboardingValues.signupQualifier === CONST.ONBOARDING_SIGNUP_QUALIFIERS.VSB;
const isSmb = onboardingValues?.signupQualifier === CONST.ONBOARDING_SIGNUP_QUALIFIERS.SMB;
const {onboardingIsMediumOrLargerScreenWidth} = useResponsiveLayout();
Expand All @@ -60,14 +60,14 @@ function BaseOnboardingWorkEmail({shouldUseNativeStyles}: BaseOnboardingWorkEmai
const isFocused = useIsFocused();

useEffect(() => {
setOnboardingErrorMessage('');
setOnboardingErrorMessage(null);
}, []);

useEffect(() => {
if (onboardingValues?.shouldValidate === undefined && onboardingValues?.isMergeAccountStepCompleted === undefined) {
return;
}
setOnboardingErrorMessage('');
setOnboardingErrorMessage(null);

if (onboardingValues?.shouldValidate) {
Navigation.navigate(ROUTES.ONBOARDING_WORK_EMAIL_VALIDATION.getRoute());
Expand Down Expand Up @@ -170,16 +170,16 @@ function BaseOnboardingWorkEmail({shouldUseNativeStyles}: BaseOnboardingWorkEmai
<OfflineWithFeedback
shouldDisplayErrorAbove
style={styles.mb3}
errors={onboardingErrorMessage ? {addWorkEmailError: onboardingErrorMessage} : undefined}
errors={onboardingErrorMessage ? {addWorkEmailError: translate(onboardingErrorMessage)} : undefined}
errorRowStyles={[styles.mt2, styles.textWrap]}
onClose={() => setOnboardingErrorMessage('')}
onClose={() => setOnboardingErrorMessage(null)}
>
<Button
large
text={translate('common.skip')}
testID="onboardingPrivateEmailSkipButton"
onPress={() => {
setOnboardingErrorMessage('');
setOnboardingErrorMessage(null);

setOnboardingMergeAccountStepValue(true, true);
}}
Expand Down
5 changes: 1 addition & 4 deletions src/pages/OnboardingWorkEmail/index.native.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import {useFocusEffect} from '@react-navigation/native';
import React, {useCallback} from 'react';
import {BackHandler} from 'react-native';
// eslint-disable-next-line @typescript-eslint/no-deprecated
import {translateLocal} from '@libs/Localize';
import {setOnboardingErrorMessage} from '@userActions/Welcome';
import BaseOnboardingWorkEmail from './BaseOnboardingWorkEmail';
import type {OnboardingWorkEmailProps} from './types';
Expand All @@ -13,8 +11,7 @@ function OnboardingWorkEmail(props: OnboardingWorkEmailProps) {
useCallback(() => {
// Return true to indicate that the back button press is handled here
const backAction = () => {
// eslint-disable-next-line @typescript-eslint/no-deprecated
setOnboardingErrorMessage(translateLocal('onboarding.purpose.errorBackButton'));
setOnboardingErrorMessage('onboarding.purpose.errorBackButton');
Comment thread
shubham1206agra marked this conversation as resolved.
Resolved
return true;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ function BaseOnboardingWorkEmailValidation({shouldUseNativeStyles}: BaseOnboardi
const [onboardingValues] = useOnyx(ONYXKEYS.NVP_ONBOARDING, {canBeMissing: true});
const isVsb = onboardingValues && 'signupQualifier' in onboardingValues && onboardingValues.signupQualifier === CONST.ONBOARDING_SIGNUP_QUALIFIERS.VSB;
const isSmb = onboardingValues?.signupQualifier === CONST.ONBOARDING_SIGNUP_QUALIFIERS.SMB;
const [onboardingErrorMessage] = useOnyx(ONYXKEYS.ONBOARDING_ERROR_MESSAGE, {canBeMissing: true});
const [onboardingErrorMessage] = useOnyx(ONYXKEYS.ONBOARDING_ERROR_MESSAGE_TRANSLATION_KEY, {canBeMissing: true});
const isValidateCodeFormSubmitting = AccountUtils.isValidateCodeFormSubmitting(account);
const isFocused = useIsFocused();

useEffect(() => {
if (onboardingValues?.isMergeAccountStepCompleted === undefined) {
return;
}
setOnboardingErrorMessage('');
setOnboardingErrorMessage(null);
if (onboardingValues?.shouldRedirectToClassicAfterMerge) {
openOldDotLink(CONST.OLDDOT_URLS.INBOX, true);
return;
Expand Down Expand Up @@ -76,7 +76,7 @@ function BaseOnboardingWorkEmailValidation({shouldUseNativeStyles}: BaseOnboardi

const validateAccountAndMerge = useCallback(
(validateCode: string) => {
setOnboardingErrorMessage('');
setOnboardingErrorMessage(null);
MergeIntoAccountAndLogin(workEmail, validateCode, session?.accountID);
},
[workEmail, session?.accountID],
Expand Down Expand Up @@ -110,15 +110,15 @@ function BaseOnboardingWorkEmailValidation({shouldUseNativeStyles}: BaseOnboardi
handleSubmitForm={validateAccountAndMerge}
sendValidateCode={sendValidateCode}
validateCodeActionErrorField="mergeIntoAccountAndLogIn"
clearError={() => setOnboardingErrorMessage('')}
clearError={() => setOnboardingErrorMessage(null)}
buttonStyles={[styles.flex2, styles.justifyContentEnd, styles.mb5]}
shouldShowSkipButton
handleSkipButtonPress={() => {
setOnboardingErrorMessage('');
setOnboardingErrorMessage(null);
setOnboardingMergeAccountStepValue(true, true);
}}
isLoading={isValidateCodeFormSubmitting}
validateError={onboardingErrorMessage ? {invalidCodeError: onboardingErrorMessage} : undefined}
validateError={onboardingErrorMessage ? {invalidCodeError: translate(onboardingErrorMessage)} : undefined}
/>
</View>
)}
Expand Down
Loading