Skip to content

Commit

Permalink
#58, allDimensions should be visible all the time regardless of the a…
Browse files Browse the repository at this point in the history
…ctual dimension selections
  • Loading branch information
HRemonen committed Mar 8, 2023
1 parent 9af24eb commit 787b869
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/client/components/ResultPage/Results.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,16 @@ const Results = ({ formResultData }: { formResultData: FormValues }) => {
)
const courseCompletionMethodId = courseCompletionMethodQuestion.id

const isAllDimensionsSelected: boolean = Object.values(
formResultData[dimensionQuestionId]
).every((dimension) => dimension)

const multipleChoiceObjectToArray = (aChoiceId: number): string[] =>
Object.keys(formResultData[aChoiceId]).filter(
(index) => formResultData[aChoiceId][index]
)

const modifiedResultObject = {
...formResultData,
[dimensionQuestionId]: isAllDimensionsSelected
? ['allDimensions']
: multipleChoiceObjectToArray(dimensionQuestionId),
[dimensionQuestionId]: ['allDimensions'].concat(
multipleChoiceObjectToArray(dimensionQuestionId)
),
[courseCompletionMethodId]: multipleChoiceObjectToArray(
courseCompletionMethodId
),
Expand Down

0 comments on commit 787b869

Please sign in to comment.