From f867699b9280f1c71837bc9aaf919584f33f2a74 Mon Sep 17 00:00:00 2001 From: John Nguyen <69529980+ImJunny@users.noreply.github.com> Date: Tue, 10 Dec 2024 01:23:08 +0000 Subject: [PATCH 1/6] Change padding --- .../(pages)/challenge-archive/page.tsx | 2 +- .../(protected)/(pages)/dashboard/page.tsx | 8 ++- .../announcement/mini-announcements.tsx | 5 +- .../challenges/archived-challenges.tsx | 15 ++-- .../_components/challenges/challenge-card.tsx | 69 +++++-------------- src/app/_components/challenges/challenges.tsx | 2 + 6 files changed, 39 insertions(+), 62 deletions(-) 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..bfdadc26 100644 --- a/src/app/(main)/(routes)/(protected)/(pages)/challenge-archive/page.tsx +++ b/src/app/(main)/(routes)/(protected)/(pages)/challenge-archive/page.tsx @@ -16,7 +16,7 @@ export default async function ChallengesPage() {
-

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..eac5c3c5 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 ? "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/challenges.tsx b/src/app/_components/challenges/challenges.tsx index 3a799e2b..7598efa3 100644 --- a/src/app/_components/challenges/challenges.tsx +++ b/src/app/_components/challenges/challenges.tsx @@ -89,6 +89,8 @@ export function Challenges({ ) } + + return (
From 534592feeb73c21b796367c231aa4016291936ec Mon Sep 17 00:00:00 2001 From: John Nguyen <69529980+ImJunny@users.noreply.github.com> Date: Tue, 10 Dec 2024 01:43:44 +0000 Subject: [PATCH 2/6] Change gap size --- .../(routes)/(protected)/(pages)/challenge-archive/page.tsx | 3 ++- src/app/(main)/(routes)/(protected)/(pages)/dashboard/page.tsx | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) 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 bfdadc26..e1d25323 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,7 +14,7 @@ export default async function ChallengesPage() { const challenges = await serverTRPC.challenges.get_archived_challenges.query(); return ( -
+

Challenge Archive

diff --git a/src/app/(main)/(routes)/(protected)/(pages)/dashboard/page.tsx b/src/app/(main)/(routes)/(protected)/(pages)/dashboard/page.tsx index eac5c3c5..6f1edfd1 100644 --- a/src/app/(main)/(routes)/(protected)/(pages)/dashboard/page.tsx +++ b/src/app/(main)/(routes)/(protected)/(pages)/dashboard/page.tsx @@ -31,7 +31,7 @@ export default async function ChallengesPage() { const challengeCount = challenges.solvedChallenges.length + challenges.unsolvedChallenges.length return ( -
+
0 ? "gap-y-8" : "gap-y-4","container grid max-w-6xl grid-cols-1")}>
From c572e26ec469c1603d8793def9be9ead2d5b2fbb Mon Sep 17 00:00:00 2001 From: John Nguyen <69529980+ImJunny@users.noreply.github.com> Date: Tue, 10 Dec 2024 04:57:53 +0000 Subject: [PATCH 3/6] Allow testing on archived challenges --- src/app/_components/challenges/challenge-content.tsx | 1 + .../_components/challenges/challenge-nav-actions.tsx | 10 ++++++---- src/app/_components/dashboard/dashboard-team-info.tsx | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) 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/dashboard/dashboard-team-info.tsx b/src/app/_components/dashboard/dashboard-team-info.tsx index 3cf34882..f5cfd4d2 100644 --- a/src/app/_components/dashboard/dashboard-team-info.tsx +++ b/src/app/_components/dashboard/dashboard-team-info.tsx @@ -70,7 +70,7 @@ export default async function DashboardTeamInfo() {

- You must be on a team to participate in challenges. + You must be on a team to participate in live challenges.

- +