import {
	inject,
	observer
} from 'mobx-react';
import {
	WeaDialog
} from 'ecCom';
import {
	MagicForm
} from '../../public/sweet-form.js';
import {
	Loading,
} from '../../public/learn';

@inject('hrmAttendanceRpSharingSetting')
@observer
class Dialog extends React.Component {
	constructor(props) {
		super(props);
	}

	getContent = () => {
		const {
			formConfig,
			formElements,
		} = this.props.hrmAttendanceRpSharingSetting, {
			form,
			loading,
		} = formElements;

		if (loading) {
			return <Loading ecId={`${this && this.props && this.props.ecId || ''}_Loading@a1f2nv`} size='sm'/>
		} else {
			return (
				<MagicForm ecId={`${this && this.props && this.props.ecId || ''}_MagicForm@0acryc`} 
					{...formConfig}
					{...formElements}
					isFormInit={form.isFormInit}
				/>
			)
		}
	}

	render() {
		const {
			dialog,
			dialogProps,
		} = this.props.hrmAttendanceRpSharingSetting;

		return (
			<WeaDialog ecId={`${this && this.props && this.props.ecId || ''}_WeaDialog@4esdkq`}
				{...dialog}
				{...dialogProps}
			>
				{this.getContent()}
			</WeaDialog>
		);
	}
}

export default Dialog;