import React, { Component } from 'react';
import { SnackbarHOC } from 'educoder';
import { Route, Switch } from 'react-router-dom';
import Loadable from 'react-loadable';
import Loading from '../../Loading';
import { CNotificationHOC } from './common/CNotificationHOC'
import "./css/Courses.css"
//引入对应跳转的组件
const ListPageIndex = Loadable({
  loader: () => import('./ListPageIndex'),
  loading: Loading,
})
// 讨论
const BoardsNew = Loadable({
  loader: () => import('./boards/BoardsNew'),
  loading: Loading,
})
const TopicDetail = Loadable({
  loader: () => import('./boards/TopicDetail'),
  loading: Loading,
})

class CoursesIndex extends Component {

  render() {

    return (
      <Switch {...this.props}>
        {/*课堂讨论*/}
        <Route exact path="/classrooms/:coursesId/boards/:boardId/messages/:topicId/edit"
          render={
            (props) => (<BoardsNew {...this.props} {...props} {...this.state} />)
          }
        ></Route>
        <Route exact path="/classrooms/:coursesId/boards/:boardId/messages/new"
          render={
            (props) => (<BoardsNew {...this.props} {...props} {...this.state} />)
          }
        ></Route>
        <Route exact path="/classrooms/:coursesId/boards/:boardId/messages/:topicId"
          render={
            (props) => (<TopicDetail {...this.props} {...this.state} {...props} />)
          }
        ></Route>
        <Route exact path="/classrooms/:coursesId/boards/:boardId/messages/:topicId"
          render={
            (props) => (<TopicDetail {...this.props} {...this.state} {...props} />)
          }
        ></Route>
        <Route exact path="/classrooms/:coursesId/boards/:boardId"
          render={
            (props) => (<ListPageIndex {...this.props} {...props} {...this.state} />)
          }
        ></Route>

      </Switch>
    )
  }
}

export default CNotificationHOC()(SnackbarHOC()((CoursesIndex)));
