import React from 'react';
import '../content.less';
import LeftTab from './leftTab.jsx';

import Patent from './patent';

const Content = React.createClass({
    getInitialState() {
        return {
            loading: false,
            leftKey: 'patent',
            component: Patent,
            userType: '0'
        };
    },
    handlekey(key) {
        switch (key) {
            case 'patent':
                this.setState({
                    component: Patent,
                    leftKey: 'patent'
                });
                break;
            case 'cognizance':
                require.ensure([], () => {
                    const Cognizance = require('./cognizance').default;
                    this.setState({
                        component: Cognizance,
                        leftKey: 'cognizance'
                    });
                });
                break;
            case 'copyright':
                require.ensure([], () => {
                    const Copyright = require('./copyright/copyright').default;
                    this.setState({
                        component: Copyright,
                        leftKey: 'copyright'
                    });
                });
                break;
            case 'technology':
                require.ensure([], () => {
                    const Technology = require('./technology').default;
                    this.setState({
                        component: Technology,
                        leftKey: 'technology'
                    });
                });
                break;
            case 'companyDetail':
                require.ensure([], () => {
                    const CompanyDetail = require('./companyDetail').default;
                    this.setState({
                        component: CompanyDetail,
                        leftKey: 'companyDetail'
                    });
                });
                break;
            case 'orgTechCenter':
                require.ensure([], () => {
                    const OrgTechCenter = require('./orgTechCenter').default;
                    this.setState({
                        component: OrgTechCenter,
                        leftKey: 'orgTechCenter'
                    });
                });
                break;
            case 'activity':
                require.ensure([], () => {
                    const Activity = require('./activity').default;
                    this.setState({
                        component: Activity,
                        leftKey: 'activity'
                    });
                });
                break;
            case 'activityCostList':
                require.ensure([], () => {
                    const ActivityCostList = require('./activityCostList').default;
                    this.setState({
                        component: ActivityCostList,
                        leftKey: 'activityCostList'
                    });
                });
                break;
            case 'techProduct':
                require.ensure([], () => {
                    const TechProduct = require('./techProduct').default;
                    this.setState({
                        component: TechProduct,
                        leftKey: 'techProduct'
                    });
                });
                break;
            case 'intellectual':
                require.ensure([], () => {
                    const Intellectual = require('./intellectual').default;
                    this.setState({
                        component: Intellectual,
                        leftKey: 'intellectual'
                    });
                });
                break;
            case 'achievement':
                require.ensure([], () => {
                    const Achievement = require('./achievement').default;
                    this.setState({
                        component: Achievement,
                        leftKey: 'achievement'
                    });
                });
                break;
            case 'ratepay':
                require.ensure([], () => {
                    const Ratepay = require('./ratepay').default;
                    this.setState({
                        component: Ratepay,
                        leftKey: 'ratepay'
                    });
                });
                break;
            case 'finance':
                require.ensure([], () => {
                    const Finance = require('./finance').default;
                    this.setState({
                        component: Finance,
                        leftKey: 'finance'
                    });
                });
                break;

            case 'honorList':
                require.ensure([], () => {
                    const HonorList = require('./honorList').default;
                    this.setState({
                        component: HonorList,
                        leftKey: 'honorList'
                    });
                });
                break;
            case 'standard':
                require.ensure([], () => {
                    const Standard = require('./standard').default;
                    this.setState({
                        component: Standard,
                        leftKey: 'standard'
                    });
                });
                break;
            case 'annualReport':
                require.ensure([], () => {
                    const AnnualReport = require('./annualReport').default;
                    this.setState({
                        component: AnnualReport,
                        leftKey: 'annualReport'
                    });
                });
                break;
        };
        window.location.hash = key;
    },
    componentWillMount() {
        if (window.location.hash) {
            this.handlekey(window.location.hash.substr(1));
        };
    },
    render() {
        return (
            <div className="acc-content">
                <LeftTab handlekey={this.handlekey} />
                <div className="content-right">
                    <this.state.component />
                </div>
            </div>
        )
    }
});

export default Content;