mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-16 21:03:29 +00:00
44 lines
1.0 KiB
TypeScript
44 lines
1.0 KiB
TypeScript
import { useEffect, useState } from 'react';
|
|
import { isOntimeEvent, OntimeEvent } from 'ontime-types';
|
|
|
|
import useRundown from '../../../common/hooks-query/useRundown';
|
|
import { cx } from '../../../common/utils/styleUtils';
|
|
|
|
import EventEditor from './EventEditor';
|
|
|
|
import style from './EntryEditor.module.scss';
|
|
|
|
interface CuesheetEventEditorProps {
|
|
eventId: string;
|
|
}
|
|
|
|
export default function CuesheetEventEditor({ eventId }: CuesheetEventEditorProps) {
|
|
const { data } = useRundown();
|
|
|
|
const [event, setEvent] = useState<OntimeEvent | null>(null);
|
|
|
|
useEffect(() => {
|
|
if (data.order.length === 0) {
|
|
setEvent(null);
|
|
return;
|
|
}
|
|
|
|
const event = data.entries[eventId];
|
|
if (event && isOntimeEvent(event)) {
|
|
setEvent(event);
|
|
} else {
|
|
setEvent(null);
|
|
}
|
|
}, [eventId, data.order, data.entries]);
|
|
|
|
if (!event) {
|
|
return null;
|
|
}
|
|
|
|
return (
|
|
<div className={cx([style.entryEditor, style.inModal])} data-testid='editor-container'>
|
|
<EventEditor event={event} />
|
|
</div>
|
|
);
|
|
}
|