From 5e973688bfa3b34ce6fb36a58d8d420d854a4547 Mon Sep 17 00:00:00 2001 From: Elena Baidakova Date: Mon, 5 Dec 2022 15:58:55 +0400 Subject: [PATCH] Added redirect to Email Preferences in Portal after resubscribing (#15940) closes TryGhost/Team#2360 - Redirect member to Email Preferences after email removed from suppression list. --- .../components/pages/EmailSuppressedPage.js | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/ghost/portal/src/components/pages/EmailSuppressedPage.js b/ghost/portal/src/components/pages/EmailSuppressedPage.js index 9b854e9f76..b507e77cef 100644 --- a/ghost/portal/src/components/pages/EmailSuppressedPage.js +++ b/ghost/portal/src/components/pages/EmailSuppressedPage.js @@ -1,22 +1,38 @@ import AppContext from 'AppContext'; import {useContext, useEffect} from 'react'; +import {hasCommentsEnabled, hasMultipleNewsletters} from 'utils/helpers'; import CloseButton from 'components/common/CloseButton'; import BackButton from 'components/common/BackButton'; import ActionButton from 'components/common/ActionButton'; import {ReactComponent as EmailDeliveryFailedIcon} from 'images/icons/email-delivery-failed.svg'; export default function EmailSuppressedPage() { - const {brandColor, lastPage, onAction, action} = useContext(AppContext); + const {brandColor, lastPage, onAction, action, site} = useContext(AppContext); useEffect(() => { if (['removeEmailFromSuppressionList:success'].includes(action)) { onAction('refreshMemberData'); } - if (['removeEmailFromSuppressionList:failed', 'refreshMemberData:success', 'refreshMemberData:failed'].includes(action)) { + if (['removeEmailFromSuppressionList:failed', 'refreshMemberData:failed'].includes(action)) { onAction('back'); } - }, [action, onAction]); + + if (['refreshMemberData:success'].includes(action)) { + const showEmailPreferences = hasMultipleNewsletters({site}) || hasCommentsEnabled({site}); + if (showEmailPreferences) { + onAction('switchPage', { + page: 'accountEmail', + lastPage: 'accountHome' + }); + onAction('showPopupNotification', { + message: 'You have been successfully resubscribed' + }); + } else { + onAction('back'); + } + } + }, [action, onAction, site]); const isRunning = ['removeEmailFromSuppressionList:running', 'refreshMemberData:running'].includes(action);