import { useCallback } from 'react'; import { CustomFieldLabel, OntimeEvent } from 'ontime-types'; import AppLink from '../../../common/components/link/app-link/AppLink'; import { useEventAction } from '../../../common/hooks/useEventAction'; import useCustomFields from '../../../common/hooks-query/useCustomFields'; import * as Editor from '../../editors/editor-utils/EditorUtils'; import EventCustom from './composite/EventEditorCustom'; import EventEditorTimes from './composite/EventEditorTimes'; import EventEditorTitles from './composite/EventEditorTitles'; import EventEditorTriggers from './composite/EventEditorTriggers'; import EventEditorEmpty from './EventEditorEmpty'; import style from './EventEditor.module.scss'; export type EditorUpdateFields = 'cue' | 'title' | 'note' | 'colour' | CustomFieldLabel; interface EventEditorProps { event: OntimeEvent; } export default function EventEditor(props: EventEditorProps) { const { event } = props; const { data: customFields } = useCustomFields(); const { updateEvent } = useEventAction(); const isEditor = window.location.pathname.includes('editor'); const handleSubmit = useCallback( (field: EditorUpdateFields, value: string) => { if (field.startsWith('custom-')) { const fieldLabel = field.split('custom-')[1]; updateEvent({ id: event?.id, custom: { [fieldLabel]: value } }); } else { updateEvent({ id: event?.id, [field]: value }); } }, [event?.id, updateEvent], ); if (!event) { return ; } return (
Custom Fields {isEditor && Manage Custom Fields}
Automations {isEditor && Manage Automations}
); }