import { IModalManagerChildrenProps } from '@/components/modal-manager'; import { useTranslate } from '@/hooks/common-hooks'; import { useFetchFlowTemplates } from '@/hooks/flow-hooks'; import { useSelectItem } from '@/hooks/logic-hooks'; import { Card, Flex, Form, Input, Modal, Space, Typography } from 'antd'; import classNames from 'classnames'; import { useEffect } from 'react'; import GraphAvatar from './graph-avatar'; import styles from './index.less'; const { Title } = Typography; interface IProps extends Omit { loading: boolean; initialName: string; onOk: (name: string, templateId: string) => void; showModal?(): void; } const CreateFlowModal = ({ visible, hideModal, loading, initialName, onOk, }: IProps) => { const [form] = Form.useForm(); const { t } = useTranslate('common'); const { data: list } = useFetchFlowTemplates(); const { selectedId, handleItemClick } = useSelectItem(list?.at(0)?.id); type FieldType = { name?: string; }; const handleOk = async () => { const ret = await form.validateFields(); return onOk(ret.name, selectedId); }; useEffect(() => { if (visible) { form.setFieldValue('name', initialName); } }, [initialName, form, visible]); return (
label={{t('name')}} name="name" rules={[{ required: true, message: t('namePlaceholder') }]} > {t('createFromTemplates', { keyPrefix: 'flow' })} {list?.map((x) => ( {x.title}

{x.description}

))}
); }; export default CreateFlowModal;