import {
	observer
} from 'mobx-react';
import {
	WeaAlertPage,
	WeaLocaleProvider,
} from 'ecCom';
import {
	Spin
} from 'antd';
const getLabel = WeaLocaleProvider.getLabel;

@observer
export default class Authority extends React.Component {
	render() {
		const {
			store
		} = this.props, {
			loading,
			hasRight,
		} = store;

		//css in js
		const style = {
			position: 'absolute',
			top: '50%',
			left: '50%',
			marginLeft: -16,
			marginTop: -16,
		}

		if (loading) {
			return (
				<div style={style}>
					<Spin ecId={`${this && this.props && this.props.ecId || ''}_Spin@lbdyc2`} spinning={true} size='large' />
				</div>
			)
		}

		if (hasRight) {
			return this.props.children;
		} else {
			return (
				<div style={{height:'100%'}}>
	                <WeaAlertPage ecId={`${this && this.props && this.props.ecId || ''}_WeaAlertPage@z2r5af`}>
	                    <div style={{ color: '#000' }}>
	                        {getLabel(2012, '对不起，您暂时没有权限！')}
	                    </div>
	                </WeaAlertPage>
	            </div>
			)
		}
	}
}