diff --git a/.env.example b/.env.example index a9a34ed..bb11841 100644 --- a/.env.example +++ b/.env.example @@ -1,3 +1,4 @@ NEXT_PUBLIC_BACKEND_URL= NEXT_PUBLIC_SUPABASE_URL= -NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY= \ No newline at end of file +NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY= +NEXT_PUBLIC_DEFAULT_IMAGE_URL=https://www.svgrepo.com/show/452030/avatar-default.svg \ No newline at end of file diff --git a/src/app/league/page.tsx b/src/app/league/page.tsx index 065eb24..107ab72 100644 --- a/src/app/league/page.tsx +++ b/src/app/league/page.tsx @@ -10,6 +10,8 @@ import { Contest } from "@/models/contest.model"; import Footer from "@/components/shared/footer"; import { getContestsWithPictures } from "@/controllers/contest.controller"; import { useEffect, useState } from "react"; +import { createClient } from "@/lib/supabase/client"; +import { suscribe_leaderboard } from "@/lib/supabase/channel_subscribe"; const navLinks = [ { key: "home", label: "Inicio", href: "/" }, @@ -20,6 +22,7 @@ const navLinks = [ href: "#upcoming-events", }, { key: "podium", label: "Podio", href: "#podium" }, + { key: "rank", label: "Raking", href: "/rank" }, ]; export default function LeagueHomePage() { @@ -31,19 +34,32 @@ export default function LeagueHomePage() { })[] >([]); + const [refresh_students, setRefreshStudents] = useState(false); + useEffect(() => { getContestsWithPictures() .then(setContests) .catch(() => setContests([])); }, []); + useEffect(() => { + const supabase = createClient(); + const channel = suscribe_leaderboard(supabase, () => { + setRefreshStudents((prev) => !prev); + }); + + return () => { + supabase.removeChannel(channel); + }; + }, []); + return ( - +