"use client" import { useState, useEffect } from "react" import { TestLayout } from "@/components/test-layout" import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card" import { Button } from "@/components/ui/button" import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group" import { Label } from "@/components/ui/label" import { useRouter } from "next/navigation" import { creativeQuestions } from "@/lib/questions/creative-questions" export default function CreativeTestPage() { const router = useRouter() const [currentQuestion, setCurrentQuestion] = useState(0) const [answers, setAnswers] = useState>({}) const [timeRemaining, setTimeRemaining] = useState(30 * 60) // 30 minutes in seconds // Timer effect useEffect(() => { const timer = setInterval(() => { setTimeRemaining((prev) => { if (prev <= 1) { handleSubmit() return 0 } return prev - 1 }) }, 1000) return () => clearInterval(timer) }, []) const formatTime = (seconds: number) => { const mins = Math.floor(seconds / 60) const secs = seconds % 60 return `${mins.toString().padStart(2, "0")}:${secs.toString().padStart(2, "0")}` } const handleAnswerChange = (value: string) => { setAnswers((prev) => ({ ...prev, [currentQuestion]: Number.parseInt(value), })) } const handleNext = () => { if (currentQuestion < creativeQuestions.length - 1) { setCurrentQuestion((prev) => prev + 1) } } const handlePrevious = () => { if (currentQuestion > 0) { setCurrentQuestion((prev) => prev - 1) } } const handleSubmit = () => { // Calculate score based on creativity scoring let totalScore = 0 creativeQuestions.forEach((question, index) => { const answer = answers[index] || 1 // For creativity, higher scores indicate more creative thinking totalScore += question.isReverse ? 6 - answer : answer }) const maxScore = creativeQuestions.length * 5 const score = Math.round((totalScore / maxScore) * 100) // Store results in localStorage const results = { type: "creative", score, totalScore, maxScore, answers, completedAt: new Date().toISOString(), } localStorage.setItem("creativeTestResults", JSON.stringify(results)) router.push("/results/creative") } const currentQ = creativeQuestions[currentQuestion] const isLastQuestion = currentQuestion === creativeQuestions.length - 1 const hasAnswer = answers[currentQuestion] !== undefined const scaleOptions = [ { value: "5", label: "我最符合", color: "text-green-600" }, { value: "4", label: "比较符合", color: "text-green-500" }, { value: "3", label: "一般", color: "text-yellow-500" }, { value: "2", label: "不太符合", color: "text-orange-500" }, { value: "1", label: "与我不符", color: "text-red-500" }, ] return ( router.push("/")} >
{currentQ.statement}

請根據這個描述與你的實際情況的符合程度進行選擇

{scaleOptions.map((option) => (
{option.value}
))}
{/* Navigation */}
{creativeQuestions.map((_, index) => ( ))}
{isLastQuestion ? ( ) : ( )}
{/* Progress Summary */}
已完成 {Object.keys(answers).length} / {creativeQuestions.length} 題
) }