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:
Oliver Eyton-Williams
2021-07-20 16:19:11 +02:00
committed by GitHub
parent e33b977f04
commit a368e7f277

View File

@ -37,18 +37,22 @@ function AcceptPrivacyTerms({
acceptedPrivacyTerms,
t
}: AcceptPrivacyTermsProps) {
// if a user navigates away from here we should set acceptedPrivacyTerms
// to true (so they do not get pulled back) without changing their email
// preferences (hence the null payload)
// This ensures the user has to click the checkbox and then click the
// 'Continue...' button to sign up.
useEffect(() => {
return () => {
// if a user navigates away from here we should set acceptedPrivacyTerms
// to true (so they do not get pulled back) without changing their email
// preferences (hence the null payload)
// This makes sure that the user has to opt in to Quincy's emails and that
// they are only asked twice
if (!acceptedPrivacyTerms) {
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) {
acceptTerms(isWeeklyEmailAccepted);