diff --git a/src/data/quiz.ts b/src/data/quiz.ts index ddd9eab..a534ed6 100644 --- a/src/data/quiz.ts +++ b/src/data/quiz.ts @@ -66,7 +66,7 @@ export const QUIZ_QUESTIONS: QuizQuestion[] = [ { id: 'desire', prompt: 'What are you craving from Adazo right now?', - sub: 'Pick up to two. No wrong answers — this is your edit.', + sub: 'Tap up to two — no Continue button. We’ll move on when you’re done.', multiSelect: true, maxSelect: 2, options: [ @@ -222,7 +222,7 @@ export const QUIZ_QUESTIONS: QuizQuestion[] = [ { id: 'priority', prompt: 'If Adazo only kept three shelves for you, which matter most?', - sub: 'Pick up to two priorities.', + sub: 'Tap up to two priorities — advances on its own.', multiSelect: true, maxSelect: 2, options: [ diff --git a/src/pages/Quiz.tsx b/src/pages/Quiz.tsx index cf2b40a..763fa7a 100644 --- a/src/pages/Quiz.tsx +++ b/src/pages/Quiz.tsx @@ -202,38 +202,67 @@ export function Quiz() { }, 340) } + /** + * Multi-select: tap to toggle. No separate Continue. + * - Hitting maxSelect auto-advances immediately + * - With 1..max-1 selected, a short settle timer advances (tap another to extend) + * - Re-tapping a selected card when it's the only pick confirms and advances + */ function toggleMulti(optionId: string) { if (!q || advancingRef.current) return const max = q.maxSelect ?? 2 + if (advanceTimer.current) clearTimeout(advanceTimer.current) + setSelectedIds((prev) => { + let next: string[] if (prev.includes(optionId)) { - return prev.filter((id) => id !== optionId) + // Only one selected → second tap confirms and advances + if (prev.length === 1) { + queueMicrotask(() => commitMulti(prev)) + return prev + } + next = prev.filter((id) => id !== optionId) + } else if (prev.length >= max) { + next = [...prev.slice(1), optionId] + } else { + next = [...prev, optionId] } - if (prev.length >= max) { - // Replace oldest selection so tap always does something - return [...prev.slice(1), optionId] + + if (next.length >= max) { + queueMicrotask(() => commitMulti(next)) + } else if (next.length > 0) { + // Allow a second pick; if they stop, advance with what they chose + advanceTimer.current = setTimeout(() => { + commitMulti(next) + }, 900) } - return [...prev, optionId] + return next }) } - function continueMulti() { - if (!q || selectedIds.length === 0 || advancingRef.current) return + function commitMulti(ids: string[]) { + if (!q || ids.length === 0 || advancingRef.current) return + if (advanceTimer.current) clearTimeout(advanceTimer.current) setAdvancingBoth(true) trackQuizAnswer({ questionId: q.id, - optionId: encodeAnswerIds(selectedIds), + optionId: encodeAnswerIds(ids), step, totalSteps, }) + const questionId = q.id + const fromStep = step const nextAnswers = { ...answers, - [q.id]: encodeAnswerIds(selectedIds), + [questionId]: encodeAnswerIds(ids), } setAnswers(nextAnswers) - setSelectedIds([]) - setAdvancingBoth(false) - advanceAfterAnswer(nextAnswers, step) + // Brief highlight, then advance + advanceTimer.current = setTimeout(() => { + setSelectedIds([]) + setAdvancingBoth(false) + advanceAfterAnswer(nextAnswers, fromStep) + }, 280) } function goBackQuestion() { @@ -376,7 +405,6 @@ export function Quiz() { advancing={advancing} onSelectSingle={commitSingle} onToggleMulti={toggleMulti} - onContinueMulti={continueMulti} onBack={goBackQuestion} /> )} @@ -417,9 +445,9 @@ function Intro({ onStart }: { onStart: () => void }) { Which Adazo persona is yours — luxury, glam, scent, or finish?

- A handful of quick taps. Zero wrong answers. Meet your house persona — - Quiet Luxe, Soft Glam Muse, Signature Scent, Fashion Finisher, and more — - with named picks ready. Save to the private edit only if you want updates. + Quick taps only — every answer advances on click, no extra Continue steps. + Meet your house persona with named picks ready. Save to the private edit + only if you want updates.

- {multi ? ( - - ) : ( -

- {advancing ? 'Next…' : 'Tap a card to continue'} -

- )} +

+ {advancing + ? 'Next…' + : multi + ? multiHint + : 'Tap a card to continue'} +

)