diff --git a/radlab-ui/webapp/src/utils/terraform.ts b/radlab-ui/webapp/src/utils/terraform.ts index 3fa5fe2e..8ff86260 100644 --- a/radlab-ui/webapp/src/utils/terraform.ts +++ b/radlab-ui/webapp/src/utils/terraform.ts @@ -156,10 +156,10 @@ const mapHclToUIVar = ( default: hclVar.default ? hclVar.default : formatType(hclVar.type) === "bool" - ? false - : hclVar.default === "" - ? "" - : null, + ? false + : hclVar.default === "" + ? "" + : null, required: mandatory, group, order, @@ -269,42 +269,40 @@ export const checkDependsOnValid = ( dependsOnVarData: string | null, userAnswerData: FormikValues, ) => { - if (dependsOnVarData) { - const dependsOnDataOperatorFormats = dependsOnVarData - .replaceAll("&&", " && ") - .replaceAll("||", " || ") - - const dependsOnDataAnswerMatchRes = dependsOnDataOperatorFormats - .split(" ") - .map((dependsOnDataOperatorFormat) => { - const checkDependsNameVar = dependsOnDataOperatorFormat.split("==") - let getwithAnswerMatch - if (checkDependsNameVar.length === 2) { - //@ts-ignore - getwithAnswerMatch = `${userAnswerData[checkDependsNameVar[0]]} == ${ - checkDependsNameVar[1] + if (!dependsOnVarData) { + return false + } + + const dependsOnDataOperatorFormats = dependsOnVarData + .replaceAll("&&", " && ") + .replaceAll("||", " || ") + + const dependsOnDataAnswerMatchRes = dependsOnDataOperatorFormats + .split(" ") + .map((dependsOnDataOperatorFormat) => { + const checkDependsNameVar = dependsOnDataOperatorFormat.split("==") + let getwithAnswerMatch + if (checkDependsNameVar.length === 2) { + getwithAnswerMatch = `${userAnswerData[checkDependsNameVar[0]!]} == ${checkDependsNameVar[1]! }` - } else { - getwithAnswerMatch = checkDependsNameVar[0] - } + } else { + getwithAnswerMatch = checkDependsNameVar[0] + } - return getwithAnswerMatch - }) - .join(" ") + return getwithAnswerMatch + }) + .join(" ") - const formatDependsOnDataAnswerMatchRes = `(${dependsOnDataAnswerMatchRes.replaceAll( - " && ", - ") && (", - )})` + const formatDependsOnDataAnswerMatchRes = `(${dependsOnDataAnswerMatchRes.replaceAll( + " && ", + ") && (", + )})` - const dependsOnDataAnswerMatchEvalute = eval( - formatDependsOnDataAnswerMatchRes, - ) + const dependsOnDataAnswerMatchEvalute = eval( + formatDependsOnDataAnswerMatchRes, + ) - return dependsOnDataAnswerMatchEvalute - } else { - return false - } + return dependsOnDataAnswerMatchEvalute } export const formatRelevantVariables = (