2022-09-14 07:43:30 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { useUser } from '@woocommerce/data';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
import '~/marketing/data';
|
2023-01-17 18:04:42 +00:00
|
|
|
import '~/marketing/data-multichannel';
|
2023-01-31 15:39:02 +00:00
|
|
|
import { CenteredSpinner } from '~/marketing/components';
|
2022-12-23 17:14:02 +00:00
|
|
|
import {
|
|
|
|
useRegisteredChannels,
|
|
|
|
useRecommendedChannels,
|
|
|
|
} from '~/marketing/hooks';
|
2022-09-14 07:43:30 +00:00
|
|
|
import { getAdminSetting } from '~/utils/admin-settings';
|
2022-12-15 17:13:32 +00:00
|
|
|
import { Campaigns } from './Campaigns';
|
2022-12-08 15:53:36 +00:00
|
|
|
import { Channels } from './Channels';
|
2022-09-14 07:43:30 +00:00
|
|
|
import { InstalledExtensions } from './InstalledExtensions';
|
|
|
|
import { DiscoverTools } from './DiscoverTools';
|
|
|
|
import { LearnMarketing } from './LearnMarketing';
|
|
|
|
import './MarketingOverviewMultichannel.scss';
|
|
|
|
|
|
|
|
export const MarketingOverviewMultichannel: React.FC = () => {
|
2023-01-19 17:02:41 +00:00
|
|
|
const {
|
|
|
|
loading: loadingRegistered,
|
|
|
|
data: dataRegistered,
|
|
|
|
refetch,
|
|
|
|
} = useRegisteredChannels();
|
2022-12-23 17:14:02 +00:00
|
|
|
const { loading: loadingRecommended, data: dataRecommended } =
|
|
|
|
useRecommendedChannels();
|
2022-09-14 07:43:30 +00:00
|
|
|
const { currentUserCan } = useUser();
|
|
|
|
|
|
|
|
const shouldShowExtensions =
|
|
|
|
getAdminSetting( 'allowMarketplaceSuggestions', false ) &&
|
|
|
|
currentUserCan( 'install_plugins' );
|
|
|
|
|
2023-01-19 17:02:41 +00:00
|
|
|
if (
|
|
|
|
( loadingRegistered && ! dataRegistered ) ||
|
|
|
|
( loadingRecommended && ! dataRecommended )
|
|
|
|
) {
|
2022-12-23 17:14:02 +00:00
|
|
|
return <CenteredSpinner />;
|
|
|
|
}
|
|
|
|
|
2022-09-14 07:43:30 +00:00
|
|
|
return (
|
|
|
|
<div className="woocommerce-marketing-overview-multichannel">
|
2023-01-31 15:50:03 +00:00
|
|
|
{ dataRegistered?.length && <Campaigns /> }
|
2023-01-19 17:02:41 +00:00
|
|
|
{ dataRegistered &&
|
|
|
|
dataRecommended &&
|
2023-01-31 16:29:38 +00:00
|
|
|
( dataRegistered.length || dataRecommended.length ) && (
|
2023-01-19 17:02:41 +00:00
|
|
|
<Channels
|
|
|
|
registeredChannels={ dataRegistered }
|
|
|
|
recommendedChannels={ dataRecommended }
|
|
|
|
onInstalledAndActivated={ refetch }
|
|
|
|
/>
|
|
|
|
) }
|
2022-09-14 07:43:30 +00:00
|
|
|
<InstalledExtensions />
|
|
|
|
{ shouldShowExtensions && <DiscoverTools /> }
|
|
|
|
<LearnMarketing />
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|