/* 03 Test de afinidad IA */ const AFFINITY_QUESTIONS = [ { // 2026-09-26: multi (antes radio) — se pueden marcar varias opciones de una en una id: 'q1', type: 'multi', max: 2, q: '¿Qué te describe mejor una noche perfecta?', opts: ['Cena íntima en un rooftop', 'Sesión de vinilos en casa', 'Concierto y planes de noche', 'Ruta rural y estrellas'], }, { id: 'q2', type: 'slider', q: '¿Cuánto planificas tu vida?', left: 'Improvisación total', right: 'Todo en agenda', }, { id: 'q3', type: 'multi', q: 'Elige 3 cosas que te enganchan a alguien', opts: ['Sentido del humor','Ambición','Estilo','Silencios cómodos','Curiosidad','Empatía','Independencia','Sensualidad','Cocinar','Bailar'], max: 3, }, { id: 'q4', type: 'radio', q: 'Discusión importante: cómo actúas', opts: ['La afronto en caliente','Pido tiempo y vuelvo','Escribo lo que pienso primero','Necesito espacio de días'], }, { id: 'q5', type: 'slider', q: '¿Cuánto peso tiene la familia en tu vida?', left: 'Vivo mi camino', right: 'Es mi base', }, { id: 'q6', type: 'text', q: 'Termina la frase: "Nunca podría estar con alguien que..."', ph: 'Sé honesto. Nadie más lo verá.', }, { // 2026-09-26: opciones SEPARADAS y marcables una a una (decisión Stokmarket). // Antes venía "Deporte y aire libre" junto: hay gente a la que le gusta la tranquilidad // del campo pero NO hacer deporte al aire libre — ahora son dos opciones independientes. id: 'q7', type: 'multi', max: 3, q: '¿Qué te gusta hacer en tus fines de semana?', opts: ['Hacer deporte', 'Aire libre y naturaleza', 'Cultura y museos', 'Bares y planes con amigos', 'Casa, cine y descanso'], }, { id: 'q8', type: 'slider', q: 'Fidelidad emocional vs. libertad', left: 'Todo compartido', right: 'Vidas paralelas', }, ]; function Affinity({ go }) { const [i, setI] = useState(0); const [answers, setAnswers] = useState({}); const [done, setDone] = useState(false); const [analyzing, setAnalyzing] = useState(false); const q = AFFINITY_QUESTIONS[i]; const total = AFFINITY_QUESTIONS.length; const setAns = (v) => setAnswers(a => ({ ...a, [q.id]: v })); const val = answers[q.id]; const canNext = () => { if (q.type === 'slider') return typeof val === 'number'; if (q.type === 'multi') return Array.isArray(val) && val.length > 0; if (q.type === 'text') return (val || '').trim().length > 3; return !!val; }; const next = () => { if (i < total - 1) setI(i + 1); else { setAnalyzing(true); setTimeout(() => { setAnalyzing(false); setDone(true); // Fase 1b: persistir respuestas en la API (best-effort, no bloquea la navegación) const s = window.CruceAPI && window.CruceAPI.Session.get(); if (s) window.CruceAPI.saveAffinity(answers).catch(() => {}); }, 3200); } }; if (done) { return ; } if (analyzing) { return ; } return (
{String(i+1).padStart(2,'0')} / {String(total).padStart(2,'0')}
IA · CRUCE-Q
Pregunta {i+1} de {total}

{q.q}

{q.type === 'radio' && (
{q.opts.map(o => ( ))}
)} {q.type === 'slider' && (
{q.left} {q.right}
setAns(Number(e.target.value))}/>
{val ?? 50}/100
)} {q.type === 'multi' && (
Elige hasta {q.max}.
{q.opts.map(o => { const arr = val || []; const has = arr.includes(o); return ( ); })}
)} {q.type === 'text' && (