|
| 1 | +import Link from "next/link"; |
| 2 | +import cityData from "@/data/cities"; |
| 3 | + |
| 4 | +export default function RegistrationState({ cityId }) { |
| 5 | + const citiesWithRegistration = Object.values(cityData) |
| 6 | + .filter((city) => !!city.registrationLink) |
| 7 | + .map((city) => ({ |
| 8 | + name: city.name, |
| 9 | + link: city.registrationLink, |
| 10 | + })); |
| 11 | + |
| 12 | + const getContent = () => { |
| 13 | + if (cityId) { |
| 14 | + const city = cityData[cityId]; |
| 15 | + return { |
| 16 | + title: city.registrationLink ? "Registro disponible" : "Registro cerrado", |
| 17 | + message: city.registrationLink |
| 18 | + ? `Inscríbete para PyDay ${city.name}` |
| 19 | + : `El registro para PyDay ${city.name} aún no está disponible.`, |
| 20 | + links: city.registrationLink ? [{ name: city.name, link: city.registrationLink }] : [], |
| 21 | + }; |
| 22 | + } |
| 23 | + |
| 24 | + return { |
| 25 | + title: |
| 26 | + citiesWithRegistration.length > 0 |
| 27 | + ? "¡Registro abierto! Cupos limitados" |
| 28 | + : "Registro cerrado", |
| 29 | + message: |
| 30 | + citiesWithRegistration.length > 0 |
| 31 | + ? "Elige tu ciudad y asegura tu lugar hoy" |
| 32 | + : "El registro abrirá próximamente. Síguenos en redes sociales.", |
| 33 | + links: citiesWithRegistration, |
| 34 | + }; |
| 35 | + }; |
| 36 | + |
| 37 | + const { title, message, links } = getContent(); |
| 38 | + |
| 39 | + if (links.length === 0) return null; |
| 40 | + |
| 41 | + return ( |
| 42 | + <div className="backdrop-blur-sm rounded-lg p-6 md:p-8 text-center"> |
| 43 | + <h3 className="text-lg md:text-xl font-bold mb-2 text-py-text">{title}</h3> |
| 44 | + <p className="text-py-text/80 mb-6">{message}</p> |
| 45 | + |
| 46 | + <div className="flex flex-wrap justify-center gap-3 md:gap-4 w-full px-4"> |
| 47 | + {links.map((city, index) => ( |
| 48 | + <Link |
| 49 | + key={index} |
| 50 | + href={city.link} |
| 51 | + target="_blank" |
| 52 | + className="btn-secondary inline-flex items-center flex-shrink-0 px-4 py-2 text-sm md:text-base" |
| 53 | + > |
| 54 | + <span className="whitespace-nowrap">{city.name}</span> |
| 55 | + <svg |
| 56 | + xmlns="http://www.w3.org/2000/svg" |
| 57 | + className="h-4 w-4 md:h-5 md:w-5 ml-1.5" |
| 58 | + viewBox="0 0 20 20" |
| 59 | + fill="currentColor" |
| 60 | + > |
| 61 | + <path |
| 62 | + fillRule="evenodd" |
| 63 | + d="M10.293 5.293a1 1 0 011.414 0l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414-1.414L12.586 11H5a1 1 0 110-2h7.586l-2.293-2.293a1 1 0 010-1.414z" |
| 64 | + clipRule="evenodd" |
| 65 | + /> |
| 66 | + </svg> |
| 67 | + </Link> |
| 68 | + ))} |
| 69 | + </div> |
| 70 | + </div> |
| 71 | + ); |
| 72 | +} |
| 73 | + |
0 commit comments