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

fix: add proper fallback route for private notes pages #28273

Merged
merged 6 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 2 additions & 1 deletion src/pages/PrivateNotes/PrivateNotesEditPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ function PrivateNotesEditPage({route, personalDetailsList, session, report}) {
Keyboard.dismiss();

// Take user back to the PrivateNotesView page
Navigation.goBack(ROUTES.HOME);
Navigation.goBack(ROUTES.PRIVATE_NOTES_VIEW.getRoute(report.reportID, route.params.accountID));
BhuvaneshPatil marked this conversation as resolved.
Show resolved Hide resolved
};

return (
Expand All @@ -106,6 +106,7 @@ function PrivateNotesEditPage({route, personalDetailsList, session, report}) {
<HeaderWithBackButton
title={translate('privateNotes.title')}
subtitle={translate('privateNotes.myNote')}
onBackButtonPress={() => Navigation.goBack(ROUTES.PRIVATE_NOTES_VIEW.getRoute(lodashGet(report, 'reportID', ''), lodashGet(route, 'params.accountID', '')))}
BhuvaneshPatil marked this conversation as resolved.
Show resolved Hide resolved
shouldShowBackButton
onCloseButtonPress={() => Navigation.dismissModal()}
/>
Expand Down
8 changes: 8 additions & 0 deletions src/pages/PrivateNotes/PrivateNotesListPage.js
BhuvaneshPatil marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import FullScreenLoadingIndicator from '../../components/FullscreenLoadingIndica
import * as Report from '../../libs/actions/Report';
import personalDetailsPropType from '../personalDetailsPropType';
import * as UserUtils from '../../libs/UserUtils';
import * as ReportUtils from '../../libs/ReportUtils';
import reportPropTypes from '../reportPropTypes';
import ScreenWrapper from '../../components/ScreenWrapper';
import withLocalize, {withLocalizePropTypes} from '../../components/withLocalize';
Expand Down Expand Up @@ -116,6 +117,12 @@ function PrivateNotesListPage({report, personalDetailsList, network, session}) {
.value();
}, [report, personalDetailsList, session, translate]);

const participantAccountIDs = lodashGet(report, 'participantAccountIDs', []);
const fallbackPath =
participantAccountIDs.length === 1 && !(ReportUtils.isPolicyExpenseChat(ReportUtils.getRootParentReport(report)) || ReportUtils.isChatRoom(report))
? ROUTES.PROFILE.getRoute(participantAccountIDs[0])
: ROUTES.REPORT_WITH_ID_DETAILS.getRoute(lodashGet(report, 'reportID', ''));

return (
<ScreenWrapper
includeSafeAreaPaddingBottom={false}
Expand All @@ -125,6 +132,7 @@ function PrivateNotesListPage({report, personalDetailsList, network, session}) {
<HeaderWithBackButton
title={translate('privateNotes.title')}
shouldShowBackButton
onBackButtonPress={() => Navigation.goBack(fallbackPath)}
onCloseButtonPress={() => Navigation.dismissModal()}
/>
{report.isLoadingPrivateNotes && _.isEmpty(lodashGet(report, 'privateNotes', {})) ? (
Expand Down
1 change: 1 addition & 0 deletions src/pages/PrivateNotes/PrivateNotesViewPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ function PrivateNotesViewPage({route, personalDetailsList, session, report}) {
>
<HeaderWithBackButton
title={translate('privateNotes.title')}
onBackButtonPress={() => Navigation.goBack(ROUTES.PRIVATE_NOTES_LIST.getRoute(lodashGet(report, 'reportID', '')))}
BhuvaneshPatil marked this conversation as resolved.
Show resolved Hide resolved
subtitle={isCurrentUserNote ? translate('privateNotes.myNote') : `${lodashGet(personalDetailsList, [route.params.accountID, 'login'], '')} note`}
shouldShowBackButton
onCloseButtonPress={() => Navigation.dismissModal()}
Expand Down
Loading