2
0

fix(results): 🐛 Loading rows

This commit is contained in:
Baptiste Arnaud
2022-02-11 15:30:02 +01:00
parent 901e2f39b0
commit 93fed893c0
13 changed files with 85 additions and 90 deletions

View File

@ -78,18 +78,25 @@ export const parseSubmissionsColumns = (
(block) => typebot && block.steps.some((step) => isInputStep(step))
)
.map((block) => {
const inputStep = block.steps.find((step) =>
isInputStep(step)
) as InputStep
const inputStep = block.steps.find((step) => isInputStep(step))
if (!inputStep || !isInputStep(inputStep)) return
return {
Header: (
<HStack>
<HStack
minW={
'isLong' in inputStep.options && inputStep.options.isLong
? '400px'
: '150px'
}
maxW="500px"
>
<StepIcon type={inputStep.type} />
<Text>{block.title}</Text>
</HStack>
),
accessor: block.id,
}
}),
})
.filter(isDefined),
]
}

View File

@ -5,6 +5,8 @@ import { stringify } from 'qs'
import { Answer } from 'db'
import { sendRequest } from 'utils'
const paginationLimit = 50
const getKey = (
typebotId: string,
pageIndex: number,
@ -16,7 +18,7 @@ const getKey = (
if (pageIndex === 0) return `/api/typebots/${typebotId}/results?limit=50`
return `/api/typebots/${typebotId}/results?lastResultId=${
previousPageData.results[previousPageData.results.length - 1].id
}&limit=50`
}&limit=${paginationLimit}`
}
export type ResultWithAnswers = Result & { answers: Answer[] }
@ -49,7 +51,10 @@ export const useResults = ({
setSize,
size,
hasMore:
data && data.length > 0 && data[data.length - 1].results.length > 0,
data &&
data.length > 0 &&
data[data.length - 1].results.length > 0 &&
data.length === paginationLimit,
}
}