fix: SettingTextField radiogroup bug

This commit is contained in:
IlyaDoronin 2023-10-04 14:56:51 +03:00
parent 4e92fb934a
commit fffc20b16f

@ -67,31 +67,16 @@ export default function SettingTextField({
<RadioGroup <RadioGroup
aria-labelledby="demo-controlled-radio-buttons-group" aria-labelledby="demo-controlled-radio-buttons-group"
name="controlled-radio-buttons-group" name="controlled-radio-buttons-group"
value={ANSWER_TYPES.findIndex(({ value }) => { value={ANSWER_TYPES.findIndex(
switch (value) { ({ value }) => question.content.answerType === value
case "multi": )}
return value === "multi";
case "number":
return value === "number";
case "single":
return value === "single";
default:
return false;
}
})}
onChange={({ target }: React.ChangeEvent<HTMLInputElement>) => { onChange={({ target }: React.ChangeEvent<HTMLInputElement>) => {
const clonedContent = { updateQuestionsList<QuizQuestionText>(quizId, totalIndex, {
...question.content, content: {
single: false, ...question.content,
multi: false, answerType: ANSWER_TYPES[Number(target.value)].value,
number: false, },
[ANSWER_TYPES[Number(target.value)].value]: true, });
};
updateQuestionsList<QuizQuestionText>(quizId, totalIndex, { content: clonedContent });
}} }}
> >
{ANSWER_TYPES.map(({ name }, index) => ( {ANSWER_TYPES.map(({ name }, index) => (