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

import Base from './base.jsx';
import Group from './group.jsx';
import Person from './person.jsx';
import Company from './company.jsx';
import Edu from './edu.jsx';
import Tech from './tech.jsx';
import Pfs from './pfs.jsx';
import Ablt from './ablt.jsx';
import HrSituation from './hrSituation.jsx';

const Content = React.createClass({
    getInitialState() {
        return {
            loading: false,
            leftKey: 'standard',
            userType: '0'
        };
    },
    handlekey(key) {
        this.setState({
            leftKey: key,
        });
        window.location.hash = key;
    },
    componentWillMount() {
        if (userData) {
            if (userData.type == '0') {
                this.state.leftKey = 'base';
            } else if (userData.type == '1') {
                this.state.leftKey = 'group';
            };
        };
        if (window.location.hash) {
            this.handlekey(window.location.hash.substr(1));
        };
    },
    render() {
        return (
            <div className="acc-content">
                {(() => {
                    if (userData.type == 1) {
                        return <GroupLeftTab handlekey={this.handlekey} />;
                    } else {
                        return <LeftTab handlekey={this.handlekey} />;
                    };
                })()}
                <div className="content-right">
                    {(() => {
                        switch (this.state.leftKey) {
                            case 'base':
                                return <Base />;
                            case 'person':
                                return <Person />;
                            case 'edu':
                                return <Edu />;
                            case 'pfs':
                                return <Pfs />;
                            case 'ablt':
                                return <Ablt />;
                            case 'group':
                                return <Group />;
                            case 'company':
                                return <Company />;
                            case 'tech':
                                return <Tech />;
                            case 'hrSituation':
                                return <HrSituation />;
                        };
                    })()}
                </div>
            </div>
        )
    }
});

export default Content;
