2
0

🚸 (results) Improve results action buttons

Now have an export all modal with settings and a better column order form
This commit is contained in:
Baptiste Arnaud
2023-02-14 14:33:26 +01:00
parent 1a3596b15c
commit 08e33fbe70
16 changed files with 645 additions and 373 deletions

View File

@ -7,12 +7,15 @@ import {
VariableWithValue,
Typebot,
ResultWithAnswersInput,
ResultWithAnswers,
InputBlockType,
} from 'models'
import { isInputBlock, isDefined, byId } from './utils'
import { isInputBlock, isDefined, byId, isNotEmpty } from './utils'
export const parseResultHeader = (
typebot: Pick<Typebot, 'groups' | 'variables'>,
linkedTypebots: Pick<Typebot, 'groups' | 'variables'>[] | undefined
linkedTypebots: Pick<Typebot, 'groups' | 'variables'>[] | undefined,
results?: ResultWithAnswers[]
): ResultHeaderCell[] => {
const parsedGroups = [
...typebot.groups,
@ -32,6 +35,7 @@ export const parseResultHeader = (
{ label: 'Submitted at', id: 'date' },
...inputsResultHeader,
...parseVariablesHeaders(parsedVariables, inputsResultHeader),
...parseResultsFromPreviousBotVersions(results ?? [], inputsResultHeader),
]
}
@ -168,6 +172,32 @@ const parseVariablesHeaders = (
return [...existingHeaders, newHeaderCell]
}, [])
const parseResultsFromPreviousBotVersions = (
results: ResultWithAnswers[],
existingInputResultHeaders: ResultHeaderCell[]
): ResultHeaderCell[] =>
results
.flatMap((result) => result.answers)
.filter(
(answer) =>
!answer.variableId &&
existingInputResultHeaders.every(
(header) => header.id !== answer.blockId
) &&
isNotEmpty(answer.content)
)
.map((answer) => ({
id: answer.blockId,
label: `Deleted block`,
blocks: [
{
id: answer.blockId,
groupId: answer.groupId,
},
],
blockType: InputBlockType.TEXT,
}))
export const parseAnswers =
(
typebot: Pick<Typebot, 'groups' | 'variables'>,