Skip to content

[Issue #1485] return last page of search if requested page is out of bounds #3796

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

Merged
merged 2 commits into from
Feb 12, 2025

Conversation

doug-s-nava
Copy link
Collaborator

@doug-s-nava doug-s-nava commented Feb 6, 2025

Summary

Fixes #1485

Time to review: 15 mins

Changes proposed

If the page of search results requested exceeds the total number of pages returned by the API, this updates the page query param to the last page of results, triggering a new search request.

Includes removal of some leftovers from the previous "maxPageError" implementation, and cleans up a couple other things too.

Worth noting that I tried solving this on the API side first, which you can see in 423d730. The issue with that is that there was no easy way to update the url to reflect the change, which seemed bad.

Context for reviewers

Test steps

  1. npm run dev on this branch
  2. visit http://localhost:3000/search?page=10000
  3. VERIFY: you are redirected to the last page of results

Additional information

Screenshots, GIF demos, code examples or output to help show the changes working as expected.

@doug-s-nava doug-s-nava changed the title [Issue #1485] retrun last page of search if requested page is out of bounds [Issue #1485] return last page of search if requested page is out of bounds Feb 6, 2025
useEffect(() => {
console.error(error);
}, [error]);

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

not sure how this came back, and the above change I think I also handled in a previous PR 🤷

@doug-s-nava doug-s-nava force-pushed the dschrashun/1485-max-page-redirect branch from 67a3a0a to 7b7957a Compare February 7, 2025 19:53
@doug-s-nava doug-s-nava marked this pull request as ready for review February 7, 2025 19:55
const t = await getTranslations("Search");

if (
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

where this is being done is more or less arbitrary since the same promise is being awaited in multiple components. That seems weird, which is one of the reasons I did the refactor in #3796

@doug-s-nava doug-s-nava force-pushed the dschrashun/1485-max-page-redirect branch from 7b7957a to f520216 Compare February 7, 2025 19:59
body: "<li>Check any terms you've entered for typos</li><li>Try different keywords</li><li>Make sure you've selected the right statuses</li><li>Try resetting filters or selecting fewer options</li>",
paginationError:
"You're trying to access opportunity results that are beyond the last page of data.",
noResultsTitle: "Your search did not return any results.",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

just updating the names here as they were confusing me when working with this component

acouch
acouch previously approved these changes Feb 11, 2025
Copy link
Collaborator

@acouch acouch left a comment

Choose a reason for hiding this comment

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

👍🏿

doug-s-nava and others added 2 commits February 11, 2025 12:25
…bounds

* updates page query param in url if requested page exceeds total number of pages
* removes remnants of previous "maxPageError"
Simplifies how the search page is structured:
* 1 promise, 1 resolution
* removes `fetch` components
* introduces search one results skeleton for suspense fallback
@doug-s-nava doug-s-nava force-pushed the dschrashun/1485-max-page-redirect branch from 79c4554 to d2519bc Compare February 11, 2025 17:25
Copy link
Collaborator

@acouch acouch left a comment

Choose a reason for hiding this comment

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

🚀

@doug-s-nava doug-s-nava merged commit 3ba84f2 into main Feb 12, 2025
8 checks passed
@doug-s-nava doug-s-nava deleted the dschrashun/1485-max-page-redirect branch February 12, 2025 20:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Redirect to the highest valid page of search results when page query param has value beyond the max page possible
2 participants