// piloto-publico.jsx — perfil público de un piloto (piloto.html?name=...). // Mismo contenido que "Mi Perfil" (perfil.jsx) pero de solo lectura y SIN la // biblioteca de logos, que es un recurso interno del staff/pilotos logueados. const { useState: useStateQ, useMemo: useMemoQ, useEffect: useEffectQ } = React; function PilotoPublico() { const params = new URLSearchParams(location.search); const name = params.get("name") || ""; const years = (() => { const ys = CDGX.pilotYears(name); return ys.length ? ys : [CDGX.years()[0]]; })(); const [year, setYear] = useStateQ(years[0]); const meta = CDGX.meta(name); const season = useMemoQ(() => CDGX.pilotSeason(name, year), [name, year]); const rkO = CDGX.rankOf(name, year, '5"'), rkT = CDGX.rankOf(name, year, "TINY"); const [extra, setExtra] = useStateQ({ multigp_id: null, photos: [], videos: [] }); const [modal, setModal] = useStateQ(null); const [toastMsg, setToastMsg] = useStateQ(""); const [toastErr, setToastErr] = useStateQ(false); function toast(m, isErr) { setToastMsg(m); setToastErr(!!isErr); } useEffectQ(() => { if (!toastMsg) return; const t = setTimeout(() => setToastMsg(""), 3200); return () => clearTimeout(t); }, [toastMsg]); // El "cálculo experto" es público: cualquiera que vea el perfil de un piloto // puede abrirlo, no solo el propio piloto logueado en Mi Perfil. const [view, setView] = useStateQ(location.hash === "#calculadora" ? "calc" : "perfil"); const [calcCat, setCalcCat] = useStateQ(null); useEffectQ(() => { const onHash = () => setView(location.hash === "#calculadora" ? "calc" : "perfil"); window.addEventListener("hashchange", onHash); return () => window.removeEventListener("hashchange", onHash); }, []); function openExpert(cat) { setCalcCat(cat); location.hash = "calculadora"; } function backToProfile() { location.hash = ""; } useEffectQ(() => { if (!name) return; fetch("public-pilot-profile.php?pilot=" + encodeURIComponent(name)) .then(r => r.json()).then(d => { if (d.ok) setExtra(d); }).catch(() => {}); }, [name]); if (!name || !season.length) { return (

Sin resultados

No encontramos carreras de "{name || "—"}" en la temporada {year}.

← Volver al ranking
); } // Para el banner de "Descargar resumen" (mismo modal que usa Mi Perfil). const cardStats = cardStatsFor(name, year, meta); if (view === "calc") { return ( ); } return ( <>
← Volver al ranking
{meta.photo ? {name} :
{name.slice(0, 2).toUpperCase()}
}
Piloto CDG · Temporada {year}

{name}

{meta.country && {meta.country}{CDGX.countryName(meta.country)}} {meta.ig && @{meta.ig}} {rkO.pos && P{rkO.pos} Open 5"} {rkT.pos && P{rkT.pos} Tinywhoop}
MultiGP ID
{extra.multigp_id ?
{extra.multigp_id}
:
ID: Pendiente
}
{extra.multigp_id ? :
QR
al asignar
}
setModal("social")} />

Progreso por fecha

Open 5"Tinywhoop
{season.map(s => { const cls = CDGX.catClass(s.race.category); return (
{s.race.date.replace(/\s\d{4}$/, "")}
{cls === "tiny" ? "Tiny" : '5"'}{s.race.name}
P{s.pos}/{s.field}
{s.points}PTS
{s.timed && s.q && s.q.time ? s.q.time : "sin tiempo"}
); })}
{(extra.photos.length > 0 || extra.videos.length > 0) && (

Fotos y videos

{extra.photos.length > 0 && (
{extra.photos.map((p, i) =>
{`Foto
)}
)} {extra.videos.length > 0 && <>
Videos
{extra.videos.map((v, i) => (
{v.host}
{v.title}↗
))}
}
)}
{modal === "social" && setModal(null)} />} {toastMsg &&
{toastMsg}
} ); } ReactDOM.createRoot(document.getElementById("pp-root")).render();