/**
* External dependencies
*/
import {
Fragment,
Suspense,
lazy,
useState,
useRef,
useEffect,
} from '@wordpress/element';
import { compose } from '@wordpress/compose';
import { withDispatch } from '@wordpress/data';
import classnames from 'classnames';
import PropTypes from 'prop-types';
import { NOTES_STORE_NAME, OPTIONS_STORE_NAME } from '@woocommerce/data';
/**
* Internal dependencies
*/
import QuickLinks from '../quick-links';
import StatsOverview from './stats-overview';
import './style.scss';
import '../dashboard/style.scss';
import TaskListPlaceholder from '../task-list/placeholder';
import InboxPanel from '../header/activity-panel/panels/inbox';
import withWCApiSelect from '../wc-api/with-select';
import { WelcomeModal } from './welcome-modal';
const TaskList = lazy( () =>
import( /* webpackChunkName: "task-list" */ '../task-list' )
);
export const Layout = ( {
isBatchUpdating,
query,
requestingTaskList,
taskListComplete,
taskListHidden,
shouldShowWelcomeModal,
updateOptions,
} ) => {
const [ showInbox, setShowInbox ] = useState( true );
const [ isContentSticky, setIsContentSticky ] = useState( false );
const content = useRef( null );
const maybeStickContent = () => {
if ( ! content.current ) {
return;
}
const { bottom } = content.current.getBoundingClientRect();
const shouldBeSticky = showInbox && bottom < window.innerHeight;
setIsContentSticky( shouldBeSticky );
};
useEffect( () => {
maybeStickContent();
window.addEventListener( 'resize', maybeStickContent );
return () => {
window.removeEventListener( 'resize', maybeStickContent );
};
}, [] );
const isTaskListEnabled = taskListHidden === false && ! taskListComplete;
const isDashboardShown = ! isTaskListEnabled || ! query.task;
const isInboxPanelEmpty = ( isEmpty ) => {
if ( isBatchUpdating ) {
return;
}
setShowInbox( ! isEmpty );
};
if ( isBatchUpdating && ! showInbox ) {
setShowInbox( true );
}
const renderColumns = () => {
return (