Show Campaigns card when banner is dismissed or campaigns total is truthy.

This commit is contained in:
Gan Eng Chin 2023-03-19 23:30:21 +08:00
parent 11683be1a8
commit ddd287cc4c
No known key found for this signature in database
GPG Key ID: 94D5D972860ADB01
1 changed files with 8 additions and 1 deletions

View File

@ -12,6 +12,7 @@ import '~/marketing/data-multichannel';
import { CenteredSpinner } from '~/marketing/components';
import {
useIntroductionBanner,
useCampaigns,
useRegisteredChannels,
useRecommendedChannels,
useCampaignTypes,
@ -31,6 +32,7 @@ export const MarketingOverviewMultichannel: React.FC = () => {
isIntroductionBannerDismissed,
dismissIntroductionBanner,
} = useIntroductionBanner();
const { loading: loadingCampaigns, meta: metaCampaigns } = useCampaigns();
const {
loading: loadingCampaignTypes,
data: dataCampaignTypes,
@ -48,6 +50,7 @@ export const MarketingOverviewMultichannel: React.FC = () => {
if (
loadingIntroductionBanner ||
( loadingCampaigns && metaCampaigns?.total === undefined ) ||
( loadingCampaignTypes && ! dataCampaignTypes ) ||
( loadingRegistered && ! dataRegistered ) ||
( loadingRecommended && ! dataRecommended )
@ -55,6 +58,10 @@ export const MarketingOverviewMultichannel: React.FC = () => {
return <CenteredSpinner />;
}
const shouldShowCampaigns =
dataRegistered?.length &&
( isIntroductionBannerDismissed || !! metaCampaigns?.total );
const shouldShowExtensions =
getAdminSetting( 'allowMarketplaceSuggestions', false ) &&
currentUserCan( 'install_plugins' );
@ -76,7 +83,7 @@ export const MarketingOverviewMultichannel: React.FC = () => {
} }
/>
) }
{ !! dataRegistered?.length && <Campaigns /> }
{ !! shouldShowCampaigns && <Campaigns /> }
{ !! ( dataRegistered && dataRecommended ) &&
!! ( dataRegistered.length || dataRecommended.length ) && (
<Channels