2022-09-14 07:43:30 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { useUser } from '@woocommerce/data';
|
2022-12-27 16:56:59 +00:00
|
|
|
import { ScrollTo } from '@woocommerce/components';
|
2022-09-14 07:43:30 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
import { getAdminSetting } from '~/utils/admin-settings';
|
2022-12-26 18:05:58 +00:00
|
|
|
import { IntroductionBanner } from './IntroductionBanner';
|
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 '~/marketing/data';
|
2022-12-23 17:14:02 +00:00
|
|
|
import {
|
2022-12-27 14:01:46 +00:00
|
|
|
useIntroductionBanner,
|
2022-12-23 17:14:02 +00:00
|
|
|
useRegisteredChannels,
|
|
|
|
useRecommendedChannels,
|
2022-12-27 17:09:37 +00:00
|
|
|
useIsLocationHashAddChannels,
|
2022-12-23 17:14:02 +00:00
|
|
|
} from '~/marketing/hooks';
|
2022-09-14 07:43:30 +00:00
|
|
|
import './MarketingOverviewMultichannel.scss';
|
2022-12-23 17:14:02 +00:00
|
|
|
import { CenteredSpinner } from '../components';
|
2022-09-14 07:43:30 +00:00
|
|
|
|
|
|
|
export const MarketingOverviewMultichannel: React.FC = () => {
|
2022-12-27 14:01:46 +00:00
|
|
|
const {
|
|
|
|
loading: loadingIntroductionBanner,
|
|
|
|
isIntroductionBannerDismissed,
|
|
|
|
dismissIntroductionBanner,
|
|
|
|
} = useIntroductionBanner();
|
2022-12-23 17:14:02 +00:00
|
|
|
const { loading: loadingRegistered, data: dataRegistered } =
|
|
|
|
useRegisteredChannels();
|
|
|
|
const { loading: loadingRecommended, data: dataRecommended } =
|
|
|
|
useRecommendedChannels();
|
2022-12-27 17:09:37 +00:00
|
|
|
const isLocationHashAddChannels = useIsLocationHashAddChannels();
|
2022-09-14 07:43:30 +00:00
|
|
|
const { currentUserCan } = useUser();
|
|
|
|
|
|
|
|
const shouldShowExtensions =
|
|
|
|
getAdminSetting( 'allowMarketplaceSuggestions', false ) &&
|
|
|
|
currentUserCan( 'install_plugins' );
|
|
|
|
|
2022-12-27 14:01:46 +00:00
|
|
|
if (
|
|
|
|
loadingIntroductionBanner ||
|
|
|
|
loadingRegistered ||
|
|
|
|
loadingRecommended
|
|
|
|
) {
|
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">
|
2022-12-27 14:01:46 +00:00
|
|
|
{ ! isIntroductionBannerDismissed && (
|
|
|
|
<IntroductionBanner
|
|
|
|
showButtons={ dataRegistered.length >= 1 }
|
|
|
|
onDismiss={ dismissIntroductionBanner }
|
|
|
|
/>
|
|
|
|
) }
|
2022-12-23 17:43:09 +00:00
|
|
|
{ dataRegistered.length >= 1 && <Campaigns /> }
|
2022-12-27 16:56:59 +00:00
|
|
|
{ ( dataRegistered.length >= 1 || dataRecommended.length >= 1 ) &&
|
2022-12-27 17:09:37 +00:00
|
|
|
( isLocationHashAddChannels ? (
|
2022-12-27 16:56:59 +00:00
|
|
|
<ScrollTo>
|
|
|
|
<Channels
|
|
|
|
registeredChannels={ dataRegistered }
|
|
|
|
recommendedChannels={ dataRecommended }
|
|
|
|
/>
|
|
|
|
</ScrollTo>
|
|
|
|
) : (
|
|
|
|
<Channels
|
|
|
|
registeredChannels={ dataRegistered }
|
|
|
|
recommendedChannels={ dataRecommended }
|
|
|
|
/>
|
|
|
|
) ) }
|
2022-09-14 07:43:30 +00:00
|
|
|
<InstalledExtensions />
|
|
|
|
{ shouldShowExtensions && <DiscoverTools /> }
|
|
|
|
<LearnMarketing />
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|