修正時間到上船數據問題
This commit is contained in:
@@ -12,6 +12,7 @@ interface CombinedAnalysisProps {
|
||||
balanceScore: number
|
||||
level: string
|
||||
description: string
|
||||
isTimeout?: boolean
|
||||
logicBreakdown?: any
|
||||
creativityBreakdown?: any
|
||||
// 個別測試結果的詳細資料
|
||||
@@ -34,6 +35,7 @@ export function CombinedAnalysis({
|
||||
balanceScore,
|
||||
level,
|
||||
description,
|
||||
isTimeout = false,
|
||||
logicBreakdown,
|
||||
creativityBreakdown,
|
||||
// 個別測試結果的詳細資料
|
||||
@@ -120,11 +122,18 @@ export function CombinedAnalysis({
|
||||
>
|
||||
<span className="text-3xl font-bold text-white">{overallScore}</span>
|
||||
</div>
|
||||
<CardTitle className="text-3xl mb-2">綜合評估完成!</CardTitle>
|
||||
<CardTitle className="text-3xl mb-2">
|
||||
綜合測試{isTimeout ? '(時間到)' : ''}完成!
|
||||
</CardTitle>
|
||||
<div className="flex items-center justify-center gap-2 mb-4">
|
||||
<Badge variant="secondary" className="text-lg px-4 py-1 bg-gradient-to-r from-blue-500 to-teal-500 text-white">
|
||||
{level}
|
||||
</Badge>
|
||||
{isTimeout && (
|
||||
<Badge variant="destructive" className="text-lg px-4 py-1">
|
||||
時間到強制提交
|
||||
</Badge>
|
||||
)}
|
||||
</div>
|
||||
<p className="text-lg text-muted-foreground mb-3">{description}</p>
|
||||
</CardHeader>
|
||||
|
124
components/time-warning-modal.tsx
Normal file
124
components/time-warning-modal.tsx
Normal file
@@ -0,0 +1,124 @@
|
||||
"use client"
|
||||
|
||||
import { useEffect, useState } from "react"
|
||||
import { Dialog, DialogContent, DialogHeader, DialogTitle } from "@/components/ui/dialog"
|
||||
import { Button } from "@/components/ui/button"
|
||||
import { AlertTriangle, Clock, CheckCircle } from "lucide-react"
|
||||
|
||||
interface TimeWarningModalProps {
|
||||
isOpen: boolean
|
||||
onClose: () => void
|
||||
type: 'warning' | 'timeout' | 'success'
|
||||
title: string
|
||||
message: string
|
||||
showCountdown?: boolean
|
||||
countdownSeconds?: number
|
||||
}
|
||||
|
||||
export function TimeWarningModal({
|
||||
isOpen,
|
||||
onClose,
|
||||
type,
|
||||
title,
|
||||
message,
|
||||
showCountdown = false,
|
||||
countdownSeconds = 0
|
||||
}: TimeWarningModalProps) {
|
||||
const [remainingSeconds, setRemainingSeconds] = useState(countdownSeconds)
|
||||
|
||||
useEffect(() => {
|
||||
if (isOpen && showCountdown && remainingSeconds > 0) {
|
||||
const timer = setInterval(() => {
|
||||
setRemainingSeconds(prev => {
|
||||
if (prev <= 1) {
|
||||
clearInterval(timer)
|
||||
onClose()
|
||||
return 0
|
||||
}
|
||||
return prev - 1
|
||||
})
|
||||
}, 1000)
|
||||
|
||||
return () => clearInterval(timer)
|
||||
}
|
||||
}, [isOpen, showCountdown, remainingSeconds, onClose])
|
||||
|
||||
useEffect(() => {
|
||||
if (isOpen) {
|
||||
setRemainingSeconds(countdownSeconds)
|
||||
}
|
||||
}, [isOpen, countdownSeconds])
|
||||
|
||||
const getIcon = () => {
|
||||
switch (type) {
|
||||
case 'warning':
|
||||
return <AlertTriangle className="w-8 h-8 text-yellow-500" />
|
||||
case 'timeout':
|
||||
return <Clock className="w-8 h-8 text-red-500" />
|
||||
case 'success':
|
||||
return <CheckCircle className="w-8 h-8 text-green-500" />
|
||||
default:
|
||||
return <AlertTriangle className="w-8 h-8 text-yellow-500" />
|
||||
}
|
||||
}
|
||||
|
||||
const getBgColor = () => {
|
||||
switch (type) {
|
||||
case 'warning':
|
||||
return 'bg-yellow-50 border-yellow-200'
|
||||
case 'timeout':
|
||||
return 'bg-red-50 border-red-200'
|
||||
case 'success':
|
||||
return 'bg-green-50 border-green-200'
|
||||
default:
|
||||
return 'bg-yellow-50 border-yellow-200'
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<Dialog open={isOpen} onOpenChange={onClose}>
|
||||
<DialogContent className={`sm:max-w-md ${getBgColor()}`}>
|
||||
<DialogHeader>
|
||||
<div className="flex items-center justify-center mb-4">
|
||||
<div className="p-3 rounded-full bg-white shadow-lg">
|
||||
{getIcon()}
|
||||
</div>
|
||||
</div>
|
||||
<DialogTitle className="text-center text-xl font-bold">
|
||||
{title}
|
||||
</DialogTitle>
|
||||
</DialogHeader>
|
||||
|
||||
<div className="text-center space-y-4">
|
||||
<p className="text-gray-700 leading-relaxed">
|
||||
{message}
|
||||
</p>
|
||||
|
||||
{showCountdown && remainingSeconds > 0 && (
|
||||
<div className="flex items-center justify-center space-x-2">
|
||||
<div className="w-8 h-8 rounded-full bg-red-500 text-white flex items-center justify-center font-bold">
|
||||
{remainingSeconds}
|
||||
</div>
|
||||
<span className="text-sm text-gray-600">秒後自動關閉</span>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="flex justify-center space-x-3 pt-4">
|
||||
<Button
|
||||
onClick={onClose}
|
||||
className={`px-6 ${
|
||||
type === 'warning'
|
||||
? 'bg-yellow-500 hover:bg-yellow-600 text-white'
|
||||
: type === 'timeout'
|
||||
? 'bg-red-500 hover:bg-red-600 text-white'
|
||||
: 'bg-green-500 hover:bg-green-600 text-white'
|
||||
}`}
|
||||
>
|
||||
{type === 'warning' ? '我知道了' : type === 'timeout' ? '確認' : '好的'}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
)
|
||||
}
|
Reference in New Issue
Block a user