Skip to content

Commit 5694a83

Browse files
feat: see winners on home
1 parent 9e98979 commit 5694a83

4 files changed

Lines changed: 30 additions & 29 deletions

File tree

app/[locale]/dashboard/winners-reveal/page.tsx

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import { useState, useEffect } from "react"
44
import { useAuth } from "@/lib/firebase/auth-context"
5-
import { ProtectedRoute } from "@/components/auth/protected-route"
65
import { useRouter, useParams } from "next/navigation"
76
import { WinnersReveal } from "@/components/admin/winners-reveal"
87
import { doc, getDoc } from "firebase/firestore"
@@ -43,28 +42,29 @@ export default function WinnersPage() {
4342
}, [])
4443

4544
useEffect(() => {
46-
if (!authLoading && !settingsLoading && user && showWinners !== null) {
45+
if (!authLoading && !settingsLoading && showWinners !== null) {
4746
// Admins always have access
48-
if (user.role === "admin") return
47+
if (user?.role === "admin") return
4948

50-
// Participants only if flag is enabled
51-
if (user.role === "participant" && showWinners) return
52-
53-
// Otherwise redirect
54-
router.replace(`/${locale}/dashboard`)
49+
// If showWinners is disabled, redirect
50+
if (!showWinners) {
51+
// If logged in, go to dashboard, otherwise home
52+
router.replace(user ? `/${locale}/dashboard` : `/${locale}`)
53+
}
5554
}
5655
}, [user, authLoading, settingsLoading, showWinners, router, locale])
5756

5857
if (authLoading || settingsLoading) return <Loading text={t.loading.synchronizing} />
5958

59+
// If winners are not to be shown and user is not admin, we return null while redirecting
60+
if (!showWinners && user?.role !== "admin") return null
61+
6062
return (
61-
<ProtectedRoute allowedRoles={["admin", "participant"]}>
62-
<main
63-
className="relative min-h-screen w-full overflow-hidden"
64-
style={{ background: "#020617" }}
65-
>
66-
<WinnersReveal />
67-
</main>
68-
</ProtectedRoute>
63+
<main
64+
className="relative min-h-screen w-full overflow-hidden"
65+
style={{ background: "#020617" }}
66+
>
67+
<WinnersReveal />
68+
</main>
6969
)
7070
}

components/admin/winners-reveal.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"use client"
22

33
import { useState, useEffect, useRef } from "react"
4+
import { useAuth } from "@/lib/firebase/auth-context"
45
import { useParams } from "next/navigation"
56
import { collection, getDocs, query, orderBy } from "firebase/firestore"
67
import { getDbClient } from "@/lib/firebase/client-config"
@@ -292,6 +293,7 @@ function PodiumCard({ winner, category, isChampion = false, t }: any) {
292293
// ─── Main Logic ───────────────────────────────────────────────────────────────
293294

294295
export function WinnersReveal() {
296+
const { user } = useAuth()
295297
const params = useParams()
296298
const locale = params.locale as Locale
297299
const t = getTranslations(locale)
@@ -483,7 +485,7 @@ export function WinnersReveal() {
483485

484486
{/* Header - More compact */}
485487
<div className="flex flex-col items-center relative z-10 text-center mb-6 md:mb-10 animate-in slide-in-from-top-8 duration-700 w-full">
486-
<Link href={`/${locale}/dashboard`}>
488+
<Link href={user ? `/${locale}/dashboard` : `/${locale}`}>
487489
<div className="w-[50vw] max-w-[600px] mb-4 cursor-pointer hover:opacity-80 transition-opacity">
488490
<img src="/images/hackitba-alt-logo.png" alt="HackITBA" />
489491
</div>

components/sections/hero.tsx

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,13 @@ export function Hero({ translations, locale }: HeroProps) {
3939
</NeonGlow>
4040
</h1>
4141
<p className="font-pixel text-lg md:text-xl text-brand-yellow">{translations.hero.subtitle}</p>
42-
{!loading && !user && (
43-
signupEnabled ? (
44-
<Link href={`/${locale}/auth/signup`} className="duration-200 ease-in-out transition-colors hover:text-brand-orange hover:border-brand-orange hover:bg-brand-orange/10 mt-6 inline-flex items-center gap-2 rounded-lg border border-brand-cyan/40 bg-brand-navy/60 px-4 py-2 font-pixel text-sm md:text-sm text-brand-cyan">
45-
{translations.hero.signupOpen}
46-
</Link>
47-
) : (
48-
<span className="duration-200 ease-in-out mt-6 inline-flex items-center gap-2 rounded-lg border border-brand-cyan/40 bg-brand-navy/60 px-4 py-2 font-pixel text-xs md:text-sm text-brand-cyan opacity-60">
49-
{translations.hero.signupClosed}
50-
</span>
51-
)
42+
{!loading && (
43+
<Link
44+
href={`/${locale}/dashboard/winners-reveal`}
45+
className="duration-200 ease-in-out mt-6 inline-flex items-center gap-2 rounded-lg border border-brand-cyan/60 bg-brand-navy/60 px-4 py-2 font-pixel text-xs md:text-sm text-brand-cyan hover:bg-brand-cyan/10 hover:border-brand-cyan hover:opacity-100 transition-all"
46+
>
47+
{translations.hero.seeWinners}
48+
</Link>
5249
)}
5350
</div>
5451
</div>

lib/i18n/translations.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@
4545
"title": "HACKITBA",
4646
"subtitle": "By Computer Society ITBA",
4747
"signupOpen": "Registrations are open!",
48-
"signupClosed": "Registrations are closed."
48+
"signupClosed": "Registrations are closed.",
49+
"seeWinners": "Check out the 2026 winning teams"
4950
},
5051
"stats": {
5152
"categories": "Categories",
@@ -891,7 +892,8 @@
891892
"title": "HACKITBA",
892893
"subtitle": "By Computer Society ITBA",
893894
"signupOpen": "¡Las inscripciones están abiertas!",
894-
"signupClosed": "Las inscripciones están cerradas."
895+
"signupClosed": "Las inscripciones están cerradas.",
896+
"seeWinners": "Mirá los equipos ganadores de 2026"
895897
},
896898
"stats": {
897899
"categories": "Categorías",

0 commit comments

Comments
 (0)