/**
* WordPress dependencies
*/
import { Button, Icon, Spinner, Tooltip } from '@safe-wordpress/components';
import { useDispatch, useSelect } from '@safe-wordpress/data';
import { createInterpolateElement } from '@safe-wordpress/element';
import { addQueryArgs } from '@safe-wordpress/url';
import { _x } from '@safe-wordpress/i18n';
/**
* External dependencies
*/
import { store as NC_CALENDAR } from '@nelio-content/calendar';
import { SubscribeAction } from '@nelio-content/components';
import { store as NC_DATA } from '@nelio-content/data';
/**
* Internal dependencies
*/
import './style.scss';
import { PeriodLabel } from '../period-label';
import TodayIcon from '../today.svg';
import { ItemCreationButton } from './item-creation-button';
import { ErrorPaneToggle } from './error-pane-toggle';
import { ReusableMessageToggle } from './reusable-message-toggle';
import { ToggleFilterPaneButton } from './toggle-filter-pane-button';
import { ToggleUnscheduledViewButton } from './toggle-unscheduled-view-button';
import { MoreOptions } from './more-options';
export const DefaultHeader = (): JSX.Element => {
const isCalendarSynching = useSelect(
( select ) => select( NC_CALENDAR ).isCalendarSynching(),
[]
);
const isSocialPublicationPaused = useSelect(
( select ) => select( NC_DATA ).isSocialPublicationPaused(),
[]
);
const isStaging = useSelect(
( select ) => select( NC_DATA ).isStaging(),
[]
);
const navLabels = useNavigationLabels();
const { previousPeriod, nextPeriod } = useDispatch( NC_CALENDAR );
const isTodayVisible = useIsTodayVisible();
const { showToday } = useDispatch( NC_CALENDAR );
return (
<>
{ !! isStaging && (
If this is not correct, please
follow these instructions.',
'user',
'nelio-content'
),
{
a: (
.
),
br:
,
}
) as unknown as string
}
>
{ ' ' }
{ _x( 'Staging', 'text', 'nelio-content' ) }
) }
{ !! isSocialPublicationPaused && (
{ ' ' }
{ _x(
'Paused',
'text (social media publication)',
'nelio-content'
) }
) }
>
);
};
// =====
// HOOKS
// =====
const useIsTodayVisible = () =>
useSelect( ( select ) => {
const { getToday, getFirstDayOfWeek } = select( NC_DATA );
const { getFirstDay, getLastDay } = select( NC_CALENDAR );
const firstDayOfWeek = getFirstDayOfWeek();
const today = getToday();
return (
getFirstDay( firstDayOfWeek ) <= today &&
today <= getLastDay( firstDayOfWeek )
);
}, [] );
const useNavigationLabels = () => {
const calendarMode = useSelect(
( select ) => select( NC_CALENDAR ).getCalendarMode(),
[]
);
switch ( calendarMode ) {
case 'month':
return {
prev: _x( 'Previous Month', 'text', 'nelio-content' ),
next: _x( 'Next Month', 'text', 'nelio-content' ),
};
case 'two-weeks':
return {
prev: _x( 'Previous Two Weeks', 'text', 'nelio-content' ),
next: _x( 'Next Two Weeks', 'text', 'nelio-content' ),
};
case 'week':
return {
prev: _x( 'Previous Week', 'text', 'nelio-content' ),
next: _x( 'Next Week', 'text', 'nelio-content' ),
};
default:
return {
prev: _x( 'Previous Period', 'text', 'nelio-content' ),
next: _x( 'Next Period', 'text', 'nelio-content' ),
};
}
};