diff --git a/src/app/questions-list/[slug]/question-detail-client.tsx b/src/app/questions-list/[slug]/question-detail-client.tsx index 74ed8aa..eb7c626 100644 --- a/src/app/questions-list/[slug]/question-detail-client.tsx +++ b/src/app/questions-list/[slug]/question-detail-client.tsx @@ -205,6 +205,12 @@ function QuestionFlowWrapper({ } } + if (question.type === "number") { + console.log( + `[DETAIL_LOG] id=${question.id}, answer=${JSON.stringify(answer)}, hasAnswer=${hasAnswer}, isAnswered=${isAnswered}`, + ); + } + return (
{ if (typeof value === "string" && value.length > 0) { const normalized = normalizeNumberString(value); + console.log( + `[NUM_LOG] useEffect normalize: id=${question.id}, value="${value}", normalized="${normalized}"`, + ); if (!NUMBER_INPUT_PATTERN.test(normalized)) { + console.log( + `[NUM_LOG] useEffect clearing invalid value: id=${question.id}, value="${value}"`, + ); setAnswerValue(question, null); } else if (normalized !== value) { const parsed = parseFloat(normalized); + console.log( + `[NUM_LOG] useEffect updating normalized: id=${question.id}, parsed=${parsed}`, + ); setAnswerValue( question, Number.isNaN(parsed) ? normalized : parsed, @@ -113,6 +122,10 @@ export default function QuestionNumber({ ? normalizedRaw : ""; + console.log( + `[NUM_LOG] Render: id=${question.id}, value=${JSON.stringify(value)}, inputValue="${inputValue}", isOutOfRange=${isOutOfRange}`, + ); + const isMonthlyIncome = question.ui_config?.currency_enabled === true; const currencyStorageKey = question.ui_config?.currency_storage_key || "marriage:income:currency"; @@ -324,16 +337,26 @@ export default function QuestionNumber({ const normalized = normalizeNumberString(raw); const cleaned = normalized.replace(/[^0-9.-]/g, ""); + console.log( + `[NUM_LOG] onChange: id=${question.id}, raw="${raw}", normalized="${normalized}", cleaned="${cleaned}"`, + ); + if (cleaned === "" || cleaned === "-") { + console.log(`[NUM_LOG] onChange clearing value (empty)`); setAnswerValue(question, null); return; } if (!NUMBER_INPUT_PATTERN.test(cleaned)) { + console.log(`[NUM_LOG] onChange rejected pattern: "${cleaned}"`); return; } const parsed = parseFloat(cleaned); + console.log( + `[NUM_LOG] onChange calling setAnswerValue with:`, + Number.isNaN(parsed) ? cleaned : parsed, + ); setAnswerValue( question, Number.isNaN(parsed) ? cleaned : parsed, diff --git a/src/components/Componentes/question-progress-tracker.tsx b/src/components/Componentes/question-progress-tracker.tsx index e13bbff..9823c76 100644 --- a/src/components/Componentes/question-progress-tracker.tsx +++ b/src/components/Componentes/question-progress-tracker.tsx @@ -130,6 +130,9 @@ export function QuestionProgressTracker({ setTotal(nextTotal); setAnswered(nextAnswered); + console.log( + `[PROG_LOG] updateProgress: answered=${nextAnswered}/${nextTotal}, passedIndexes=[${Array.from(passedQuestionIndexes).join(",")}]`, + ); }, [passedQuestionIndexes]); useEffect(() => {