-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d369b4d
commit 698867d
Showing
13 changed files
with
232 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
.table-wrapper { | ||
background-image: linear-gradient(to right, white, white), | ||
linear-gradient(to right, white, white), | ||
linear-gradient(to right, rgba(0, 0, 0, 0.1), rgba(255, 255, 255, 0)), | ||
linear-gradient(to left, rgba(0, 0, 0, 0.1), rgba(255, 255, 255, 0)); | ||
background-position: left center, right center, left center, right center; | ||
background-repeat: no-repeat; | ||
background-color: white; | ||
background-size: 30px 100%, 30px 100%, 15px 100%, 15px 100%; | ||
background-attachment: local, local, scroll, scroll; | ||
} |
77 changes: 77 additions & 0 deletions
77
apps/builder/components/results/SubmissionsTable/SubmissionsTable.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* eslint-disable react/jsx-key */ | ||
import { Box, Flex } from '@chakra-ui/react' | ||
import { useTypebot } from 'contexts/TypebotContext' | ||
import React from 'react' | ||
import { useTable } from 'react-table' | ||
import { parseSubmissionsColumns } from 'services/publicTypebot' | ||
|
||
// eslint-disable-next-line @typescript-eslint/ban-types | ||
type SubmissionsTableProps = {} | ||
|
||
export const SubmissionsTable = ({}: SubmissionsTableProps) => { | ||
const { publishedTypebot } = useTypebot() | ||
const columns: any = React.useMemo( | ||
() => parseSubmissionsColumns(publishedTypebot), | ||
[publishedTypebot] | ||
) | ||
const data = React.useMemo(() => [], []) | ||
const { getTableProps, headerGroups, rows, prepareRow, getTableBodyProps } = | ||
useTable({ columns, data }) | ||
return ( | ||
<Flex overflowX="scroll" maxW="full" className="table-wrapper" rounded="md"> | ||
<Box as="table" rounded="md" {...getTableProps()}> | ||
<Box as="thead"> | ||
{headerGroups.map((headerGroup) => { | ||
return ( | ||
<Box as="tr" {...headerGroup.getHeaderGroupProps()}> | ||
{headerGroup.headers.map((column) => { | ||
return ( | ||
<Box | ||
py={2} | ||
px={4} | ||
border="1px" | ||
borderColor="gray.200" | ||
as="th" | ||
minW="200px" | ||
color="gray.500" | ||
fontWeight="normal" | ||
textAlign="left" | ||
{...column.getHeaderProps()} | ||
> | ||
{column.render('Header')} | ||
</Box> | ||
) | ||
})} | ||
</Box> | ||
) | ||
})} | ||
</Box> | ||
|
||
<Box as="tbody" {...getTableBodyProps()}> | ||
{rows.map((row) => { | ||
prepareRow(row) | ||
return ( | ||
<Box as="tr" {...row.getRowProps()}> | ||
{row.cells.map((cell) => { | ||
return ( | ||
<Box | ||
py={2} | ||
px={4} | ||
border="1px" | ||
as="td" | ||
minW="200px" | ||
borderColor="gray.200" | ||
{...cell.getCellProps()} | ||
> | ||
{cell.render('Cell')} | ||
</Box> | ||
) | ||
})} | ||
</Box> | ||
) | ||
})} | ||
</Box> | ||
</Box> | ||
</Flex> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { SubmissionsTable } from './SubmissionsTable' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import React from 'react' | ||
|
||
export const AnalyticsContent = () => { | ||
return <>Hi</> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { Button, Flex, HStack, Stack } from '@chakra-ui/react' | ||
import { NextChakraLink } from 'components/nextChakra/NextChakraLink' | ||
import { useTypebot } from 'contexts/TypebotContext' | ||
import { useRouter } from 'next/router' | ||
import React, { useMemo } from 'react' | ||
import { AnalyticsContent } from './AnalyticsContent' | ||
import { SubmissionsContent } from './SubmissionContent' | ||
|
||
export const ResultsContent = () => { | ||
const router = useRouter() | ||
const { typebot } = useTypebot() | ||
const isAnalytics = useMemo( | ||
() => router.pathname.endsWith('analytics'), | ||
[router.pathname] | ||
) | ||
return ( | ||
<Flex h="full" w="full" justifyContent="center" align="flex-start"> | ||
<Stack maxW="1200px" w="full" pt="4" spacing={6}> | ||
<HStack> | ||
<Button | ||
as={NextChakraLink} | ||
colorScheme={!isAnalytics ? 'blue' : 'gray'} | ||
variant={!isAnalytics ? 'outline' : 'ghost'} | ||
size="sm" | ||
href={`/typebots/${typebot?.id}/results`} | ||
> | ||
Submissions | ||
</Button> | ||
<Button | ||
as={NextChakraLink} | ||
colorScheme={isAnalytics ? 'blue' : 'gray'} | ||
variant={isAnalytics ? 'outline' : 'ghost'} | ||
href={`/typebots/${typebot?.id}/results/analytics`} | ||
size="sm" | ||
> | ||
Analytics | ||
</Button> | ||
</HStack> | ||
{isAnalytics ? <AnalyticsContent /> : <SubmissionsContent />} | ||
</Stack> | ||
</Flex> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { SubmissionsTable } from 'components/results/SubmissionsTable' | ||
import React from 'react' | ||
|
||
export const SubmissionsContent = () => { | ||
return ( | ||
<> | ||
<SubmissionsTable /> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { Flex } from '@chakra-ui/layout' | ||
import withAuth from 'components/HOC/withUser' | ||
import { ResultsContent } from 'layouts/results/ResultsContent' | ||
import { Seo } from 'components/Seo' | ||
import { TypebotHeader } from 'components/shared/TypebotHeader' | ||
import { TypebotContext } from 'contexts/TypebotContext' | ||
import { useRouter } from 'next/router' | ||
import React from 'react' | ||
|
||
const ResultsPage = () => { | ||
const { query } = useRouter() | ||
return ( | ||
<TypebotContext typebotId={query.id?.toString()}> | ||
<Seo title="Share" /> | ||
<Flex overflow="hidden" h="100vh" flexDir="column"> | ||
<TypebotHeader /> | ||
<ResultsContent /> | ||
</Flex> | ||
</TypebotContext> | ||
) | ||
} | ||
|
||
export default withAuth(ResultsPage) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { Flex } from '@chakra-ui/layout' | ||
import withAuth from 'components/HOC/withUser' | ||
import { ResultsContent } from 'layouts/results/ResultsContent' | ||
import { Seo } from 'components/Seo' | ||
import { TypebotHeader } from 'components/shared/TypebotHeader' | ||
import { TypebotContext } from 'contexts/TypebotContext' | ||
import { useRouter } from 'next/router' | ||
import React from 'react' | ||
|
||
const AnalyticsPage = () => { | ||
const { query } = useRouter() | ||
return ( | ||
<TypebotContext typebotId={query.id?.toString()}> | ||
<Seo title="Analytics" /> | ||
<Flex overflow="hidden" h="100vh" flexDir="column"> | ||
<TypebotHeader /> | ||
<ResultsContent /> | ||
</Flex> | ||
</TypebotContext> | ||
) | ||
} | ||
|
||
export default withAuth(AnalyticsPage) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters