import PropTypes from 'prop-types'; import { forwardRef } from 'react'; import { bound, clsm } from '../../../utils'; import { ChevronLeft, ChevronRight } from '../../../assets/icons'; import { dashboard as $dashboardContent } from '../../../content'; import { useStreams } from '../../../contexts/Streams'; import Button from '../../../components/Button'; import useDateTime from '../../../hooks/useDateTime'; const $content = $dashboardContent.header; const NAV_BUTTON_CLASSES = [ 'h-auto', 'py-1.5', 'px-3.5', 'min-w-[auto]', 'xs:hidden', 'bg-lightMode-gray-extraLight' ]; const TIME_CLASSES = [ 'dark:text-darkMode-gray-light', 'flex', 'space-x-0.5', 'items-center', 'justify-center', 'text-lightMode-gray-medium' ]; const SessionNavigator = forwardRef( ({ isNavOpen, toggleNavPopup }, navButtonRef) => { const { activeStreamSession, fetchStreamSessionsError, isInitialFetchingStreamData, streamSessions, updateActiveStreamSession, refreshCurrentStreamSessions } = useStreams(); const { startTime, endTime, isLive } = activeStreamSession || {}; const [date, time, dayDiff] = useDateTime(startTime, endTime, 5); const sessionsLength = streamSessions?.length; const isPrevDisabled = !activeStreamSession || !sessionsLength || activeStreamSession.index === 0; const isNextDisabled = !activeStreamSession || !sessionsLength || activeStreamSession.index === sessionsLength - 1; const handleSessionNavigator = () => { if (!isNavOpen) refreshCurrentStreamSessions(); toggleNavPopup(); }; const handleNextStream = (e) => { if (!isNextDisabled) { const nextStreamSessionIdx = bound( activeStreamSession.index + 1, 0, sessionsLength ); updateActiveStreamSession(streamSessions?.[nextStreamSessionIdx]); } }; const handlePreviousStream = () => { if (!isPrevDisabled) { const prevStreamSessionIdx = bound( activeStreamSession.index - 1, 0, sessionsLength ); updateActiveStreamSession(streamSessions?.[prevStreamSessionIdx]); } }; return (