Back

0% Statements 0/53
0% Branches 0/1
0% Functions 0/1
0% Lines 0/53

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54                                                                                                           
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { createRoot } from 'react-dom/client';
import LaunchCelebrationModal from './launch-celebration-modal';
import LaunchSite from './launch-site';
import SiteVisibility from './site-visibility';
import type { SitePreviewLinkObject } from './site-preview-link';

declare global {
	interface Window {
		JETPACK_MU_WPCOM_SITE_VISIBILITY?: {
			homeUrl: string;
			siteTitle: string;
			blogId: number;
			isWpcomStagingSite: boolean;
			isUnlaunchedSite: boolean;
			hasSitePreviewLink: boolean;
			sitePreviewLink?: SitePreviewLinkObject;
			sitePreviewLinkNonce: string;
			blogPublic: number;
			wpcomComingSoon: number;
			wpcomPublicComingSoon: number;
			wpcomDataSharingOptOut: boolean;
			siteDomain: string;
			sitePlan?: { product_slug: string; product_name?: string };
			hasCustomDomain: boolean;
			usePublishCopy: boolean;
		};
	}
}

const queryClient = new QueryClient();

document.addEventListener( 'DOMContentLoaded', function () {
	const container = document.getElementById( 'wpcom-site-visibility' );
	const props = typeof window === 'object' ? window.JETPACK_MU_WPCOM_SITE_VISIBILITY : null;
	if ( container && props ) {
		const root = createRoot( container );
		if ( props.isUnlaunchedSite ) {
			root.render(
				<QueryClientProvider client={ queryClient }>
					<LaunchSite { ...props } />
				</QueryClientProvider>
			);
		} else {
			root.render(
				<>
					<SiteVisibility { ...props } />
					<LaunchCelebrationModal { ...props } />
				</>
			);
		}
	}
} );