-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Extract assessment answer presentation
This change extracts the handling of rendering assessment answers within another component, for example, a list of panels with a tag into another presenter. This will allow it to be shared by other parts of the app and give the ability to present the assessment answers in separate ways more easily. This change does still contain a style of loading settings internally that we would like to get rid of (see #696) as the refactor would be a much bigger and more time consuming change at this stage.
- Loading branch information
1 parent
9e9850a
commit 02b513a
Showing
11 changed files
with
474 additions
and
452 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,23 @@ | ||
const { sortBy, mapValues } = require('lodash') | ||
|
||
const { TAG_CATEGORY_WHITELIST } = require('../../config') | ||
const { filterExpired } = require('../helpers/reference-data') | ||
const { ASSESSMENT_ANSWERS_CATEGORY_SETTINGS } = require('../../config') | ||
const referenceDataHelpers = require('../helpers/reference-data') | ||
|
||
module.exports = function assessmentAnswersByCategory(assessmentAnswers = []) { | ||
const mapped = mapValues(TAG_CATEGORY_WHITELIST, (params, category) => { | ||
const answers = assessmentAnswers | ||
.filter(answer => answer.category === category) | ||
.filter(filterExpired) | ||
const mapped = mapValues( | ||
ASSESSMENT_ANSWERS_CATEGORY_SETTINGS, | ||
(params, category) => { | ||
const answers = assessmentAnswers | ||
.filter(answer => answer.category === category) | ||
.filter(referenceDataHelpers.filterExpired) | ||
|
||
return { | ||
...params, | ||
answers, | ||
key: category, | ||
return { | ||
...params, | ||
answers, | ||
key: category, | ||
} | ||
} | ||
}) | ||
) | ||
|
||
return sortBy(mapped, 'sortOrder') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.