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 ( -
+
- -

Welcome to the Challenge Archive

+ +

Challenge Archive

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 ( -

+
0 ? "gap-y-8" : "gap-y-4","container grid max-w-6xl grid-cols-1")}>
-
- + 0 ? "mt-8":""}/>
); diff --git a/src/app/_components/announcement/mini-announcements.tsx b/src/app/_components/announcement/mini-announcements.tsx index 9436a9ac..f32c114a 100644 --- a/src/app/_components/announcement/mini-announcements.tsx +++ b/src/app/_components/announcement/mini-announcements.tsx @@ -3,8 +3,9 @@ import { MiniAnnouncementPost } from "./mini-announcement-post"; import { Card, CardContent } from "../ui/card"; import Link from "next/link"; import { siteConfig } from "@/app/_config/site"; +import { cn } from "@/app/_lib/client-utils"; -export async function MiniAnnouncements({}: React.HTMLAttributes) { +export async function MiniAnnouncements({className}: React.HTMLAttributes) { const serverAnnouncementPosts = await serverTRPC.announcements.get_announcement_posts.query(); @@ -23,7 +24,7 @@ export async function MiniAnnouncements({}: React.HTMLAttributes }); return ( -
+
diff --git a/src/app/_components/challenges/archived-challenges.tsx b/src/app/_components/challenges/archived-challenges.tsx index e54dd9c8..dfa73090 100644 --- a/src/app/_components/challenges/archived-challenges.tsx +++ b/src/app/_components/challenges/archived-challenges.tsx @@ -20,10 +20,13 @@ export default function ArchivedChallenges({ return a.challenge_points - b.challenge_points; }); - for (const challenge of challenges){ + for (let i=0; i - + +

{challenge.challenge_title}

@@ -46,16 +49,16 @@ export default function ArchivedChallenges({
- +
) } if (challengeElements.length>0){ return( -
+ {challengeElements} -
+
) }else{ return( diff --git a/src/app/_components/challenges/challenge-card.tsx b/src/app/_components/challenges/challenge-card.tsx index 6b3ca2d1..5a9838a4 100644 --- a/src/app/_components/challenges/challenge-card.tsx +++ b/src/app/_components/challenges/challenge-card.tsx @@ -25,56 +25,25 @@ export default function ChallengeCard({ challenge_points, } = challengeData; - const router = useRouter(); - - if (challengesEnabled || userRole !== "participant") { - return ( + if(challengesEnabled || userRole!=="participant"){ + return( -
{ - if (challengesEnabled || userRole !== "participant") - router.push(siteConfig.paths.challenge + "/" + challenge_id); - }} - > -
-

{challenge_title}

-
- - {challenge_points} - - - {challenge_difficulty} - -
-
-
- - ); + + + ) + }else{ + return ( +
+ +
+ ) } - - return ( -
{ - if (challengesEnabled || userRole !== "participant") - router.push(siteConfig.paths.challenge + "/" + challenge_id); - }} - > + + function ChallengeCardLink(){ + return (

{challenge_title}

@@ -83,7 +52,7 @@ export default function ChallengeCard({
-
-
- ); +
+ ) + } } diff --git a/src/app/_components/challenges/challenge-content-info.tsx b/src/app/_components/challenges/challenge-content-info.tsx index 283468bd..b49f2520 100644 --- a/src/app/_components/challenges/challenge-content-info.tsx +++ b/src/app/_components/challenges/challenge-content-info.tsx @@ -61,11 +61,11 @@ export default function ChallengeContentInfo({ -
+        
           {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.

- +