Better error toast when previewing bot

Closes #475
This commit is contained in:
Baptiste Arnaud
2023-04-27 11:21:32 +02:00
parent 3c6a666d9b
commit d448e64dc9
7 changed files with 235 additions and 40 deletions

View File

@@ -1,8 +1,8 @@
import { WebhookIcon } from '@/components/icons'
import { useEditor } from '@/features/editor/providers/EditorProvider'
import { useTypebot } from '@/features/editor/providers/TypebotProvider'
import { useGraph } from '@/features/graph/providers/GraphProvider'
import { useToast } from '@/hooks/useToast'
import { UseToastOptions } from '@chakra-ui/react'
import { Standard } from '@typebot.io/react'
import { ChatReply } from '@typebot.io/schemas'
@@ -15,7 +15,17 @@ export const WebPreview = () => {
const handleNewLogs = (logs: ChatReply['logs']) => {
logs?.forEach((log) => {
showToast(log as UseToastOptions)
showToast({
icon: <WebhookIcon />,
title: 'An error occured',
description: log.description,
details: log.details
? {
lang: 'json',
content: JSON.stringify(log.details, null, 2),
}
: undefined,
})
console.error(log)
})
}