( state: QuestionBodyState, request: QuestionRequest, answer: string, custom = false, )
| 155 | } |
| 156 | |
| 157 | function questionPick( |
| 158 | state: QuestionBodyState, |
| 159 | request: QuestionRequest, |
| 160 | answer: string, |
| 161 | custom = false, |
| 162 | ): QuestionStep { |
| 163 | const answers = [...state.answers] |
| 164 | answers[state.tab] = [answer] |
| 165 | let next: QuestionBodyState = { |
| 166 | ...state, |
| 167 | answers, |
| 168 | editing: false, |
| 169 | } |
| 170 | |
| 171 | if (custom) { |
| 172 | const list = [...state.custom] |
| 173 | list[state.tab] = answer |
| 174 | next = { |
| 175 | ...next, |
| 176 | custom: list, |
| 177 | } |
| 178 | } |
| 179 | |
| 180 | if (questionSingle(request)) { |
| 181 | return { |
| 182 | state: next, |
| 183 | reply: { |
| 184 | requestID: request.id, |
| 185 | answers: [[answer]], |
| 186 | }, |
| 187 | } |
| 188 | } |
| 189 | |
| 190 | return { |
| 191 | state: questionSetTab(next, state.tab + 1), |
| 192 | } |
| 193 | } |
| 194 | |
| 195 | function questionToggle(state: QuestionBodyState, answer: string): QuestionBodyState { |
| 196 | const list = [...(state.answers[state.tab] ?? [])] |
no test coverage detected