Skip to content

Commit 7927bdc

Browse files
authored
Limit question response choices to 99 (#693)
You'd have to try really hard to do this in the UI, but this should also serve as documentation.
1 parent e7e4e71 commit 7927bdc

File tree

2 files changed

+49
-32
lines changed

2 files changed

+49
-32
lines changed

.changeset/rotten-mugs-develop.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'wingman-fe': patch
3+
---
4+
5+
QuestionnaireBuilder: Limit response choices to 99

fe/lib/components/QuestionnaireBuilder/FormBuilder/components/NewQuestionForm/components/SelectOptions.tsx

Lines changed: 44 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
Columns,
66
FieldMessage,
77
Stack,
8+
Text,
89
TextField,
910
} from 'braid-design-system';
1011
import React, { useMemo, useRef } from 'react';
@@ -15,6 +16,11 @@ import { createResolver } from '../../../../../../utils';
1516

1617
import DisplayOption from './DisplayOption';
1718

19+
/**
20+
* https://developer.seek.com/schema/#/named-type/ApplicationQuestionInput/field/responseChoice
21+
*/
22+
const RESPONSE_CHOICE_LIMIT = 99;
23+
1824
interface FormValues {
1925
option: string;
2026
}
@@ -99,39 +105,45 @@ export default ({ options, setOptionList }: SelectOptionsProps) => {
99105

100106
return (
101107
<Stack space="medium">
102-
<Stack space="small">
103-
<Columns alignY="bottom" space="small">
104-
<Column>
105-
<Controller
106-
control={control}
107-
name="option"
108-
render={({ field }) => (
109-
<TextField
110-
{...field}
111-
id="questionnaireBuilderAddOption"
112-
label="Options"
113-
onClear={() => setValue('option', '')}
114-
ref={optionInputRef}
115-
tone={errors.option ? 'critical' : undefined}
116-
/>
117-
)}
108+
{options.length >= RESPONSE_CHOICE_LIMIT ? (
109+
<Text tone="secondary">
110+
You can’t provide more than {RESPONSE_CHOICE_LIMIT} options.
111+
</Text>
112+
) : (
113+
<Stack space="small">
114+
<Columns alignY="bottom" space="small">
115+
<Column>
116+
<Controller
117+
control={control}
118+
name="option"
119+
render={({ field }) => (
120+
<TextField
121+
{...field}
122+
id="questionnaireBuilderAddOption"
123+
label="Options"
124+
onClear={() => setValue('option', '')}
125+
ref={optionInputRef}
126+
tone={errors.option ? 'critical' : undefined}
127+
/>
128+
)}
129+
/>
130+
</Column>
131+
<Column width="content">
132+
<Actions>
133+
<Button onClick={handleSubmit(addOption)}>Add</Button>
134+
</Actions>
135+
</Column>
136+
</Columns>
137+
138+
{errors.option?.message ? (
139+
<FieldMessage
140+
id="questionnaireBuilderAddOptionMessage"
141+
message={errors.option.message}
142+
tone="critical"
118143
/>
119-
</Column>
120-
<Column width="content">
121-
<Actions>
122-
<Button onClick={handleSubmit(addOption)}>Add</Button>
123-
</Actions>
124-
</Column>
125-
</Columns>
126-
127-
{errors.option?.message ? (
128-
<FieldMessage
129-
id="questionnaireBuilderAddOptionMessage"
130-
message={errors.option.message}
131-
tone="critical"
132-
/>
133-
) : null}
134-
</Stack>
144+
) : null}
145+
</Stack>
146+
)}
135147

136148
<Stack dividers space="small">
137149
{options.map(({ text, preferredIndicator }) => (

0 commit comments

Comments
 (0)