import React from 'react';
import {
	observer,
	inject
} from 'mobx-react';
import {
	AlertPage,
	Loading,
} from '../../public/learn';
import '../../style/report.less';

import Top from './Top';
import Dialog from './Dialog';

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

	componentWillMount() {
		this.props.hrmVacationBalanceReportCopy.cwm();
	}

	componentDidMount() {
		this.props.hrmVacationBalanceReportCopy.getPermissionInfo();
	}

	componentWillReceiveProps(nextProps) {
		if (this.props.location.key !== nextProps.location.key) {
			this.props.hrmVacationBalanceReportCopy.cwr();
		}
	}

	render() {
		const {
			hrmVacationBalanceReportCopy,
		} = this.props, {
			pageAccessPermission
		} = hrmVacationBalanceReportCopy, {
			hasRight,
			loading
		} = pageAccessPermission;

		if (!hasRight) {
			return loading ? <Loading ecId={`${this && this.props && this.props.ecId || ''}_Loading@dj0ofr`} size='lg'/> : <AlertPage ecId={`${this && this.props && this.props.ecId || ''}_AlertPage@cohqtf`} />
		} else {
			return (
				<div className='report'>
					<Top ecId={`${this && this.props && this.props.ecId || ''}_Top@rr33zq`} />
					<Dialog ecId={`${this && this.props && this.props.ecId || ''}_Dialog@s464sc`} />
				</div>
			)
		}
	}
}