/** * WordPress dependencies */ import { Spinner } from '@safe-wordpress/components'; import { useDispatch, useSelect } from '@safe-wordpress/data'; import { _x } from '@safe-wordpress/i18n'; /** * External dependencies */ import { store as NC_CALENDAR } from '@nelio-content/calendar'; import type { DraggableItemSummary } from '@nelio-content/types'; /** * Internal dependencies */ import './style.scss'; import { PeriodControl } from './period-control'; import { Trash } from './trash'; import { PeriodLabel } from '../period-label'; const HOVER_INTERVAL = 1000; export type DraggingHeaderProps = { readonly type: DraggableItemSummary[ 'type' ]; }; export const DraggingHeader = ( { type, }: DraggingHeaderProps ): JSX.Element => { const isCalendarSynching = useSelect( ( select ) => select( NC_CALENDAR ).isCalendarSynching(), [] ); const navigation = useNavigationControls(); return (
{ _x( 'Previous', 'command', 'nelio-content' ) } { _x( 'Next', 'command', 'nelio-content' ) } { isCalendarSynching && }
{ 'post' === type ? _x( 'Trash', 'command', 'nelio-content' ) : _x( 'Delete', 'command', 'nelio-content' ) }
); }; // ===== // HOOKS // ===== const useNavigationControls = () => { const { previousPeriod, nextPeriod } = useDispatch( NC_CALENDAR ); return { prev: () => previousPeriod( HOVER_INTERVAL + 200 ), next: () => nextPeriod( HOVER_INTERVAL + 200 ), }; };