"use client" import type React from "react" import { useState } from "react" import { Button } from "@/components/ui/button" import { Input } from "@/components/ui/input" import { Label } from "@/components/ui/label" import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from "@/components/ui/dialog" import { Alert, AlertDescription } from "@/components/ui/alert" import { Mail, ArrowLeft, CheckCircle } from "lucide-react" interface ForgotPasswordDialogProps { open: boolean onOpenChange: (open: boolean) => void onBackToLogin: () => void } export function ForgotPasswordDialog({ open, onOpenChange, onBackToLogin }: ForgotPasswordDialogProps) { const [email, setEmail] = useState("") const [isLoading, setIsLoading] = useState(false) const [isSuccess, setIsSuccess] = useState(false) const [error, setError] = useState("") const handleSubmit = async (e: React.FormEvent) => { e.preventDefault() setError("") if (!email) { setError("請輸入電子郵件地址") return } if (!email.includes("@")) { setError("請輸入有效的電子郵件地址") return } setIsLoading(true) // Simulate API call await new Promise((resolve) => setTimeout(resolve, 2000)) setIsLoading(false) setIsSuccess(true) } const handleClose = () => { setEmail("") setError("") setIsSuccess(false) onOpenChange(false) } const handleResend = async () => { setIsLoading(true) await new Promise((resolve) => setTimeout(resolve, 1000)) setIsLoading(false) } if (isSuccess) { return (
重設密碼郵件已發送 我們已將重設密碼的連結發送到您的電子郵件

請檢查您的電子郵件:

{email}

• 請檢查您的收件匣和垃圾郵件資料夾

• 重設連結將在 24 小時後過期

• 如果您沒有收到郵件,請點擊下方重新發送

) } return ( 忘記密碼 請輸入您的電子郵件地址,我們將發送重設密碼的連結給您
setEmail(e.target.value)} className="pl-10" required />
{error && ( {error} )}
) }