🚸 Try to parse stringified array before loading them in as dynamic items

This commit is contained in:
Baptiste Arnaud 2025-03-04 16:19:14 +01:00
parent 098078875c
commit 75814efe0e
No known key found for this signature in database

View File

@ -1,3 +1,4 @@
import { JSONParse } from "@typebot.io/lib/JSONParse";
import { isNotDefined } from "@typebot.io/lib/utils";
import type { Variable, VariableWithValue } from "./schemas";
@ -12,6 +13,21 @@ export const transformVariablesToList =
typeof variable.value !== "string"
)
return variables;
try {
const potentialArray = JSONParse(variable.value);
console.log(potentialArray);
if (Array.isArray(potentialArray))
return [
...variables,
{
...variable,
value: potentialArray,
},
];
return variables;
} catch (error) {
// Not an stringified array, skipping...
}
return [
...variables,
{