import * as React from 'react' import { createPortal } from 'react-dom' import debounce from 'lodash.debounce' import * as Styled from './index.style' import { showMessage } from '../../common/toast/toast' import { QuetionNaire, QuestionItem } from '../../template-activity-container/type' import Input from '../input' import Textarea from '../text-area' import Select from '../select' import { signupRequest } from '../signup-request' import { TemplateActivityContext } from '../../common/template-context' import { lock, unlock } from '../../utils/body-scroll-lock' import log from '../../utils/lofter-log' interface Props { show: boolean; onCancel: () => void; onSubmit: () => void; data?: QuetionNaire; refetch?: () => Promise; resubmit?: boolean; } class QuestionnaireModal extends React.Component { static contextType = TemplateActivityContext context: React.ContextType modalContent: HTMLElement; state = { formValue: {} } handleValueChange = (item: QuestionItem, value: string) => { const { formValue } = this.state this.setState({ formValue: { ...formValue, [item.name]: value } }) } renderTitle = (item: QuestionItem, index: number) => { return ( { item.required ? : null } Q{index + 1}: {item.name} { item.type === 'checkbox' ? '(多选)' : '' } ) } renderQues = (item: QuestionItem, index: number) => { if (item.type === 'input') { return ( { this.renderTitle(item, index) } ) } else if (item.type === 'textarea') { return ( { this.renderTitle(item, index) }