Skip to content

Commit

Permalink
Merge branch 'main' into fix-search-labels
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/components/search/autocompletion.tsx
  • Loading branch information
zoglo committed Jul 10, 2024
2 parents bd8756b + ac463ac commit 3110296
Show file tree
Hide file tree
Showing 35 changed files with 496 additions and 358 deletions.
2 changes: 1 addition & 1 deletion app/(footer)/contact/contact.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export const Contact = () => {
})
}
>
<option value="">Select a category</option>
<option>Select a category</option>
<option value="bug">
I want to report a bug
</option>
Expand Down
58 changes: 19 additions & 39 deletions app/homepage.tsx → app/home/homepage.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,14 @@
"use client";

import Link from "next/link";
import { Button, Col, Row } from "react-bootstrap";
import { PatreonBunnySvgWithoutLink } from "~app/patron/patreon-info";
import { Run } from "~src/common/types";
import { Game } from "~app/games/games.types";
import React from "react";
import { Col, Row, Button } from "react-bootstrap";
import { DataHolder } from "~src/components/frontpage/data-holder";
import { SkeletonPersonalBests } from "~src/components/skeleton/index/skeleton-personal-bests";
import { PopularGames } from "~src/components/game/popular-games";
import { SkeletonPopularGames } from "~src/components/skeleton/index/skeleton-popular-games";
import React from "react";
import { useTranslations } from "next-intl";

