import React, { Component } from 'react';
import '../content.less';
import LeftTab from './leftTab';


class Content extends Component {
    constructor() {
        super();
        this.state = {
            loading: false,
            component: <div></div>,
        };
    }
    componentWillMount() {
        if (window.location.hash) {
            this.getKey(window.location.hash.substr(1));
        } else {
            this.getKey("myClient");
        };
    }
    getKey(key) {
        switch (key) {          	
            case 'myClient':
                require.ensure([], () => {
                    const MyClient = require('./customerData/myClient').default;
                    this.setState({
                        component: <MyClient />                      
                      
                    });
                });
                break;           
            case 'publicCustomer': 
                require.ensure([], () => {
                    const PublicCustomer = require('./customerData/publicCustomer').default;
                    this.setState({
                        component:<PublicCustomer />,                                             
                    });
                });
                break;
            case 'companyCustomer':
                require.ensure([], () => {
	                const CompanyCustomer = require('./customerData/companyCustomer').default;
	                this.setState({
	                    component:<CompanyCustomer />,	                    	                  
	                });
          	    });
          	    break;
          	case 'individualCustomer':
                require.ensure([], () => {
                    const IndividualCustomer = require('./individualCustomer/individualCustomer').default;
                    this.setState({
                        component: <IndividualCustomer />                      
                      
                    });
                });
                break;           
            case 'publicindividualCustomer': 
                require.ensure([], () => {
                    const PublicindividualCustomer = require('./individualCustomer/publicindividualCustomer').default;
                    this.setState({
                        component:<PublicindividualCustomer />,                                             
                    });
                });
                break;
            case 'queryCustomer':
                require.ensure([], () => {
	                const QueryCustomer = require('./individualCustomer/queryCustomer').default;
	                this.setState({
	                    component:<QueryCustomer />,	                    	                  
	                });
          	    });
          	    break;
          	    
      	    case 'myBusiness':
            require.ensure([], () => {
                const MyBusiness = require('./customerService/myBusiness').default;
                this.setState({
                    component:<MyBusiness />,	                                      
                });
      	    });
      	    break;
      	    case 'serviceQuery':
            require.ensure([], () => {
                const ServiceQuery = require('./customerService/serviceQuery').default;
                this.setState({
                    component:<ServiceQuery />,	                                      
                });
      	    });
      	    break;
        };
        window.location.hash = key;
    }
    render() {
        return (
            <div className="manage-content">
                <LeftTab handlekey={this.getKey.bind(this)} />
                <div className="content-right">
                   {this.state.component}
                </div>
            </div>
        )
    }
}

export default Content;
