2
0

🦴 Add results backbone

This commit is contained in:
Baptiste Arnaud
2021-12-24 10:08:41 +01:00
parent d369b4d941
commit 698867da5d
13 changed files with 232 additions and 2 deletions

View File

@ -1,4 +1,11 @@
import { PublicTypebot, Typebot } from 'bot-engine'
import {
Block,
InputStep,
PublicTypebot,
Step,
StepType,
Typebot,
} from 'bot-engine'
import { sendRequest } from './utils'
import shortId from 'short-uuid'
@ -33,3 +40,18 @@ export const updatePublishedTypebot = async (
method: 'PUT',
body: typebot,
})
export const parseSubmissionsColumns = (
typebot?: PublicTypebot
): {
Header: string
accessor: string
}[] =>
(typebot?.blocks ?? [])
.filter(blockContainsInput)
.map((block) => ({ Header: block.title, accessor: block.id }))
const blockContainsInput = (block: Block) => block.steps.some(stepIsInput)
const stepIsInput = (step: Step): step is InputStep =>
step.type === StepType.TEXT_INPUT