diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 7f3d1324b411..4b5659df3061 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -127,7 +127,10 @@ const ROUTES = { }, WORKSPACE_SWITCHER: 'workspace-switcher', 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 8016342f090b..4e7271e4c8a7 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -524,6 +524,7 @@ const translations = { validate: 'Validate', expenseReports: 'Expense Reports', rateOutOfPolicy: 'Rate out of policy', + editYourProfile: 'Edit your profile', }, supportalNoAccess: { title: 'Not so fast', diff --git a/src/languages/es.ts b/src/languages/es.ts index 0d82fb9fe399..7f578acc2bc2 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -515,6 +515,7 @@ const translations = { validate: 'Validar', expenseReports: 'Informes de Gastos', rateOutOfPolicy: 'Tasa fuera de póliza', + editYourProfile: 'Edita tu perfil', }, supportalNoAccess: { title: 'No tan rápido', diff --git a/src/libs/Navigation/linkingConfig/config.ts b/src/libs/Navigation/linkingConfig/config.ts index 90d14b50890a..03223e6ed7c0 100644 --- a/src/libs/Navigation/linkingConfig/config.ts +++ b/src/libs/Navigation/linkingConfig/config.ts @@ -1550,7 +1550,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 fc73a6db8626..13b5a2c1eea8 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -300,6 +300,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/pages/ProfilePage.tsx b/src/pages/ProfilePage.tsx index 5e2bad5cab1f..dd105fc46cb9 100755 --- a/src/pages/ProfilePage.tsx +++ b/src/pages/ProfilePage.tsx @@ -278,6 +278,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 62e75f6895cd..cb2b5f8f60ec 100644 --- a/src/pages/settings/Profile/Contacts/NewContactMethodPage.tsx +++ b/src/pages/settings/Profile/Contacts/NewContactMethodPage.tsx @@ -44,7 +44,7 @@ function NewContactMethodPage({route}: NewContactMethodPageProps) { const loginData = loginList?.[pendingContactAction?.contactMethod ?? contactMethod]; const validateLoginError = ErrorUtils.getLatestErrorField(loginData, 'addedLogin'); - const navigateBackTo = route?.params?.backTo ?? ROUTES.SETTINGS_PROFILE; + const navigateBackTo = route?.params?.backTo ?? ROUTES.SETTINGS_PROFILE.getRoute(); const hasFailedToSendVerificationCode = !!pendingContactAction?.errorFields?.actionVerified; @@ -103,7 +103,7 @@ function NewContactMethodPage({route}: 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 06093b88e306..0308c6c4c39d 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 51aa2e2efeb6..b9e25b03c846 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