diff --git a/src/app/(main)/(routes)/(protected)/(pages)/challenge-archive/page.tsx b/src/app/(main)/(routes)/(protected)/(pages)/challenge-archive/page.tsx index 02250319..b630f551 100644 --- a/src/app/(main)/(routes)/(protected)/(pages)/challenge-archive/page.tsx +++ b/src/app/(main)/(routes)/(protected)/(pages)/challenge-archive/page.tsx @@ -1,5 +1,6 @@ import ArchivedChallenges from "@/app/_components/challenges/archived-challenges"; import { Card, CardContent } from "@/app/_components/ui/card"; +import { cn } from "@/app/_lib/client-utils"; import { serverTRPC } from "@/app/_trpc/server"; import { type Metadata } from "next"; import React from "react"; @@ -13,10 +14,10 @@ export default async function ChallengesPage() { const challenges = await serverTRPC.challenges.get_archived_challenges.query(); return ( -
These are challenges that have been used in past events and are currently not being used. You can still run and test them, but they will not give you any points. It is possible for some of these challenges to appear in the next event. diff --git a/src/app/(main)/(routes)/(protected)/(pages)/dashboard/page.tsx b/src/app/(main)/(routes)/(protected)/(pages)/dashboard/page.tsx index e47ca799..6f1edfd1 100644 --- a/src/app/(main)/(routes)/(protected)/(pages)/dashboard/page.tsx +++ b/src/app/(main)/(routes)/(protected)/(pages)/dashboard/page.tsx @@ -2,6 +2,7 @@ import { MiniAnnouncements } from "@/app/_components/announcement/mini-announcem import { Challenges } from "@/app/_components/challenges/challenges"; import ChallengesProgress from "@/app/_components/challenges/challenges-progress"; import DashboardTeamInfo from "@/app/_components/dashboard/dashboard-team-info"; +import { cn } from "@/app/_lib/client-utils"; import { serverTRPC } from "@/app/_trpc/server"; import { type TUserRole } from "@/db/drizzle/startup_seed"; import { composeServerComponentClient } from "@/server/lib/supabase/server"; @@ -27,20 +28,21 @@ export default async function ChallengesPage() { user_uuid: user.id, }); + const challengeCount = challenges.solvedChallenges.length + challenges.unsolvedChallenges.length + return ( -
+{challengeData?.challenge_example_input}-+{challengeData?.challenge_example_output}diff --git a/src/app/_components/challenges/challenge-content.tsx b/src/app/_components/challenges/challenge-content.tsx index e6fa55b1..2fbfd81e 100644 --- a/src/app/_components/challenges/challenge-content.tsx +++ b/src/app/_components/challenges/challenge-content.tsx @@ -127,6 +127,7 @@ export default function ChallengeContentPage({ solved={solved} setLanguage={setLanguage} setOutputData={setOutputData} + challengeLive={challengeData!.challenge_is_live!} /> diff --git a/src/app/_components/challenges/challenge-nav-actions.tsx b/src/app/_components/challenges/challenge-nav-actions.tsx index aab56f3d..e67df486 100644 --- a/src/app/_components/challenges/challenge-nav-actions.tsx +++ b/src/app/_components/challenges/challenge-nav-actions.tsx @@ -28,6 +28,7 @@ type ChallengeNavActionsProps = { solved: boolean; setLanguage: Dispatch>; setOutputData: Dispatch >; + challengeLive: boolean }; export default function ChallengeNavActions({ @@ -40,6 +41,7 @@ export default function ChallengeNavActions({ solved, setLanguage, setOutputData, + challengeLive }: ChallengeNavActionsProps) { //runs code const { refetch: runCode, isFetching: isRunning } = @@ -76,11 +78,11 @@ export default function ChallengeNavActions({ //runs code async function attemptRunCode() { await checkUserOnTeam(); - if (onTeam?.is_on_team) await runCode(); + if (!challengeLive || (onTeam?.is_on_team && challengeLive)) await runCode(); else { toast({ variant: "destructive", - description: "You must be on a team to participate in challenges.", + description: "You must be on a team to participate in live challenges.", duration: 4000, }); } @@ -88,11 +90,11 @@ export default function ChallengeNavActions({ //submits code async function attemptSubmitCode() { await checkUserOnTeam(); - if (onTeam?.is_on_team) await submitCode(); + if (!challengeLive || (onTeam?.is_on_team && challengeLive)) await submitCode(); else { toast({ variant: "destructive", - description: "You must be on a team to participate in challenges.", + description: "You must be on a team to participate in live challenges.", duration: 4000, }); } diff --git a/src/app/_components/challenges/challenges.tsx b/src/app/_components/challenges/challenges.tsx index 3a799e2b..c771bae1 100644 --- a/src/app/_components/challenges/challenges.tsx +++ b/src/app/_components/challenges/challenges.tsx @@ -77,7 +77,7 @@ export function Challenges({ return( - No challenges yet
+No challenges yet
You can visit the Challenge Archive to view past challenges.