mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-18 05:34:09 +00:00
50 lines
1.3 KiB
TypeScript
50 lines
1.3 KiB
TypeScript
import { useEffect, useState } from 'react';
|
|
import { isOntimeEvent, OntimeEvent } from 'ontime-types';
|
|
|
|
import useRundown from '../../../common/hooks-query/useRundown';
|
|
import { useEventSelection } from '../useEventSelection';
|
|
|
|
import { EventEditorFooter } from './composite/EventEditorFooter';
|
|
import EventEditor from './EventEditor';
|
|
import EventEditorEmpty from './EventEditorEmpty';
|
|
|
|
import style from './EventEditor.module.scss';
|
|
|
|
export default function RundownEventEditor() {
|
|
const selectedEvents = useEventSelection((state) => state.selectedEvents);
|
|
const { data } = useRundown();
|
|
|
|
const [event, setEvent] = useState<OntimeEvent | null>(null);
|
|
|
|
useEffect(() => {
|
|
if (data.order.length === 0) {
|
|
setEvent(null);
|
|
return;
|
|
}
|
|
|
|
const selectedEventId = Array.from(selectedEvents).at(0);
|
|
if (!selectedEventId) {
|
|
setEvent(null);
|
|
return;
|
|
}
|
|
const event = data.entries[selectedEventId];
|
|
|
|
if (event && isOntimeEvent(event)) {
|
|
setEvent(event);
|
|
} else {
|
|
setEvent(null);
|
|
}
|
|
}, [data.order, data.entries, selectedEvents]);
|
|
|
|
if (!event) {
|
|
return <EventEditorEmpty />;
|
|
}
|
|
|
|
return (
|
|
<div className={style.eventEditor} data-testid='editor-container'>
|
|
<EventEditor event={event} />
|
|
<EventEditorFooter id={event.id} cue={event.cue} />
|
|
</div>
|
|
);
|
|
}
|