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 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
3 changes: 2 additions & 1 deletion src/pages/PrivateNotes/PrivateNotesEditPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,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 @@ -114,6 +114,7 @@ function PrivateNotesEditPage({route, personalDetailsList, session, report}) {
<HeaderWithBackButton
title={translate('privateNotes.title')}
subtitle={translate('privateNotes.myNote')}
onBackButtonPress={() => Navigation.goBack(ROUTES.PRIVATE_NOTES_VIEW.getRoute(report.repotID, route.params.accountID))}
Copy link
Contributor

Choose a reason for hiding this comment

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

repotID lol 😅
we're fixing it here

shouldShowBackButton
onCloseButtonPress={() => Navigation.dismissModal()}
/>
Expand Down
11 changes: 11 additions & 0 deletions src/pages/PrivateNotes/PrivateNotesViewPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,16 @@ function PrivateNotesViewPage({route, personalDetailsList, session, report}) {
const isCurrentUserNote = Number(session.accountID) === Number(route.params.accountID);
const privateNote = lodashGet(report, ['privateNotes', route.params.accountID, 'note'], '');

const getFallbackRoute = () => {
const privateNotes = lodashGet(report, 'privateNotes', {});

if (_.keys(privateNotes).length === 1) {
return ROUTES.HOME;
}

Copy link
Contributor

Choose a reason for hiding this comment

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

NAB: It would have been nice to include some comments for this method.

return ROUTES.PRIVATE_NOTES_LIST.getRoute(report.reportID);
};

return (
<ScreenWrapper
includeSafeAreaPaddingBottom={false}
Expand All @@ -67,6 +77,7 @@ function PrivateNotesViewPage({route, personalDetailsList, session, report}) {
>
<HeaderWithBackButton
title={translate('privateNotes.title')}
onBackButtonPress={() => Navigation.goBack(getFallbackRoute())}
subtitle={isCurrentUserNote ? translate('privateNotes.myNote') : `${lodashGet(personalDetailsList, [route.params.accountID, 'login'], '')} note`}
shouldShowBackButton
onCloseButtonPress={() => Navigation.dismissModal()}
Expand Down
Loading