2
0

fix(results): 🐛 Display results for blocks w/ multiple inputs

This commit is contained in:
Baptiste Arnaud
2022-03-10 09:25:44 +01:00
parent 7e61ab19eb
commit 4767cdc542
7 changed files with 437 additions and 231 deletions

View File

@ -7,6 +7,7 @@ import {
deleteAllResults,
deleteResults,
getAllResults,
parseResultHeader,
useResults,
} from 'services/typebots'
import { unparse } from 'papaparse'
@ -49,6 +50,8 @@ export const SubmissionsContent = ({
].filter(isDefined),
}
const resultHeader = parseResultHeader(blocksAndVariables)
const { data, mutate, setSize, hasMore } = useResults({
typebotId,
onError: (err) => toast({ title: err.name, description: err.message }),
@ -117,14 +120,12 @@ export const SubmissionsContent = ({
if (!publishedTypebot) return []
const { data, error } = await getAllResults(typebotId)
if (error) toast({ description: error.message, title: error.name })
return convertResultsToTableData(blocksAndVariables)(data?.results)
return convertResultsToTableData(data?.results, resultHeader)
}
const tableData: { [key: string]: string }[] = useMemo(
() =>
publishedTypebot
? convertResultsToTableData(blocksAndVariables)(results)
: [],
publishedTypebot ? convertResultsToTableData(results, resultHeader) : [],
// eslint-disable-next-line react-hooks/exhaustive-deps
[results]
)
@ -159,7 +160,7 @@ export const SubmissionsContent = ({
</Flex>
<SubmissionsTable
blocksAndVariables={blocksAndVariables}
resultHeader={resultHeader}
data={tableData}
onNewSelection={handleNewSelection}
onScrollToBottom={handleScrolledToBottom}