mirror of
https://github.com/formbricks/formbricks.git
synced 2026-05-01 03:33:40 -05:00
fix: not allow new logic jump until previous filled & do not allow saving survey until atleast 2 fields are filled
This commit is contained in:
+12
@@ -20,6 +20,7 @@ import {
|
||||
import { QuestionMarkCircleIcon, TrashIcon } from "@heroicons/react/24/solid";
|
||||
import { ChevronDown, SplitIcon } from "lucide-react";
|
||||
import { useMemo } from "react";
|
||||
import { toast } from "react-hot-toast";
|
||||
import { BsArrowDown, BsArrowReturnRight } from "react-icons/bs";
|
||||
|
||||
interface LogicEditorProps {
|
||||
@@ -141,6 +142,17 @@ export default function LogicEditor({
|
||||
};
|
||||
|
||||
const addLogic = () => {
|
||||
if (question.logic && question.logic?.length >= 0) {
|
||||
const hasUndefinedLogic = question.logic.some(
|
||||
(logic) =>
|
||||
logic.condition === undefined && logic.value === undefined && logic.destination === undefined
|
||||
);
|
||||
if (hasUndefinedLogic) {
|
||||
toast.error("Please fill the existing logic jump first!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const newLogic: Logic[] = !question.logic ? [] : question.logic;
|
||||
newLogic.push({
|
||||
condition: undefined,
|
||||
|
||||
+13
@@ -115,6 +115,19 @@ export default function SurveyMenuBar({
|
||||
return false;
|
||||
}
|
||||
|
||||
for (const question of survey.questions) {
|
||||
for (const logic of question.logic || []) {
|
||||
const validFields = ["condition", "destination", "value"].filter(
|
||||
(field) => logic[field] !== undefined
|
||||
).length;
|
||||
|
||||
if (validFields < 2) {
|
||||
toast.error("Please fill all the opened Logic Jumps or delete them!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Check whether the count for autocomplete responses is not less
|
||||
than the current count of accepted response and also it is not set to 0
|
||||
|
||||
Reference in New Issue
Block a user