Skip to content

Commit

Permalink
add check for record.answers (#544)
Browse files Browse the repository at this point in the history
Co-authored-by: Mailn Nifeli Snieske <[email protected]>
  • Loading branch information
malinnsnieske and Mailn Nifeli Snieske authored Dec 10, 2024
1 parent 1c8f512 commit 87593c6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions frontend/beCompliant/src/utils/tablePageUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,16 @@ export const filterData = (

return filteredData.filter((record: Question) => {
if (fieldName === 'Svar') {
const lastAnswer = record.answers.at(-1)?.answer;
const lastAnswer = Array.isArray(record.answers)
? record.answers.at(-1)?.answer
: undefined;
return lastAnswer?.toLowerCase() === filterValue;
}

if (fieldName === 'Status') {
const lastAnswerExists = record.answers.at(-1) != null;
const lastAnswerExists = Array.isArray(record.answers)
? record.answers.at(-1) != null
: false;

if (filterValue === 'utfylt') {
return lastAnswerExists;
Expand Down

0 comments on commit 87593c6

Please sign in to comment.