2
0

feat(template): 📝 Add Quizz

This commit is contained in:
Baptiste Arnaud
2022-04-08 18:07:14 -05:00
parent 4c9f97b254
commit 5aac8229d2
5 changed files with 997 additions and 10 deletions

View File

@ -66,7 +66,11 @@ export const InputChatStep = ({
{hasAvatar && (
<div className="flex w-6 xs:w-10 h-6 xs:h-10 mr-2 mb-2 mt-1 flex-shrink-0 items-center" />
)}
<Input step={step} onSubmit={handleSubmit} defaultValue={defaultValue} />
<Input
step={step}
onSubmit={handleSubmit}
defaultValue={defaultValue?.toString()}
/>
</div>
)
}

View File

@ -18,7 +18,9 @@ export const parseVariables =
})
if (!variable) return ''
return (
(options.fieldToParse === 'value' ? variable.value : variable.id) || ''
(options.fieldToParse === 'value'
? variable.value?.toString()
: variable.id) || ''
)
})
}
@ -32,7 +34,7 @@ export const evaluateExpression = (variables: Variable[]) => (str: string) => {
)
)
const evaluatedResult = func(...variables.map((v) => v.value))
return isNotDefined(evaluatedResult) ? '' : evaluatedResult.toString()
return isNotDefined(evaluatedResult) ? '' : evaluatedResult
} catch (err) {
console.log(err)
return str