HEX
Server: Apache
System: Linux c040.dattaweb.com 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
User: c0400220 (20588)
PHP: 7.4.33
Disabled: system, shell, exec, system_exec, shell_exec, mysql_pconnect, passthru, popen, proc_open, proc_close, proc_nice, proc_terminate, proc_get_status, escapeshellarg, escapeshellcmd, eval, dl, imap_mail, libvirt_connect, gnupg_init, unsetenv, apache_setenv, pcntl_exec, pcntl_alarm, pcntl_fork, pcntl_waitpid, pcntl_wait, pcntl_wifexited, pcntl_wifstopped, pcntl_wifsignaled, pcntl_wifcontinued, pcntl_wexitstatus, pcntl_wtermsig, pcntl_wstopsig, pcntl_signal, pcntl_signal_get_handler, pcntl_signal_dispatch, pcntl_get_last_error, pcntl_strerror, pcntl_sigprocmask, pcntl_sigwaitinfo, pcntl_sigtimedwait, pcntl_getpriority, pcntl_setpriority, pcntl_async_signals, opcache_get_status, opcache_reset, opcache_get_configuration
Upload Files
File: /home/c0400220/public_html/2020/wp-content/plugins/everest-forms/src/dashboard/header-standalone.js
import {
	Box,
	ChakraProvider,
	Container,
	HStack,
	Skeleton,
	SkeletonCircle,
	Stack,
	useToast,
} from '@chakra-ui/react';
import { QueryClient, QueryClientProvider, useQuery } from '@tanstack/react-query';
import apiFetch from '@wordpress/api-fetch';
import { __ } from '@wordpress/i18n';
import React from 'react';
import ReactDOM from 'react-dom/client';
import { BrowserRouter } from 'react-router-dom';
import { Header } from './components';
import Theme from './Theme/Theme';

const queryClient = new QueryClient();

function HeaderWithQuery() {
	const toast = useToast();

	/* global _EVF_DASHBOARD_ */
	const {
		evfRestApiNonce,
		restURL,
		allStepsCompleted,
	} =
		typeof _EVF_DASHBOARD_ !== 'undefined' && _EVF_DASHBOARD_;

	const siteAssistantQuery = useQuery({
		queryKey: ['siteAssistant'],
		queryFn: async () => {
			const response = await apiFetch({
				path: `${restURL}everest-forms/v1/site-assistant`,
				method: 'GET',
				headers: {
					'X-WP-Nonce': evfRestApiNonce,
				},
			});
			return response;
		},
		cacheTime: Infinity,
		staleTime: Infinity,
		retry: 1,
		onError: (error) => {
			console.error('Error fetching site assistant data:', error);
			toast({
				title: __('Error', 'everest-forms'),
				description: __('Failed to load setup status.', 'everest-forms'),
				status: 'error',
				duration: 3000,
				isClosable: true,
			});
		},
	});

	const isAllStepsCompleted = siteAssistantQuery?.isLoading
		? Boolean(allStepsCompleted === '1')
		: siteAssistantQuery?.data?.data?.all_steps_completed;

	// Show skeleton loading that matches the actual header UI
	if (siteAssistantQuery.isLoading) {
		return (
			<Box
				bg="white"
				borderBottom="1px solid #E9E9E9"
				width="100%"
				position="relative"
				zIndex="10"
			>
				<Container maxW="full">
					<Stack direction="row" minH="70px" justify="space-between">
						{/* Left Side - Logo and Navigation Skeleton */}
						<Stack direction="row" align="center" gap="7">
							{/* Logo Skeleton */}
							<SkeletonCircle size="10" />

							{/* Navigation Links Skeleton */}
							<HStack spacing="1" h="full">
								<Skeleton height="20px" width="100px" />
								<Skeleton height="20px" width="80px" />
								<Skeleton height="20px" width="90px" />
								<Skeleton height="20px" width="95px" />
							</HStack>
						</Stack>

						{/* Right Side - Actions Skeleton */}
						<Stack direction="row" align="center" spacing="12px">
							<HStack spacing="1" >
								<Skeleton height="20px" width="60px" />
								<Skeleton height="20px" width="90px" />
							</HStack>
							<Skeleton height="20px" width="100px" />
							<Skeleton height="24px" width="50px" borderRadius="xl" />
							<SkeletonCircle size="10" />
						</Stack>
					</Stack>
				</Container>
			</Box>
		);
	}

	return <Header hideSiteAssistant={isAllStepsCompleted} />;
}

(function () {
	const headerContainer = document.getElementById('evf-react-header-root');

	if (!headerContainer) return;

	const headerRoot = ReactDOM.createRoot(headerContainer);

	if (headerRoot) {
		headerRoot.render(
			<React.StrictMode>
				<QueryClientProvider client={queryClient}>
					<ChakraProvider theme={Theme}>
						<BrowserRouter>
							<HeaderWithQuery />
						</BrowserRouter>
					</ChakraProvider>
				</QueryClientProvider>
			</React.StrictMode>,
		);
	}
})();