chore: improve convention entry <> event

This commit is contained in:
Carlos Valente
2025-04-13 20:46:47 +02:00
committed by Carlos Valente
parent 3ca0abad53
commit 1c4f13a0ed
23 changed files with 211 additions and 210 deletions
@@ -2,7 +2,7 @@ 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 { useEntryActions } from '../../../common/hooks/useEntryAction';
import useCustomFields from '../../../common/hooks-query/useCustomFields';
import * as Editor from '../../editors/editor-utils/EditorUtils';
@@ -23,7 +23,7 @@ interface EventEditorProps {
export default function EventEditor(props: EventEditorProps) {
const { event } = props;
const { data: customFields } = useCustomFields();
const { updateEvent } = useEventAction();
const { updateEntry } = useEntryActions();
const isEditor = window.location.pathname.includes('editor');
@@ -31,12 +31,12 @@ export default function EventEditor(props: EventEditorProps) {
(field: EditorUpdateFields, value: string) => {
if (field.startsWith('custom-')) {
const fieldLabel = field.split('custom-')[1];
updateEvent({ id: event?.id, custom: { [fieldLabel]: value } });
updateEntry({ id: event?.id, custom: { [fieldLabel]: value } });
} else {
updateEvent({ id: event?.id, [field]: value });
updateEntry({ id: event?.id, [field]: value });
}
},
[event?.id, updateEvent],
[event?.id, updateEntry],
);
if (!event) {