36 lines
1.0 KiB
TypeScript
36 lines
1.0 KiB
TypeScript
import { useEditor } from '@/features/editor/providers/EditorProvider'
|
|
import { useTypebot } from '@/features/editor/providers/TypebotProvider'
|
|
import { useGraph } from '@/features/graph'
|
|
import { useToast } from '@/hooks/useToast'
|
|
import { UseToastOptions } from '@chakra-ui/react'
|
|
import { Standard } from '@typebot.io/react'
|
|
import { ChatReply } from 'models'
|
|
|
|
export const WebPreview = () => {
|
|
const { typebot } = useTypebot()
|
|
const { startPreviewAtGroup } = useEditor()
|
|
const { setPreviewingBlock } = useGraph()
|
|
|
|
const { showToast } = useToast()
|
|
|
|
const handleNewLogs = (logs: ChatReply['logs']) => {
|
|
logs?.forEach((log) => showToast(log as UseToastOptions))
|
|
}
|
|
|
|
if (!typebot) return null
|
|
|
|
return (
|
|
<Standard
|
|
key={`web-preview${startPreviewAtGroup ?? ''}`}
|
|
typebot={typebot}
|
|
startGroupId={startPreviewAtGroup}
|
|
onNewInputBlock={setPreviewingBlock}
|
|
onNewLogs={handleNewLogs}
|
|
style={{
|
|
borderWidth: '1px',
|
|
borderRadius: '0.25rem',
|
|
}}
|
|
/>
|
|
)
|
|
}
|