import { Button, Flex, HStack, Tag, useToast, Text } from '@chakra-ui/react' import { NextChakraLink } from 'components/nextChakra/NextChakraLink' import { useTypebot } from 'contexts/TypebotContext/TypebotContext' import { useUser } from 'contexts/UserContext' import { useRouter } from 'next/router' import React, { useMemo } from 'react' import { useStats } from 'services/analytics' import { isFreePlan } from 'services/user/user' import { AnalyticsContent } from './AnalyticsContent' import { SubmissionsContent } from './SubmissionContent' export const ResultsContent = () => { const router = useRouter() const { user } = useUser() const { typebot, publishedTypebot } = useTypebot() const isAnalytics = useMemo( () => router.pathname.endsWith('analytics'), [router.pathname] ) const toast = useToast({ position: 'top-right', status: 'error', }) const { stats, mutate } = useStats({ typebotId: publishedTypebot?.typebotId, onError: (err) => toast({ title: err.name, description: err.message }), }) const handleDeletedResults = (total: number) => { if (!stats) return mutate({ stats: { ...stats, totalStarts: stats.totalStarts - total }, }) } return ( {publishedTypebot && (isAnalytics ? ( ) : ( ))} ) }