mirror of
https://github.com/formbricks/formbricks.git
synced 2026-04-19 19:21:15 -05:00
fix: variable and hidden field comparison
This commit is contained in:
@@ -44,14 +44,14 @@ const evaluateSingleCondition = (
|
||||
selectedLanguage: string
|
||||
): boolean => {
|
||||
try {
|
||||
const leftValue = getLeftOperandValue(
|
||||
let leftValue = getLeftOperandValue(
|
||||
localSurvey,
|
||||
data,
|
||||
variablesData,
|
||||
condition.leftOperand,
|
||||
selectedLanguage
|
||||
);
|
||||
const rightValue = condition.rightOperand
|
||||
let rightValue = condition.rightOperand
|
||||
? getRightOperandValue(localSurvey, data, variablesData, condition.rightOperand)
|
||||
: undefined;
|
||||
|
||||
@@ -83,6 +83,14 @@ const evaluateSingleCondition = (
|
||||
rightField = "";
|
||||
}
|
||||
|
||||
if (
|
||||
condition.leftOperand.type === "variable" &&
|
||||
(leftField as TSurveyVariable).type === "number" &&
|
||||
condition.rightOperand?.type === "hiddenField"
|
||||
) {
|
||||
rightValue = Number(rightValue as string);
|
||||
}
|
||||
|
||||
switch (condition.operator) {
|
||||
case "equals":
|
||||
if (condition.leftOperand.type === "question") {
|
||||
@@ -341,9 +349,7 @@ const getRightOperandValue = (
|
||||
if (variable.type === "number") return Number(variableValue) || 0;
|
||||
return variableValue || "";
|
||||
case "hiddenField":
|
||||
return !isNaN(data[rightOperand.value] as number)
|
||||
? Number(data[rightOperand.value])
|
||||
: data[rightOperand.value];
|
||||
return data[rightOperand.value];
|
||||
case "static":
|
||||
return rightOperand.value;
|
||||
default:
|
||||
|
||||
@@ -44,14 +44,14 @@ const evaluateSingleCondition = (
|
||||
selectedLanguage: string
|
||||
): boolean => {
|
||||
try {
|
||||
const leftValue = getLeftOperandValue(
|
||||
let leftValue = getLeftOperandValue(
|
||||
localSurvey,
|
||||
data,
|
||||
variablesData,
|
||||
condition.leftOperand,
|
||||
selectedLanguage
|
||||
);
|
||||
const rightValue = condition.rightOperand
|
||||
let rightValue = condition.rightOperand
|
||||
? getRightOperandValue(localSurvey, data, variablesData, condition.rightOperand)
|
||||
: undefined;
|
||||
|
||||
@@ -83,6 +83,14 @@ const evaluateSingleCondition = (
|
||||
rightField = "";
|
||||
}
|
||||
|
||||
if (
|
||||
condition.leftOperand.type === "variable" &&
|
||||
(leftField as TSurveyVariable).type === "number" &&
|
||||
condition.rightOperand?.type === "hiddenField"
|
||||
) {
|
||||
rightValue = Number(rightValue as string);
|
||||
}
|
||||
|
||||
switch (condition.operator) {
|
||||
case "equals":
|
||||
if (condition.leftOperand.type === "question") {
|
||||
@@ -341,9 +349,7 @@ const getRightOperandValue = (
|
||||
if (variable.type === "number") return Number(variableValue) || 0;
|
||||
return variableValue || "";
|
||||
case "hiddenField":
|
||||
return !isNaN(data[rightOperand.value] as number)
|
||||
? Number(data[rightOperand.value])
|
||||
: data[rightOperand.value];
|
||||
return data[rightOperand.value];
|
||||
case "static":
|
||||
return rightOperand.value;
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user