import { AutomationDTO, OntimeAction, OntimeActionKey, SecondarySource } from 'ontime-types'; import { PropsWithChildren, useState } from 'react'; import { UseFormRegister, UseFormSetValue, UseFormWatch } from 'react-hook-form'; import Input from '../../../../common/components/input/input/Input'; import Select from '../../../../common/components/select/Select'; import * as Panel from '../../panel-utils/PanelUtils'; import style from './AutomationForm.module.scss'; interface OntimeActionFormProps { index: number; register: UseFormRegister; rowErrors?: { action?: { message?: string }; time?: { message?: string }; text?: { message?: string }; visible?: { message?: string }; secondarySource?: { message?: string }; }; value: OntimeAction['action']; watch: UseFormWatch; setValue: UseFormSetValue; } export default function OntimeActionForm({ index, register, setValue, rowErrors, value, children, watch, }: PropsWithChildren) { const [selectedAction, setSelectedAction] = useState(value); const handleSetAction = (value: OntimeActionKey) => { setValue(`outputs.${index}.action`, value, { shouldDirty: true }); setSelectedAction(value); }; return (
)} {selectedAction === 'message-set' && ( <> )}
{children}
); }