import {
	inject,
	observer,
} from 'mobx-react'

import {
	Spin,
	message,
} from 'antd'

import Editor from './Editor'

@inject('hrmSingleMajorStore')
@observer
export default class SingleMajor extends React.Component {
	constructor(props) {
		super(props);
	}

	componentWillMount() {
		const {
			hrmSingleMajorStore
		} = this.props, {
			setMajorId
		} = hrmSingleMajorStore;

		setMajorId(this.props.location.query.id);
	}

	componentDidMount() {
		const {
			hrmSingleMajorStore
		} = this.props, {
			getRight,
			setParentHideMthd,
		} = hrmSingleMajorStore;

		getRight();
		this.props.onRef && this.props.onRef(this);
		setParentHideMthd(this.props.hide)
	}

	save = () => {
		const {
			hrmSingleMajorStore
		} = this.props, {
			saveMajorForm,
		} = hrmSingleMajorStore;

		saveMajorForm();
	}

	render() {
		const {
			hrmSingleMajorStore
		} = this.props, {
			major,
			date,
		} = hrmSingleMajorStore;

		return (
			<div>
				<Editor {...major} isFormInit={major.form.isFormInit} />
			</div>
		)

	}
}