Skip to content

Commit

Permalink
feat(results): ✨ Brand new Results table
Browse files Browse the repository at this point in the history
- Resizable columns
- Hide / Show columns
- Reorganize columns
- Expand result
  • Loading branch information
baptisteArno committed Jul 1, 2022
1 parent cf6e8a2 commit d84f990
Show file tree
Hide file tree
Showing 34 changed files with 1,422 additions and 733 deletions.
7 changes: 7 additions & 0 deletions apps/builder/assets/icons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -474,3 +474,10 @@ export const BuoyIcon = (props: IconProps) => (
<line x1="4.93" y1="19.07" x2="9.17" y2="14.83"></line>
</Icon>
)

export const EyeOffIcon = (props: IconProps) => (
<Icon viewBox="0 0 24 24" {...featherIconsBaseProps} {...props}>
<path d="M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24"></path>
<line x1="1" y1="1" x2="23" y2="23"></line>
</Icon>
)
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ import { isDefined } from 'utils'

type Props = {
typebotId: string
resultId?: string
resultId: string | null
onClose: () => void
}
export const LogsModal = ({ typebotId, resultId, onClose }: Props) => {
const { isLoading, logs } = useLogs(typebotId, resultId)
const { isLoading, logs } = useLogs(typebotId, resultId ?? undefined)
return (
<Modal isOpen={isDefined(resultId)} onClose={onClose} size="xl">
<ModalOverlay />
Expand Down
55 changes: 55 additions & 0 deletions apps/builder/components/results/ResultModal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import {
Modal,
ModalOverlay,
ModalContent,
ModalCloseButton,
ModalBody,
Stack,
Heading,
Text,
HStack,
} from '@chakra-ui/react'
import { useResults } from 'contexts/ResultsProvider'
import React from 'react'
import { isDefined } from 'utils'
import { HeaderIcon } from './ResultsTable/ResultsTable'

type Props = {
resultIdx: number | null
onClose: () => void
}

export const ResultModal = ({ resultIdx, onClose }: Props) => {
const { tableData, resultHeader } = useResults()
const result = isDefined(resultIdx) ? tableData[resultIdx] : undefined

const getHeaderValue = (
val: string | { plainText: string; element?: JSX.Element | undefined }
) => (typeof val === 'string' ? val : val.element ?? val.plainText)

return (
<Modal isOpen={isDefined(result)} onClose={onClose} size="2xl">
<ModalOverlay />
<ModalContent>
<ModalCloseButton />
<ModalBody as={Stack} p="10" spacing="10">
{resultHeader.map((header) =>
result && result[header.label] ? (
<Stack key={header.id} spacing="4">
<HStack>
<HeaderIcon header={header} />
<Heading fontSize="md">{header.label}</Heading>
</HStack>
<Text whiteSpace="pre-wrap" textAlign="justify">
{getHeaderValue(result[header.label])}
</Text>
</Stack>
) : (
<></>
)
)}
</ModalBody>
</ModalContent>
</Modal>
)
}
81 changes: 0 additions & 81 deletions apps/builder/components/results/ResultsActionButtons.tsx

This file was deleted.

81 changes: 81 additions & 0 deletions apps/builder/components/results/ResultsContent.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import { Stack } from '@chakra-ui/react'
import { SubmissionsTable } from 'components/results/ResultsTable'
import React, { useState } from 'react'
import { UnlockPlanInfo } from 'components/shared/Info'
import { LogsModal } from './LogsModal'
import { useTypebot } from 'contexts/TypebotContext'
import { Plan } from 'db'
import { useResults } from 'contexts/ResultsProvider'
import { ResultModal } from './ResultModal'

export const ResultsContent = () => {
const {
flatResults: results,
fetchMore,
hasMore,
resultHeader,
totalHiddenResults,
tableData,
} = useResults()
const { typebot, publishedTypebot } = useTypebot()
const [inspectingLogsResultId, setInspectingLogsResultId] = useState<
string | null
>(null)
const [expandedResultIndex, setExpandedResultIndex] = useState<number | null>(
null
)

const handleLogsModalClose = () => setInspectingLogsResultId(null)

const handleResultModalClose = () => setExpandedResultIndex(null)

const handleLogOpenIndex = (index: number) => () => {
if (!results) return
setInspectingLogsResultId(results[index].id)
}

const handleResultExpandIndex = (index: number) => () =>
setExpandedResultIndex(index)

return (
<Stack
pb="28"
px={['4', '0']}
spacing="4"
maxW="1600px"
overflow="scroll"
w="full"
>
{totalHiddenResults && (
<UnlockPlanInfo
buttonLabel={`Unlock ${totalHiddenResults} results`}
contentLabel="You are seeing complete submissions only."
plan={Plan.PRO}
/>
)}
{publishedTypebot && (
<LogsModal
typebotId={publishedTypebot?.typebotId}
resultId={inspectingLogsResultId}
onClose={handleLogsModalClose}
/>
)}
<ResultModal
resultIdx={expandedResultIndex}
onClose={handleResultModalClose}
/>

{typebot && (
<SubmissionsTable
preferences={typebot.resultsTablePreferences}
resultHeader={resultHeader}
data={tableData}
onScrollToBottom={fetchMore}
hasMore={hasMore}
onLogOpenIndex={handleLogOpenIndex}
onResultExpandIndex={handleResultExpandIndex}
/>
)}
</Stack>
)
}
Loading

4 comments on commit d84f990

@vercel
Copy link

@vercel vercel bot commented on d84f990 Jul 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

docs – ./apps/docs

docs-typebot-io.vercel.app
docs.typebot.io
docs-git-main-typebot-io.vercel.app

@vercel
Copy link

@vercel vercel bot commented on d84f990 Jul 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

viewer-v2-alpha – ./apps/viewer

apr.nigerias.io
sat.cr8.ai
an.nigerias.io
aso.nigerias.io
vhpage.cr8.ai
ar.nigerias.io
bt.id8rs.com
bot.aws.bj
apo.nigerias.io
am.nigerias.io
bot.upfunnel.art
eventhub.com.au
chat.sureb4.com
clo.closeer.work
faqs.nigerias.io
games.klujo.com
feedback.ofx.one
bot.piccinato.co
sakuranembro.it
stan.vselise.com
bot.agfunnel.tech
app.chatforms.net
ov2.wpwakanda.com
bot.maitempah.com
gentleman-shop.fr
voicehelp.cr8.ai
ov1.wpwakanda.com
ov3.wpwakanda.com
admin.applepie.pro
sell.applepie.pro
this-is-a-test.com
zap.techadviser.in
goalsettingbot.com
forms.webisharp.com
order.maitempah.com
bot.eventhub.com.au
typebot.stillio.com
bot.ansuraniphone.my
chat.hayurihijab.com
bot.cotemeuplano.com
get.freebotoffer.xyz
bbutton.wpwakanda.com
abutton.wpwakanda.com
bot.incusservices.com
bot.meuesocial.com.br
cdd.searchcube.com.sg
sbutton.wpwakanda.com
bbutton.wpwwakanda.com
apply.ansuraniphone.my
chat.missarkansas.org
c23111azqw.nigerias.io
felipewelington.com.br
info.clickasuransi.com
form.searchcube.com.sg
gcase.barrettamario.it
83242573.actualizar.xyz
view.onlinebotdemo.xyz
bot.upgradesolutions.eu
kodawariab736.skeep.it
mainmenu.diddancing.com
subfooter.wpwakanda.com
form.sergiolimajr.com.br
hunterbot.saleshunter.ai
91181264.your-access.one
type.opaulovieira.com.br
aibot.angrybranding.co.uk
type.dericsoncalari.com.br
designguide.techyscouts.com
bot.cabinrentalagency.com
boyfriend-breakup.riku.ai
presente.empresarias.com.mx
piazzatorre.barrettamario.it
type.talitasouzamarques.com.br
onboarding.libertydreamcare.ie
agendamento.sergiolimajr.com.br
bot.comercializadoraomicron.com
studiotecnicoimmobiliaremerelli.it
personal-trainer.barrettamario.it
bookings.littlepartymonkeys.com
preagendamento.sergiolimajr.com.br
viewer-v2-alpha-typebot-io.vercel.app
viewer-v2-alpha-git-main-typebot-io.vercel.app

@vercel
Copy link

@vercel vercel bot commented on d84f990 Jul 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on d84f990 Jul 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

builder-v2 – ./apps/builder

builder-v2-git-main-typebot-io.vercel.app
app.typebot.io
builder-v2-typebot-io.vercel.app

Please sign in to comment.