export default function Homepage({
runs,
gamestats,
}: {
runs: Run[];
gamestats: Game[];
}) {
export const Homepage = () => {
const t = useTranslations("homepage");

return (
Expand Down Expand Up @@ -57,32 +47,22 @@ export default function Homepage({
</div>
</div>

<DataSection runs={runs} gamestats={gamestats} />
</div>
);
}

const DataSection = ({
runs,
gamestats,
}: {
runs: Run[];
gamestats: Game[];
}) => {
return (
<div>
<Row className="text-center">
<Col xl={6} lg={12} className="mt-4">
<h2>Recent Personal Bests</h2>
{runs && <DataHolder runs={runs} />}
{!runs && <SkeletonPersonalBests />}
</Col>
<Col xl={6} lg={12} className="mt-4">
<h2>Popular Games</h2>
{gamestats && <PopularGames gamestats={gamestats} />}
{!gamestats && <SkeletonPopularGames />}
</Col>
</Row>
<div>
<Row className="text-center">
<Col xl={6} className="mt-4">
<h2>Recent Personal Bests</h2>
<React.Suspense fallback={<SkeletonPersonalBests />}>
<DataHolder />
</React.Suspense>
</Col>
<Col xl={6} className="mt-4">
<h2>Popular Games</h2>
<React.Suspense fallback={<SkeletonPopularGames />}>
<PopularGames />
</React.Suspense>
</Col>
</Row>
</div>
</div>
);
};
12 changes: 7 additions & 5 deletions app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@ export default async function RootLayout({
}: {
children: React.ReactNode;
}) {
const session = await getSession();
const [
session,
locale,
// Providing all messages to the client
// side is the easiest way to get started
messages,
] = await Promise.all([getSession(), getLocale(), getMessages()]);
const sessionError = session.sessionError;
const locale = await getLocale();
// Providing all messages to the client
// side is the easiest way to get started
const messages = await getMessages();
return (
<html lang={locale} suppressHydrationWarning>
<body>
Expand Down
2 changes: 1 addition & 1 deletion app/marathon/show-marathon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ const BasePage: React.FunctionComponent<BasePageProps> = ({
setSelectedUser(e.target.value);
}}
>
<option key="">Select a user</option>
<option>Select a user</option>
{Object.keys(updatedLiveDataMap).map((key) => {
return <option key={key}>{key}</option>;
})}
Expand Down
14 changes: 2 additions & 12 deletions app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,8 @@
import React from "react";
import { getPersonalBestRuns } from "~src/lib/get-personal-best-runs";
import { getTabulatedGameStatsPopular } from "~src/components/game/get-tabulated-game-stats";
import Homepage from "~app/homepage";
import { Homepage } from "~app/home/homepage";

export const revalidate = 60;

export default async function Page() {
const runsPromise = getPersonalBestRuns();
const gamestatsPromise = getTabulatedGameStatsPopular();

const [runs, gamestats] = await Promise.all([
runsPromise,
gamestatsPromise,
]);

return <Homepage runs={runs} gamestats={gamestats} />;
return <Homepage />;
}
16 changes: 16 additions & 0 deletions app/races/[race]/edit/edit-race.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
BreadcrumbItem,
} from "~src/components/breadcrumbs/breadcrumb";
import { UnderlineTooltip } from "~src/components/tooltip";
import React from "react";

export const EditRace = ({ race, user }: { race: Race; user: User }) => {
const [state, formAction] = useFormState(editRace, { message: "" });
Expand Down Expand Up @@ -85,6 +86,21 @@ export const EditRace = ({ race, user }: { race: Race; user: User }) => {
defaultValue={race.forceStream}
/>
</Form.Group>
<Form.Group controlId="password">
<Form.Label>
<UnderlineTooltip
title="Password"
content="Sets a password. Participants need to enter this password in order to join the race."
element="Password"
/>
</Form.Label>
<Form.Control
name="password"
type="text"
placeholder="Enter a Race Password"
required={false}
/>
</Form.Group>
<div className="text-end">
<SubmitButton />
</div>
Expand Down
4 changes: 2 additions & 2 deletions app/races/race-faq.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ export const RaceFaq = () => {

const RaceFaqBody = () => {
return (
<div className="">
<div>
<p className="flex-center fs-4">
This is an attempt to modernize speedrun racing.
</p>
<p className="">
<p>
It has a modern ELO-based rating system, live tracking of the
race with live-standings as the race happens with full LiveSplit
Integration. It is extremely easy to start, join and participate
Expand Down
1 change: 1 addition & 0 deletions app/races/races.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ export interface EditRaceInput {
description?: string;
customName?: string;
forceStream?: string;
password?: string;
}

export type WebsocketRaceMessageType =
Expand Down
2 changes: 1 addition & 1 deletion app/races/stats/[game]/category-stats-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const CategoryStatsListDisplay = ({
);

return (
<div className="">
<div>
<PaginationSearch text="Search for category" />
<div className="mt-2 mb-4">
{pagination.data.map((gameStats) => {
Expand Down
10 changes: 10 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"cookies-next": "^4.1.0",
"country-flag-icons": "^1.5.9",
"d3": "^7.8.5",
"fuse.js": "^7.0.0",
"globby": "^14.0.0",
"joi": "^17.11.0",
"jquery": "^3.7.1",
Expand Down
2 changes: 2 additions & 0 deletions src/actions/races/edit-race.action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export async function editRace(_prevState: unknown, raceInput: FormData) {
description: raceInput.get("description") as string,
customName: raceInput.get("customName") as string,
forceStream: raceInput.get("forceStream") as string,
password: raceInput.get("password") as string,
};

const raceId = raceInput.get("raceId") as string;
Expand Down Expand Up @@ -54,6 +55,7 @@ export const validateInput = (
customName: Joi.string().min(0).max(40).optional(),
description: Joi.string().min(0).max(1000).optional(),
forceStream: Joi.string().min(0).max(100).optional(),
password: Joi.string().min(0).max(40).optional(),
});

return raceSchema.validate(input);
Expand Down
51 changes: 0 additions & 51 deletions src/components/css/Search.module.scss

This file was deleted.

6 changes: 3 additions & 3 deletions src/components/frontpage/data-holder.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"use client";

import { Col, Row, Table } from "react-bootstrap";
import { RunPreview } from "./run-preview";
import React from "react";
import { type Run } from "../../common/types";
import { getPersonalBestRuns } from "~src/lib/get-personal-best-runs";

export const DataHolder = ({ runs }: { runs: Run[] }) => {
export const DataHolder = async () => {
const runs = await getPersonalBestRuns();
return (
<Row>
<Col>
Expand Down
4 changes: 2 additions & 2 deletions src/components/game/get-tabulated-game-stats.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PaginatedGameResult } from "~app/games/games.types";
import { Game, PaginatedGameResult } from "~app/games/games.types";
import { getApiKey } from "~src/actions/api-key.action";

const fetchData = async (url: string) => {
Expand Down Expand Up @@ -43,7 +43,7 @@ export const getTabulatedGameStats = async () => {
return fetchData(url);
};

export const getTabulatedGameStatsPopular = async () => {
export const getTabulatedGameStatsPopular = async (): Promise<Game[]> => {
const url = `${process.env.NEXT_PUBLIC_DATA_URL}/games/stats/`;

return fetchData(url);
Expand Down
11 changes: 3 additions & 8 deletions src/components/game/popular-games.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
"use client";

import { Game } from "~app/games/games.types";
import { Row, Table } from "react-bootstrap";
import { GameLink, UserLink } from "../links/links";
import { DurationToFormatted } from "../util/datetime";
import React from "react";
import { GameImage } from "~src/components/image/gameimage";
import { getTabulatedGameStatsPopular } from "./get-tabulated-game-stats";

interface PopularGamesProps {
gamestats: Game[];
}

export const PopularGames: React.FC<PopularGamesProps> = ({ gamestats }) => {
export const PopularGames = async () => {
const gamestats = await getTabulatedGameStatsPopular();
return (
<div>
<Table striped bordered hover responsive>
Expand Down
1 change: 1 addition & 0 deletions src/components/links/links.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"use client";
import Link from "next/link";
import { ReactNode } from "react";
import { usePatreons } from "../patreon/use-patreons";
Expand Down
1 change: 1 addition & 0 deletions src/components/patreon/patreon-name.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"use client";
import { useEffect, useState } from "react";
import patreonStyles from "./patreon-styles";
import { PatreonBunnySvgWithoutLink } from "~app/patron/patreon-info";
Expand Down
1 change: 1 addition & 0 deletions src/components/patreon/use-patreons.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"use client";
import useSWR from "swr";
import { fetcher } from "../../utils/fetcher";
import { PatronList } from "../../../types/patreon.types";
Expand Down
Loading

0 comments on commit 3110296

Please sign in to comment.