import { useEffect } from "react";
import { Box, Button, Typography, useTheme } from "@mui/material";
import CustomCheckbox from "@ui_kit/CustomCheckbox";
import { questionStore, updateQuestionsList } from "@root/questions";
import InfoIcon from "../../../assets/icons/InfoIcon";
import FormatIcon2 from "../../../assets/icons/questionsPage/FormatIcon2";
import FormatIcon1 from "../../../assets/icons/questionsPage/FormatIcon1";
import ProportionsIcon11 from "../../../assets/icons/questionsPage/ProportionsIcon11";
import ProportionsIcon21 from "../../../assets/icons/questionsPage/ProportionsIcon21";
import ProportionsIcon12 from "../../../assets/icons/questionsPage/ProportionsIcon12";
interface Props {
Icon: React.ElementType;
isActive?: boolean;
onClick: () => void;
}
type SettingOpytionsPictProps = {
totalIndex: number;
};
const PROPORTIONS = [
{ value: "1:1", icon: ProportionsIcon11 },
{ value: "2:1", icon: ProportionsIcon21 },
{ value: "1:2", icon: ProportionsIcon12 },
];
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: "auto",
minWidth: 0,
"& .MuiButton-startIcon": {
mr: 0,
ml: 0,
},
"&:hover": {
border: "none",
borderColor: isActive
? theme.palette.brightPurple.main
: theme.palette.grey2.main,
},
}}
/>
);
}
export default function SettingOpytionsPict({
totalIndex,
}: SettingOpytionsPictProps) {
const { listQuestions } = questionStore();
useEffect(() => {
if (!listQuestions[totalIndex].content.xy) {
updateProportions("1:1");
}
}, []);
const updateProportions = (proportions: string) => {
const clonContent = listQuestions[totalIndex].content;
clonContent.xy = proportions;
updateQuestionsList(totalIndex, { content: clonContent });
};
return (
<>
Пропорции
{PROPORTIONS.map(({ value, icon }, index) => (
updateProportions(value)}
isActive={listQuestions[totalIndex].content.xy === value}
Icon={icon}
/>
))}
Настройки ответов
updateQuestionsList(totalIndex, {
content: {
...listQuestions[totalIndex].content,
multi: !listQuestions[totalIndex].content.multi,
},
})
}
/>
updateQuestionsList(totalIndex, {
content: {
...listQuestions[totalIndex].content,
largeCheck: !listQuestions[totalIndex].content.largeCheck,
},
})
}
/>
Форма
updateQuestionsList(totalIndex, {
content: {
...listQuestions[totalIndex].content,
format: "carousel",
},
})
}
isActive={listQuestions[totalIndex].content.format === "carousel"}
Icon={FormatIcon2}
/>
updateQuestionsList(totalIndex, {
content: {
...listQuestions[totalIndex].content,
format: "masonry",
},
})
}
isActive={listQuestions[totalIndex].content.format === "masonry"}
Icon={FormatIcon1}
/>
Настройки вопросов
>
);
}