From cc9142e89b529b120233d3a2f0a8b2224cf48145 Mon Sep 17 00:00:00 2001 From: ShubhamPalriwala Date: Thu, 31 Aug 2023 21:08:56 +0530 Subject: [PATCH] fix: user can now cannot 2 exactly same logic conditions --- .../surveys/[surveyId]/edit/SurveyMenuBar.tsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/apps/web/app/(app)/environments/[environmentId]/surveys/[surveyId]/edit/SurveyMenuBar.tsx b/apps/web/app/(app)/environments/[environmentId]/surveys/[surveyId]/edit/SurveyMenuBar.tsx index fbab7253cd..4a2186755f 100644 --- a/apps/web/app/(app)/environments/[environmentId]/surveys/[surveyId]/edit/SurveyMenuBar.tsx +++ b/apps/web/app/(app)/environments/[environmentId]/surveys/[surveyId]/edit/SurveyMenuBar.tsx @@ -44,6 +44,8 @@ export default function SurveyMenuBar({ const [isConfirmDialogOpen, setConfirmDialogOpen] = useState(false); const { product } = useProduct(environmentId); let faultyQuestions: String[] = []; + const existingLogicConditions = new Set(); + useEffect(() => { if (audiencePrompt && activeId === "settings") { @@ -125,6 +127,13 @@ export default function SurveyMenuBar({ toast.error("Please fill all the opened Logic Jumps or delete them!"); return false; } + + const thisLogic = `${logic.condition}-${logic.value}`; + if (existingLogicConditions.has(thisLogic)) { + toast.error("You have 2 exactly same logic conditons!"); + return false; + } + existingLogicConditions.add(thisLogic); } }