import { IModalManagerChildrenProps } from '@/components/modal-manager'; import { useSetModalState, useTranslate } from '@/hooks/common-hooks'; import { useFetchFlowTemplates } from '@/hooks/flow-hooks'; import { useSelectItem } from '@/hooks/logic-hooks'; import { Button, Card, Flex, List, Modal, Typography } from 'antd'; import { useCallback, useState } from 'react'; import CreateAgentModal from './create-agent-modal'; import GraphAvatar from './graph-avatar'; import DOMPurify from 'dompurify'; import styles from './index.less'; const { Title, Text, Paragraph } = Typography; interface IProps extends Omit { loading: boolean; onOk: (name: string, templateId: string) => void; showModal?(): void; } const AgentTemplateModal = ({ visible, hideModal, loading, onOk }: IProps) => { const { t } = useTranslate('common'); const { data: list } = useFetchFlowTemplates(); const { selectedId, handleItemClick } = useSelectItem(''); const [checkedId, setCheckedId] = useState(''); const { visible: creatingVisible, hideModal: hideCreatingModal, showModal: showCreatingModal, } = useSetModalState(); const handleOk = useCallback( async (name: string) => { return onOk(name, checkedId); }, [onOk, checkedId], ); const onShowCreatingModal = useCallback( (id: string) => () => { showCreatingModal(); setCheckedId(id); }, [showCreatingModal], ); return (
{t('createFromTemplates', { keyPrefix: 'flow' })} ( {x.title}
{selectedId === x.id && ( )}
)} />
{creatingVisible && ( )}
); }; export default AgentTemplateModal;