Skip to content

Feat: Sign up prompt on hub pages - #1125

Open
JoshKornfeld wants to merge 12 commits into
masterfrom
feat/sign-up-pop-up-prompt
Open

JoshKornfeld wants to merge 12 commits into
masterfrom
feat/sign-up-pop-up-prompt

Conversation

@JoshKornfeld

@JoshKornfeld JoshKornfeld commented Nov 9, 2022

Copy link
Copy Markdown
Contributor

Description

Closes #1120

Introduces a new component SignUpPromptDialog according to the design in the issue. This prompt will show up to users who are not logged in and are viewing a location hub (Climate Hub Erlangen) and under the condition that they did not a set a cookie "display_signup_prompt".

The user can close the dialog which will prevent it from being shown for 30 days or until cookies are cleared. The user can also click join to sign up or enter their email and then click join. Clicking join will redirect the user to the sign up page. The input of the textfield will be displayed in the email field of sign up.

Missing features / TODO:

  • need to fix some CSS stuff, e.g. image formatting and mobile margin not working

Test plan

  • Be signed out
  • Go to a location hub
  • Pop up should appear
  • You can either enter an email into the textfield and click "Join" or close the dialog and it will not show up again for 30 days
  • If join is clicked, the user will be redirected to the sign up page and whatever is inputted into the textfield will be displayed as the email for signing up.

Before landing

  1. PR has meaningful title
  2. yarn lint passes (frontend)
  3. yarn format passes (frontend)
  4. make format passes (backend)

@JoshKornfeld
JoshKornfeld marked this pull request as ready for review November 10, 2022 12:20

@piperchester piperchester left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Awesome work so far!

Comment on lines +334 to +341
buttonText={texts.join + "!"}
image={"/images/sign_up_prompt_image.jpg"}
infoTextOne={texts.receive_regular_updates_about_projects_topics}
infoTextTwo={texts.send_messages_comments_and_more}
onClose={handleCloseSignUpPrompt}
open={showSignUpPrompt}
subTitle={texts.sign_up_today_and_help_make_climate_neutral}
title={texts.change_the_world}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: do you mind sorting these props? If you use VS Code this should be really easy with cmd+shift+p and type 'alphabetize'.

Comment thread frontend/pages/signup.js
export default function Signup() {
const { ReactGA } = useContext(UserContext);
const router = useRouter();
const email = router.query.email;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Will .query always be defined? Want to minimize the chance for ReferenceError.

Comment on lines +46 to +58
// wasn't really sure how to handle the first time a user comes the page as the cookie being looked up is undefined at first
if (typeof cookieContent === "undefined") {
const expiryDate = new Date();
const month = (expiryDate.getMonth() + 1) % 12;
/*
new Date = gets today's date. Then, the next line is to get next month.
We use modulo for the edge case where it is currently December and we want it to return 1, instead of 13.
We then set variable, expiryDate (now one month ahead), to our cookie. */
expiryDate.setMonth(month);
const cookieProps = getCookieProps(expiryDate);
cookies.set("display_signup_prompt", "true", cookieProps);
return true;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do you mind writing a unit test for this behavior?


export function getDisplaySignUpPromptFromCookie(cookieContent) {
const cookies = new Cookies();
// wasn't really sure how to handle the first time a user comes the page as the cookie being looked up is undefined at first

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

That's fair! We could probably remove this comment, or keep its context in the PR description as opposed to the code.

Suggested change
// wasn't really sure how to handle the first time a user comes the page as the cookie being looked up is undefined at first

de: "Alle Orte",
},
sign_up_today_and_help_make_climate_neutral: {
en: `Sign up today and help to make ${hubName} climate neutral.`,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Honest question we might want to codify / standardize: do we always include punctuation in the translations? E.g., this .. I think it'd be useful to pick one way or the other: always include, or never include. WDYT?

Comment on lines +91 to +92


Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change

width:"65%",
height:"65%",
[theme.breakpoints.down("sm")]: {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change

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.

Add Popup prompting a user to sign up when they first visit the page

2 participants