fix: update goToNextQuestion logic to work in last question

This commit is contained in:
moritzrengert
2023-05-30 08:50:39 +02:00
parent b70b0008c1
commit f71cc87b3d
@@ -191,16 +191,15 @@ export default function PreviewSurvey({
}
}
}
return questions[currentQuestionIndex + 1]?.id || "";
return questions[currentQuestionIndex + 1]?.id || "end";
}
const gotoNextQuestion = (data) => {
const currentIndex = questions.findIndex((q) => q.id === activeQuestionId);
const nextQuestionId = getNextQuestion(data);
if (currentIndex < questions.length - 1 && nextQuestionId !== "end") {
if (currentIndex < questions.length - 1 || nextQuestionId !== "end") {
setActiveQuestionId(nextQuestionId);
// setActiveQuestionId(questions[currentIndex + 1].id);
} else {
if (thankYouCard?.enabled) {
setActiveQuestionId("thank-you-card");