From 9532df5c75c0be16ab3a3b2143767d959baa7c4b Mon Sep 17 00:00:00 2001 From: Li Yi Yu Date: Wed, 18 Oct 2023 21:13:01 -0400 Subject: [PATCH] update survey banner warning --- frontend/src/scenes/surveys/Surveys.tsx | 6 ++++-- frontend/src/scenes/surveys/surveyLogic.tsx | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/frontend/src/scenes/surveys/Surveys.tsx b/frontend/src/scenes/surveys/Surveys.tsx index b6e969e01c649..1252eef3172b8 100644 --- a/frontend/src/scenes/surveys/Surveys.tsx +++ b/frontend/src/scenes/surveys/Surveys.tsx @@ -60,7 +60,8 @@ export function Surveys(): JSX.Element { const { user } = useValues(userLogic) const { currentTeam } = useValues(teamLogic) - const surveysPopupDisabled = currentTeam && !currentTeam?.surveys_opt_in + const surveysPopupDisabled = + currentTeam && !currentTeam?.surveys_opt_in && surveys.some((s) => s.start_date && !s.end_date) const [tab, setSurveyTab] = useState(SurveysTabs.Active) const shouldShowEmptyState = !surveysLoading && surveys.length === 0 @@ -139,7 +140,8 @@ export function Surveys(): JSX.Element { }} className="mb-2" > - Survey popovers are currently disabled for this project. + Survey popovers are currently disabled for this project but there are active surveys running. + Re-enable them in the settings. ) : null} diff --git a/frontend/src/scenes/surveys/surveyLogic.tsx b/frontend/src/scenes/surveys/surveyLogic.tsx index fa6c07f314d4f..a9476839eb672 100644 --- a/frontend/src/scenes/surveys/surveyLogic.tsx +++ b/frontend/src/scenes/surveys/surveyLogic.tsx @@ -424,8 +424,8 @@ export const surveyLogic = kea([ stopSurveySuccess: ({ survey }) => { actions.loadSurveys() if (values.currentTeam?.surveys_opt_in === true) { - const allActiveSurveys = values.surveys.filter((s) => s.start_date && !s.end_date) - if (allActiveSurveys.length === 0) { + const hasActiveSurveys = values.surveys.some((s) => s.start_date && !s.end_date) + if (!hasActiveSurveys) { actions.setSurveysOptIn(false) } }