fix nps summary NaN bug, fix add question not working for some question types

This commit is contained in:
Matthias Nannt
2023-04-19 14:55:06 +02:00
parent fbc1c74046
commit 8352d05d04
3 changed files with 13 additions and 5 deletions

View File

@@ -59,8 +59,11 @@ export default function QuestionCard({
</div>
<Collapsible.Root
open={open}
onOpenChange={(open) => {
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">
<Collapsible.CollapsibleTrigger

View File

@@ -17,6 +17,7 @@ interface Result {
}
export default function NPSSummary({ questionSummary }: NPSSummaryProps) {
console.log(questionSummary);
const percentage = (count, total) => {
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) {

View File

@@ -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;
};