Stress Level Quiz Page 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 import React, { useState } from 'react'; import { useRouter } from 'next/router'; import { Card, CardContent, Button } from '@/components/ui'; const StressLevelQuiz = () => { const [step, setStep] = useState(1); const [answers, setAnswers] = useState({}); const router = useRouter(); const questions = [ { id: 1, text: 'How often do you feel overwhelmed by your daily tasks?' }, { id: 2, text: 'How often do you experience tension or tightness in your body?' }, { id: 3, text: 'How often do you find it difficult to relax or calm your mind?' }, { id: 4, text: 'How often do you feel irritable or easily frustrated?' }, { id: 5, text: 'How often do you have trouble sleeping due to stress?' } ]; const handleAnswer = (questionId, value) => { setAnswers({ ...answers, [questionId]: value }); if (step < questions.length) { setStep(step + 1); } else { const totalScore = Object.values(answers).reduce((a, b) => a + b, 0); router.push({ pathname: '/quiz-results', query: { score: totalScore } }); } }; return (
{step <= questions.length ? (

Question {step} of {questions.length}

{questions[step - 1].text}

{[1, 2, 3, 4, 5].map((value) => ( ))}
) : (
Loading...
)}
); }; export default StressLevelQuiz;
import React from 'react'; import { useRouter } from 'next/router'; import { Card, CardContent } from '@/components/ui'; const QuizResults = () => { const router = useRouter(); const { score } = router.query; const getResultMessage = (score) => { if (!score) return 'Calculating...'; const scoreNum = parseInt(score, 10); if (scoreNum <= 8) return 'Your stress level is Low. Keep maintaining your calm and balance!'; if (scoreNum <= 15) return 'Your stress level is Moderate. It’s important to take time for relaxation and rejuvenation.'; return 'Your stress level is High. Consider incorporating more wellness practices to help reduce your stress.'; }; return (

Stress Level Results

{getResultMessage(score)}

); }; export default QuizResults;