import React, { useEffect, useState } from "react";

import { Route, Switch } from "react-router-dom";
import { withRouter } from "react-router";
import { SnackbarHOC } from "educoder";
import { CNotificationHOC } from "../modules/courses/common/CNotificationHOC";
import { TPMIndexHOC } from "../modules/tpm/TPMIndexHOC";
import Loadable from "react-loadable";
import Loading from "../Loading";
import AdminRouter from "./components/adminRouter";
import { ImageLayerOfCommentHOC } from "../modules/page/layers/ImageLayerOfCommentHOC";
import './index.scss';

{/* 任务管理审核 */}
const TaskManage = Loadable({
  loader: () => import("./task/taskManage"),
  loading: Loading,
});

{/* 成果管理审核 */}
const PaperManage = Loadable({
  loader: () => import("./task/paperManage"),
  loading: Loading,
});

{/* 成果申诉管理审核 */}
const PaperComplain = Loadable({
  loader: () => import("./task/paperComplain"),
  loading: Loading,
});

const ProofManage = Loadable({
  loader: () => import("./task/proofManage"),
  loading: Loading,
});

const PublicityComplain = Loadable({
  loader: () => import("./task/publicityComplain"),
  loading: Loading,
});

const AgreementManage = Loadable({
  loader: () => import("./task/agreementManage"),
  loading: Loading,
});

// 协议签订模板
const AgreementContent = Loadable({
  loader: () => import("./task/agreementContent"),
  loading: Loading,
});

const PayProof = Loadable({
  loader: () => import("./task/payProof"),
  loading: Loading,
});

const TaskAdmin = Loadable({
  loader: () => import("./task/taskAdmin"),
  loading: Loading,
});

const DelayManage = Loadable({
  loader: () => import("./task/delayManage"),
  loading: Loading,
});



// 专家库
const ExpertList = Loadable({
  loader: () => import("./expert/expertList"),
  loading: Loading,
});
// 专家审核
const RegisterList = Loadable({
  loader: () => import("./expert/registerList"),
  loading: Loading,
});
//创客任务评审规则
const ReviewRules = Loadable({
  loader : () => import("./expert/reviewRules"),
  loading: Loading,
});
//创客任务选择评审专家
const SelectExpert = Loadable({
  loader: () => import("./expert/selectExpert"),
  loading: Loading,
});
//创客任务评审结果查看
const ReviewResult = Loadable({
  loader: () => import("./expert/reviewResult"),
  loading: Loading,
});
//竞赛评审任务列表
const CompetitionList = Loadable({
  loader: () => import("./expert/competionList"),
  loading: Loading,
})

const Managements = (propsF) => {

  return (
    <div className="newMain clearfix">
      <AdminRouter {...propsF} />
      <Switch {...propsF}>
        {/* 任务管理审核 */}
        <Route
          path="/managements/task/taskManage/:publishMode"
          render={(props) => (
            <TaskManage {...propsF} {...props} />
          )}
        ></Route>

        {/* 成果管理审核 */}
        <Route
          path="/managements/task/paperManage"
          render={(props) => (
            <PaperManage {...propsF} {...props} />
          )}
        ></Route>

        {/* 成果申诉管理审核 */}
        <Route
          path="/managements/task/paperComplain"
          render={(props) => (
            <PaperComplain {...propsF} {...props} />
          )}
        ></Route>

        {/* 公示期成果申诉管理审核 */}
        <Route
          path="/managements/task/publicityComplain"
          render={(props) => (
            <PublicityComplain {...propsF} {...props} />
          )}
        ></Route>

        {/* 佐证管理审核 */}
        <Route
          path="/managements/task/proofManage"
          render={(props) => (
            <ProofManage {...propsF} {...props} />
          )}
        ></Route>

        {/* 管理员协议审核 */}
        <Route
          path="/managements/task/agreementManage"
          render={(props) => (
            <AgreementManage {...propsF} {...props} />
          )}
        ></Route>

         {/* 协议内容 */}
         <Route
          path="/managements/task/agreement/content"
          render={(props) => (
            <AgreementContent {...propsF} {...props} />
          )}
        ></Route>

        {/* 管理员上传支付凭证 */}
        <Route
          path="/managements/task/payProof"
          render={(props) => (
            <PayProof {...propsF} {...props} />
          )}
        ></Route>

        {/* 管理员任务列表 */}
        <Route
          path="/managements/task/taskAdmin"
          render={(props) => (
            <TaskAdmin {...propsF} {...props} />
          )}
        ></Route>

        {/* 延期管理 */}
        <Route
          path="/managements/task/delayManage"
          render={(props) => (
            <DelayManage {...propsF} {...props} />
          )}
        ></Route>



        {/* 专家审核 */}
        <Route
          path="/managements/expert/register"
          render={(props) => (
            <RegisterList {...propsF} {...props} />
          )}
        ></Route>
        {/* 专家库列表 */}
        <Route
          path="/managements/expert/list"
          render={(props) => (
            <ExpertList {...propsF} {...props} />
          )}
        ></Route>
        {/* 创客任务评审规则 */}
        <Route
          path="/managements/expert/task/review/rules/:containerType/:containerId"
          render={(props) => (
            <ReviewRules {...propsF} {...props} />
          )}
        ></Route>
        {/* 创客任务选择评审专家 */}
        <Route
          path="/managements/expert/task/review/select/:containerType/:containerId"
          render={(props) => (
            <SelectExpert {...propsF} {...props} />
          )}
        ></Route>
        {/* 创客任务评审结果查看 */}
        <Route
          path="/managements/expert/task/review/results/:containerType/:containerId"
          render={(props) => (
            <ReviewResult {...propsF} {...props} />
          )}
        ></Route>
        {/* 竞赛评审任务列表 */}
        <Route
          path="/managements/expert/competition"
          render={(props) => (
            <CompetitionList {...propsF} {...props} />
          )}
        ></Route>
      </Switch>
    </div>
  );
}

export default withRouter(
  ImageLayerOfCommentHOC({
    imgSelector: ".imageLayerParent img, .imageLayerParent .imageTarget",
    parentSelector: ".newMain",
  })(CNotificationHOC()(SnackbarHOC()(TPMIndexHOC(Managements))))
);
