import {
Box,
Button,
Tooltip,
Typography,
useMediaQuery,
useTheme,
} from "@mui/material";
import { setQuestionInnerName, updateQuestion } from "@root/questions/actions";
import CustomCheckbox from "@ui_kit/CustomCheckbox";
import CustomTextField from "@ui_kit/CustomTextField";
import { useDebouncedCallback } from "use-debounce";
import InfoIcon from "../../../assets/icons/InfoIcon";
import FormatIcon1 from "../../../assets/icons/questionsPage/FormatIcon1";
import FormatIcon2 from "../../../assets/icons/questionsPage/FormatIcon2";
import ProportionsIcon11 from "../../../assets/icons/questionsPage/ProportionsIcon11";
import ProportionsIcon12 from "../../../assets/icons/questionsPage/ProportionsIcon12";
import ProportionsIcon21 from "../../../assets/icons/questionsPage/ProportionsIcon21";
import type { QuizQuestionImages } from "../../../model/questionTypes/images";
type Proportion = "1:1" | "2:1" | "1:2";
type ProportionItem = {
value: Proportion;
icon: (props: { color: string; }) => JSX.Element;
};
const PROPORTIONS: ProportionItem[] = [
{ value: "1:1", icon: ProportionsIcon11 },
{ value: "2:1", icon: ProportionsIcon21 },
{ value: "1:2", icon: ProportionsIcon12 },
];
type SettingOpytionsPictProps = {
question: QuizQuestionImages;
};
export default function SettingOpytionsPict({ question }: SettingOpytionsPictProps) {
const theme = useTheme();
const isTablet = useMediaQuery(theme.breakpoints.down(985));
const isMobile = useMediaQuery(theme.breakpoints.down(790));
const isFigmaTablte = useMediaQuery(theme.breakpoints.down(990));
const debounced = useDebouncedCallback((value) => {
setQuestionInnerName(question.id, value);
}, 200);
const updateProportions = (proportions: Proportion) => {
updateQuestion(question.id, question => {
if (question.type !== "images") return;
question.content.xy = proportions;
});
};
return (
<>
{/*
Пропорции
{PROPORTIONS.map(({ value, icon }, index) => (
updateProportions(value)}
isActive={question.content.xy === value}
Icon={icon}
/>
))}
Настройки ответов
updateQuestion(question.id, question => {
if (question.type !== "images") return;
question.content.multi = target.checked;
})
}
/>
{question.content.xy !== "1:1" &&
question.content.format !== "masonry" && (
updateQuestion(question.id, question => {
if (question.type !== "images") return;
question.content.largeCheck = target.checked;
})
}
/>
)}
updateQuestion(question.id, question => {
if (question.type !== "images") return;
question.content.own = target.checked;
})
}
/>
*/}
{/*
Формат
updateQuestion(question.id, question => {
if (question.type !== "images") return;
question.content.format = "carousel";
})
}
isActive={question.content.format === "carousel"}
Icon={FormatIcon2}
/>
updateQuestion(question.id, question => {
if (question.type !== "images") return;
question.content.format = "masonry";
})
}
isActive={question.content.format === "masonry"}
Icon={FormatIcon1}
/>
*/}
Настройки вопросов
updateQuestion(question.id, question => {
if (question.type !== "images") return;
question.content.required = !target.checked;
})
}
/>
{/**/}
{/* updateQuestion(question.id, question => {*/}
{/* if (question.type !== "images") return;*/}
{/* question.content.innerNameCheck = target.checked;*/}
{/* question.content.innerName = "";*/}
{/* })*/}
{/* }*/}
{/* />*/}
{/* */}
{/* */}
{/* */}
{/* */}
{/* */}
{/**/}
{/*{question.content.innerNameCheck && (*/}
{/* debounced(target.value)}*/}
{/* />*/}
{/*)}*/}
>
);
}
interface Props {
Icon: (props: { color: string; }) => JSX.Element;
// Icon: React.ElementType;
isActive?: boolean;
onClick: () => void;
}
export function SelectIconButton({ Icon, isActive = false, onClick }: Props) {
const theme = useTheme();
return (
}
sx={{
backgroundColor: isActive ? theme.palette.brightPurple.main : "#eee4fc",
borderRadius: 0,
border: "none",
color: isActive
? theme.palette.brightPurple.main
: theme.palette.grey2.main,
p: "7px",
width: "40px",
height: "40px",
minWidth: 0,
"& .MuiButton-startIcon": {
mr: 0,
ml: 0,
},
"&:hover": {
border: "none",
borderColor: isActive
? theme.palette.brightPurple.main
: theme.palette.grey2.main,
},
}}
/>
);
}