mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-18 16:01:40 +03:00
Added notification for default unsubscribed newsletter
refs https://github.com/TryGhost/Team/issues/1495
This commit is contained in:
parent
2e9735c5c4
commit
43a6b8c1ed
@ -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
|
||||
|
@ -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',
|
||||
|
Loading…
Reference in New Issue
Block a user