import { Box, Button, Typography, useMediaQuery, useTheme, } from "@mui/material"; import { setQuizStartpageType } from "@root/quizes/actions"; import { useCurrentQuiz } from "@root/quizes/hooks"; import cardImage1 from "../../assets/card-1.png"; import cardImage2 from "../../assets/card-2.png"; import cardImage3 from "../../assets/card-3.png"; import CardWithImage from "./CardWithImage"; import { useRef, useState, useEffect } from "react"; import arrowLeftIcon from "../../assets/icons/arrow_left.svg"; import arrowRightIcon from "../../assets/icons/arrow_right.svg"; export default function Steptwo() { const quiz = useCurrentQuiz(); const config = quiz?.config; const theme = useTheme(); const isSmallMonitor = useMediaQuery(theme.breakpoints.down(1300)); const isSlider = useMediaQuery(theme.breakpoints.down(1250)); const containerRef = useRef(null); const buttonRefs = useRef<(HTMLButtonElement | null)[]>([]); const [currentIndex, setCurrentIndex] = useState(0); useEffect(() => { if (containerRef.current && buttonRefs.current.length > 0) { const buttonWidth = buttonRefs.current[0]!.offsetWidth; containerRef.current.scrollTo({ left: currentIndex * buttonWidth, behavior: "smooth", }); } }, [currentIndex]); const handlePrevClick = () => { setCurrentIndex((prevIndex) => Math.max(prevIndex - 1, 0)); }; const handleNextClick = () => { setCurrentIndex((prevIndex) => Math.min(prevIndex + 1, 2)); }; if (!config) return null; return ( Стартовая страница {isSlider && ( <> )} ); }