Skip to content

Commit

Permalink
Merge pull request #606 from nwplus/gender-self-describe
Browse files Browse the repository at this point in the history
  • Loading branch information
martincai8 authored Oct 1, 2024
2 parents f47f57a + d890709 commit 4c146fc
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/components/ApplicationQuestions/SelectAll.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,28 @@ import { applyCustomSort, toCamelCase, toOtherCamelCase } from '../../utility/ut
import { TextInput, Select } from '../Input'

const SelectAll = ({ refs, errors, formInputs, onChange, question }) => {
const transformSelectAllOptions = (options, includeOther) => {
const transformSelectAllOptions = (options, includeOther, formInput) => {
const transformedOptions = options.reduce((acc, option) => {
acc[toCamelCase(option)] = option.toString()
return acc
}, {})

if (includeOther) {
transformedOptions.other = 'Other (Please specify)'
if (formInput === 'gender') {
transformedOptions.other = 'Prefer to self-describe'
} else {
transformedOptions.other = 'Other (Please specify)'
}
}

return transformedOptions
}

const selectAllOptions = transformSelectAllOptions(question.options, question.other)
const selectAllOptions = transformSelectAllOptions(
question.options,
question.other,
question.formInput
)

return (
<>
Expand Down

0 comments on commit 4c146fc

Please sign in to comment.