// Archetype Personality Quiz Logic for Wix Velo
import wixLocation from 'wix-location';
let score = {
Sovereign: 0,
Titan: 0,
Sage: 0,
Infernal: 0,
Sentinel: 0,
Vessel: 0
};
let currentQuestion = 1;
const totalQuestions = 12;
// Called when a user selects an answer
export function answerSelected(archetype) {
score[archetype]++;
goToNextQuestion();
}
function goToNextQuestion() {
// Hide current question
$w(`#q${currentQuestion}`).hide("fade");
currentQuestion++;
// Show next question or finish
if (currentQuestion <= totalQuestions) {
$w(`#q${currentQuestion}`).show("fade");
} else {
showFinalResult();
}
}
function showFinalResult() {
// Find the archetype with the highest score
let result = Object.entries(score).reduce((a, b) => a[1] >= b[1] ? a : b)[0];
// Redirect to result page
wixLocation.to(`/results/${result.toLowerCase()}`);
}
// For each answer button, connect to the handler like this:
// export function q1a_click(event) { answerSelected("Sovereign"); }
// export function q1b_click(event) { answerSelected("Titan"); }
// ...etc
// Repeat for q2a_click, q2b_click, ..., q12f_click
// Example implementations for Q1
export function q1a_click(event) { answerSelected("Sovereign"); }
export function q1b_click(event) { answerSelected("Titan"); }
export function q1c_click(event) { answerSelected("Sage"); }
export function q1d_click(event) { answerSelected("Infernal"); }
export function q1e_click(event) { answerSelected("Sentinel"); }
export function q1f_click(event) { answerSelected("Vessel"); }
// Repeat above click handlers for all 12 questions, updating the function names and archetypes accordingly.