import { Flex, Stack, Heading, Text, Button, VStack } from '@chakra-ui/react' import { Standard } from '@typebot.io/nextjs' import { ArrowRight } from 'assets/icons/ArrowRight' import { HandDrawnArrow } from 'assets/illustrations/HandDrawnArrow' import { PublicTypebot, Typebot } from '@typebot.io/schemas' import Link from 'next/link' import React, { useEffect, useRef, useState } from 'react' import { sendRequest } from '@typebot.io/lib' const nameBlockId = 'shuUtMDMw9P4iAHbz7B5SqJ' const messageBlockId = 'sqvXpT1YXE3Htp6BCPvVGv3' export const RealTimeResults = () => { const iframeRef = useRef(null) const [typebot, setTypebot] = useState() const fetchTemplate = async () => { const { data, error } = await sendRequest( `/typebots/realtime-airtable.json` ) if (error) return const typebot = data as Typebot setTypebot({ ...typebot, typebotId: typebot.id } as PublicTypebot) } useEffect(() => { fetchTemplate() }, []) const refreshIframeContent = () => { if (!iframeRef.current) return iframeRef.current.src += '' } const handleAnswer = ({ blockId }: { blockId: string }) => { if ([nameBlockId, messageBlockId].includes(blockId)) setTimeout(refreshIframeContent, 1000) } return ( Collect results in real-time One of the main advantage of a chat application is that you collect the user's responses on each question.{' '} You won't lose any valuable data. {typebot && ( )}