import Layout from "@/components/Layout"; import SEO from "@/components/SEO"; import { Button } from "@/components/ui/button"; import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from "@/components/ui/card"; import { Badge } from "@/components/ui/badge"; import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger, } from "@/components/ui/dialog"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Textarea } from "@/components/ui/textarea"; import LoadingScreen from "@/components/LoadingScreen"; import { aethexToast } from "@/lib/aethex-toast"; import { cn } from "@/lib/utils"; import { Link, useLocation, useNavigate } from "react-router-dom"; import { useAuth } from "@/contexts/AuthContext"; import FeaturedStudiosGrid from "@/components/community/FeaturedStudiosGrid"; import { useCallback, useEffect, useMemo, useRef, useState, type FormEvent, type ReactNode, } from "react"; import { AlertTriangle, ArrowDown, ArrowRight, Award, BarChart3, BookOpen, Briefcase, Calendar, CheckCircle, ClipboardList, Clock, Coffee, Code, Flag, FolderGit2, Gamepad2, Gavel, Github, Hash, Headphones, Heart, Layers, Loader2, Mail, MapPin, Megaphone, MessageCircle, MessageSquare, MessageSquarePlus, MessageSquareText, Mic, MonitorSmartphone, Palette, Play, Puzzle, Search, Shield, Shirt, Sparkles, Star, TrendingUp, Trophy, Twitter, Users, UserCircle, Video, Vote, type LucideIcon, } from "lucide-react"; type EventStatus = "Registration Open" | "Recurring" | "Upcoming" | "Waitlist"; type CommunityEvent = { id: string; title: string; date: string; location: string; type: string; participants: number; prize?: string | null; status: EventStatus; description: string; agenda: string[]; registrationEnabled: boolean; registrationUrl?: string; }; type EventRegistrationPayload = { name: string; email: string; teamName?: string; message?: string; }; type ForumSpace = { id: string; name: string; description: string; threads: number; activeToday: number; latestThread: { title: string; author: string; timeAgo: string; }; icon: LucideIcon; }; type FeedbackChannel = { id: string; title: string; description: string; submissionsThisWeek: number; statuses: { label: string; count: number; tone: "neutral" | "positive" | "warning"; }[]; owner: string; icon: LucideIcon; }; type PollTrend = "up" | "steady" | "down"; type PollOption = { id: string; label: string; votes: number; trend: PollTrend; }; type CommunityPoll = { id: string; question: string; closesIn: string; options: PollOption[]; }; type ChatChannel = { id: string; name: string; description: string; participants: number; activeNow: number; icon: LucideIcon; }; type ProfileHighlight = { id: string; title: string; description: string; metricLabel: string; metricValue: string; icon: LucideIcon; }; type WorkshopItem = { id: string; title: string; description: string; downloads: number; rating: number; author: string; icon: LucideIcon; }; type MediaItem = { id: string; title: string; type: "Screenshot" | "Artwork" | "Video"; thumbnail: string; author: string; likes: number; }; type SpotlightCreator = { id: string; name: string; role: string; highlight: string; link: string; avatar: string; metrics: { label: string; value: string; }[]; }; type FeaturedContributor = { name: string; avatar: string; title: string; contributions: number; badge: string; speciality: string; bio: string; recentContribution: string; reputation: string; profileUrl: string; }; type ModerationTool = { id: string; title: string; description: string; icon: LucideIcon; }; type ReportReason = { id: string; label: string; description: string; }; interface EventCardProps { event: CommunityEvent; animationDelay: number; isRegistered: boolean; registrant?: EventRegistrationPayload; onRegister: (payload: EventRegistrationPayload) => void; } function EventCard({ event, animationDelay, isRegistered, registrant, onRegister, }: EventCardProps) { const [open, setOpen] = useState(false); const [form, setForm] = useState({ name: registrant?.name ?? "", email: registrant?.email ?? "", teamName: registrant?.teamName ?? "", message: registrant?.message ?? "", }); const [submitting, setSubmitting] = useState(false); const [error, setError] = useState(null); useEffect(() => { if (registrant) { setForm({ name: registrant.name, email: registrant.email, teamName: registrant.teamName ?? "", message: registrant.message ?? "", }); } }, [registrant]); useEffect(() => { if (!open) { setError(null); } }, [open]); const handleSubmit = (eventSubmit: FormEvent) => { eventSubmit.preventDefault(); const trimmedName = form.name.trim(); const trimmedEmail = form.email.trim(); const trimmedTeam = form.teamName.trim(); const trimmedMessage = form.message.trim(); if (!trimmedName || !trimmedEmail) { setError("Please provide both your name and email to register."); return; } const emailPattern = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; if (!emailPattern.test(trimmedEmail)) { setError("Please enter a valid email address."); return; } setError(null); setSubmitting(true); setTimeout(() => { onRegister({ name: trimmedName, email: trimmedEmail, teamName: trimmedTeam || undefined, message: trimmedMessage || undefined, }); setSubmitting(false); setOpen(false); }, 600); }; const statusStyles: Record = { "Registration Open": "bg-gradient-to-r from-emerald-500/20 to-aethex-500/30 text-emerald-200 border border-emerald-400/40", Recurring: "bg-blue-500/10 text-blue-200 border border-blue-400/40", Upcoming: "bg-orange-500/10 text-orange-200 border border-orange-400/40", Waitlist: "bg-amber-500/10 text-amber-200 border border-amber-400/40", }; const buttonLabel = isRegistered ? "Manage Registration" : "Register"; const submitLabel = isRegistered ? "Update Registration" : "Confirm Registration"; return (

{event.title}

{event.status} {isRegistered && ( Registered )}

{event.description}

{event.date}
{event.location}
{event.participants} spots
{event.prize && (
{event.prize}
)}
{event.type} {event.title} Reserve your spot by sharing your details. We'll send a confirmation to your inbox.
setForm((prev) => ({ ...prev, name: eventChange.target.value, })) } placeholder="Enter your name" required />
setForm((prev) => ({ ...prev, email: eventChange.target.value, })) } placeholder="you@example.com" required />
setForm((prev) => ({ ...prev, teamName: eventChange.target.value, })) } placeholder="Who are you building with?" />