diff --git a/services/frontend/src/pages/Competition/index.tsx b/services/frontend/src/pages/Competition/index.tsx index a7822a9..20be3eb 100644 --- a/services/frontend/src/pages/Competition/index.tsx +++ b/services/frontend/src/pages/Competition/index.tsx @@ -1,6 +1,6 @@ import { useParams, Link, useNavigate } from "react-router-dom"; import { Button } from "@/components/ui/button"; -import { ArrowLeft, Clock, Trophy, BookOpen, BarChart2 } from "lucide-react"; +import { ArrowLeft, Clock, Trophy, BookOpen, BarChart2, AlertCircle } from "lucide-react"; import ReactMarkdown from "react-markdown"; import { useQuery, useMutation } from "@tanstack/react-query"; import { getCompetition, startCompetition } from "@/shared/api/competitions"; @@ -59,17 +59,7 @@ const CompetitionPage = () => { }; const handleViewResults = () => { - console.log("sorryan") - }; - - // Check if competition has ended - const isCompetitionEnded = () => { - if (!competition?.end_date) return false; - - const endDate = new Date(competition.end_date); - const now = new Date(); - - return now > endDate; + console.log("sorryan"); }; if (competitionQuery.isLoading) { @@ -81,7 +71,27 @@ const CompetitionPage = () => { } const competition = competitionQuery.data; + + const isCompetitionEnded = () => { + if (!competition?.end_date) return false; + + const endDate = new Date(competition.end_date); + const now = new Date(); + + return now > endDate; + }; + + const isCompetitionNotStarted = () => { + if (!competition?.start_date) return false; + + const startDate = new Date(competition.start_date); + const now = new Date(); + + return now < startDate; + }; + const competitionEnded = isCompetitionEnded(); + const competitionNotStarted = isCompetitionNotStarted(); return (