fix: prevent early redirection from email-signup (#42944)
Co-authored-by: Victor Duarte <victor-duarte@users.noreply.github.com> Co-authored-by: Shaun Hamilton <shauhami020@gmail.com> Co-authored-by: Victor Duarte <victor-duarte@users.noreply.github.com> Co-authored-by: Shaun Hamilton <shauhami020@gmail.com>
This commit is contained in:
committed by
GitHub
parent
e33b977f04
commit
a368e7f277
@ -37,18 +37,22 @@ function AcceptPrivacyTerms({
|
|||||||
acceptedPrivacyTerms,
|
acceptedPrivacyTerms,
|
||||||
t
|
t
|
||||||
}: AcceptPrivacyTermsProps) {
|
}: AcceptPrivacyTermsProps) {
|
||||||
|
useEffect(() => {
|
||||||
|
return () => {
|
||||||
// if a user navigates away from here we should set acceptedPrivacyTerms
|
// if a user navigates away from here we should set acceptedPrivacyTerms
|
||||||
// to true (so they do not get pulled back) without changing their email
|
// to true (so they do not get pulled back) without changing their email
|
||||||
// preferences (hence the null payload)
|
// preferences (hence the null payload)
|
||||||
// This ensures the user has to click the checkbox and then click the
|
// This makes sure that the user has to opt in to Quincy's emails and that
|
||||||
// 'Continue...' button to sign up.
|
// they are only asked twice
|
||||||
useEffect(() => {
|
|
||||||
return () => {
|
|
||||||
if (!acceptedPrivacyTerms) {
|
if (!acceptedPrivacyTerms) {
|
||||||
acceptTerms(null);
|
acceptTerms(null);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}, [acceptTerms, acceptedPrivacyTerms]);
|
// We're ignoring all dependencies, since this effect must only run once
|
||||||
|
// (when the user leaves the page).
|
||||||
|
// TODO: figure out how to useCallback to only run this effect once.
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, []);
|
||||||
|
|
||||||
function onClick(isWeeklyEmailAccepted: boolean) {
|
function onClick(isWeeklyEmailAccepted: boolean) {
|
||||||
acceptTerms(isWeeklyEmailAccepted);
|
acceptTerms(isWeeklyEmailAccepted);
|
||||||
|
Reference in New Issue
Block a user