diff --git a/src/components/ApplicationForm/BasicInfo.js b/src/components/ApplicationForm/BasicInfo.js index 391431e2..5e4a9126 100644 --- a/src/components/ApplicationForm/BasicInfo.js +++ b/src/components/ApplicationForm/BasicInfo.js @@ -359,6 +359,17 @@ const StyledTextInput = styled(TextInput)` margin: 0.5em 1em 1em 0; ` +const applyCustomSort = (data, sort) => { + data.sort((a, b) => { + const indexA = sort.indexOf(a[0]) + const indexB = sort.indexOf(b[0]) + + return indexA - indexB + }) + + return data +} + // form part 1 export default ({ refs, errors, formInputs, onChange }) => ( <> @@ -660,22 +671,23 @@ export default ({ refs, errors, formInputs, onChange }) => ( {errors?.dietaryRestriction && {errors?.dietaryRestriction}} {formInputs && - Object.entries(formInputs?.dietaryRestriction) - .sort() - .map(([key, val]) => ( - + onChange({ + dietaryRestriction: { ...formInputs.dietaryRestriction, [key]: !val }, + }) + } + customRef={key === 'vegetarian' ? refs['dietaryRestrictionRef'] : null} + /> + ))}
{formInputs?.dietaryRestriction?.other && ( ( What are your pronouns? {/* {errors?.pronouns && {errors?.pronouns}} */} {formInputs && - Object.entries(formInputs?.pronouns) - .sort() - .map(([key, val]) => ( + applyCustomSort(Object.entries(formInputs?.pronouns), Object.keys(PRONOUN_OPTIONS)).map( + ([key, val]) => ( ( } customRef={refs['ethnicityRef']} /> - ))} + ) + )}
{formInputs?.ethnicity?.other && (