import React, { useState } from 'react'; const mockEvents = [ { id: 1, title: 'Monthly Community Townhall', description: 'Join us for our monthly Q&A session with the AeThex team. Ask questions, get updates, and connect with the community.', type: 'stage', channel: 'community-stage', startTime: new Date(Date.now() + 2 * 60 * 60 * 1000), // 2 hours from now endTime: new Date(Date.now() + 4 * 60 * 60 * 1000), host: { name: 'Anderson', avatar: 'A', color: '#ff0000' }, interested: 234, image: null, recurring: 'monthly', }, { id: 2, title: 'Game Night: Among Us', description: 'Weekly game night! This week we\'re playing Among Us. Join the voice channel 10 minutes early.', type: 'voice', channel: 'gaming-voice', startTime: new Date(Date.now() + 26 * 60 * 60 * 1000), // Tomorrow endTime: new Date(Date.now() + 29 * 60 * 60 * 1000), host: { name: 'Sarah', avatar: 'S', color: '#ffa500' }, interested: 89, image: null, recurring: 'weekly', }, { id: 3, title: 'AeThex SDK Workshop', description: 'Learn how to integrate the AeThex SDK into your projects. Hands-on coding session with live Q&A.', type: 'external', location: 'https://workshop.aethex.com', startTime: new Date(Date.now() + 3 * 24 * 60 * 60 * 1000), // 3 days endTime: new Date(Date.now() + 3 * 24 * 60 * 60 * 1000 + 2 * 60 * 60 * 1000), host: { name: 'Trevor', avatar: 'T', color: '#0066ff' }, interested: 456, image: null, recurring: null, }, ]; export default function EventsPanel({ onClose, onCreateEvent }) { const [activeTab, setActiveTab] = useState('upcoming'); const [selectedEvent, setSelectedEvent] = useState(null); const formatDate = (date) => { const now = new Date(); const diff = date - now; const days = Math.floor(diff / (1000 * 60 * 60 * 24)); if (days === 0) { const hours = Math.floor(diff / (1000 * 60 * 60)); if (hours === 0) { const minutes = Math.floor(diff / (1000 * 60)); return `In ${minutes} minutes`; } return `In ${hours} hours`; } else if (days === 1) { return 'Tomorrow'; } else { return date.toLocaleDateString('en-US', { weekday: 'long', month: 'short', day: 'numeric' }); } }; const formatTime = (date) => { return date.toLocaleTimeString('en-US', { hour: 'numeric', minute: '2-digit' }); }; const getTypeIcon = (type) => { switch (type) { case 'stage': return '📢'; case 'voice': return '🔊'; case 'external': return '🔗'; default: return '📅'; } }; if (selectedEvent) { return ( setSelectedEvent(null)} formatDate={formatDate} formatTime={formatTime} getTypeIcon={getTypeIcon} /> ); } return (

Events

{mockEvents.map(event => (
setSelectedEvent(event)} >
{event.startTime.toLocaleDateString('en-US', { month: 'short' })} {event.startTime.getDate()}
{formatDate(event.startTime)} {formatTime(event.startTime)} - {formatTime(event.endTime)}

{getTypeIcon(event.type)} {event.title}

{event.description}

{event.host.avatar}
Hosted by {event.host.name}
⭐ {event.interested} interested
{event.recurring && (
🔄 Repeats {event.recurring}
)}
))}
{mockEvents.length === 0 && (
📅

No upcoming events

Create an event to bring your community together!

)}
); } function EventDetail({ event, onBack, formatDate, formatTime, getTypeIcon }) { const [isInterested, setIsInterested] = useState(false); return (
{getTypeIcon(event.type)} {event.type.charAt(0).toUpperCase() + event.type.slice(1)}

{event.title}

📅 Date & Time

{formatDate(event.startTime)}

{formatTime(event.startTime)} - {formatTime(event.endTime)}

{event.recurring && (

🔄 Repeats {event.recurring}

)}

📍 Location

{event.type === 'external' ? ( {event.location} ) : (

#{event.channel}

)}

📝 Description

{event.description}

👤 Host

{event.host.avatar}
{event.host.name}
⭐ {event.interested + (isInterested ? 1 : 0)} interested
); } // Event creation modal export function CreateEventModal({ onSubmit, onClose }) { const [title, setTitle] = useState(''); const [description, setDescription] = useState(''); const [type, setType] = useState('voice'); const [date, setDate] = useState(''); const [startTime, setStartTime] = useState(''); const [endTime, setEndTime] = useState(''); const handleSubmit = () => { if (!title.trim() || !date || !startTime) return; onSubmit?.({ title, description, type, date, startTime, endTime, }); onClose?.(); }; return (
e.stopPropagation()}>

Create Event

setTitle(e.target.value)} maxLength={100} />