Browse Source

fix(questions): accurately compute isAnswered for birthplace objects and strings

master
mortezaei 3 days ago
parent
commit
2abad06265
  1. 7
      src/app/questions-list/[slug]/question-detail-client.tsx

7
src/app/questions-list/[slug]/question-detail-client.tsx

@ -17,6 +17,7 @@ import {
} from "@/components/Componentes/question-answer-storage"; } from "@/components/Componentes/question-answer-storage";
import QuestionExitNavigationButton from "@/components/Componentes/question-exit-navigation-button"; import QuestionExitNavigationButton from "@/components/Componentes/question-exit-navigation-button";
import QuestionRenderer from "@/components/Componentes/question-renderer"; import QuestionRenderer from "@/components/Componentes/question-renderer";
import { parseValue as parseBirthplaceValue } from "@/components/Componentes/question-birthplace";
import QuestionSectionFlow from "@/components/Componentes/question-section-flow"; import QuestionSectionFlow from "@/components/Componentes/question-section-flow";
import StickyHeader from "@/components/Componentes/sticky-header"; import StickyHeader from "@/components/Componentes/sticky-header";
import TestIntroPage from "@/components/Componentes/test-intro-page"; import TestIntroPage from "@/components/Componentes/test-intro-page";
@ -197,10 +198,8 @@ function QuestionFlowWrapper({
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
isAnswered = emailRegex.test(String(answer).trim()); isAnswered = emailRegex.test(String(answer).trim());
} else if (question.type === "birthplace") { } else if (question.type === "birthplace") {
const strVal = String(answer);
const parts = strVal.split(",").map((p) => p.trim());
isAnswered =
parts.length >= 2 && parts[0].length > 0 && parts[1].length > 0;
const parsed = parseBirthplaceValue(answer);
isAnswered = Boolean(parsed.country?.trim() && parsed.city?.trim());
} else if (question.type === "checkbox") { } else if (question.type === "checkbox") {
isAnswered = Array.isArray(answer) ? answer.length > 0 : hasAnswer; isAnswered = Array.isArray(answer) ? answer.length > 0 : hasAnswer;
} }

Loading…
Cancel
Save