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

Add condition to display back button #356

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

prachigarg19
Copy link
Collaborator

@prachigarg19 prachigarg19 commented Dec 22, 2022

Changes in this pull request:

  • We need to implement a logic change on the mobile view such that if we do not pass a callback URL and reaches the page from an external then we will no longer provide the button as we cannot take the users back to the source they came from.
  • If we are reaching the page from within the webapp, we will display the back button regardless of whether callback URL is provided or not.
  • If callbackURL is provided we will display the back button regardless of whether the user came from external link or not.

=====================

  • Show Cancel button instead of back button (in top panel)
  • Show Cancel button only if there is a callback or if user visits from donate.plant-for-the-planet.org

@

@vercel
Copy link

vercel bot commented Dec 22, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
donate-with-planet ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 16, 2023 1:32pm

Copy link
Collaborator

@norbertschuler norbertschuler left a comment

Choose a reason for hiding this comment

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

This implementation does not really work for me, as windows.origin is always the same value and when I hit the back button e.g. on the contact form page, I get redirected to the callback_url.

Bildschirm­foto 2022-12-26 um 13 44 58

@@ -103,6 +103,7 @@ function DonationInfo() {
} = React.useContext(QueryParamContext);

const [isMobile, setIsMobile] = React.useState(false);
const [showBackButton, setShowBackButton] = React.useState(null);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe use boolean state as for isMobile above?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is because I if the value if set to false at any point of time, it means that the user came from an external link and so I don't want to display the back button. Setting false initially would prevent me from updating the value and setting true would display the back button. Hence, I've set null as the initial value.

storage.setItem("currentPath", window.origin);
}

useEffect(storePathValues, [router]);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not put the code of the function directly into the useEffect(() => {...}, [router]); instead of defining a new function storePathValues?

if (!storage) return;
// Set the previous path as the value of the current path.
const prevPath = storage.getItem("currentPath");
storage.setItem("prevPath", prevPath);
Copy link
Collaborator

Choose a reason for hiding this comment

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

This raises a warning about a type error for string | null.

Comment on lines +169 to +171
const isShow = storage.getItem("showBackButton") === "true";

setShowBackButton(isShow);
Copy link
Collaborator

Choose a reason for hiding this comment

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

This could be just one line of code.

@sunilsabatp
Copy link
Contributor

sunilsabatp commented Jan 3, 2023

when I tried to visit from webapp to donation using donate button in the webapp , The back button was not visible for me
webapp-to-donation
image

sunilsabatp
sunilsabatp previously approved these changes Jan 16, 2023
@sunilsabatp sunilsabatp dismissed their stale review January 16, 2023 06:21

need to review again

@mariahosfeld
Copy link
Contributor

Checked this, when I have originally no callback_url and click on the back arrow from the contact details, then I also see the back button, that should be not visible in this case.

@norbertschuler norbertschuler requested review from norbertschuler and removed request for norbertschuler April 30, 2023 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants