Con los números de preguntas y secciones

This commit is contained in:
markosbenitez
2026-06-08 20:25:23 -03:00
parent 307a54dabc
commit 52295a78d0
12 changed files with 367 additions and 33 deletions

View File

@@ -9,9 +9,9 @@ import { ProgressBar } from './progress-bar'
import { QuestionRenderer } from './question-renderer'
// Section metadata (code prefix → display title)
const SECTIONS: { prefix: string; title: string; sensitive?: boolean }[] = [
const SECTIONS: { prefix: string; title: string }[] = [
{ prefix: 'A', title: 'Datos Generales' },
{ prefix: '1', title: 'Prevalencia: cuidado y discapacidad', sensitive: true },
{ prefix: '1', title: 'Prevalencia: cuidado y discapacidad' },
{ prefix: '2', title: 'Intensidad y rol del cuidado' },
{ prefix: '3', title: 'Impacto económico del cuidado' },
{ prefix: '4', title: 'Tiempo y descanso' },
@@ -190,13 +190,13 @@ export function SurveyForm({ survey, questions }: SurveyFormProps) {
return v !== null && v !== undefined && v !== '' && !(Array.isArray(v) && v.length === 0)
}).length
type Section = { prefix: string; title: string; sensitive?: boolean; questions: Question[] }
type Section = { prefix: string; title: string; questions: Question[] }
const sectionMap = new Map<string, Section>()
for (const q of visibleQuestions) {
const prefix = getSectionPrefix(q.code)
if (!sectionMap.has(prefix)) {
const meta = SECTIONS.find((s) => s.prefix === prefix)
sectionMap.set(prefix, { prefix, title: meta?.title ?? prefix, sensitive: meta?.sensitive, questions: [] })
sectionMap.set(prefix, { prefix, title: meta?.title ?? prefix, questions: [] })
}
sectionMap.get(prefix)!.questions.push(q)
}
@@ -242,13 +242,7 @@ export function SurveyForm({ survey, questions }: SurveyFormProps) {
aria-labelledby={`section-${section.prefix}`}
>
<div className="section-header">
<h2 id={`section-${section.prefix}`} className="section-title">{section.title}</h2>
{section.sensitive && (
<p className="section-sensitive-note" role="note">
Esta sección contiene preguntas sensibles sobre salud o discapacidad.
Responder es completamente voluntario.
</p>
)}
<h2 id={`section-${section.prefix}`} className="section-title">Sección {section.prefix} · {section.title}</h2>
</div>
{section.questions.map((q) => (
<div key={q.id} className="question-wrapper" data-code={q.code}>