import { ChangeEvent, useState } from "react"; import { Box, Button, ButtonBase, Checkbox, FormControl, FormControlLabel, MenuItem, Select, Tooltip, Typography, useMediaQuery, useTheme, } from "@mui/material"; import { createPortal } from "react-dom"; import CustomCheckbox from "@ui_kit/CustomCheckbox"; import AlignLeftIcon from "@icons/AlignLeftIcon"; import AlignRightIcon from "@icons/AlignRightIcon"; import ArrowDown from "@icons/ArrowDownIcon"; import InfoIcon from "@icons/InfoIcon"; import LayoutCenteredIcon from "@icons/LayoutCenteredIcon"; import LayoutExpandedIcon from "@icons/LayoutExpandedIcon"; import LayoutStandartIcon from "@icons/LayoutStandartIcon"; import MobilePhoneIcon from "@icons/MobilePhoneIcon"; import UploadIcon from "../../assets/icons/UploadIcon"; import SelectableButton from "@ui_kit/SelectableButton"; import SelectableIconButton from "./SelectableIconButton"; import UploadBox from "@ui_kit/UploadBox"; import CustomTextField from "@ui_kit/CustomTextField"; import { quizStore } from "@root/quizes"; import { useParams } from "react-router-dom"; import * as React from "react"; import ModalSizeImage from "./ModalSizeImage"; import { DropZone } from "./dropZone"; import Extra from "./extra"; import AlignCenterIcon from "@icons/AlignCenterIcon"; import DropFav from "./dropfavicon"; import { createQuestion } from "@root/questions"; import { StartPagePreview } from "@ui_kit/StartPagePreview"; const designTypes = [ [ "standard", (color: string) => , "Standard", ], [ "expanded", (color: string) => , "Expanded", ], [ "centered", (color: string) => , "Centered", ], ] as const; // type DesignType = typeof designTypes[number][0]; type BackgroundType = "image" | "video"; type AlignType = "left" | "right" | "center"; export default function StartPageSettings() { const [alignType, setAlignType] = useState("left"); const [formState, setFormState] = useState<"design" | "content">("design"); const { listQuizes, updateQuizesList, removeQuiz, createBlank } = quizStore(); const params = Number(useParams().quizId); const theme = useTheme(); const designType = listQuizes[params].startpage; const [backgroundType, setBackgroundType] = useState( listQuizes[params].config.startpage.background.type ); const isSmallMonitor = useMediaQuery(theme.breakpoints.down(1500)); const isTablet = useMediaQuery(theme.breakpoints.down(950)); const handleNext = () => { updateQuizesList(params, { step: listQuizes[params].step + 1 }); }; const videoHC = (videoInp: HTMLInputElement) => { const file = videoInp.files?.[0]; if (file) { setVideo(URL.createObjectURL(file)); } }; const [video, setVideo] = React.useState(""); const mutationHC = (e: ChangeEvent) => { let SPageClone = listQuizes[params].config; SPageClone.startpage.description = e.target.value; updateQuizesList(params, { config: SPageClone }); }; const mutationButtonHC = (e: ChangeEvent) => { let SPageClone = listQuizes[params].config; SPageClone.startpage.button = e.target.value; updateQuizesList(params, { config: SPageClone }); }; const mutationPhoneHC = (e: ChangeEvent) => { let SPageClone = listQuizes[params].config; SPageClone.info.phonenumber = e.target.value; updateQuizesList(params, { config: SPageClone }); }; const mutationSiteHC = (e: ChangeEvent) => { let SPageClone = listQuizes[params].config; SPageClone.info.site = e.target.value; updateQuizesList(params, { config: SPageClone }); }; const mutationLawHC = (e: ChangeEvent) => { let SPageClone = listQuizes[params].config; SPageClone.info.law = e.target.value; updateQuizesList(params, { config: SPageClone }); }; const mutationOrgNameHC = (e: ChangeEvent) => { let SPageClone = listQuizes[params].config; SPageClone.info.orgname = e.target.value; updateQuizesList(params, { config: SPageClone }); }; const mutationPositionHC = (e: ChangeEvent) => { let SPageClone = listQuizes[params].config; SPageClone.startpage.position = e.target.value; updateQuizesList(params, { config: SPageClone }); }; const [mobileVersion, setMobileVersion] = React.useState(false); const MobileVersionHC = (bool: boolean) => { setMobileVersion(bool); }; return ( <> Стартовая страница {isSmallMonitor && ( )} {(!isSmallMonitor || (isSmallMonitor && formState === "design")) && ( Дизайн Фон { setBackgroundType("image"); let SPageClone = listQuizes[params].config; SPageClone.startpage.background.type = "image"; updateQuizesList(params, { config: SPageClone }); }} > Изображение { setBackgroundType("video"); let SPageClone = listQuizes[params].config; SPageClone.startpage.background.type = "video"; updateQuizesList(params, { config: SPageClone }); }} > Видео Изображение } checkedIcon={} /> } label="мобильная версия" sx={{ color: theme.palette.brightPurple.main, textDecorationLine: "underline", textDecorationColor: theme.palette.brightPurple.main, ml: "-9px", userSelect: "none", }} onClick={() => { MobileVersionHC(!mobileVersion); }} /> {mobileVersion ? ( Изображение для мобильной версии ) : ( <> )} Добавить видео videoHC(event.target)} hidden accept=".mp4" multiple type="file" /> } sx={{ height: "48px", width: "48px", marginBottom: "20px", }} /> {video ? Расположение элементов { setAlignType("left"); let SPageClone = listQuizes[params].config; SPageClone.startpage.position = "ltr"; updateQuizesList(params, { config: SPageClone }); }} isActive={alignType === "left"} Icon={AlignLeftIcon} /> { setAlignType("center"); let SPageClone = listQuizes[params].config; SPageClone.startpage.position = "cnt"; updateQuizesList(params, { config: SPageClone }); }} isActive={alignType === "center"} Icon={AlignCenterIcon} sx={{ display: designType === "centered" ? "flex" : "none" }} /> { setAlignType("right"); let SPageClone = listQuizes[params].config; SPageClone.startpage.position = "rtl"; updateQuizesList(params, { config: SPageClone }); }} isActive={alignType === "right"} Icon={AlignRightIcon} /> {(isTablet || !isSmallMonitor) && ( <> Логотип Favicon 5 MB максимум )} )} {/*Правая сторона*/} {!isTablet && isSmallMonitor && formState === "design" && ( <> Логотип Favicon 5 MB максимум )} {(!isSmallMonitor || (isSmallMonitor && formState === "content")) && ( <> Заголовок updateQuizesList(params, { name: e.target.value }) } /> Текст Текст кнопки Телефон { let SPageClone = listQuizes[params].config; SPageClone.info.clickable = e.target.checked; updateQuizesList(params, { config: SPageClone }); }} /> Название или слоган компании Сайт Юридическая информация )} {isSmallMonitor && ( {formState === "content" && ( )} {formState === "design" && ( )} )} Отключить стартовую страницу } checkedIcon={ } sx={{ borderRadius: 0, padding: 0, }} onChange={(e) => { let SPageClone = listQuizes[params].config; SPageClone.noStartPage = e.target.checked; updateQuizesList(params, { config: SPageClone }); }} checked={listQuizes[params].config.noStartPage} /> } label="" sx={{ color: theme.palette.brightPurple.main, margin: "0", userSelect: "none", justifyContent: "flex-end", }} /> {createPortal(, document.body)} ); } function IconCheck() { return ( ); }