2
0

🚸 (condition) Improve comparison with lists

Closes #363
This commit is contained in:
Baptiste Arnaud
2023-03-07 09:47:05 +01:00
parent 767a8208a8
commit 0c19ea20f8
2 changed files with 45 additions and 13 deletions

View File

@@ -218,3 +218,14 @@ const updateTypebotVariables =
...serializedNewVariables,
]
}
export const findUniqueVariableValue =
(variables: Variable[]) =>
(value: string | undefined): string | string[] | null => {
if (!value || !value.startsWith('{{') || !value.endsWith('}}')) return null
const variableName = value.slice(2, -2)
const variable = variables.find(
(variable) => variable.name === variableName
)
return variable?.value ?? null
}