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


class Content extends Component {
    constructor() {
        super();
        this.state = {
            loading: false,
            component: 'div'
        };
    }
    componentWillMount() {
        if (window.location.hash) {
            this.getKey(window.location.hash.substr(1));
        } else {
            this.getKey("techDemand");
        };
    }
    getKey(key) {
        switch (key) {
            case 'techDemand':
                require.ensure([], () => {
                    const TechDemand = require('./techDemand').default;
                    this.setState({
                        component: TechDemand
                    });
                });
                break;
        };
        window.location.hash = key;
    }
    render() {
        return (
            <div className="acc-content">
                <LeftTab handlekey={this.getKey.bind(this)} />
                <div className="content-right">
                    <this.state.component />
                </div>
            </div>
        )
    }
}

export default Content;
