Skip to content

Commit

Permalink
added twitter and some small content details
Browse files Browse the repository at this point in the history
  • Loading branch information
lowtorola committed Dec 23, 2024
1 parent e9760ff commit d612810
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 38 deletions.
21 changes: 3 additions & 18 deletions frontend/src/api/loaders/rankingsLoader.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,16 @@
import type { QueryClient } from "@tanstack/react-query";
import { redirect, type LoaderFunction } from "react-router-dom";
import type { LoaderFunction } from "react-router-dom";
import { episodeInfoFactory } from "../episode/episodeFactories";
import { buildKey, safeEnsureQueryData } from "../helpers";
import { safeEnsureQueryData } from "../helpers";
import { searchTeamsFactory } from "../team/teamFactories";
import type { Episode } from "api/_autogen";
import toast from "react-hot-toast";

export const rankingsLoader =
(queryClient: QueryClient): LoaderFunction =>
async ({ params }) => {
({ params }) => {
const { episodeId } = params;

if (episodeId === undefined) return null;

// Ensure that this page is available for the episode
const episodeData = queryClient.ensureQueryData<Episode>({
queryKey: buildKey(episodeInfoFactory.queryKey, { id: episodeId }),
queryFn: async () => await episodeInfoFactory.queryFn({ id: episodeId }),
});

if ((await episodeData).game_release.getTime() > Date.now()) {
toast.error(
`Rankings page not released yet for ${(await episodeData).name_long}.`,
);
return redirect(`/${episodeId}/home`);
}

// Episode info
safeEnsureQueryData({ id: episodeId }, episodeInfoFactory, queryClient);

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/sidebar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const COMPETE_ITEMS: SidebarItemData[] = [
iconName: "chart_bar",
text: "Rankings",
linkTo: "rankings",
requireGameReleased: true,
requireGameReleased: false,
userAuthLevel: UserAuthLevel.LOGGED_OUT,
},
{
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/content/bc25java.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ export const RESOURCES: Partial<Record<ResourcesPageKey, string>> = {
Lectures: `
Battlecode 2025 Java will be holding lectures, where a dev will be going over possible strategy, coding up an example player, answering questions, etc. Lectures are streamed on Twitch. More details coming soon!
All lectures are streamed live on [our Twitch account](https://twitch.tv/mitbattlecode), and are later uploaded to [our YouTube channel](https://youtube.com/@MITBattlecode).
`,
All lectures are streamed live on [our YouTube channel](https://youtube.com/@MITBattlecode), and are later uploaded as videos.
`,
};

export const DEBUGGINGTIPS: Partial<Record<DebuggingTipsPageKey, string>> = {};
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/content/bc25python.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ To participate in Battlecode, you need an account and a team. Each team can cons
export const RESOURCES: Partial<Record<ResourcesPageKey, string>> = {
Lectures: `
Battlecode 2025 Python will be holding lectures, where a dev will be going over possible strategy, coding up an example player, answering questions, etc. Lectures are streamed on Twitch. More details coming soon!
Battlecode 2025 Python will be holding lectures, where a dev will be going over possible strategy, coding up an example player, answering questions, etc. Lectures are streamed on Twitch. More details coming soon!
All lectures are streamed live on [our Twitch account](https://twitch.tv/mitbattlecode), and are later uploaded to [our YouTube channel](https://youtube.com/@MITBattlecode).
All lectures are streamed live on [our YouTube channel](https://youtube.com/@MITBattlecode), and are later uploaded as videos.
`,
};

Expand Down
33 changes: 25 additions & 8 deletions frontend/src/views/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import { useUserTeam } from "api/team/useTeam";
// import UserChart from "components/compete/chart/UserChart";
// import { useCurrentUser } from "contexts/CurrentUserContext";
import { isPresent } from "utils/utilTypes";
import { dateTime } from "utils/dateTime";
import Markdown from "components/elements/Markdown";

const Home: React.FC = () => {
// const TOP_TEAMS = 10;
Expand All @@ -25,6 +27,21 @@ const Home: React.FC = () => {
const SOCIAL =
"hover:drop-shadow-lg hover:opacity-80 transition-opacity duration-300 ease-in-out";

// This is a temporary message until we have a working countdown :)
let WELCOME =
episode.isSuccess && isPresent(episode.data.blurb)
? episode.data.blurb
: `Welcome!`;

if (episode.isSuccess && episode.data.game_release.getTime() > Date.now()) {
WELCOME += "\n\n";
WELCOME += `The competition will be launched on **${
dateTime(episode.data.game_release).localFullString
}**.`;
WELCOME += "\n\n";
WELCOME += `In the meantime, [create or join a team](/${episodeId}/my_team) and check out the [quick start](/${episodeId}/quick_start) page.`;
}

return (
<div className="p-6">
<div className="flex flex-col gap-6 xl:flex-row">
Expand All @@ -37,11 +54,7 @@ const Home: React.FC = () => {
}
loading={episode.isLoading}
>
<span>
{episode.isSuccess && isPresent(episode.data.blurb)
? episode.data.blurb
: `Welcome!`}
</span>
<Markdown text={WELCOME} />
</SectionCard>

<SectionCard title="Scrimmaging Record" loading={userTeam.isLoading}>
Expand Down Expand Up @@ -82,19 +95,23 @@ const Home: React.FC = () => {
</SectionCard>
<SectionCard title="Social Media">
<div className="flex w-full flex-row items-center justify-evenly pt-2">
<SocialIcon url="https://discord.gg/N86mxkH" className={SOCIAL} />
<SocialIcon
url="https://www.github.com/battlecode"
url="https://www.youtube.com/@MITBattlecode"
className={SOCIAL}
/>
<SocialIcon
url="https://www.youtube.com/@MITBattlecode"
url="https://x.com/mitbattlecode"
className={SOCIAL}
/>
<SocialIcon
url="https://www.instagram.com/mitbattlecode"
className={SOCIAL}
/>
<SocialIcon url="https://discord.gg/N86mxkH" className={SOCIAL} />
<SocialIcon
url="https://www.github.com/battlecode"
className={SOCIAL}
/>
</div>
</SectionCard>
{/* <SectionCard title="Top Teams">
Expand Down
7 changes: 0 additions & 7 deletions frontend/src/views/MyTeam.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,6 @@ const MyTeam: React.FC = () => {
hideAllScrimmages={true}
/>
</SectionCard>
<SectionCard className="shrink xl:hidden" title="Scrimmaging Record">
<ScrimmagingRecord
team={teamData.data}
hideTeamName={true}
hideAllScrimmages={true}
/>
</SectionCard>
</div>
{/* Display the members list, file upload, and win/loss to the right when on a big screen. */}
<div className="hidden max-w-2xl gap-8 xl:flex xl:flex-1 xl:flex-col">
Expand Down

0 comments on commit d612810

Please sign in to comment.