import React, { useState, useEffect } from 'react'; import Select from '@/_ui/Select'; import { appsService } from '@/_services'; import CodeHinter from '@/AppBuilder/CodeEditor'; import './workflows-query.scss'; import { v4 as uuidv4 } from 'uuid'; import useStore from '@/AppBuilder/_stores/store'; export function Workflows({ options, optionsChanged, currentState }) { const [workflowOptions, setWorkflowOptions] = useState([]); const [_selectedWorkflowId, setSelectedWorkflowId] = useState(undefined); const [params, setParams] = useState([...(options.params ?? [{ key: '', value: '' }])]); const appId = useStore((state) => state.app.appId); useEffect(() => { appsService.getWorkflows(appId).then(({ workflows }) => { setWorkflowOptions( workflows.map((workflow) => ({ value: workflow.id, name: workflow.name, })) ); }); // eslint-disable-next-line react-hooks/exhaustive-deps }, []); useEffect(() => { optionsChanged({ ...options, params, }); // eslint-disable-next-line react-hooks/exhaustive-deps }, [params]); return ( <>