Skip to content

Commit

Permalink
fix(surveys): see multiple question surveys in overview (#18048)
Browse files Browse the repository at this point in the history
  • Loading branch information
liyiy authored Oct 17, 2023
1 parent 90d5152 commit ea0e048
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions frontend/src/scenes/surveys/SurveyView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { surveyLogic } from './surveyLogic'
import { surveysLogic } from './surveysLogic'
import { PageHeader } from 'lib/components/PageHeader'
import { SurveyReleaseSummary } from './Survey'
import { SurveyAppearance } from './SurveyAppearance'
import {
PropertyFilterType,
PropertyOperator,
Expand All @@ -25,7 +24,7 @@ import {
import { SurveyAPIEditor } from './SurveyAPIEditor'
import { NodeKind } from '~/queries/schema'
import { dayjs } from 'lib/dayjs'
import { defaultSurveyAppearance, SURVEY_EVENT_NAME } from './constants'
import { SURVEY_EVENT_NAME } from './constants'
import { FEATURE_FLAGS } from 'lib/constants'
import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import {
Expand All @@ -36,6 +35,7 @@ import {
OpenTextViz,
} from './surveyViewViz'
import './SurveyView.scss'
import { SurveyFormAppearance } from './SurveyFormAppearance'

export function SurveyView({ id }: { id: string }): JSX.Element {
const { survey, surveyLoading } = useValues(surveyLogic)
Expand All @@ -44,6 +44,8 @@ export function SurveyView({ id }: { id: string }): JSX.Element {
const { deleteSurvey } = useActions(surveysLogic)

const [tabKey, setTabKey] = useState(survey.start_date ? 'results' : 'overview')
const [activePreview, setActivePreview] = useState(0)

useEffect(() => {
if (survey.start_date) {
setTabKey('results')
Expand Down Expand Up @@ -221,17 +223,16 @@ export function SurveyView({ id }: { id: string }): JSX.Element {
)}
{survey.type !== SurveyType.API ? (
<div className="mt-6">
<SurveyAppearance
type={survey.questions[0].type}
surveyQuestionItem={survey.questions[0]}
appearance={survey.appearance || defaultSurveyAppearance}
question={survey.questions[0].question}
description={survey.questions[0].description}
link={
survey.questions[0].type === SurveyQuestionType.Link
? survey.questions[0].link
: undefined
<SurveyFormAppearance
activePreview={activePreview}
survey={survey}
showThankYou={
!!(
survey.appearance.displayThankYouMessage &&
activePreview >= survey.questions.length
)
}
setActivePreview={(preview) => setActivePreview(preview)}
/>
</div>
) : (
Expand Down

0 comments on commit ea0e048

Please sign in to comment.