Skip to content

Commit

Permalink
Change has_open_choice to hasOpenChoice
Browse files Browse the repository at this point in the history
  • Loading branch information
ssoonmi committed Nov 21, 2023
1 parent e205c70 commit 983ff10
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 8 deletions.
3 changes: 1 addition & 2 deletions frontend/src/scenes/surveys/SurveyAppearance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -643,8 +643,7 @@ export function SurveyMultipleChoiceAppearance({
)}
<div className="multiple-choice-options">
{(multipleChoiceQuestion.choices || []).map((choice, idx) =>
multipleChoiceQuestion?.has_open_choice &&
idx === multipleChoiceQuestion.choices?.length - 1 ? (
multipleChoiceQuestion?.hasOpenChoice && idx === multipleChoiceQuestion.choices?.length - 1 ? (
<OpenEndedChoice
key={idx}
index={idx}
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/scenes/surveys/SurveyEdit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ export default function SurveyEdit(): JSX.Element {
question.type ===
SurveyQuestionType.MultipleChoice) && (
<div className="flex flex-col gap-2">
<Field name="has_open_choice">
<Field name="hasOpenChoice">
{({
value: hasOpenChoice,
onChange: toggleHasOpenChoice,
Expand All @@ -466,7 +466,7 @@ export default function SurveyEdit(): JSX.Element {
hasOpenChoice &&
index ===
value?.length -
1
1
return (
<div
className="flex flex-row gap-2 relative"
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/scenes/surveys/surveyLogic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ const MULTIPLE_CHOICE_SURVEY_WITH_OPEN_CHOICE: Survey = {
choices: ['Tutorials', 'Customer case studies', 'Product announcements', 'Other'],
question: 'Which types of content would you like to see more of?',
description: '',
has_open_choice: true,
hasOpenChoice: true,
},
],
conditions: null,
Expand Down Expand Up @@ -154,7 +154,7 @@ const SINGLE_CHOICE_SURVEY_WITH_OPEN_CHOICE: Survey = {
choices: ['Yes', 'No', 'Maybe (explain)'],
question: 'Would you like us to continue this feature?',
description: '',
has_open_choice: true,
hasOpenChoice: true,
},
],
conditions: null,
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/scenes/surveys/surveyLogic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ export const surveyLogic = kea<surveyLogicType>([

// Zero-fill choices that are not open-ended
question.choices.forEach((choice, idx) => {
const isOpenChoice = idx == question.choices.length - 1 && question?.has_open_choice
const isOpenChoice = idx == question.choices.length - 1 && question?.hasOpenChoice
if (results?.length && !isOpenChoice && !results.some((r) => r[1] === choice)) {
results.push([0, choice])
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2241,7 +2241,7 @@ export interface RatingSurveyQuestion extends SurveyQuestionBase {
export interface MultipleSurveyQuestion extends SurveyQuestionBase {
type: SurveyQuestionType.SingleChoice | SurveyQuestionType.MultipleChoice
choices: string[]
has_open_choice?: boolean
hasOpenChoice?: boolean
}

export type SurveyQuestion = BasicSurveyQuestion | LinkSurveyQuestion | RatingSurveyQuestion | MultipleSurveyQuestion
Expand Down

0 comments on commit 983ff10

Please sign in to comment.