2
0

fix(analytics): 🐛 Analytics board

This commit is contained in:
Baptiste Arnaud
2022-02-11 18:06:59 +01:00
parent 93fed893c0
commit 7c164e25d7
13 changed files with 179 additions and 108 deletions

View File

@ -1,6 +1,7 @@
import { Flex, useToast } from '@chakra-ui/react'
import { StatsCards } from 'components/analytics/StatsCards'
import { Graph } from 'components/shared/Graph'
import { GraphProvider } from 'contexts/GraphContext'
import { useTypebot } from 'contexts/TypebotContext/TypebotContext'
import { Stats } from 'models'
import React from 'react'
@ -25,14 +26,17 @@ export const AnalyticsContent = ({ stats }: { stats?: Stats }) => {
h="full"
justifyContent="center"
>
{publishedTypebot && (
<Graph
flex="1"
answersCounts={[
{ blockId: 'start-block', totalAnswers: stats?.totalViews ?? 0 },
...(answersCounts ?? []),
]}
/>
{publishedTypebot && answersCounts && stats && (
<GraphProvider blocks={publishedTypebot?.blocks ?? []} isReadOnly>
<Graph
flex="1"
typebot={publishedTypebot}
answersCounts={[
{ ...answersCounts[0], totalAnswers: stats?.totalStarts },
...answersCounts?.slice(1),
]}
/>
</GraphProvider>
)}
<StatsCards stats={stats} pos="absolute" top={10} />
</Flex>