import { Box, useMediaQuery, useTheme } from "@mui/material";
import { FC } from "react";
import { StepButtonsBlock } from "./StepButtonsBlock";
import { CustomSelect } from "../../../../components/CustomSelect/CustomSelect";
import { CustomRadioGroup } from "../../../../components/CustomRadioGroup/CustomRadioGroup";
import { MinifiedData } from "./types";
import { ModalTitle } from "./ModalTitle";

type Props = {
  users: MinifiedData[];
  steps: MinifiedData[];
  handlePrevStep: () => void;
  handleNextStep: () => void;
  selectedDealUser: string | null;
  setSelectedDealPerformer: (value: string | null) => void;
  selectedStep: string | null;
  setSelectedStep: (value: string | null) => void;

  titleProps: {
    step: number;
    title: string;
    desc: string;
    toSettings: () => void;
  }
  onScroll: () => void;
  onScrollUsers: () => void;
};

export const PipelineSteps: FC<Props> = ({
  users,
  selectedDealUser,
  setSelectedDealPerformer,

  steps,
  selectedStep,
  setSelectedStep,
  onScroll,
  onScrollUsers,


  handlePrevStep,
  handleNextStep,

  titleProps
}) => {
  const theme = useTheme();
  const isMobile = useMediaQuery(theme.breakpoints.down(600));
  const isTablet = useMediaQuery(theme.breakpoints.down(1000));

  return (
    <>
      <Box
        sx={{
          display: "flex",
          flexDirection: "column",
          alignItems: "center",
          height: "100%",
          overflow: "auto",
          flexGrow: 1,
        }}
      >
        <Box
          sx={{
            height: "100%",
            overflow: "auto",
            zIndex: 3,
            width: "100%",
          }}>
          <Box sx={{ width: "100%", zIndex: 3 }}>
            <ModalTitle
              {...titleProps}
            />
            <CustomSelect
              items={users}
              selectedItemId={selectedDealUser}
              setSelectedItem={setSelectedDealPerformer}
              handleScroll={onScrollUsers}
            />
          </Box>
          <Box
            sx={{
              marginTop: "13px",
              flexGrow: 1,
              width: "100%",
            }}
          >
            <CustomRadioGroup
              items={steps}
              selectedItemId={selectedStep}
              setSelectedItem={setSelectedStep}
              handleScroll={onScroll}
            />
          </Box>
        </Box>
        <Box
          sx={{
            alignSelf: "end",
          }}
        >
          <StepButtonsBlock
            onLargeBtnClick={handleNextStep}
            onSmallBtnClick={handlePrevStep}
          />
        </Box>
      </Box>
    </>
  );
};
