"use client" import { useState } from "react" import { useAuth } from "@/contexts/auth-context" import { useCompetition } from "@/contexts/competition-context" import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from "@/components/ui/dialog" import { Button } from "@/components/ui/button" import { Input } from "@/components/ui/input" import { Label } from "@/components/ui/label" import { Textarea } from "@/components/ui/textarea" import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select" import { Checkbox } from "@/components/ui/checkbox" import { Badge } from "@/components/ui/badge" import { Progress } from "@/components/ui/progress" import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card" import { Separator } from "@/components/ui/separator" import { ChevronLeft, ChevronRight, Trophy, Users, FileText, CheckCircle, Target, Award, Loader2 } from "lucide-react" interface RegistrationDialogProps { open: boolean onOpenChange: (open: boolean) => void } interface RegistrationData { // 應用資訊 appName: string appDescription: string appType: string techStack: string mainFeatures: string // 團隊資訊 teamName: string teamSize: string contactName: string contactEmail: string contactPhone: string department: string // 參賽動機 motivation: string expectedOutcome: string agreeTerms: boolean } export function RegistrationDialog({ open, onOpenChange }: RegistrationDialogProps) { const { user } = useAuth() const { currentCompetition } = useCompetition() const [currentStep, setCurrentStep] = useState(1) const [isSubmitting, setIsSubmitting] = useState(false) const [isSubmitted, setIsSubmitted] = useState(false) const [applicationId, setApplicationId] = useState("") const [formData, setFormData] = useState({ appName: "", appDescription: "", appType: "", techStack: "", mainFeatures: "", teamName: "", teamSize: "1", contactName: user?.name || "", contactEmail: user?.email || "", contactPhone: "", department: "", motivation: "", expectedOutcome: "", agreeTerms: false, }) const totalSteps = 3 const progress = (currentStep / totalSteps) * 100 const handleInputChange = (field: keyof RegistrationData, value: string | boolean) => { setFormData((prev) => ({ ...prev, [field]: value })) } const validateStep = (step: number): boolean => { switch (step) { case 1: return !!(formData.appName && formData.appDescription && formData.appType && formData.techStack) case 2: return !!(formData.teamName && formData.contactName && formData.contactEmail && formData.department) case 3: return !!(formData.motivation && formData.agreeTerms) default: return false } } const handleNext = () => { if (validateStep(currentStep) && currentStep < totalSteps) { setCurrentStep((prev) => prev + 1) } } const handlePrevious = () => { if (currentStep > 1) { setCurrentStep((prev) => prev - 1) } } const handleSubmit = async () => { if (!validateStep(3)) return setIsSubmitting(true) // 模擬提交過程 await new Promise((resolve) => setTimeout(resolve, 2000)) // 生成申請編號 const id = `REG${Date.now().toString().slice(-6)}` setApplicationId(id) setIsSubmitted(true) setIsSubmitting(false) } const handleClose = () => { if (isSubmitted) { // 重置表單 setCurrentStep(1) setIsSubmitted(false) setApplicationId("") setFormData({ appName: "", appDescription: "", appType: "", techStack: "", mainFeatures: "", teamName: "", teamSize: "1", contactName: user?.name || "", contactEmail: user?.email || "", contactPhone: "", department: "", motivation: "", expectedOutcome: "", agreeTerms: false, }) } onOpenChange(false) } const renderStepContent = () => { if (isSubmitted) { return (

報名成功!

您的競賽報名已成功提交

申請編號

{applicationId}

• 我們將在 3-5 個工作日內審核您的申請

• 審核結果將通過郵件通知您

• 如有疑問,請聯繫管理員

) } switch (currentStep) { case 1: return (

應用資訊

請填寫您要參賽的 AI 應用基本資訊

handleInputChange("appName", e.target.value)} placeholder="請輸入應用名稱" />