diff --git a/frontend/src/api/loaders/scrimmagingLoader.ts b/frontend/src/api/loaders/scrimmagingLoader.ts index a54122d78..0201410af 100644 --- a/frontend/src/api/loaders/scrimmagingLoader.ts +++ b/frontend/src/api/loaders/scrimmagingLoader.ts @@ -11,6 +11,7 @@ import { buildKey, safeEnsureQueryData } from "../helpers"; import { myTeamFactory, searchTeamsFactory } from "../team/teamFactories"; import { CompeteMatchScrimmagingRecordRetrieveScrimmageTypeEnum, + Status526Enum, type Episode, type TeamPrivate, } from "api/_autogen"; @@ -30,17 +31,9 @@ export const scrimmagingLoader = queryFn: async () => await episodeInfoFactory.queryFn({ id: episodeId }), }); - if ((await episodeData).game_release.getTime() > Date.now()) { - toast.error( - `Scrimmaging page not released yet for ${ - (await episodeData).name_long - }.`, - ); - return redirect(`/${episodeId}/home`); - } - + let teamData: TeamPrivate | null = null; try { - await queryClient.ensureQueryData({ + teamData = await queryClient.ensureQueryData({ queryKey: buildKey(myTeamFactory.queryKey, { episodeId }), queryFn: async () => await myTeamFactory.queryFn({ episodeId }), }); @@ -49,6 +42,18 @@ export const scrimmagingLoader = return redirect(`/${episodeId}/home`); } + const isStaffTeam = teamData.status === Status526Enum.S; + if ( + !isStaffTeam && + (await episodeData).game_release.getTime() > Date.now() + ) { + toast.error( + `Scrimmaging page not released yet for ${ + (await episodeData).name_long + }.`, + ); + return redirect(`/${episodeId}/home`); + } // Outbox safeEnsureQueryData({ episodeId }, scrimmageInboxListFactory, queryClient); diff --git a/frontend/src/api/loaders/submissionsLoader.ts b/frontend/src/api/loaders/submissionsLoader.ts index d89a502c0..aaab82050 100644 --- a/frontend/src/api/loaders/submissionsLoader.ts +++ b/frontend/src/api/loaders/submissionsLoader.ts @@ -5,7 +5,7 @@ import { tournamentSubsListFactory, } from "../compete/competeFactories"; import { buildKey, safeEnsureQueryData } from "../helpers"; -import type { Episode, TeamPrivate } from "api/_autogen"; +import { type Episode, Status526Enum, type TeamPrivate } from "api/_autogen"; import { episodeInfoFactory } from "api/episode/episodeFactories"; import { myTeamFactory } from "api/team/teamFactories"; import toast from "react-hot-toast"; @@ -26,17 +26,9 @@ export const submissionsLoader = queryFn: async () => await episodeInfoFactory.queryFn({ id: episodeId }), }); - if ((await episodeData).game_release.getTime() > Date.now()) { - toast.error( - `Submissions page not released yet for ${ - (await episodeData).name_long - }.`, - ); - return redirect(`/${episodeId}/home`); - } - + let teamData: TeamPrivate | null = null; try { - await queryClient.ensureQueryData({ + teamData = await queryClient.ensureQueryData({ queryKey: buildKey(myTeamFactory.queryKey, { episodeId }), queryFn: async () => await myTeamFactory.queryFn({ episodeId }), }); @@ -45,6 +37,19 @@ export const submissionsLoader = return redirect(`/${episodeId}/home`); } + const isStaffTeam = teamData.status === Status526Enum.S; + if ( + !isStaffTeam && + (await episodeData).game_release.getTime() > Date.now() + ) { + toast.error( + `Submissions page not released yet for ${ + (await episodeData).name_long + }.`, + ); + return redirect(`/${episodeId}/home`); + } + // Submissions list safeEnsureQueryData({ episodeId, page }, subsListFactory, queryClient); diff --git a/frontend/src/components/sidebar/index.tsx b/frontend/src/components/sidebar/index.tsx index b6054a57c..519393916 100644 --- a/frontend/src/components/sidebar/index.tsx +++ b/frontend/src/components/sidebar/index.tsx @@ -1,8 +1,8 @@ import type React from "react"; import SidebarSection from "./SidebarSection"; import type { IconName } from "../elements/Icon"; -import type { Episode, TeamPrivate } from "api/_autogen"; import type { UseQueryResult } from "@tanstack/react-query"; +import { type Episode, type TeamPrivate, Status526Enum } from "api/_autogen"; import { type AuthState, AuthStateEnum } from "contexts/CurrentUserContext"; interface SidebarProps { @@ -132,10 +132,12 @@ export const renderableItems = ( const loggedIn = authState === AuthStateEnum.AUTHENTICATED; const userHasTeam = userTeam.isSuccess; + const staffTeam = userTeam.data?.status === Status526Enum.S; return items.filter((itemData) => { // Ensure that we are allowed to render this item - if (itemData.requireGameReleased && !gameReleased) return false; + if (!staffTeam && itemData.requireGameReleased && !gameReleased) + return false; if (itemData.userAuthLevel > UserAuthLevel.LOGGED_OUT && !loggedIn) return false; if ( diff --git a/frontend/src/views/Submissions.tsx b/frontend/src/views/Submissions.tsx index a6dd9ef64..5b4064dc9 100644 --- a/frontend/src/views/Submissions.tsx +++ b/frontend/src/views/Submissions.tsx @@ -19,6 +19,8 @@ import { import { useQueryClient } from "@tanstack/react-query"; import { useSearchParams } from "react-router-dom"; import { getParamEntries, parsePageParam } from "../utils/searchParamHelpers"; +import { useUserTeam } from "api/team/useTeam"; +import { Status526Enum, LanguageEnum } from "api/_autogen"; interface SubmissionFormInput { file: FileList; @@ -119,6 +121,7 @@ const Submissions: React.FC = () => { const CodeSubmission: React.FC = () => { const { episodeId } = useEpisodeId(); + const teamData = useUserTeam({ episodeId }); const queryClient = useQueryClient(); const episode = useEpisodeInfo({ id: episodeId }); @@ -150,7 +153,8 @@ const CodeSubmission: React.FC = () => { if (!episode.isSuccess) return null; - if (episode.data.frozen) + const isStaffTeam = teamData.data?.status === Status526Enum.S; + if (!isStaffTeam && episode.data.frozen) return (

Submissions are currently frozen! This is most likely due to a @@ -159,77 +163,153 @@ const CodeSubmission: React.FC = () => {

); - return ( -
-

Submit your code using the button below.

-

- Create a{" "} - - zip - {" "} - file of your robot player, and submit it below. The submission format - should be a zip file containing a single folder (which is your package - name), which should contain{" "} - - RobotPlayer.java - {" "} - and any other code you have written, for example: -

- -

- { - "submission.zip --> examplefuncsplayer --> RobotPlayer.java, FooBar.java" - } + if (episode.data.language === LanguageEnum.Py3) { + return ( +

+

Submit your python code using the button below.

+

+ Create a{" "} + + zip + {" "} + file of your robot player, and submit it below. The submission format + should be a zip file containing a single folder (which is your package + name), which should contain{" "} + + bot.py + {" "} + and any other code you have written, for example:

- -
{ - void handleSubmit(onSubmit)(e); - }} - className="mt-4 flex flex-col gap-4" - > -
- - -
-
- +

+ {"submission.zip --> examplefuncsplayer --> bot.py, utils.py"} +

+ + { + void handleSubmit(onSubmit)(e); + }} + className="mt-4 flex flex-col gap-4" + > +
+ + +
+
+ + +
+
+ ); + } else { + return ( +
+

Submit your java code using the button below.

+

+ Create a{" "} + + zip + {" "} + file of your robot player, and submit it below. The submission format + should be a zip file containing a single folder (which is your package + name), which should contain{" "} + + RobotPlayer.java + {" "} + and any other code you have written, for example: +

+ +

+ { + "submission.zip --> examplefuncsplayer --> RobotPlayer.java, FooBar.java" + } +

+
+ { + void handleSubmit(onSubmit)(e); + }} + className="mt-4 flex flex-col gap-4" + > +
+ + +
+
+ + +
+
-
- ); + +
+ ); + } }; export default Submissions;