mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-23 16:09:11 +00:00
refactor: extract utility type
This commit is contained in:
committed by
Carlos Valente
parent
4cbe25a845
commit
2fc4e6da16
@@ -5,7 +5,7 @@ import { IoLink } from '@react-icons/all-files/io5/IoLink';
|
|||||||
import { IoLockClosed } from '@react-icons/all-files/io5/IoLockClosed';
|
import { IoLockClosed } from '@react-icons/all-files/io5/IoLockClosed';
|
||||||
import { IoLockOpenOutline } from '@react-icons/all-files/io5/IoLockOpenOutline';
|
import { IoLockOpenOutline } from '@react-icons/all-files/io5/IoLockOpenOutline';
|
||||||
import { IoUnlink } from '@react-icons/all-files/io5/IoUnlink';
|
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 TimeInputWithButton from '../../../common/components/input/time-input/TimeInputWithButton';
|
||||||
import { useEventAction } from '../../../common/hooks/useEventAction';
|
import { useEventAction } from '../../../common/hooks/useEventAction';
|
||||||
@@ -25,14 +25,12 @@ interface EventBlockTimerProps {
|
|||||||
delay: number;
|
delay: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
type TimeActions = 'timeStart' | 'timeEnd' | 'duration';
|
|
||||||
|
|
||||||
function TimeInputFlow(props: EventBlockTimerProps) {
|
function TimeInputFlow(props: EventBlockTimerProps) {
|
||||||
const { eventId, isTimeToEnd, timeStart, timeEnd, duration, timeStrategy, linkStart, delay } = props;
|
const { eventId, isTimeToEnd, timeStart, timeEnd, duration, timeStrategy, linkStart, delay } = props;
|
||||||
const { updateEvent, updateTimer } = useEventAction();
|
const { updateEvent, updateTimer } = useEventAction();
|
||||||
|
|
||||||
// In sync with EventEditorTimes
|
// In sync with EventEditorTimes
|
||||||
const handleSubmit = (field: TimeActions, value: string) => {
|
const handleSubmit = (field: TimeField, value: string) => {
|
||||||
updateTimer(eventId, field, value);
|
updateTimer(eventId, field, value);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -64,7 +62,7 @@ function TimeInputFlow(props: EventBlockTimerProps) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<TimeInputWithButton<TimeActions>
|
<TimeInputWithButton<TimeField>
|
||||||
name='timeStart'
|
name='timeStart'
|
||||||
submitHandler={handleSubmit}
|
submitHandler={handleSubmit}
|
||||||
time={timeStart}
|
time={timeStart}
|
||||||
@@ -80,7 +78,7 @@ function TimeInputFlow(props: EventBlockTimerProps) {
|
|||||||
</Tooltip>
|
</Tooltip>
|
||||||
</TimeInputWithButton>
|
</TimeInputWithButton>
|
||||||
|
|
||||||
<TimeInputWithButton<TimeActions>
|
<TimeInputWithButton<TimeField>
|
||||||
name='timeEnd'
|
name='timeEnd'
|
||||||
submitHandler={handleSubmit}
|
submitHandler={handleSubmit}
|
||||||
time={timeEnd}
|
time={timeEnd}
|
||||||
@@ -100,7 +98,7 @@ function TimeInputFlow(props: EventBlockTimerProps) {
|
|||||||
</Tooltip>
|
</Tooltip>
|
||||||
</TimeInputWithButton>
|
</TimeInputWithButton>
|
||||||
|
|
||||||
<TimeInputWithButton<TimeActions>
|
<TimeInputWithButton<TimeField>
|
||||||
name='duration'
|
name='duration'
|
||||||
submitHandler={handleSubmit}
|
submitHandler={handleSubmit}
|
||||||
time={duration}
|
time={duration}
|
||||||
|
|||||||
@@ -45,3 +45,4 @@ export type OntimeEvent = OntimeBaseEvent & {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export type PlayableEvent = OntimeEvent & { skip: false };
|
export type PlayableEvent = OntimeEvent & { skip: false };
|
||||||
|
export type TimeField = 'timeStart' | 'timeEnd' | 'duration';
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ export {
|
|||||||
type OntimeBlock,
|
type OntimeBlock,
|
||||||
type OntimeEvent,
|
type OntimeEvent,
|
||||||
type PlayableEvent,
|
type PlayableEvent,
|
||||||
|
type TimeField,
|
||||||
SupportedEvent,
|
SupportedEvent,
|
||||||
} from './definitions/core/OntimeEvent.type.js';
|
} from './definitions/core/OntimeEvent.type.js';
|
||||||
export type { OntimeEntryCommonKeys, OntimeRundown, OntimeRundownEntry } from './definitions/core/Rundown.type.js';
|
export type { OntimeEntryCommonKeys, OntimeRundown, OntimeRundownEntry } from './definitions/core/Rundown.type.js';
|
||||||
|
|||||||
Reference in New Issue
Block a user