import * as React from 'react'; import { useFormContext } from 'react-hook-form'; import Collapse from '@mui/material/Collapse'; import ListItem from '@mui/material/ListItem'; import Button from '@mui/material/Button'; import Stack from '@mui/material/Stack'; import type { IStep, ISubstep } from '@automatisch/types'; import { EditorContext } from 'contexts/Editor'; import FlowSubstepTitle from 'components/FlowSubstepTitle'; import InputCreator from 'components/InputCreator'; import FilterConditions from './FilterConditions'; type FlowSubstepProps = { substep: ISubstep; expanded?: boolean; onExpand: () => void; onCollapse: () => void; onChange: ({ step }: { step: IStep }) => void; onSubmit: () => void; step: IStep; }; function FlowSubstep(props: FlowSubstepProps): React.ReactElement { const { substep, expanded = false, onExpand, onCollapse, onSubmit, step, } = props; const { name, arguments: args } = substep; const editorContext = React.useContext(EditorContext); const formContext = useFormContext(); const validationStatus = formContext.formState.isValid; const onToggle = expanded ? onCollapse : onExpand; return ( {!!args?.length && ( {args.map((argument) => ( ))} )} {step.appKey === 'filter' && } ); } export default FlowSubstep;