7?
Some checks failed
Deploy Website / deploy (push) Failing after 1m36s
Deploy Backend / deploy (push) Successful in 3m11s

This commit is contained in:
Lee 2024-10-17 15:47:20 +01:00
parent e37f0d5548
commit d08f81b25d
6 changed files with 11 additions and 13 deletions

@ -1,12 +1,11 @@
import { Metadata } from "../types/metadata"; import { Metadata } from "../types/metadata";
import { BeatSaverMap } from "../model/beatsaver/beatsaver-map"; import { BeatSaverMap } from "../model/beatsaver/beatsaver-map";
import Score from "../score/score";
export default interface LeaderboardScoresResponse<L> { export default interface LeaderboardScoresResponse<S, L> {
/** /**
* The scores that were set. * The scores that were set.
*/ */
readonly scores: Score[]; readonly scores: S[];
/** /**
* The leaderboard that was used. * The leaderboard that was used.

@ -3,6 +3,7 @@ import { kyFetch } from "./utils";
import PlayerScoresResponse from "../response/player-scores-response"; import PlayerScoresResponse from "../response/player-scores-response";
import { Config } from "../config"; import { Config } from "../config";
import { ScoreSort } from "../score/score-sort"; import { ScoreSort } from "../score/score-sort";
import LeaderboardScoresResponse from "../response/leaderboard-scores-response";
/** /**
* Fetches the player's scores * Fetches the player's scores
@ -33,5 +34,5 @@ export async function fetchPlayerScores<S, L>(
* @param page the page * @param page the page
*/ */
export async function fetchLeaderboardScores<S, L>(leaderboard: Leaderboards, id: string, page: number) { export async function fetchLeaderboardScores<S, L>(leaderboard: Leaderboards, id: string, page: number) {
return kyFetch<PlayerScoresResponse<S, L>>(`${Config.apiUrl}/scores/leaderboard/${leaderboard}/${id}/${page}`); return kyFetch<LeaderboardScoresResponse<S, L>>(`${Config.apiUrl}/scores/leaderboard/${leaderboard}/${id}/${page}`);
} }

@ -121,7 +121,5 @@ export default async function LeaderboardPage(props: Props) {
if (response == undefined) { if (response == undefined) {
return redirect("/"); return redirect("/");
} }
const { leaderboardResponse, scores } = response; return <LeaderboardData initialLeaderboard={response.leaderboardResponse} initialScores={response.scores} />;
return <LeaderboardData initialLeaderboard={response.leaderboardResponse} initialScores={scores} />;
} }

@ -8,7 +8,7 @@ import { LeaderboardResponse } from "@ssr/common/response/leaderboard-response";
import { useQuery } from "@tanstack/react-query"; import { useQuery } from "@tanstack/react-query";
import { useState } from "react"; import { useState } from "react";
import { fetchLeaderboard } from "@ssr/common/utils/leaderboard.util"; import { fetchLeaderboard } from "@ssr/common/utils/leaderboard.util";
import PlayerScoresResponse from "../../../../common/src/response/player-scores-response.ts"; import LeaderboardScoresResponse from "@ssr/common/response/leaderboard-scores-response";
const REFRESH_INTERVAL = 1000 * 60 * 5; const REFRESH_INTERVAL = 1000 * 60 * 5;
@ -21,7 +21,7 @@ type LeaderboardDataProps = {
/** /**
* The initial score data. * The initial score data.
*/ */
initialScores: PlayerScoresResponse<ScoreSaberScore, ScoreSaberLeaderboard>; initialScores?: LeaderboardScoresResponse<ScoreSaberScore, ScoreSaberLeaderboard>;
}; };
export function LeaderboardData({ initialLeaderboard, initialScores }: LeaderboardDataProps) { export function LeaderboardData({ initialLeaderboard, initialScores }: LeaderboardDataProps) {

@ -2,8 +2,8 @@ import LeaderboardPlayer from "./leaderboard-player";
import LeaderboardScoreStats from "./leaderboard-score-stats"; import LeaderboardScoreStats from "./leaderboard-score-stats";
import ScoreRankInfo from "@/components/score/score-rank-info"; import ScoreRankInfo from "@/components/score/score-rank-info";
import ScoreSaberPlayer from "@ssr/common/player/impl/scoresaber-player"; import ScoreSaberPlayer from "@ssr/common/player/impl/scoresaber-player";
import ScoreSaberScore from "@ssr/common/score/impl/scoresaber-score";
import ScoreSaberLeaderboard from "@ssr/common/leaderboard/impl/scoresaber-leaderboard"; import ScoreSaberLeaderboard from "@ssr/common/leaderboard/impl/scoresaber-leaderboard";
import ScoreSaberScore from "@ssr/common/score/impl/scoresaber-score";
type Props = { type Props = {
/** /**

@ -15,7 +15,7 @@ import { fetchLeaderboardScores } from "@ssr/common/utils/score-utils";
import ScoreSaberScore from "@ssr/common/score/impl/scoresaber-score"; import ScoreSaberScore from "@ssr/common/score/impl/scoresaber-score";
import ScoreSaberLeaderboard from "@ssr/common/leaderboard/impl/scoresaber-leaderboard"; import ScoreSaberLeaderboard from "@ssr/common/leaderboard/impl/scoresaber-leaderboard";
import ScoreSaberPlayer from "@ssr/common/player/impl/scoresaber-player"; import ScoreSaberPlayer from "@ssr/common/player/impl/scoresaber-player";
import PlayerScoresResponse from "../../../../common/src/response/player-scores-response.ts"; import LeaderboardScoresResponse from "@ssr/common/response/leaderboard-scores-response";
type LeaderboardScoresProps = { type LeaderboardScoresProps = {
/** /**
@ -26,7 +26,7 @@ type LeaderboardScoresProps = {
/** /**
* The initial scores to show. * The initial scores to show.
*/ */
initialScores?: PlayerScoresResponse<ScoreSaberScore, ScoreSaberLeaderboard>; initialScores?: LeaderboardScoresResponse<ScoreSaberScore, ScoreSaberLeaderboard>;
/** /**
* The leaderboard to display. * The leaderboard to display.
@ -75,7 +75,7 @@ export default function LeaderboardScores({
const [previousPage, setPreviousPage] = useState(initialPage); const [previousPage, setPreviousPage] = useState(initialPage);
const [currentPage, setCurrentPage] = useState(initialPage); const [currentPage, setCurrentPage] = useState(initialPage);
const [currentScores, setCurrentScores] = useState< const [currentScores, setCurrentScores] = useState<
PlayerScoresResponse<ScoreSaberScore, ScoreSaberLeaderboard> | undefined LeaderboardScoresResponse<ScoreSaberScore, ScoreSaberLeaderboard> | undefined
>(initialScores); >(initialScores);
const topOfScoresRef = useRef<HTMLDivElement>(null); const topOfScoresRef = useRef<HTMLDivElement>(null);
const [shouldFetch, setShouldFetch] = useState(true); const [shouldFetch, setShouldFetch] = useState(true);