Added notification for default unsubscribed newsletter

refs https://github.com/TryGhost/Team/issues/1495
This commit is contained in:
Rishabh 2022-05-16 16:38:19 +05:30
parent 2e9735c5c4
commit 43a6b8c1ed
2 changed files with 21 additions and 0 deletions

View File

@ -110,6 +110,7 @@ function ShowPaidMemberMessage({site, isPaid}) {
}
export default function NewsletterManagement({
notification,
subscribedNewsletters,
updateSubscribedNewsletters,
unsubscribeAll,
@ -117,10 +118,15 @@ export default function NewsletterManagement({
}) {
const isDisabled = !subscribedNewsletters?.length;
const {brandColor, site} = useContext(AppContext);
const EmptyNotification = () => {
return null;
};
const FinalNotification = notification || EmptyNotification;
return (
<div className='gh-portal-content with-footer'>
<CloseButton />
<AccountHeader />
<FinalNotification />
<div className='gh-portal-section'>
<div className='gh-portal-list'>
<NewsletterPrefs

View File

@ -47,6 +47,7 @@ export default function UnsubscribePage() {
const defaultNewsletters = siteNewsletters.filter((d) => {
return d.subscribe_on_signup;
});
const [hasInteracted, setHasInteracted] = useState(false);
const [subscribedNewsletters, setSubscribedNewsletters] = useState(defaultNewsletters);
const [showPrefs, setShowPrefs] = useState(false);
@ -115,14 +116,28 @@ export default function UnsubscribePage() {
</div>
);
}
const HeaderNotification = () => {
const unsubscribedNewsletter = siteNewsletters?.find((d) => {
return d.uuid === pageData.newsletterUuid;
});
const hideClassName = hasInteracted ? 'hide' : '';
return (
<p className={`gh-portal-text-center ${hideClassName}`}><strong>{member?.email}</strong> will no longer receive <strong>{unsubscribedNewsletter?.name}</strong> newsletter.</p>
);
};
return (
<NewsletterManagement
notification={HeaderNotification}
subscribedNewsletters={subscribedNewsletters}
updateSubscribedNewsletters={async (newsletters) => {
setSubscribedNewsletters(newsletters);
setHasInteracted(true);
await api.member.updateNewsletters({uuid: pageData.uuid, newsletters});
}}
unsubscribeAll={async () => {
setHasInteracted(true);
setSubscribedNewsletters([]);
onAction('showPopupNotification', {
action: 'updated:success',