'use client'; import { useState, useEffect } from 'react'; import Link from 'next/link'; import Image from 'next/image'; import { useLanguage } from '@/context/LanguageContext'; import { eventsApi, contactsApi, Event } from '@/lib/api'; import Button from '@/components/ui/Button'; import Card from '@/components/ui/Card'; import Input from '@/components/ui/Input'; import { CalendarIcon, MapPinIcon, UserGroupIcon, ChatBubbleLeftRightIcon, AcademicCapIcon, SparklesIcon } from '@heroicons/react/24/outline'; import toast from 'react-hot-toast'; export default function HomePage() { const { t, locale } = useLanguage(); const [nextEvent, setNextEvent] = useState(null); const [loading, setLoading] = useState(true); const [email, setEmail] = useState(''); const [subscribing, setSubscribing] = useState(false); useEffect(() => { eventsApi.getNextUpcoming() .then(({ event }) => setNextEvent(event)) .catch(console.error) .finally(() => setLoading(false)); }, []); const handleSubscribe = async (e: React.FormEvent) => { e.preventDefault(); if (!email) return; setSubscribing(true); try { await contactsApi.subscribe(email); toast.success(t('home.newsletter.success')); setEmail(''); } catch (error) { toast.error(t('home.newsletter.error')); } finally { setSubscribing(false); } }; const formatDate = (dateStr: string) => { return new Date(dateStr).toLocaleDateString(locale === 'es' ? 'es-ES' : 'en-US', { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric', }); }; const formatTime = (dateStr: string) => { return new Date(dateStr).toLocaleTimeString(locale === 'es' ? 'es-ES' : 'en-US', { hour: '2-digit', minute: '2-digit', }); }; return ( <> {/* Hero Section */}

{t('home.hero.title')}

{t('home.hero.subtitle')}

{/* Hero Image Grid */}
Language exchange event
Group language practice
Community meetup
Language exchange group
{/* Decorative elements */}
{/* Next Event Section */}

{t('home.nextEvent.title')}

{loading ? (
) : nextEvent ? (

{locale === 'es' && nextEvent.titleEs ? nextEvent.titleEs : nextEvent.title}

{locale === 'es' && nextEvent.descriptionEs ? nextEvent.descriptionEs : nextEvent.description}

{formatDate(nextEvent.startDatetime)}
{formatTime(nextEvent.startDatetime)}
{nextEvent.location}
{nextEvent.price === 0 ? t('events.details.free') : `${nextEvent.price.toLocaleString()} ${nextEvent.currency}`}

{nextEvent.availableSeats} {t('events.details.spotsLeft')}

) : (

{t('home.nextEvent.noEvents')}

{t('home.nextEvent.stayTuned')}

)}
{/* About Section */}

{t('home.about.title')}

{t('home.about.description')}

{t('home.about.feature1')}

{t('home.about.feature1Desc')}

{t('home.about.feature2')}

{t('home.about.feature2Desc')}

{t('home.about.feature3')}

{t('home.about.feature3Desc')}

{/* Newsletter Section */}

{t('home.newsletter.title')}

{t('home.newsletter.description')}

setEmail(e.target.value)} className="flex-1 bg-white/10 border-white/20 text-white placeholder:text-gray-400" required />
); }