✨ Introducing The Forge (#1072)
The Forge allows anyone to easily create their own Typebot Block. Closes #380
This commit is contained in:
26
packages/variables/transformVariablesToList.ts
Normal file
26
packages/variables/transformVariablesToList.ts
Normal file
@ -0,0 +1,26 @@
|
||||
import { isNotDefined } from '@typebot.io/lib/utils'
|
||||
import { Variable, VariableWithValue } from '@typebot.io/schemas'
|
||||
|
||||
export const transformVariablesToList =
|
||||
(variables: Variable[]) =>
|
||||
(variableIds: string[]): VariableWithValue[] => {
|
||||
const newVariables = variables.reduce<VariableWithValue[]>(
|
||||
(variables, variable) => {
|
||||
if (
|
||||
!variableIds.includes(variable.id) ||
|
||||
isNotDefined(variable.value) ||
|
||||
typeof variable.value !== 'string'
|
||||
)
|
||||
return variables
|
||||
return [
|
||||
...variables,
|
||||
{
|
||||
...variable,
|
||||
value: [variable.value],
|
||||
},
|
||||
]
|
||||
},
|
||||
[]
|
||||
)
|
||||
return newVariables
|
||||
}
|
Reference in New Issue
Block a user