import { FC, useEffect, useRef, useState } from "react";
import {
Box,
FormControl,
IconButton,
Popper,
TextField,
Typography,
} from "@mui/material";
import { People } from "@mui/icons-material";
import { SidebarModal } from "./SidebarModal";
import BackArrowIcon from "@icons/BackArrowIcon";
import { ChartLineUp } from "./icons/ChartLineUp";
import { ReturnTime } from "./icons/ReturnTime";
import { Question } from "./icons/Question";
import { Settings } from "./icons/Settings";
import { Pencil } from "./icons/Pencil";
import { ArrowDown } from "./icons/ArrowDown";
import Sidebar from "@ui_kit/Sidebar";
import { Link, useNavigate } from "react-router-dom";
import { updateQuiz } from "@root/quizes/actions";
import { useCurrentQuiz } from "@root/quizes/hooks";
interface Iprops {
open: boolean;
changePage: (step: number) => void;
}
const quizSetupSteps = [
{ sidebarIcon: },
{ sidebarIcon: },
{
sidebarIcon: ,
},
{
sidebarIcon: ,
},
{ sidebarIcon: },
] as const;
export const SidebarMobile: FC = ({ open, changePage }) => {
const [anchorEl, setAnchorEl] = useState(null);
const [inputOpen, setInputOpen] = useState(false);
const quiz = useCurrentQuiz();
const ref = useRef(null);
const handleClick = (event) => {
setAnchorEl(anchorEl ? null : event.currentTarget);
};
const clickInput = (event) => {
if (ref.current && !ref.current.contains(event.target)) setInputOpen(false);
};
useEffect(() => {
document.addEventListener("mousedown", clickInput);
return () => {
document.removeEventListener("mousedown", clickInput);
};
}, []);
const openPopper = Boolean(anchorEl);
const id = openPopper ? "simple-popper" : undefined;
return (
Название
{inputOpen ? (
updateQuiz(quiz.id, (quiz) => {
quiz.name = e.target.value;
})
}
fullWidth
id="project-name"
placeholder="Название проекта"
sx={{
width: "270px",
"& .MuiInputBase-root": {
height: "34px",
borderRadius: "8px",
p: 0,
},
}}
inputProps={{
sx: {
height: "20px",
borderRadius: "8px",
fontSize: "16px",
lineHeight: "20px",
p: "7px",
color: "white",
"&::placeholder": {
opacity: 1,
},
},
}}
/>
) : (
{quiz.name}
)}
setInputOpen(true)}>
{/*{quizSetupSteps.map(({ sidebarIcon }, index) => (*/}
{/* changePage(index)}*/}
{/* sx={{*/}
{/* cursor: "pointer",*/}
{/* width: "44px",*/}
{/* height: "44px",*/}
{/* background: "#262835",*/}
{/* display: "flex",*/}
{/* justifyContent: "center",*/}
{/* alignItems: "center",*/}
{/* borderRadius: "8px",*/}
{/* }}*/}
{/* >*/}
{/* {sidebarIcon}*/}
{/* */}
{/*))}*/}
);
};