0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-18 02:21:47 -05:00

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.
This commit is contained in:
Elena Baidakova 2022-12-05 15:58:55 +04:00 committed by GitHub
parent 3817f583fa
commit 5e973688bf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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);