import { Affix, Col, Menu, Row, type MenuProps } from "antd";
import {
  FileSearchOutlined,
  AlertOutlined,
  CarryOutOutlined,
  SettingOutlined,
  FileProtectOutlined,
  SyncOutlined
} from "@ant-design/icons";
import Box from "../components/Box";
import { useState } from "react";
import VqdTaskPage from "../components/VqdTask";
import VqdCheckTaskPage from "../components/VqdPolling";
import VqdTaskTemplatePage from "../components/VqdTaskTemplate";
import VqdTimeTemplatePage from "../components/VqdTimeTemplate";
import VqdAlarmPage from "../components/VqdAlarm";
import VqdConfigPage from "../components/VqdConfig";

type MenuItem = Required<MenuProps>["items"][number];
export default function Home() {
  const [currentMenu, setCurrentMenu] = useState("sub0");

  const items: MenuItem[] = [
    {
      key: "sub0",
      label: "视频诊断任务",
      icon: <FileSearchOutlined />,
    },
    {
      key: "sub1",
      label: "轮询诊断任务",
      icon: <SyncOutlined />,
    },
    {
      key: "sub2",
      label: "诊断结果查询",
      icon: <AlertOutlined />,
    },
    {
      key: "sub3",
      label: "诊断时间管理",
      icon: <CarryOutOutlined />,
    },
    {
      key: "sub4",
      label: "诊断参数设置",
      icon: <FileProtectOutlined />,
    },
    {
      key: "sub5",
      label: "基础配置",
      icon: <SettingOutlined />,
    },
  ];

  const onClickMenu = (item: any) => {
    setCurrentMenu(item?.key as string);
  };

  return (
    <Row gutter={16}>
      <Col sm={24} md={24} lg={3} xl={3} xxl={3} className="w-full">
        <Affix className="hidden lg:block" offsetTop={0}>
          <Box
            className="mr-0 px-0"
          >
            <Menu
              className="litegbs-menu-item select-none"
              key={"config"}
              selectedKeys={[currentMenu]}
              onClick={onClickMenu}
              items={items}
            />
          </Box>
        </Affix>
        <Box
          className="mr-0 px-0 block lg:hidden"
        >
          <Menu
            className="litegbs-menu-item"
            key={"config"}
            selectedKeys={[currentMenu]}
            onClick={onClickMenu}
            items={items}
          />
        </Box>
      </Col>
      <Col sm={24} md={24} lg={21} xl={21} xxl={21} className="w-full">
        {/* <Col sm={24} md={24}  className="w-full"> */}
        {currentMenu == "sub0" && (
          <Box>
            <VqdTaskPage />
          </Box>
        )}
        {currentMenu == "sub1" && (
          <Box>
            <VqdCheckTaskPage />
          </Box>
        )}
        {currentMenu == "sub2" && (
          <Box>
            <VqdAlarmPage />
          </Box>
        )}
        {currentMenu == "sub3" && (
          <Box>
            <VqdTimeTemplatePage />
          </Box>
        )}
        {currentMenu == "sub4" && (
          <Box>
            <VqdTaskTemplatePage />
          </Box>
        )}
        {currentMenu == "sub5" && (
          <Box>
            <VqdConfigPage />
          </Box>
        )}
      </Col>
    </Row>
  );
}
