(state: QuestionBodyState, request: QuestionRequest)
| 217 | } |
| 218 | |
| 219 | export function questionSelect(state: QuestionBodyState, request: QuestionRequest): QuestionStep { |
| 220 | const info = questionInfo(request, state) |
| 221 | if (!info) { |
| 222 | return { state } |
| 223 | } |
| 224 | |
| 225 | if (questionOther(request, state)) { |
| 226 | if (!info.multiple) { |
| 227 | return { |
| 228 | state: questionSetEditing(state, true), |
| 229 | } |
| 230 | } |
| 231 | |
| 232 | const value = questionInput(state) |
| 233 | if (value && questionPicked(state)) { |
| 234 | return { |
| 235 | state: questionToggle(state, value), |
| 236 | } |
| 237 | } |
| 238 | |
| 239 | return { |
| 240 | state: questionSetEditing(state, true), |
| 241 | } |
| 242 | } |
| 243 | |
| 244 | const option = info.options[state.selected] |
| 245 | if (!option) { |
| 246 | return { state } |
| 247 | } |
| 248 | |
| 249 | if (info.multiple) { |
| 250 | return { |
| 251 | state: questionToggle(state, option.label), |
| 252 | } |
| 253 | } |
| 254 | |
| 255 | return questionPick(state, request, option.label) |
| 256 | } |
| 257 | |
| 258 | export function questionSave(state: QuestionBodyState, request: QuestionRequest): QuestionStep { |
| 259 | const info = questionInfo(request, state) |
no test coverage detected