Feature : Toggle Multi-Select and Single-Select Question Types

Feature : Toggle Multi-Select and Single-Select Question Types
This commit is contained in:
Johannes
2023-08-05 16:23:39 +02:00
committed by GitHub
3 changed files with 21 additions and 1 deletions

View File

@@ -223,6 +223,15 @@ export default function MultipleChoiceMultiForm({
Add "Other"
</Button>
)}
<Button
size="sm"
variant="minimal"
type="button"
onClick={() => {
updateQuestion(questionIdx, { type: "multipleChoiceSingle" });
}}>
Convert to Single Select
</Button>
<div className="flex flex-1 items-center justify-end gap-2">
<Select

View File

@@ -223,6 +223,15 @@ export default function MultipleChoiceSingleForm({
Add &quot;Other&quot;
</Button>
)}
<Button
size="sm"
variant="minimal"
type="button"
onClick={() => {
updateQuestion(questionIdx, { type: "multipleChoiceMulti" });
}}>
Convert to Multi Select
</Button>
<div className="flex flex-1 items-center justify-end gap-2">
<Select

View File

@@ -39,7 +39,8 @@ export default function MultipleChoiceMultiQuestion({
.map((choice) => choice.label);
useEffect(() => {
const nonOtherSavedChoices = storedResponseValue?.filter((answer) =>
if(Array.isArray(storedResponseValue)){
const nonOtherSavedChoices = storedResponseValue?.filter((answer) =>
nonOtherChoiceLabels.includes(answer)
);
const savedOtherSpecified = storedResponseValue?.find((answer) => !nonOtherChoiceLabels.includes(answer));
@@ -50,6 +51,7 @@ export default function MultipleChoiceMultiQuestion({
setOtherSpecified(savedOtherSpecified);
setShowOther(true);
}
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [storedResponseValue, question.id]);