2024-05-23 18:53:04 +08:00
|
|
|
import { IModalProps } from '@/interfaces/common';
|
|
|
|
|
import { Drawer } from 'antd';
|
2024-06-05 10:46:06 +08:00
|
|
|
import { Node } from 'reactflow';
|
|
|
|
|
import AnswerForm from '../answer-form';
|
|
|
|
|
import BeginForm from '../begin-form';
|
|
|
|
|
import { Operator } from '../constant';
|
|
|
|
|
import GenerateForm from '../generate-form';
|
|
|
|
|
import { useHandleFormValuesChange } from '../hooks';
|
|
|
|
|
import RetrievalForm from '../retrieval-form';
|
|
|
|
|
|
|
|
|
|
interface IProps {
|
|
|
|
|
node?: Node;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const FormMap = {
|
|
|
|
|
[Operator.Begin]: BeginForm,
|
|
|
|
|
[Operator.Retrieval]: RetrievalForm,
|
|
|
|
|
[Operator.Generate]: GenerateForm,
|
|
|
|
|
[Operator.Answer]: AnswerForm,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const FlowDrawer = ({
|
|
|
|
|
visible,
|
|
|
|
|
hideModal,
|
|
|
|
|
node,
|
|
|
|
|
}: IModalProps<any> & IProps) => {
|
|
|
|
|
const operatorName: Operator = node?.data.label;
|
|
|
|
|
const OperatorForm = FormMap[operatorName];
|
|
|
|
|
const { handleValuesChange } = useHandleFormValuesChange(node?.id);
|
2024-05-23 18:53:04 +08:00
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Drawer
|
2024-06-05 10:46:06 +08:00
|
|
|
title={node?.data.label}
|
2024-05-23 18:53:04 +08:00
|
|
|
placement="right"
|
|
|
|
|
onClose={hideModal}
|
|
|
|
|
open={visible}
|
|
|
|
|
getContainer={false}
|
|
|
|
|
mask={false}
|
2024-06-05 10:46:06 +08:00
|
|
|
width={470}
|
2024-05-23 18:53:04 +08:00
|
|
|
>
|
2024-06-05 10:46:06 +08:00
|
|
|
{visible && (
|
|
|
|
|
<OperatorForm onValuesChange={handleValuesChange}></OperatorForm>
|
|
|
|
|
)}
|
2024-05-23 18:53:04 +08:00
|
|
|
</Drawer>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default FlowDrawer;
|