Skip to content

Commit

Permalink
fix(surveys): multiple questions bug fix (#17832)
Browse files Browse the repository at this point in the history
* fix multiple questions new q

* remove debugger
  • Loading branch information
liyiy authored Oct 5, 2023
1 parent 8e754e4 commit c5e4a99
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
5 changes: 4 additions & 1 deletion frontend/src/scenes/surveys/Survey.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,10 @@ export function SurveyForm({ id }: { id: string }): JSX.Element {
className="w-max"
icon={<IconPlus />}
onClick={() => {
setSurveyValue('questions', [...survey.questions, { ...defaultSurveyFieldValues.open }])
setSurveyValue('questions', [
...survey.questions,
{ ...defaultSurveyFieldValues.open.questions[0] },
])
}}
>
Add question
Expand Down
5 changes: 5 additions & 0 deletions frontend/src/scenes/surveys/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export const defaultSurveyFieldValues = {
[SurveyQuestionType.Open]: {
questions: [
{
type: SurveyQuestionType.Open,
question: 'Give us feedback on our product!',
description: '',
},
Expand All @@ -47,6 +48,7 @@ export const defaultSurveyFieldValues = {
[SurveyQuestionType.Link]: {
questions: [
{
type: SurveyQuestionType.Link,
question: 'Do you want to join our upcoming webinar?',
description: '',
},
Expand All @@ -59,6 +61,7 @@ export const defaultSurveyFieldValues = {
[SurveyQuestionType.Rating]: {
questions: [
{
type: SurveyQuestionType.Rating,
question: 'How likely are you to recommend us to a friend?',
description: '',
display: 'number',
Expand All @@ -74,6 +77,7 @@ export const defaultSurveyFieldValues = {
[SurveyQuestionType.SingleChoice]: {
questions: [
{
type: SurveyQuestionType.SingleChoice,
question: 'Have you found this tutorial useful?',
description: '',
choices: ['Yes', 'No'],
Expand All @@ -87,6 +91,7 @@ export const defaultSurveyFieldValues = {
[SurveyQuestionType.MultipleChoice]: {
questions: [
{
type: SurveyQuestionType.MultipleChoice,
question: 'Which types of content would you like to see more of?',
description: '',
choices: ['Tutorials', 'Customer case studies', 'Product announcements'],
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/scenes/surveys/surveyLogic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -167,17 +167,17 @@ export const surveyLogic = kea<surveyLogicType>([
) => {
const question = isEditingQuestion
? state.questions[idx].question
: defaultSurveyFieldValues[type].questions[idx].question
: defaultSurveyFieldValues[type].questions[0].question
const description = isEditingDescription
? state.questions[idx].description
: defaultSurveyFieldValues[type].questions[idx].description
: defaultSurveyFieldValues[type].questions[0].description
const thankYouMessageHeader = isEditingThankYouMessage
? state.appearance.thankYouMessageHeader
: defaultSurveyFieldValues[type].appearance.thankYouMessageHeader
const newQuestions = [...state.questions]
newQuestions[idx] = {
...state.questions[idx],
...(defaultSurveyFieldValues[type].questions[idx] as SurveyQuestionBase),
...(defaultSurveyFieldValues[type].questions[0] as SurveyQuestionBase),
question,
description,
}
Expand Down

0 comments on commit c5e4a99

Please sign in to comment.