import { Affix, Col, Menu, Row, type MenuProps } from "antd";
import {
  FileSearchOutlined,
  UnorderedListOutlined,
} from "@ant-design/icons";
import Box from "../components/Box";
import { useState } from "react";
import AudioEncodePage from "../components/AudioEncode";
import AudioTaskPage from "../components/AudioTask";

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: <UnorderedListOutlined />,
    },
  ];

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

  return (
    <Row gutter={16}>
      <div>
        <Affix className="hidden lg:block" offsetTop={0}>
          <Box
            style={{ minWidth: "10rem", width: "12rem" }}
            className="mr-0 px-0"
          >
            <Menu
              className="litegbs-menu-item select-none"
              key={"config"}
              selectedKeys={[currentMenu]}
              onClick={onClickMenu}
              items={items}
            />
          </Box>
        </Affix>
        <Box
          style={{ minWidth: "10rem", width: "12rem" }}
          className="mr-0 px-0 block lg:hidden"
        >
          <Menu
            className="litegbs-menu-item"
            key={"config"}
            selectedKeys={[currentMenu]}
            onClick={onClickMenu}
            items={items}
          />
        </Box>
      </div>
      <Col sm={24} md={24} lg={18} xl={18} xxl={18} className="w-full">
        {/* <Col sm={24} md={24}  className="w-full"> */}
        {currentMenu == "sub0" && (
          <Box>
            <AudioEncodePage />
          </Box>
        )}
        {currentMenu == "sub1" && (
          <Box>
            <AudioTaskPage />
          </Box>
        )}
      </Col>
    </Row>
  );
}
