2
0

🐛 (results) Fix export results when more than 200

This commit is contained in:
Baptiste Arnaud
2022-11-21 14:49:03 +01:00
parent fbd33046a1
commit 8c15fd17a1
3 changed files with 14 additions and 16 deletions

View File

@ -62,16 +62,17 @@ export const ResultsActionButtons = ({
const getAllTableData = async () => {
if (!workspaceId || !typebotId) return []
const allResults = []
let cursor: string | undefined | null
let cursor: string | undefined
do {
try {
const { results, nextCursor } =
await trpcContext.results.getResults.fetch({
typebotId,
limit: '200',
cursor,
})
allResults.push(...results)
cursor = nextCursor
cursor = nextCursor ?? undefined
} catch (error) {
showToast({ description: (error as TRPCError).message })
}

View File

@ -24,7 +24,7 @@ import { ResultsActionButtons } from './ResultsActionButtons'
import { Row } from './Row'
import { HeaderRow } from './HeaderRow'
import { CellValueType, TableData } from '../../types'
import { HeaderIcon } from '../../utils'
import { HeaderIcon, parseAccessor } from '../../utils'
import { IndeterminateCheckbox } from './IndeterminateCheckbox'
type ResultsTableProps = {
@ -111,7 +111,7 @@ export const ResultsTable = ({
},
...resultHeader.map<ColumnDef<TableData>>((header) => ({
id: header.id,
accessorKey: header.label,
accessorKey: parseAccessor(header.label),
size: 200,
header: () => (
<HStack overflow="hidden" data-testid={`${header.label} header`}>
@ -120,14 +120,9 @@ export const ResultsTable = ({
</HStack>
),
cell: (info) => {
try {
const value = info?.getValue() as CellValueType | undefined
if (!value) return
return value.element || value.plainText || ''
} catch (err) {
console.error(err)
return
}
const value = info?.getValue() as CellValueType | undefined
if (!value) return
return value.element || value.plainText || ''
},
})),
{

View File

@ -20,7 +20,9 @@ export const parseDateToReadable = (date: Date): string =>
minute: '2-digit',
})
export const parseSubmissionsColumns = (
export const parseAccessor = (label: string) => label.replaceAll('.', '')
export const parseHeaderCells = (
resultHeader: ResultHeaderCell[]
): HeaderCell[] =>
resultHeader.map((header) => ({
@ -30,7 +32,7 @@ export const parseSubmissionsColumns = (
<Text>{header.label}</Text>
</HStack>
),
accessor: header.label,
accessor: parseAccessor(header.label),
}))
export const HeaderIcon = ({ header }: { header: ResultHeaderCell }) =>
@ -66,7 +68,7 @@ export const convertResultsToTableData = (
if (!header || !header.blocks || !header.blockType) return o
return {
...o,
[header.label]: {
[parseAccessor(header.label)]: {
element: parseContent(answer.content, header.blockType),
plainText: answer.content,
},
@ -80,7 +82,7 @@ export const convertResultsToTableData = (
if (isDefined(o[key])) return o
return {
...o,
[key]: { plainText: variable.value?.toString() },
[parseAccessor(key)]: { plainText: variable.value?.toString() },
}
}, {}),
}))