fix(engine): 🐛 Save variables from webhooks in results
This commit is contained in:
@@ -131,7 +131,7 @@ export const convertResultsToTableData = (
|
||||
): { [key: string]: string }[] =>
|
||||
(results ?? []).map((result) => ({
|
||||
'Submitted at': parseDateToReadable(result.createdAt),
|
||||
...[...result.answers, ...result.prefilledVariables].reduce<{
|
||||
...[...result.answers, ...result.variables].reduce<{
|
||||
[key: string]: string
|
||||
}>((o, answerOrVariable) => {
|
||||
if ('blockId' in answerOrVariable) {
|
||||
|
||||
@@ -54,11 +54,9 @@ export const TypebotPage = ({
|
||||
setShowTypebot(true)
|
||||
}
|
||||
|
||||
const handleVariablesPrefilled = async (
|
||||
prefilledVariables: VariableWithValue[]
|
||||
) => {
|
||||
const handleNewVariables = async (variables: VariableWithValue[]) => {
|
||||
if (!resultId) return setError(new Error('Result was not created'))
|
||||
const { error } = await updateResult(resultId, { prefilledVariables })
|
||||
const { error } = await updateResult(resultId, { variables })
|
||||
if (error) setError(error)
|
||||
}
|
||||
|
||||
@@ -98,7 +96,7 @@ export const TypebotPage = ({
|
||||
predefinedVariables={predefinedVariables}
|
||||
onNewAnswer={handleNewAnswer}
|
||||
onCompleted={handleCompleted}
|
||||
onVariablesPrefilled={handleVariablesPrefilled}
|
||||
onVariablesUpdated={handleNewVariables}
|
||||
onNewLog={handleNewLog}
|
||||
/>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user