mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-14 03:43:50 +00:00
e5fdf27f6c
* fix: bug with applying delays * fix: show delay data only in production screens * chore: cover delay with feature test * refactor: simplify type assertion
54 lines
1.5 KiB
TypeScript
54 lines
1.5 KiB
TypeScript
import Empty from '../state/Empty';
|
|
|
|
import { useSchedule } from './ScheduleContext';
|
|
import ScheduleItem from './ScheduleItem';
|
|
|
|
import './Schedule.scss';
|
|
|
|
interface ScheduleProps {
|
|
isProduction?: boolean;
|
|
className?: string;
|
|
}
|
|
|
|
export default function Schedule({ isProduction, className }: ScheduleProps) {
|
|
const { paginatedEvents, selectedEventId, isBackstage, scheduleType } = useSchedule();
|
|
|
|
if (paginatedEvents?.length < 1) {
|
|
return <Empty text='No events to show' />;
|
|
}
|
|
|
|
let selectedState: 'past' | 'now' | 'future' = 'past';
|
|
|
|
return (
|
|
<ul className={`schedule ${className}`}>
|
|
{paginatedEvents.map((event) => {
|
|
if (scheduleType === 'past' || scheduleType === 'future') {
|
|
selectedState = scheduleType;
|
|
} else {
|
|
if (event.id === selectedEventId) {
|
|
selectedState = 'now';
|
|
} else if (selectedState === 'now') {
|
|
selectedState = 'future';
|
|
}
|
|
}
|
|
|
|
const timeStart = isProduction ? event.timeStart + (event?.delay ?? 0) : event.timeStart;
|
|
const timeEnd = isProduction ? event.timeEnd + (event?.delay ?? 0) : event.timeEnd;
|
|
|
|
return (
|
|
<ScheduleItem
|
|
key={event.id}
|
|
selected={selectedState}
|
|
timeStart={timeStart}
|
|
timeEnd={timeEnd}
|
|
title={event.title}
|
|
colour={isBackstage ? event.colour : ''}
|
|
backstageEvent={!event.isPublic}
|
|
skip={event.skip}
|
|
/>
|
|
);
|
|
})}
|
|
</ul>
|
|
);
|
|
}
|