import { Box, Tooltip, Typography, useMediaQuery, useTheme } from "@mui/material";
import { useState } from "react";
import InfoIcon from "@/assets/icons/InfoIcon";
import ButtonsOptions from "../ButtonsOptions";
import SwitchData from "./switchData";
import TooltipClickInfo from "@ui_kit/Toolbars/TooltipClickInfo";
import { QuizQuestionDate } from "@frontend/squzanswerer";

interface Props {
  question: QuizQuestionDate;
  openBranchingPage: boolean;
  setOpenBranchingPage: (a: boolean) => void;
}

export default function DateOptions({ question, openBranchingPage, setOpenBranchingPage }: Props) {
  const [switchState, setSwitchState] = useState("setting");
  const theme = useTheme();
  const isMobile = useMediaQuery(theme.breakpoints.down(790));

  return (
    <>
      <Box
        sx={{
          width: isMobile ? "auto" : "100%",
          maxWidth: "493px",
          display: "flex",
          pl: "20px",
          pr: "20px",
          flexDirection: "column",
          gap: isMobile ? "18px" : "20px",
        }}
      >
        <Box
          sx={{
            display: "flex",
            alignItems: "flex-start",
            gap: "12px",
            mb: "20px",
          }}
        >
          <Typography
            sx={{
              fontWeight: 400,
              fontSize: "16px",
              lineHeight: "18.96px",
              color: theme.palette.grey2.main,
            }}
          >
            Пользователю будет предложено выбрать дату
          </Typography>
          {isMobile ? (
            <TooltipClickInfo title={"Выбор даты."} />
          ) : (
            <Tooltip
              title="Выбор даты."
              placement="top"
            >
              <Box>
                <InfoIcon />
              </Box>
            </Tooltip>
          )}
        </Box>
      </Box>
      <ButtonsOptions
        switchState={switchState}
        setSwitchState={setSwitchState}
        questionId={question.id}
        questionContentId={question.content.id}
        questionType={question.type}
        questionHasParent={question.content.rule.parentId?.length !== 0}
        setOpenBranchingPage={setOpenBranchingPage}
      />
      <SwitchData
        switchState={switchState}
        question={question}
      />
    </>
  );
}
