From ccc2e65d98ce8f91c57315dc658a2877f5e12efd Mon Sep 17 00:00:00 2001 From: Marton Moro Date: Fri, 20 Dec 2024 18:53:23 +0100 Subject: [PATCH] chore(private-credential): ifThenElse in formatLogicNode --- .../features/src/web-connector/utils/render-payload.tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/features/src/web-connector/utils/render-payload.tsx b/packages/features/src/web-connector/utils/render-payload.tsx index 2cd7dcc9..2eb20481 100644 --- a/packages/features/src/web-connector/utils/render-payload.tsx +++ b/packages/features/src/web-connector/utils/render-payload.tsx @@ -184,6 +184,13 @@ const formatLogicNode = (node: LogicNode, level = 0): string => { throw Error("CONSTANT node must have 'data'") } return `${node.data}` + case "ifThenElse": + if (!node.condition || !node.thenNode || !node.elseNode) { + throw Error( + "IF_THEN_ELSE node must have 'condition', 'thenNode', and 'elseNode'", + ) + } + return `${indent}If this condition is true:\n${indent}- ${formatLogicNode(node.condition, level + 1)}\n${indent}Then:\n${indent}- ${formatLogicNode(node.thenNode, level + 1)}\n${indent}Otherwise:\n${indent}- ${formatLogicNode(node.elseNode, level + 1)}` default: throw Error(`Unknown node type: ${node.type}`)