2023-03-15 22:56:53 +00:00
|
|
|
|
import {Box, Typography} from "@mui/material";
|
|
|
|
|
import CustomCheckbox from "@ui_kit/CustomCheckbox";
|
2023-05-03 19:21:00 +00:00
|
|
|
|
import InfoIcon from "../../../assets/icons/InfoIcon";
|
2023-07-11 10:43:04 +00:00
|
|
|
|
import * as React from "react";
|
|
|
|
|
import CustomTextField from "@ui_kit/CustomTextField";
|
|
|
|
|
import {useParams} from "react-router-dom";
|
|
|
|
|
import {questionStore} from "@root/questions";
|
2023-03-15 22:56:53 +00:00
|
|
|
|
|
2023-07-11 10:43:04 +00:00
|
|
|
|
interface Props {
|
|
|
|
|
totalIndex: number,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default function ResponseSettings({totalIndex}: Props) {
|
|
|
|
|
const params = Number(useParams().quizId);
|
|
|
|
|
const {listQuestions, updateQuestionsList, createQuestion, removeQuestion} = questionStore()
|
|
|
|
|
const [checked, setChecked] = React.useState([true, false]);
|
|
|
|
|
const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
|
|
|
setChecked([checked[0], event.target.checked, ]);
|
|
|
|
|
};
|
2023-03-15 22:56:53 +00:00
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Box sx={{display: 'flex'}}>
|
2023-07-11 10:43:04 +00:00
|
|
|
|
<Box sx={{padding: '20px', display: 'flex', flexDirection: "column"}}>
|
2023-03-15 22:56:53 +00:00
|
|
|
|
<Typography>Настройки ответов</Typography>
|
|
|
|
|
<CustomCheckbox label={'Длинный текстовый ответ'}/>
|
2023-07-12 21:24:12 +00:00
|
|
|
|
<CustomCheckbox label={'Можно несколько'}
|
|
|
|
|
checked={listQuestions[params][totalIndex].content.multi}
|
|
|
|
|
handleChange={(e) => {
|
|
|
|
|
let clonContent = listQuestions[params][totalIndex].content
|
|
|
|
|
clonContent.multi = e.target.checked
|
|
|
|
|
updateQuestionsList(params, totalIndex, {content: clonContent})
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
<CustomCheckbox label={'Вариант "свой ответ"'}
|
|
|
|
|
checked={listQuestions[params][totalIndex].content.own}
|
|
|
|
|
handleChange={(e) => {
|
|
|
|
|
let clonContent = listQuestions[params][totalIndex].content
|
|
|
|
|
clonContent.own = e.target.checked
|
|
|
|
|
updateQuestionsList(params, totalIndex, {content: clonContent})
|
|
|
|
|
}}
|
|
|
|
|
/>
|
2023-03-15 22:56:53 +00:00
|
|
|
|
</Box>
|
2023-07-11 10:43:04 +00:00
|
|
|
|
<Box sx={{padding: '20px', display: 'flex', flexDirection: "column"}}>
|
2023-03-15 22:56:53 +00:00
|
|
|
|
<Typography>Настройки вопросов</Typography>
|
2023-07-11 10:43:04 +00:00
|
|
|
|
<CustomCheckbox label={'Необязательный вопрос'} checked={!(listQuestions[params][totalIndex].required)}
|
|
|
|
|
handleChange={(e) => {
|
|
|
|
|
updateQuestionsList(params, totalIndex, {required: !e.target.checked})
|
|
|
|
|
console.log(listQuestions[params][totalIndex].required)}}/>
|
|
|
|
|
<Box sx={{display: "flex"}}>
|
|
|
|
|
<CustomCheckbox label={'Внутреннее название вопроса'} checked={checked[1]} handleChange={handleChange}/> <InfoIcon />
|
|
|
|
|
</Box>
|
|
|
|
|
{checked[1] ?
|
|
|
|
|
<CustomTextField placeholder={"Развёрнутое описание вопроса"} text={listQuestions[params][totalIndex].description}
|
|
|
|
|
onChange={e => updateQuestionsList(params, totalIndex, {description: e.target.value})}/>
|
|
|
|
|
:
|
|
|
|
|
<></>
|
|
|
|
|
}
|
2023-03-15 22:56:53 +00:00
|
|
|
|
</Box>
|
|
|
|
|
</Box>
|
|
|
|
|
);
|
|
|
|
|
};
|