2
0

🐛 (results) Fix results display when variable has undefined value

This commit is contained in:
Baptiste Arnaud
2022-11-23 09:17:37 +01:00
parent ec0e4bee77
commit d80cc1b248
4 changed files with 14 additions and 7 deletions

View File

@ -3,6 +3,7 @@ import { canReadTypebot } from '@/utils/api/dbRules'
import { authenticatedProcedure } from '@/utils/server/trpc'
import { TRPCError } from '@trpc/server'
import { ResultWithAnswers, resultWithAnswersSchema } from 'models'
import { isDefined } from 'utils'
import { z } from 'zod'
const maxLimit = 200
@ -57,5 +58,12 @@ export const getResultsProcedure = authenticatedProcedure
nextCursor = nextResult?.id
}
return { results, nextCursor }
return { results: parseResults(results), nextCursor }
})
// TODO: remove once DB entries are fixed
const parseResults = (results: ResultWithAnswers[]): ResultWithAnswers[] =>
results.map((result) => ({
...result,
variables: result.variables.filter((variable) => isDefined(variable.value)),
}))