"use client"; import { useEffect, useState } from "react"; import { useBackgroundImage } from "@/hooks/usePreferences"; interface Event { id: string; date: string; name: string; description: string; type: "SUMMIT" | "LAUNCH" | "FESTIVAL" | "COMPETITION"; status: "UPCOMING" | "LIVE" | "PAST"; } const getEventTypeColor = (type: Event["type"]) => { switch (type) { case "SUMMIT": return "from-blue-600 to-cyan-500"; case "LAUNCH": return "from-purple-600 to-pink-500"; case "FESTIVAL": return "from-pixel-gold to-orange-500"; case "COMPETITION": return "from-red-600 to-orange-500"; default: return "from-gray-600 to-gray-500"; } }; const getEventTypeLabel = (type: Event["type"]) => { switch (type) { case "SUMMIT": return "Sommet"; case "LAUNCH": return "Lancement"; case "FESTIVAL": return "Festival"; case "COMPETITION": return "Compétition"; default: return type; } }; const getStatusBadge = (status: Event["status"]) => { switch (status) { case "UPCOMING": return ( À venir ); case "LIVE": return ( En direct ); case "PAST": return ( Passé ); } }; export default function EventsPageSection() { const [events, setEvents] = useState([]); const [loading, setLoading] = useState(true); const backgroundImage = useBackgroundImage("events", "/got-2.jpg"); useEffect(() => { fetch("/api/events") .then((res) => res.json()) .then((data) => { setEvents(data); setLoading(false); }) .catch((err) => { console.error("Error fetching events:", err); setLoading(false); }); }, []); if (loading) { return (
Chargement...
); } return (
{/* Background Image */}
{/* Dark overlay for readability */}
{/* Content */}
{/* Title Section */}

EVENTS

Événements à venir et passés

Rejoignez-nous pour des événements tech passionnants, des compétitions et des célébrations tout au long de l'année

{/* Events Grid */}
{events.map((event) => (
{/* Event Header */}
{/* Event Content */}
{/* Status Badge */}
{getStatusBadge(event.status)} {getEventTypeLabel(event.type)}
{/* Date */}
{event.date}
{/* Event Name */}

{event.name}

{/* Description */}

{event.description}

{/* Action Button */} {event.status === "UPCOMING" && ( )} {event.status === "LIVE" && ( )} {event.status === "PAST" && ( )}
))}
{/* Footer Info */}

Restez informé de nos derniers événements et annonces

); }