import {
	observer
} from 'mobx-react';
import {
	Loading,
} from '../../public/learn';
import NoLinkageForm from './NoLinkageForm';
import PreInfo from './PreInfo';
import CollapseForm from './CollapseForm';

@observer
export default class DialogContent extends React.Component {
	constructor(props) {
		super(props);
	}

	getDialogContent = () => {
		const {
			store
		} = this.props, {
			cPage,
			preInfo,
			step,
			dialogForm,
			isRenderCollapseForm,
		} = store, {
			loading
		} = dialogForm, {
			currentIndex
		} = step;

		if (loading) {
			return <Loading />;
		}

		if (cPage === 'main') {
			return (
				<div className='preInfo'>
					<PreInfo preInfo={preInfo}/>
				</div>
			)
		}

		return isRenderCollapseForm ? <CollapseForm form={dialogForm.form} /> : (
			<div className='form'>
				<NoLinkageForm form={dialogForm.form} isEdit='1'/>
			</div>
		)
	}

	render() {
		return (
			<div className='dialog'>{this.getDialogContent()}</div>
		);
	}
}