import React, { useCallback } from 'react' import { useTranslation } from 'react-i18next' import { useEmbeddedChatbotContext } from '../context' import Input from '@/app/components/base/input' import Textarea from '@/app/components/base/textarea' import { PortalSelect } from '@/app/components/base/select' import { FileUploaderInAttachmentWrapper } from '@/app/components/base/file-uploader' import { InputVarType } from '@/app/components/workflow/types' type Props = { showTip?: boolean } const InputsFormContent = ({ showTip }: Props) => { const { t } = useTranslation() const { appParams, inputsForms, currentConversationId, currentConversationItem, newConversationInputs, newConversationInputsRef, handleNewConversationInputsChange, } = useEmbeddedChatbotContext() const inputsFormValue = currentConversationId ? currentConversationItem?.inputs : newConversationInputs const readonly = !!currentConversationId const handleFormChange = useCallback((variable: string, value: any) => { handleNewConversationInputsChange({ ...newConversationInputsRef.current, [variable]: value, }) }, [newConversationInputsRef, handleNewConversationInputsChange]) return (
{inputsForms.map(form => (
{form.label}
{!form.required && (
{t('appDebug.variableTable.optional')}
)}
{form.type === InputVarType.textInput && ( handleFormChange(form.variable, e.target.value)} placeholder={form.label} readOnly={readonly} disabled={readonly} /> )} {form.type === InputVarType.number && ( handleFormChange(form.variable, e.target.value)} placeholder={form.label} readOnly={readonly} disabled={readonly} /> )} {form.type === InputVarType.paragraph && (