From 836b6e7be94f1d402a762330e41b77a646857c95 Mon Sep 17 00:00:00 2001 From: Princi Vershwal Date: Thu, 18 Jul 2024 19:14:18 +0530 Subject: [PATCH] Fixed publishing issue when site has no active newsletters Ref ENG-1253 Not allowing users to archive their last active newsletter --- .../settings/email/newsletters/NewsletterDetailModal.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModal.tsx b/apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModal.tsx index a762d5a707..0b73777146 100644 --- a/apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModal.tsx +++ b/apps/admin-x-settings/src/components/settings/email/newsletters/NewsletterDetailModal.tsx @@ -106,8 +106,15 @@ const Sidebar: React.FC<{ const {localSettings} = useSettingGroup(); const [siteTitle] = getSettingValues(localSettings, ['title']) as string[]; const handleError = useHandleError(); + const {data: {newsletters: apiNewsletters} = {}} = useBrowseNewsletters(); let newsletterAddress = renderSenderEmail(newsletter, config, defaultEmailAddress); + const [newsletters, setNewsletters] = useState(apiNewsletters || []); + const activeNewsletters = newsletters.filter(n => n.status === 'active'); + + useEffect(() => { + setNewsletters(apiNewsletters || []); + }, [apiNewsletters]); const fontOptions: SelectOption[] = [ {value: 'serif', label: 'Elegant serif', className: 'font-serif'}, @@ -252,7 +259,7 @@ const Sidebar: React.FC<{ />
- {newsletter.status === 'active' ? (!onlyOne &&
},