mirror of
https://github.com/formbricks/formbricks.git
synced 2026-04-19 19:21:15 -05:00
fix: multi option multi choose can now not have same options
This commit is contained in:
@@ -199,7 +199,15 @@ export default function MultipleChoiceMultiForm({
|
||||
className={cn(choice.id === "other" && "border-dashed")}
|
||||
placeholder={choice.id === "other" ? "Other" : `Option ${choiceIdx + 1}`}
|
||||
onChange={(e) => updateChoice(choiceIdx, { label: e.target.value })}
|
||||
isInvalid={isInValid && choice.label.trim() === ""}
|
||||
isInvalid={
|
||||
isInValid &&
|
||||
(choice.label.trim() === "" ||
|
||||
question.choices.some((element, index) =>
|
||||
question.choices
|
||||
.slice(index + 1)
|
||||
.some((nextElement) => nextElement.label.trim() === element.label.trim())
|
||||
))
|
||||
}
|
||||
/>
|
||||
{question.choices && question.choices.length > 2 && (
|
||||
<TrashIcon
|
||||
|
||||
@@ -44,8 +44,6 @@ export default function SurveyMenuBar({
|
||||
const [isConfirmDialogOpen, setConfirmDialogOpen] = useState(false);
|
||||
const { product } = useProduct(environmentId);
|
||||
let faultyQuestions: String[] = [];
|
||||
const existingLogicConditions = new Set();
|
||||
const existingQuestionIds = new Set();
|
||||
|
||||
useEffect(() => {
|
||||
if (audiencePrompt && activeId === "settings") {
|
||||
@@ -96,6 +94,9 @@ export default function SurveyMenuBar({
|
||||
};
|
||||
|
||||
const validateSurvey = (survey) => {
|
||||
const existingLogicConditions = new Set();
|
||||
const existingQuestionIds = new Set();
|
||||
|
||||
if (localSurvey.questions.length === 0) {
|
||||
toast.error("Please add at least one question");
|
||||
return;
|
||||
|
||||
@@ -9,7 +9,14 @@ import {
|
||||
|
||||
const validationRules = {
|
||||
multipleChoiceMulti: (question: MultipleChoiceMultiQuestion) => {
|
||||
return !question.choices.some((element) => element.label.trim() === "");
|
||||
return !(
|
||||
question.choices.some((element) => element.label.trim() === "") ||
|
||||
question.choices.some((element, index) =>
|
||||
question.choices
|
||||
.slice(index + 1)
|
||||
.some((nextElement) => nextElement.label.trim() === element.label.trim())
|
||||
)
|
||||
);
|
||||
},
|
||||
multipleChoiceSingle: (question: MultipleChoiceSingleQuestion) => {
|
||||
return !(
|
||||
|
||||
Reference in New Issue
Block a user