import type { FC } from 'react' import { useContext } from 'use-context-selector' import type { CodeBasedExtensionForm } from '@/models/common' import I18n from '@/context/i18n' import { PortalSelect } from '@/app/components/base/select' import Textarea from '@/app/components/base/textarea' import type { ModerationConfig } from '@/models/debug' type FormGenerationProps = { forms: CodeBasedExtensionForm[] value: ModerationConfig['config'] onChange: (v: Record) => void } const FormGeneration: FC = ({ forms, value, onChange, }) => { const { locale } = useContext(I18n) const handleFormChange = (type: string, v: string) => { onChange({ ...value, [type]: v }) } return ( <> { forms.map((form, index) => (
{locale === 'zh-Hans' ? form.label['zh-Hans'] : form.label['en-US']}
{ form.type === 'text-input' && ( handleFormChange(form.variable, e.target.value)} /> ) } { form.type === 'paragraph' && (