import { useContext } from 'react'; import { Divider, Tooltip } from '@chakra-ui/react'; import { FiSettings } from '@react-icons/all-files/fi/FiSettings'; import { FiTarget } from '@react-icons/all-files/fi/FiTarget'; import { IoContract } from '@react-icons/all-files/io5/IoContract'; import { IoExpand } from '@react-icons/all-files/io5/IoExpand'; import { IoMoon } from '@react-icons/all-files/io5/IoMoon'; import { formatDisplay } from 'ontime-utils'; import PropTypes from 'prop-types'; import { TableSettingsContext } from '../../common/context/TableSettingsContext'; import useFullscreen from '../../common/hooks/useFullscreen'; import { useTimer } from '../../common/hooks/useSocket'; import useEventData from '../../common/hooks-query/useEventData'; import { formatTime } from '../../common/utils/time'; import { tooltipDelayFast } from '../../ontimeConfig'; import PlaybackIcon from './tableElements/PlaybackIcon'; import style from './Table.module.scss'; export default function TableHeader({ handleCSVExport, featureData }) { const { followSelected, showSettings, toggleTheme, toggleSettings, toggleFollow } = useContext(TableSettingsContext); const timer = useTimer(); const { isFullScreen, toggleFullScreen } = useFullscreen(); const { data: event } = useEventData(); const selected = !featureData.numEvents ? 'No events' : `Event ${featureData.selectedEventIndex != null ? featureData.selectedEventIndex + 1 : '-'}/${ featureData.numEvents ? featureData.numEvents : '-' }`; // prepare presentation variables const isOvertime = timer.current < 0; const timerNow = `${isOvertime ? '-' : ''}${formatDisplay(timer.current)}`; const timeNow = formatTime(timer.clock, { showSeconds: true, format: 'hh:mm:ss a', }); return (