Skip to content

Commit

Permalink
added indicator to tell people if question is filled
Browse files Browse the repository at this point in the history
  • Loading branch information
tfhuhtal committed Nov 12, 2024
1 parent 9f16f1f commit 85bd191
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ const QuestionPicker = ({ index, label, questionsList, form }) => {
const { t } = useTranslation()
const dispatch = useDispatch()
const lang = useSelector(state => state.language)
const allSelectedQuestions = useSelector(({ form }) => form.data.selectedQuestionIds || [])
const answers = useSelector(({ form }) => form.data)
const allSelectedQuestions = answers.selectedQuestionIds || []
const [sectionQuestions, setSectionQuestions] = useState([])

useEffect(() => {
Expand All @@ -31,9 +32,25 @@ const QuestionPicker = ({ index, label, questionsList, form }) => {
updateAllSelectedQuestions(newQuestion)
}

const isFilled = question => {
const questionKeys = Object.keys(answers).filter(
key => key.startsWith(`${question.id}_`) && !key.includes('degree_radio') && !key.includes('modal'),
)
if (questionKeys.some(key => answers[key] && answers[key].length > 0)) {
return (
<>
<span>{`${question.index}. ${question.label[lang]}-`}</span>
<span style={{ color: 'green' }}>{`(${t('common:filled')})`}</span>
</>
)
}

return <span>{`${question.index}. ${question.label[lang]}`}</span>
}

const dropdownOptions = questionsList.map(question => ({
key: question.id,
text: `${question.index}. ${question.label[lang]}`,
text: isFilled(question),
value: question.id,
}))

Expand Down
1 change: 1 addition & 0 deletions client/util/locales/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export default {
cancel: 'Cancel',
edit: 'Edit',
delete: 'Delete',
filled: 'filled',

yearlyAssessment: 'Annual follow-up',
evaluation: 'Review',
Expand Down
1 change: 1 addition & 0 deletions client/util/locales/fi.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export default {
cancel: 'Peruuta',
edit: 'Muokkaa',
delete: 'Poista',
filled: 'täytetty',

modifyLights: 'Muokkaa valoja',

Expand Down
1 change: 1 addition & 0 deletions client/util/locales/se.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export default {
cancel: 'Avbryt',
edit: 'Redigera',
delete: 'Ta bort',
filled: 'ifylld',

yearlyAssessment: 'Årlig uppföljning',
evaluation: 'Översynen',
Expand Down

0 comments on commit 85bd191

Please sign in to comment.