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

MPDX-8492 - Enhance loadSession to Redirect Placeholder _ to Default Account List #1225

Merged
merged 2 commits into from
Dec 13, 2024

Conversation

dr-bizz
Copy link
Contributor

@dr-bizz dr-bizz commented Dec 12, 2024

Description

The loadSession function has been updated to automatically redirect users to their default accountListID when the placeholder _ is detected.

This enhancement enables the sharing of links with users without requiring knowledge of their specific accountListID.

For example, a link like https://mpdx.org/accountLists/_/reports/salaryCurrency will seamlessly redirect the user to the correct account list context.

Test:
https://salary-page-error.d3dytjb8adxkk5.amplifyapp.com/accountLists/_/contacts?filters=%257B%2522status%2522%253A%255B%2522NEVER_CONTACTED%2522%255D%257D

https://salary-page-error.d3dytjb8adxkk5.amplifyapp.com/accountLists/_/settings/preferences

Checklist:

  • I have given my PR a title with the format "MPDX-(JIRA#) (summary sentence max 80 chars)"
  • I have applied the appropriate labels. (Add the label "On Staging" to get the branch automatically merged into staging.)
  • I have requested a review from another person on the project

@dr-bizz dr-bizz added the Preview Environment Add this label to create an Amplify Preview label Dec 12, 2024
@dr-bizz dr-bizz requested a review from canac December 12, 2024 19:04
Copy link
Contributor

Preview branch generated at https://salary-page-error.d3dytjb8adxkk5.amplifyapp.com

Copy link
Contributor

github-actions bot commented Dec 12, 2024

Bundle sizes [mpdx-react]

Compared against 8cd426f

No significant changes found

@dr-bizz dr-bizz requested a review from caleballdrin December 12, 2024 19:37
@caleballdrin
Copy link
Contributor

I think we did something similar in this PR.
https://github.com/CruGlobal/mpdx-react/pull/1084/files

Copy link
Contributor

@canac canac left a comment

Choose a reason for hiding this comment

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

Do we need to add this logic to the anywhere enforceAdmin is used and to pages/accountLists/[accountListId].page.tsx?

pages/api/utils/pagePropsHelpers.ts Outdated Show resolved Hide resolved
pages/api/utils/pagePropsHelpers.ts Outdated Show resolved Hide resolved
pages/api/utils/pagePropsHelpers.ts Outdated Show resolved Hide resolved
pages/api/utils/pagePropsHelpers.ts Outdated Show resolved Hide resolved
pages/api/utils/pagePropsHelpers.test.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@canac canac left a comment

Choose a reason for hiding this comment

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

I tested on the salary report page and it works.

@dr-bizz
Copy link
Contributor Author

dr-bizz commented Dec 13, 2024

https://github.com/CruGlobal/mpdx-react/pull/1084/files

We did, but to redirect, you have to wait for a failed request before you are redirected to the correct one. This caused many people issues. Find out more in the slack message I link in the description.

In my code, we catch it on the server and then redirect it, making it a quicker and smoother experience for the user. The code in the ttps://github.com//pull/1084 will be an excellent backup, or if someone is trying to access the account list, they don't have access to it.

@dr-bizz
Copy link
Contributor Author

dr-bizz commented Dec 13, 2024

I will retest on the preview link and then merge

pages/accountLists/[accountListId].page.tsx Outdated Show resolved Hide resolved
pages/api/utils/pagePropsHelpers.ts Outdated Show resolved Hide resolved
pages/api/utils/pagePropsHelpers.ts Outdated Show resolved Hide resolved
pages/api/utils/pagePropsHelpers.ts Outdated Show resolved Hide resolved
export const enforceAdmin: GetServerSideProps<PagePropsWithSession> = async (
export const enforceAdmin = async (
Copy link
Contributor

@canac canac Dec 13, 2024

Choose a reason for hiding this comment

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

Sorry if I wasn't clear the types on enforceAdmin and ensureSessionAnddAccountList were fine and probably better how they were because they include the session on the props. I was just wanting to add some kind of return type to handleUnderscoreAccountListRedirect.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because I changed handleUnderscoreAccountListRedirect I also had to update the other functions as they had TS errors.

…ountList Id if they have an underscore as their accountList ID
@dr-bizz dr-bizz merged commit 89c49ed into main Dec 13, 2024
17 checks passed
@dr-bizz dr-bizz deleted the salary-page-error branch December 13, 2024 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Preview Environment Add this label to create an Amplify Preview
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants