import React from 'react';
import {
	inject,
	observer
} from 'mobx-react';
import {
	WeaLocaleProvider
} from 'ecCom';
import Base from './Base';
import * as asyncFetch from '../../apis/country';
const getLabel = WeaLocaleProvider.getLabel;
const {
	getLocaleLabelByCode
} = WeaLocaleProvider;

@inject('hrmBrowseBoxLinkPage')
@observer
export default class Country extends React.Component {
	constructor(props) {
		super(props);
		this.state = {
			reRender: false
		}
	}

	componentDidMount() {
		getLocaleLabelByCode('hrm').then(() => this.setState({
			reRender: true
		}));
		['setTopTitle', 'getFormElements', 'setDirtyIdFlag'].map((f, i) => {
			let params;
			if (i === 0) {
				params = {
					title: () => getLabel('391219', "国家")
				}
			} else if (i === 1) {
				params = {
					asyncFetch,
					fetchParams: {
						countryid: this.props.location.query.id
					}
				}
			} else {
				params = {
					hasDirtyId: true
				}
			}

			this.props.hrmBrowseBoxLinkPage[f](params);
		});
	}

	render() {
		if (!this.state.reRender)
			return <div />
		return (
			<Base ecId={`${this && this.props && this.props.ecId || ''}_Base@5765jv`} />
		)
	}
}