From 8f501b2bf8f75bba52f9cce912d5d4dfd233d3c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20=C3=81ngel=20Dur=C3=A1n?= Date: Mon, 13 May 2024 17:00:42 -0700 Subject: [PATCH] Add King of the Kill pronosticos --- src/components/ForecastBoxer.astro | 15 ++++++-- src/pages/combates/[id].astro | 2 +- src/sections/Forecasts.astro | 60 ++++++++++++++++++++++++++---- 3 files changed, 65 insertions(+), 12 deletions(-) diff --git a/src/components/ForecastBoxer.astro b/src/components/ForecastBoxer.astro index 17efcfbd2..0d67aef4e 100644 --- a/src/components/ForecastBoxer.astro +++ b/src/components/ForecastBoxer.astro @@ -5,9 +5,10 @@ interface Props { boxerId: string boxerName: string boxerHref: string + isSmall?: boolean } -const { image, imageAlt, boxerId, boxerName, boxerHref } = Astro.props +const { image, imageAlt, boxerId, boxerName, boxerHref, isSmall = false } = Astro.props --- {imageAlt}

{boxerName}

 

diff --git a/src/pages/combates/[id].astro b/src/pages/combates/[id].astro index 3570de457..591d2b110 100644 --- a/src/pages/combates/[id].astro +++ b/src/pages/combates/[id].astro @@ -59,7 +59,7 @@ export const prerender = true image={`https://cdn.lavelada.dev/matches/og-${id}-min.jpg`} > -
+
diff --git a/src/sections/Forecasts.astro b/src/sections/Forecasts.astro index a7cfd6ba8..bb116550a 100644 --- a/src/sections/Forecasts.astro +++ b/src/sections/Forecasts.astro @@ -16,7 +16,45 @@ const boxers = combat?.boxers.map((boxer) => BOXERS.find((b) => b.id === boxer)) --- { - combatId !== REY_DE_LA_PISTA_ID && combatId !== "3-zeling-y-nissaxter-vs-alana-y-ama-blitz" && ( + combatId === REY_DE_LA_PISTA_ID &&
+
+

Pronóstico

+

+ Basado en 0 predicciones +

+
+ +
+ {boxers.map((boxer) => boxer && ( + + ))} +
+ +
+ + ¡Haz tu pronóstico! + +
+
+} + +{ combatId !== REY_DE_LA_PISTA_ID && combatId !== "3-zeling-y-nissaxter-vs-alana-y-ama-blitz" && (
BOXERS.find((b) => b.id === boxer)) const { totalVotes, percentageVotes } = json?.data ?? {} if (totalVotes == null || totalVotes === 0) return - const [, lastBoxer] = $forecast.querySelectorAll(".boxer-forecast") - const lastBoxerId = lastBoxer.getAttribute("data-id") - if (lastBoxerId == null) return + const allBoxers = $forecast.querySelectorAll(".boxer-forecast") + + const isKingOfTheHill = allBoxers.length > 4 + + if (!isKingOfTheHill) { + const [, lastBoxer] = $forecast.querySelectorAll(".boxer-forecast") + const lastBoxerId = lastBoxer.getAttribute("data-id") + if (lastBoxerId == null) return - const percentage = percentageVotes[lastBoxerId] - if (percentage) { - const event = new CustomEvent("forecast:loaded", { detail: percentage }) - dispatchEvent(event) + const percentage = percentageVotes[lastBoxerId] + if (percentage) { + const event = new CustomEvent("forecast:loaded", { detail: percentage }) + dispatchEvent(event) + } } const $pronostico = $forecast.querySelector(".pronostico") as HTMLElement