From 2fc4e6da1625122d5a147cc786f1344116c1a7e0 Mon Sep 17 00:00:00 2001 From: Carlos Valente Date: Fri, 20 Dec 2024 12:39:04 +0100 Subject: [PATCH] refactor: extract utility type --- .../rundown/time-input-flow/TimeInputFlow.tsx | 12 +++++------- .../types/src/definitions/core/OntimeEvent.type.ts | 1 + packages/types/src/index.ts | 1 + 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/apps/client/src/features/rundown/time-input-flow/TimeInputFlow.tsx b/apps/client/src/features/rundown/time-input-flow/TimeInputFlow.tsx index f71cb1b27..175469d76 100644 --- a/apps/client/src/features/rundown/time-input-flow/TimeInputFlow.tsx +++ b/apps/client/src/features/rundown/time-input-flow/TimeInputFlow.tsx @@ -5,7 +5,7 @@ import { IoLink } from '@react-icons/all-files/io5/IoLink'; import { IoLockClosed } from '@react-icons/all-files/io5/IoLockClosed'; import { IoLockOpenOutline } from '@react-icons/all-files/io5/IoLockOpenOutline'; import { IoUnlink } from '@react-icons/all-files/io5/IoUnlink'; -import { MaybeString, TimeStrategy } from 'ontime-types'; +import { MaybeString, TimeField, TimeStrategy } from 'ontime-types'; import TimeInputWithButton from '../../../common/components/input/time-input/TimeInputWithButton'; import { useEventAction } from '../../../common/hooks/useEventAction'; @@ -25,14 +25,12 @@ interface EventBlockTimerProps { delay: number; } -type TimeActions = 'timeStart' | 'timeEnd' | 'duration'; - function TimeInputFlow(props: EventBlockTimerProps) { const { eventId, isTimeToEnd, timeStart, timeEnd, duration, timeStrategy, linkStart, delay } = props; const { updateEvent, updateTimer } = useEventAction(); // In sync with EventEditorTimes - const handleSubmit = (field: TimeActions, value: string) => { + const handleSubmit = (field: TimeField, value: string) => { updateTimer(eventId, field, value); }; @@ -64,7 +62,7 @@ function TimeInputFlow(props: EventBlockTimerProps) { return ( <> - + name='timeStart' submitHandler={handleSubmit} time={timeStart} @@ -80,7 +78,7 @@ function TimeInputFlow(props: EventBlockTimerProps) { - + name='timeEnd' submitHandler={handleSubmit} time={timeEnd} @@ -100,7 +98,7 @@ function TimeInputFlow(props: EventBlockTimerProps) { - + name='duration' submitHandler={handleSubmit} time={duration} diff --git a/packages/types/src/definitions/core/OntimeEvent.type.ts b/packages/types/src/definitions/core/OntimeEvent.type.ts index 801cf295d..035a53015 100644 --- a/packages/types/src/definitions/core/OntimeEvent.type.ts +++ b/packages/types/src/definitions/core/OntimeEvent.type.ts @@ -45,3 +45,4 @@ export type OntimeEvent = OntimeBaseEvent & { }; export type PlayableEvent = OntimeEvent & { skip: false }; +export type TimeField = 'timeStart' | 'timeEnd' | 'duration'; diff --git a/packages/types/src/index.ts b/packages/types/src/index.ts index 11d80f8eb..0f3d3c34b 100644 --- a/packages/types/src/index.ts +++ b/packages/types/src/index.ts @@ -9,6 +9,7 @@ export { type OntimeBlock, type OntimeEvent, type PlayableEvent, + type TimeField, SupportedEvent, } from './definitions/core/OntimeEvent.type.js'; export type { OntimeEntryCommonKeys, OntimeRundown, OntimeRundownEntry } from './definitions/core/Rundown.type.js';