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';
//新开发账户管理
import Account from './newAccount/account';
import Unit from './newAccount/unit';
import Personal from './newAccount/personal';
import Contacts from './newAccount/contacts';

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 />;
                            case 'account':
                                return <Account />;
                            case 'unit':
                                return <Unit />;
                            case 'personal':
                                return <Personal />;
                            case 'contacts':
                                return <Contacts />;    
                        };
                    })()}
                </div>
            </div>
        )
    }
});

export default Content;
