diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 92c9a3650b5a..6250546a602e 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -158,7 +158,10 @@ const ROUTES = { getRoute: (backTo?: string) => getUrlWithBackToParam(`troubleshoot/console`, backTo), }, SETTINGS: 'settings', - SETTINGS_PROFILE: 'settings/profile', + SETTINGS_PROFILE: { + route: 'settings/profile', + getRoute: (backTo?: string) => getUrlWithBackToParam('settings/profile', backTo), + }, SETTINGS_CHANGE_CURRENCY: 'settings/add-payment-card/change-currency', SETTINGS_SHARE_CODE: 'settings/shareCode', SETTINGS_DISPLAY_NAME: 'settings/profile/display-name', diff --git a/src/languages/en.ts b/src/languages/en.ts index 3aa623573778..8c094d6899fc 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -534,6 +534,7 @@ const translations = { help: 'Help', expenseReports: 'Expense Reports', rateOutOfPolicy: 'Rate out of policy', + editYourProfile: 'Edit your profile', comments: 'Comments', }, supportalNoAccess: { diff --git a/src/languages/es.ts b/src/languages/es.ts index 433ba5a3f63b..5e77a2c7a2c1 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -525,6 +525,7 @@ const translations = { help: 'Ayuda', expenseReports: 'Informes de Gastos', rateOutOfPolicy: 'Tasa fuera de póliza', + editYourProfile: 'Edita tu perfil', comments: 'Comentarios', }, supportalNoAccess: { diff --git a/src/libs/Navigation/AppNavigator/useRootNavigatorScreenOptions.ts b/src/libs/Navigation/AppNavigator/useRootNavigatorScreenOptions.ts index f01b5fad8db8..74db2ef11326 100644 --- a/src/libs/Navigation/AppNavigator/useRootNavigatorScreenOptions.ts +++ b/src/libs/Navigation/AppNavigator/useRootNavigatorScreenOptions.ts @@ -75,7 +75,7 @@ const useRootNavigatorScreenOptions = () => { splitNavigator: { ...commonScreenOptions, // We need to turn off animation for the full screen to avoid delay when closing screens. - animation: Animations.NONE, + animation: shouldUseNarrowLayout ? Animations.SLIDE_FROM_RIGHT : Animations.NONE, web: { cardStyleInterpolator: (props: StackCardInterpolationProps) => modalCardStyleInterpolator({props, isFullScreenModal: true}), cardStyle: StyleUtils.getNavigationModalCardStyle(), diff --git a/src/libs/Navigation/linkingConfig/config.ts b/src/libs/Navigation/linkingConfig/config.ts index 4c2ec248eb81..557f452ed514 100644 --- a/src/libs/Navigation/linkingConfig/config.ts +++ b/src/libs/Navigation/linkingConfig/config.ts @@ -1541,7 +1541,7 @@ const config: LinkingOptions['config'] = { exact: true, }, [SCREENS.SETTINGS.PROFILE.ROOT]: { - path: ROUTES.SETTINGS_PROFILE, + path: ROUTES.SETTINGS_PROFILE.route, exact: true, }, [SCREENS.SETTINGS.SECURITY]: { diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index 160a88797e25..f177391c9dcc 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -303,6 +303,7 @@ type SettingsNavigatorParamList = { tagName: string; backTo?: Routes; }; + [SCREENS.SETTINGS.PROFILE.ROOT]: {backTo?: Routes}; [SCREENS.SETTINGS.SUBSCRIPTION.ROOT]: {backTo?: Routes}; [SCREENS.SETTINGS.SUBSCRIPTION.SIZE]: { canChangeSize: 0 | 1; diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 2a2b36ceb3c7..39c8af5289c2 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -4874,7 +4874,7 @@ function navigateToDetailsPage(report: OnyxEntry, backTo?: string) { const participantAccountID = getParticipantsAccountIDsForDisplay(report); if (isSelfDMReport || isOneOnOneChatReport) { - Navigation.navigate(ROUTES.PROFILE.getRoute(participantAccountID.at(0), backTo)); + Navigation.navigate(ROUTES.PROFILE.getRoute(participantAccountID.at(0), isSelfDMReport ? Navigation.getActiveRoute() : backTo)); return; } diff --git a/src/pages/ProfilePage.tsx b/src/pages/ProfilePage.tsx index 21edcf9f5342..0de17711be74 100755 --- a/src/pages/ProfilePage.tsx +++ b/src/pages/ProfilePage.tsx @@ -261,6 +261,14 @@ function ProfilePage({route}: ProfilePageProps) { ) : null} {shouldShowLocalTime && } + {isCurrentUser && ( + Navigation.navigate(ROUTES.SETTINGS_PROFILE.getRoute(Navigation.getActiveRoute()))} + /> + )} {shouldShowNotificationPreference && ( Navigation.navigate(ROUTES.SETTINGS_PROFILE), + action: () => Navigation.navigate(ROUTES.SETTINGS_PROFILE.getRoute()), }, { translationKey: 'common.wallet', diff --git a/src/pages/settings/Profile/Contacts/NewContactMethodPage.tsx b/src/pages/settings/Profile/Contacts/NewContactMethodPage.tsx index 8d796c1bb503..e5d4e7d1c180 100644 --- a/src/pages/settings/Profile/Contacts/NewContactMethodPage.tsx +++ b/src/pages/settings/Profile/Contacts/NewContactMethodPage.tsx @@ -53,7 +53,7 @@ function NewContactMethodPage({route, navigation}: NewContactMethodPageProps) { const validateLoginError = getLatestErrorField(loginData, 'addedLogin'); const [isUserValidated] = useOnyx(ONYXKEYS.USER, {selector: (user) => !!user?.validated}); - const navigateBackTo = route?.params?.backTo ?? ROUTES.SETTINGS_PROFILE; + const navigateBackTo = route?.params?.backTo ?? ROUTES.SETTINGS_PROFILE.getRoute(); const hasFailedToSendVerificationCode = !!pendingContactAction?.errorFields?.actionVerified; @@ -121,7 +121,7 @@ function NewContactMethodPage({route, navigation}: NewContactMethodPageProps) { ); const onBackButtonPress = useCallback(() => { - if (navigateBackTo === ROUTES.SETTINGS_PROFILE) { + if (navigateBackTo === ROUTES.SETTINGS_PROFILE.getRoute()) { Navigation.goBack(ROUTES.SETTINGS_CONTACT_METHODS.route); return; } diff --git a/src/pages/settings/Profile/ProfilePage.tsx b/src/pages/settings/Profile/ProfilePage.tsx index b305c483a586..9e6b913bf08c 100755 --- a/src/pages/settings/Profile/ProfilePage.tsx +++ b/src/pages/settings/Profile/ProfilePage.tsx @@ -1,3 +1,4 @@ +import {useRoute} from '@react-navigation/native'; import React, {useState} from 'react'; import {View} from 'react-native'; import {useOnyx} from 'react-native-onyx'; @@ -24,6 +25,8 @@ import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; import {formatPhoneNumber} from '@libs/LocalePhoneNumber'; import Navigation from '@libs/Navigation/Navigation'; +import type {PlatformStackRouteProp} from '@libs/Navigation/PlatformStackNavigation/types'; +import type {SettingsNavigatorParamList} from '@libs/Navigation/types'; import {getFormattedAddress} from '@libs/PersonalDetailsUtils'; import {getFullSizeAvatar, getLoginListBrickRoadIndicator, isDefaultAvatar} from '@libs/UserUtils'; import {clearAvatarErrors, deleteAvatar, updateAvatar} from '@userActions/PersonalDetails'; @@ -31,6 +34,7 @@ import CONST from '@src/CONST'; import type {TranslationPaths} from '@src/languages/types'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; +import type SCREENS from '@src/SCREENS'; import {isEmptyObject} from '@src/types/utils/EmptyObject'; function ProfilePage() { @@ -44,7 +48,7 @@ function ProfilePage() { const [loginList] = useOnyx(ONYXKEYS.LOGIN_LIST); const [privatePersonalDetails] = useOnyx(ONYXKEYS.PRIVATE_PERSONAL_DETAILS); const currentUserPersonalDetails = useCurrentUserPersonalDetails(); - + const route = useRoute>(); const [isLoadingApp] = useOnyx(ONYXKEYS.IS_LOADING_APP); const getPronouns = (): string => { @@ -148,7 +152,7 @@ function ProfilePage() { > Navigation.goBack()} + onBackButtonPress={() => Navigation.goBack(route.params?.backTo)} shouldShowBackButton={shouldUseNarrowLayout} shouldDisplaySearchRouter icon={Illustrations.Profile} diff --git a/tests/navigation/NavigateTests.tsx b/tests/navigation/NavigateTests.tsx index ec10a45e08ff..c478871469df 100644 --- a/tests/navigation/NavigateTests.tsx +++ b/tests/navigation/NavigateTests.tsx @@ -55,7 +55,7 @@ describe('Navigate', () => { // When navigate to the page from the same split navigator act(() => { - Navigation.navigate(ROUTES.SETTINGS_PROFILE); + Navigation.navigate(ROUTES.SETTINGS_PROFILE.getRoute()); }); // Then push a new page to the current split navigator