{description}
diff --git a/components/time-warning-modal.tsx b/components/time-warning-modal.tsx new file mode 100644 index 0000000..cb44f58 --- /dev/null +++ b/components/time-warning-modal.tsx @@ -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