diff --git a/src/pages/Questions/AnswerDraggableList/AnswerItem.tsx b/src/pages/Questions/AnswerDraggableList/AnswerItem.tsx index c8f45b0d..378d4f9f 100644 --- a/src/pages/Questions/AnswerDraggableList/AnswerItem.tsx +++ b/src/pages/Questions/AnswerDraggableList/AnswerItem.tsx @@ -19,12 +19,14 @@ import TextareaAutosize from "@mui/base/TextareaAutosize"; import type { ChangeEvent, KeyboardEvent } from "react"; import type { Variants } from "@root/questions"; +import { ReactNode } from "react"; type AnswerItemProps = { index: number; totalIndex: number; variants: Variants[]; variant: Variants; + icon?: ReactNode; }; export const AnswerItem = ({ @@ -32,6 +34,7 @@ export const AnswerItem = ({ totalIndex, variants, variant, + icon, }: AnswerItemProps) => { const { listQuestions } = questionStore(); const theme = useTheme(); @@ -105,12 +108,15 @@ export const AnswerItem = ({ } InputProps={{ startAdornment: ( - - - + <> + + + + {icon && icon} + ), endAdornment: ( diff --git a/src/pages/Questions/AnswerDraggableList/index.tsx b/src/pages/Questions/AnswerDraggableList/index.tsx index b766bcd7..897d3114 100644 --- a/src/pages/Questions/AnswerDraggableList/index.tsx +++ b/src/pages/Questions/AnswerDraggableList/index.tsx @@ -7,17 +7,20 @@ import { updateVariants } from "@root/questions"; import { reorder } from "./helper"; +import { ReactNode } from "react"; import type { DropResult } from "react-beautiful-dnd"; import type { Variants } from "@root/questions"; type AnswerDraggableListProps = { variants: Variants[]; totalIndex: number; + icon?: ReactNode; }; export const AnswerDraggableList = ({ variants, totalIndex, + icon, }: AnswerDraggableListProps) => { const onDragEnd = ({ destination, source }: DropResult) => { if (destination) { @@ -39,6 +42,7 @@ export const AnswerDraggableList = ({ totalIndex={totalIndex} variants={variants} variant={variant} + icon={icon} /> ))} {provided.placeholder} diff --git a/src/pages/Questions/Emoji/Emoji.tsx b/src/pages/Questions/Emoji/Emoji.tsx index d02652c2..a160b776 100644 --- a/src/pages/Questions/Emoji/Emoji.tsx +++ b/src/pages/Questions/Emoji/Emoji.tsx @@ -4,43 +4,50 @@ import ButtonsOptions from "../ButtonsOptions"; import SwitchEmoji from "./switchEmoji"; import React from "react"; import AddEmoji from "../../../assets/icons/questionsPage/addEmoji"; +import { AnswerDraggableList } from "../AnswerDraggableList"; +import { questionStore, updateQuestionsList } from "@root/questions"; interface Props { totalIndex: number; } export default function Emoji({ totalIndex }: Props) { - const theme = useTheme(); const [switchState, setSwitchState] = React.useState("setting"); + const { listQuestions } = questionStore(); + const theme = useTheme(); + const SSHC = (data: string) => { setSwitchState(data); }; + return ( <> - - - - Добавьте ответ - - + + + + } + /> { - // console.info("I'm a button."); - // }} + onClick={() => { + const answerNew = + listQuestions[totalIndex].content.variants.slice(); + answerNew.push({ answer: "", answerLong: "", hints: "" }); + + updateQuestionsList(totalIndex, { + content: { + ...listQuestions[totalIndex].content, + variants: answerNew, + }, + }); + }} > Добавьте ответ diff --git a/src/pages/Questions/Emoji/settingEmoji.tsx b/src/pages/Questions/Emoji/settingEmoji.tsx index 46bc0d10..92d3be87 100644 --- a/src/pages/Questions/Emoji/settingEmoji.tsx +++ b/src/pages/Questions/Emoji/settingEmoji.tsx @@ -1,21 +1,43 @@ -import {Box, Typography} from "@mui/material"; +import { Box, Typography } from "@mui/material"; import CustomCheckbox from "@ui_kit/CustomCheckbox"; import InfoIcon from "../../../assets/icons/InfoIcon"; +import { questionStore, updateQuestionsList } from "@root/questions"; +type SettingEmojiProps = { + totalIndex: number; +}; -export default function SettingEmoji() { - return ( - - - Настройки ответов - - - - - Настройки вопросов - - - - - ); -}; \ No newline at end of file +export default function SettingEmoji({ totalIndex }: SettingEmojiProps) { + const { listQuestions } = questionStore(); + + return ( + + + Настройки ответов + { + let clonContent = listQuestions[totalIndex].content; + clonContent.multi = e.target.checked; + updateQuestionsList(totalIndex, { content: clonContent }); + }} + /> + { + let clonContent = listQuestions[totalIndex].content; + clonContent.own = e.target.checked; + updateQuestionsList(totalIndex, { content: clonContent }); + }} + /> + + + Настройки вопросов + + + + + ); +} diff --git a/src/pages/Questions/Emoji/switchEmoji.tsx b/src/pages/Questions/Emoji/switchEmoji.tsx index a89579a6..7fda054b 100644 --- a/src/pages/Questions/Emoji/switchEmoji.tsx +++ b/src/pages/Questions/Emoji/switchEmoji.tsx @@ -14,7 +14,7 @@ export default function SwitchEmoji({ }: Props) { switch (switchState) { case "setting": - return ; + return ; break; case "help": return ;