import React from 'react';

import { Route, Switch } from "react-router-dom";
import Loadable from "react-loadable";
import Loading from "../../Loading";
import { withRouter } from "react-router";
import { SnackbarHOC } from "educoder";
import { CNotificationHOC } from "../../modules/courses/common/CNotificationHOC";
import { TPMIndexHOC } from "../../modules/tpm/TPMIndexHOC";
import '../css/index.scss';
import './Index.scss';

const GroupNew = Loadable({
  loader: () => import("./Group/GroupNew"),
  loading: Loading,
});
const New = Loadable({
  loader: () => import("./New"),
  loading: Loading,
});
const DetailIndex = Loadable({
  loader: () => import("./Sub/Detail"),
  loading: Loading,
});
const SubDetailIndex = Loadable({
  loader: () => import("./Sub/SubDetail"),
  loading: Loading,
});
// forge项目详情
const ProjectDetail = Loadable({
  loader: () => import("../Main/Detail"),
  loading: Loading,
});
export default withRouter(CNotificationHOC()(SnackbarHOC()(TPMIndexHOC(
  ((props)=>{
    return (
      <div className="newMain">
        <Switch>
          {/* 新建组织 */}
          <Route
            path="/organize/new"
            render={(p) => {
              return <New {...props}  {...p}/>
            }}
          ></Route>
          {/* 组织团队-新建 */}
          <Route
            path="/:OIdentifier/teams/new"
            render={(p) => {
              return <GroupNew {...props} {...p}/>
            }}
          ></Route>
          {/* 组织团队-设置 */}
          <Route
            path="/:OIdentifier/teams/:groupId/setting"
            render={(p) => {
              return <SubDetailIndex {...props} {...p}/>
            }}
          ></Route>
          {/* 组织团队-子级（包含组织团队列表） */}
          <Route
            path="/:OIdentifier/teams"
            render={(p) => {
              return <DetailIndex {...props}  {...p}/>
            }}
          ></Route>
          {/* 组织成员 */}
          <Route
            path="/:OIdentifier/members"
            render={(p) => {
              return <DetailIndex {...props}  {...p}/>
            }}
          ></Route>
          

          {/* 组织详情（包含组织设置） */}
          <Route
            path="/:OIdentifier/setting"
            render={(p) => (
              <DetailIndex {...props} {...p}/>
            )}
          ></Route>

          {/* 组织下的项目详情 */}
          <Route
          path="/:owner/:projectsId"
          render={(p) => (
            <ProjectDetail  {...props} {...p} />
          )}
        ></Route> 

          {/* 组织详情（包含组织设置） */}
          <Route
            path="/:OIdentifier"
            render={(p) => (
              <DetailIndex {...props} {...p}/>
            )}
          ></Route>
        </Switch>
      </div>
    )
  })
))))