import { memo } from 'react'; import { IoAlertCircleOutline, IoLink, IoLockClosed, IoLockOpenOutline, IoUnlink } from 'react-icons/io5'; import { InputRightElement, Tooltip } from '@chakra-ui/react'; import { TimeField, TimeStrategy } from 'ontime-types'; import { dayInMs } from 'ontime-utils'; import TimeInputWithButton from '../../../common/components/input/time-input/TimeInputWithButton'; import { useEventAction } from '../../../common/hooks/useEventAction'; import { cx } from '../../../common/utils/styleUtils'; import { tooltipDelayFast, tooltipDelayMid } from '../../../ontimeConfig'; import * as Editor from '../../editors/editor-utils/EditorUtils'; import style from './TimeInputFlow.module.scss'; interface EventBlockTimerProps { eventId: string; countToEnd: boolean; timeStart: number; timeEnd: number; duration: number; timeStrategy: TimeStrategy; linkStart: boolean; delay: number; showLabels?: boolean; } function TimeInputFlow(props: EventBlockTimerProps) { const { eventId, countToEnd, timeStart, timeEnd, duration, timeStrategy, linkStart, delay, showLabels } = props; const { updateEvent, updateTimer } = useEventAction(); // In sync with EventEditorTimes const handleSubmit = (field: TimeField, value: string) => { updateTimer(eventId, field, value); }; const handleChangeStrategy = (timeStrategy: TimeStrategy) => { updateEvent({ id: eventId, timeStrategy }); }; const handleLink = (doLink: boolean) => { updateEvent({ id: eventId, linkStart: doLink }); }; const warnings = []; if (timeStart + duration > dayInMs) { warnings.push('Over midnight'); } if (countToEnd) { warnings.push('Count to End'); } const hasDelay = delay !== 0; const isLockedEnd = timeStrategy === TimeStrategy.LockEnd; const isLockedDuration = timeStrategy === TimeStrategy.LockDuration; const activeStart = cx([style.timeAction, linkStart && style.active]); const activeEnd = cx([style.timeAction, isLockedEnd && style.active]); const activeDuration = cx([style.timeAction, isLockedDuration && style.active]); return ( <>