Revert fixed publishing issue when site has no active newsletters

This commit is contained in:
Princi Vershwal 2024-07-18 19:25:49 +05:30 committed by GitHub
parent 836b6e7be9
commit f05ba155b8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -106,15 +106,8 @@ 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<Newsletter[]>(apiNewsletters || []);
const activeNewsletters = newsletters.filter(n => n.status === 'active');
useEffect(() => {
setNewsletters(apiNewsletters || []);
}, [apiNewsletters]);
const fontOptions: SelectOption[] = [
{value: 'serif', label: 'Elegant serif', className: 'font-serif'},
@ -259,7 +252,7 @@ const Sidebar: React.FC<{
/>
</Form>
<div className='mb-5 mt-10'>
{newsletter.status === 'active' ? (!onlyOne && <Button color='red' disabled={activeNewsletters.length === 1} label='Archive newsletter' link onClick={confirmStatusChange}/>) : <Button color='green' label='Reactivate newsletter' link onClick={confirmStatusChange} />}
{newsletter.status === 'active' ? (!onlyOne && <Button color='red' label='Archive newsletter' link onClick={confirmStatusChange} />) : <Button color='green' label='Reactivate newsletter' link onClick={confirmStatusChange} />}
</div>
</>
},