2
0

fix(results): 🐛 Collect prefilled variables in db

This commit is contained in:
Baptiste Arnaud
2022-02-17 16:08:01 +01:00
parent 0336bc2a42
commit aaf78e8a54
19 changed files with 454 additions and 507 deletions

View File

@ -21,8 +21,18 @@ export const ChatStep = ({
}) => {
const { addAnswer } = useAnswers()
const handleInputSubmit = (content: string, isRetry: boolean) => {
if (!isRetry) addAnswer({ stepId: step.id, blockId: step.blockId, content })
const handleInputSubmit = (
content: string,
isRetry: boolean,
variableId?: string
) => {
if (!isRetry)
addAnswer({
stepId: step.id,
blockId: step.blockId,
content,
variableId: variableId ?? null,
})
onTransitionEnd(content, isRetry)
}
@ -38,7 +48,7 @@ const InputChatStep = ({
onSubmit,
}: {
step: InputStep
onSubmit: (value: string, isRetry: boolean) => void
onSubmit: (value: string, isRetry: boolean, variableId?: string) => void
}) => {
const { typebot } = useTypebot()
const { addNewAvatarOffset } = useHostAvatars()
@ -54,7 +64,7 @@ const InputChatStep = ({
const handleSubmit = (value: string) => {
setAnswer(value)
onSubmit(value, !isInputValid(value, step.type))
onSubmit(value, !isInputValid(value, step.type), step.options.variableId)
}
if (answer) {