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: Redirect to 404 page if reserve details asset is invalid #1551

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Jdecristi
Copy link
Contributor

@Jdecristi Jdecristi commented Apr 13, 2023

General Changes

Developer Notes

Implementing getStaticProps will run at build time rather than query. To handle redirection based on route parameters, redirect on static. This can be achieved by checking for the existence of a reserve based on the underlyingAsset during page mount. If the reserve exists, load the page. Otherwise, redirect to the 404 page.


Author Checklist

Please ensure you, the author, have gone through this checklist to ensure there is an efficient workflow for the reviewers.

  • The base branch is set to main
  • The title is using Conventional Commit formatting
  • The Github issue has been linked to the PR in the Development section
  • The General Changes section has been filled out
  • Developer Notes have been added (optional)

If the PR is ready for review:

  • The PR is in Open state and not in Draft mode
  • The Ready for Dev Review label has been added

Reviewer Checklist

Please ensure you, as the reviewer(s), have gone through this checklist to ensure that the code changes are ready to ship safely and to help mitigate any downstream issues that may occur.

  • End-to-end tests are passing without any errors
  • Code style generally follows existing patterns
  • Code changes do not significantly increase the application bundle size
  • If there are new 3rd-party packages, they do not introduce potential security threats
  • If there are new environment variables being added, they have been added to the .env.example file as well as the pertinant .github/actions/* files
  • There are no CI changes, or they have been approved by the DevOps and Engineering team(s)
  • Code changes have been quality checked in the ephemeral URL
  • QA verification has been completed
  • There are two or more approvals from the core team
  • Squash and merge has been checked

@height
Copy link

height bot commented Apr 13, 2023

Link Height tasks by mentioning a task ID in the pull request title or commit messages, or description and comments with the keyword link (e.g. "Link T-123").

💡Tip: You can also use "Close T-X" to automatically close a task when the pull request is merged.

@defispartan defispartan added the Ready for Dev Review Read for frontend engineer reviews label Apr 18, 2023
@Jdecristi Jdecristi force-pushed the Fix-redirect-to-404-page-if-reserve-details-asset-is-invalid branch from 5a22767 to c3f786a Compare May 6, 2023 19:51
@Jdecristi
Copy link
Contributor Author

@defispartan @grothem I fixed the issues you mentioned

  const { reserves, loading } = useAppDataContext();

  ...

  useEffect(() => {
    if (!mode) setMode('overview');

    if (loading && reserves.length) {
      const reserveFound = reserves.find((reserve) => reserve.underlyingAsset === underlyingAsset);

      if (reserveFound) setReserve(reserveFound);
      else router.replace('/404');
    }

    // eslint-disable-next-line react-hooks/exhaustive-deps
  }, [lg, loading, reserves.length]);

@defispartan
Copy link
Collaborator

The re-direct to 404 is working, but when I click an asset from the markets or dashboard page it just takes me to a blank reserve page and I have to refresh for the page to load. This happens in development and production mode

@Jdecristi Jdecristi force-pushed the Fix-redirect-to-404-page-if-reserve-details-asset-is-invalid branch from c3f786a to ea84935 Compare May 17, 2023 05:06
@Jdecristi
Copy link
Contributor Author

Jdecristi commented May 17, 2023

@defispartan @grothem I figured out the issue, it was when I changed the if (router.isReady && reserves.length) to if (loading && reserves.length). Loading the page does check the reserves, but re-loading the page doesn't. I had to change it back to fix the issue.

@defispartan defispartan self-requested a review May 24, 2023 19:41
@foodaka
Copy link
Collaborator

foodaka commented May 25, 2023

@Jdecristi if I visit the reserve page such as DAI. And then I change the query params to something like https://app.aave.com/reserve-overview/?underlyingAsset=213&marketName=proto_mainnet_v3 I still do not get a 404 page. Can you try and fix? Thank you for your contributions!!

@Jdecristi
Copy link
Contributor Author

@foodaka I'm not able to reproduce your error. Would you mind going into more detail or showing through a screen recording?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority:medium Ready for Dev Review Read for frontend engineer reviews
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Redirect to 404 page if reserve details asset is invalid
4 participants