Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Add Edit profile row in RHP profile #58050

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
5 changes: 4 additions & 1 deletion src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
1 change: 1 addition & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
1 change: 1 addition & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,7 @@ const translations = {
validate: 'Validar',
expenseReports: 'Informes de Gastos',
rateOutOfPolicy: 'Tasa fuera de póliza',
editYourProfile: 'Edita tu perfil',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@twilight2294 Please add the discussion here where you confirmed this Spanish translation.

},
supportalNoAccess: {
title: 'No tan rápido',
Expand Down
2 changes: 1 addition & 1 deletion src/libs/Navigation/linkingConfig/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1550,7 +1550,7 @@ const config: LinkingOptions<RootNavigatorParamList>['config'] = {
exact: true,
},
[SCREENS.SETTINGS.PROFILE.ROOT]: {
path: ROUTES.SETTINGS_PROFILE,
path: ROUTES.SETTINGS_PROFILE.route,
exact: true,
},
[SCREENS.SETTINGS.SECURITY]: {
Expand Down
1 change: 1 addition & 0 deletions src/libs/Navigation/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 8 additions & 0 deletions src/pages/ProfilePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,14 @@ function ProfilePage({route}: ProfilePageProps) {
) : null}
{shouldShowLocalTime && <AutoUpdateTime timezone={timezone} />}
</View>
{isCurrentUser && (
<MenuItem
shouldShowRightIcon
title={translate('common.editYourProfile')}
icon={Expensicons.Pencil}
onPress={() => Navigation.navigate(ROUTES.SETTINGS_PROFILE.getRoute(Navigation.getActiveRoute()))}
/>
)}
{shouldShowNotificationPreference && (
<MenuItemWithTopDescription
shouldShowRightIcon
Expand Down
2 changes: 1 addition & 1 deletion src/pages/settings/InitialSettingsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ function InitialSettingsPage({currentUserPersonalDetails}: InitialSettingsPagePr
icon: Expensicons.Profile,
screenName: SCREENS.SETTINGS.PROFILE.ROOT,
brickRoadIndicator: profileBrickRoadIndicator,
action: () => Navigation.navigate(ROUTES.SETTINGS_PROFILE),
action: () => Navigation.navigate(ROUTES.SETTINGS_PROFILE.getRoute()),
},
{
translationKey: 'common.wallet',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}
Expand Down
8 changes: 6 additions & 2 deletions src/pages/settings/Profile/ProfilePage.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -24,13 +25,16 @@ 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';
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() {
Expand All @@ -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<PlatformStackRouteProp<SettingsNavigatorParamList, typeof SCREENS.SETTINGS.PROFILE.ROOT>>();
const [isLoadingApp] = useOnyx(ONYXKEYS.IS_LOADING_APP);

const getPronouns = (): string => {
Expand Down Expand Up @@ -148,7 +152,7 @@ function ProfilePage() {
>
<HeaderWithBackButton
title={translate('common.profile')}
onBackButtonPress={() => Navigation.goBack()}
onBackButtonPress={() => Navigation.goBack(route.params?.backTo)}
shouldShowBackButton={shouldUseNarrowLayout}
shouldDisplaySearchRouter
icon={Illustrations.Profile}
Expand Down
2 changes: 1 addition & 1 deletion tests/navigation/NavigateTests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading