import { Button, Modal } from "antd";
import { useContext } from "react";
import { Context } from "~/pages/Container/Map/js/context";
import AlarmEquipment from "./AlarmEquipment";
import BlindBoardWork from "./BlindBoardWork";
import BreakGroundWork from "./BreakgroundWork";
import ConfinedSpaceWork from "./ConfinedSpaceWork";
import CutRoadWork from "./CutRoadWork";
import ElectricityWork from "./ElectricityWork";
import FireControlRoom from "./FireControlRoom";
import FirePointLocation from "./FirePointLocation";
import FirePumpRoom from "./FirePumpRoom";
import FireRescueTeam from "./FireRescueTeam";
import FireWaterSource from "./FireWaterSource";
import HighWork from "./HighWork";
import HoistingWork from "./HoistingWork";
import HotWork from "./HotWork";
import KeyProject from "./KeyProject";
import MeteorologicalMonitoring from "./MeteorologicalMonitoring";
import VideoPlay from "./VideoPlay";

const CustomModal = () => {
  const { modalVisible, modalData, actions } = useContext(Context);

  const renderContent = () => {
    const markType = modalData.markType?.replace("标记点_", "");
    return {
      meteorologicalMonitoring: <MeteorologicalMonitoring />, // 气象监测
      fireRescueTeam: <FireRescueTeam id={modalData.id} />, // 消防救援队
      fireControlRoom: <FireControlRoom id={modalData.id} />, // 消防控制室
      firePumpRoom: <FirePumpRoom id={modalData.id} />, // 消防泵房
      fireWaterSource: <FireWaterSource id={modalData.id} />, // 消防水源
      firePointLocation: <FirePointLocation id={modalData.id} />, // 消防点位
      alarmEquipment: <AlarmEquipment id={modalData.id} />, // 报警设备
      hot_work: <HotWork id={modalData.id} workId={modalData.workId} />, // 动火作业
      confinedspace_work: <ConfinedSpaceWork id={modalData.id} workId={modalData.workId} />, // 受限空间作业
      electricity_work: <ElectricityWork id={modalData.id} workId={modalData.workId} />, // 临时用电作业
      high_work: <HighWork id={modalData.id} workId={modalData.workId} />, // 高处作业
      cutroad_work: <CutRoadWork id={modalData.id} workId={modalData.workId} />, // 断路作业
      breakground_work: <BreakGroundWork id={modalData.id} workId={modalData.workId} />, // 动土作业
      hoisting_work: <HoistingWork id={modalData.id} workId={modalData.workId} />, // 吊装作业
      blindboard_work: <BlindBoardWork id={modalData.id} workId={modalData.workId} />, // 盲板抽堵作业
      keyProject: <KeyProject id={modalData.id} />, // 重点工程定位
      video: <VideoPlay cameraNumber={modalData.cameraNumber} />, // 重点工程-视频定位
      platCamera: <VideoPlay cameraNumber={modalData.cameraNumber} />, // 视频巡屏-摄像头
    }[markType];
  };

  return (
    <Modal
      open={modalVisible}
      mask={{ closable: false }}
      footer={[
        <Button key="cancel" onClick={() => actions.resetMark()}>取消</Button>,
      ]}
      width={1500}
      onCancel={() => {
        actions.resetMark();
      }}
      title={modalData.title || ""}
      classNames={{ root: "map_bi_model" }}
    >
      <div key={modalData.id}>
        {renderContent()}
      </div>
    </Modal>
  );
};

export default CustomModal;
