diff --git a/apps/web/app/environments/[environmentId]/surveys/[surveyId]/edit/QuestionCard.tsx b/apps/web/app/environments/[environmentId]/surveys/[surveyId]/edit/QuestionCard.tsx index 07ef4087f7..0aa91b8acd 100644 --- a/apps/web/app/environments/[environmentId]/surveys/[surveyId]/edit/QuestionCard.tsx +++ b/apps/web/app/environments/[environmentId]/surveys/[surveyId]/edit/QuestionCard.tsx @@ -59,8 +59,11 @@ export default function QuestionCard({ { - setActiveQuestionId(open ? question.id : null); + onOpenChange={() => { + if (activeQuestionId !== question.id) { + // only be able to open other question + setActiveQuestionId(question.id); + } }} className="flex-1 rounded-r-lg border border-slate-200"> { return count / total; }; @@ -32,7 +33,7 @@ export default function NPSSummary({ questionSummary }: NPSSummaryProps) { for (let response of questionSummary.responses) { const value = response.value; - if (!value || typeof value !== "number") continue; + if (typeof value !== "number") continue; data.total++; if (value >= 9) { diff --git a/apps/web/lib/templates.ts b/apps/web/lib/templates.ts index 6ac32b0239..7c639021f3 100644 --- a/apps/web/lib/templates.ts +++ b/apps/web/lib/templates.ts @@ -5,8 +5,12 @@ export const replaceQuestionPresetPlaceholders = (question: Question, product) = if (!question) return; if (!product) return question; const newQuestion = JSON.parse(JSON.stringify(question)); - newQuestion.headline = newQuestion.headline.replace("{{productName}}", product.name); - newQuestion.subheader = newQuestion.subheader?.replace("{{productName}}", product.name); + if (newQuestion.headline) { + newQuestion.headline = newQuestion.headline.replace("{{productName}}", product.name); + } + if (newQuestion.subheader) { + newQuestion.subheader = newQuestion.subheader?.replace("{{productName}}", product.name); + } return newQuestion; };