update to canary next and few small changes
All checks were successful
Deploy / deploy (push) Successful in 2m21s

This commit is contained in:
Lee
2024-09-27 21:55:49 +01:00
parent 52203bbb77
commit 89389667f8
7 changed files with 353 additions and 75 deletions

View File

@ -7,12 +7,13 @@ import { Metadata } from "next";
import { redirect } from "next/navigation";
type Props = {
params: {
params: Promise<{
slug: string[];
};
}>;
};
export async function generateMetadata({ params: { slug } }: Props): Promise<Metadata> {
export async function generateMetadata({ params }: Props): Promise<Metadata> {
const { slug } = await params;
const id = slug[0]; // The players id
const player = await scoresaberService.lookupPlayer(id, false);
if (player === undefined) {
@ -38,7 +39,8 @@ export async function generateMetadata({ params: { slug } }: Props): Promise<Met
};
}
export default async function Search({ params: { slug } }: Props) {
export default async function Search({ params }: Props) {
const { slug } = await params;
const id = slug[0]; // The players id
const sort: ScoreSort = (slug[1] as ScoreSort) || "recent"; // The sorting method
const page = parseInt(slug[2]) || 1; // The page number

View File

@ -20,7 +20,7 @@ const playerData = [
{
showWhenInactiveOrBanned: false,
icon: (player: ScoreSaberPlayerToken) => {
return <CountryFlag code={player.country.toLowerCase()} size={15} />;
return <CountryFlag code={player.country} size={15} />;
},
render: (player: ScoreSaberPlayerToken) => {
return <p>#{formatNumberWithCommas(player.countryRank)}</p>;

View File

@ -105,7 +105,7 @@ export default function PlayerRankChart({ player }: Props) {
};
return (
<Card className="h-96 w-full">
<Card className="h-96">
<Line className="w-fit" options={options} data={data} />
</Card>
);

View File

@ -1,7 +1,7 @@
import { leaderboards } from "@/common/leaderboards";
import ScoreSaberPlayerToken from "@/common/model/token/scoresaber/score-saber-player-token";
import { ScoreSaberPlayersPageToken } from "@/common/model/token/scoresaber/score-saber-players-page-token";
import { formatPp } from "@/common/number-utils";
import { formatNumberWithCommas, formatPp } from "@/common/number-utils";
import { GlobeAmericasIcon } from "@heroicons/react/24/solid";
import { useQuery } from "@tanstack/react-query";
import Link from "next/link";
@ -11,6 +11,7 @@ import CountryFlag from "../country-flag";
import { Avatar, AvatarImage } from "../ui/avatar";
const REFRESH_INTERVAL = 5 * 60 * 1000; // 5 minutes
const PLAYER_NAME_MAX_LENGTH = 14;
type MiniProps = {
type: "Global" | "Country";
@ -97,7 +98,7 @@ export default function Mini({ type, player }: MiniProps) {
}
return (
<Card className="w-full flex gap-2">
<Card className="w-full flex gap-2 sticky">
<div className="flex gap-2">
{icon}
<p>{type} Ranking</p>
@ -107,6 +108,10 @@ export default function Mini({ type, player }: MiniProps) {
{isError && <p className="text-red-500">Error</p>}
{players?.map((player, index) => {
const rank = type == "Global" ? player.rank : player.countryRank;
const playerName =
player.name.length > PLAYER_NAME_MAX_LENGTH
? player.name.substring(0, PLAYER_NAME_MAX_LENGTH) + "..."
: player.name;
return (
<Link
@ -115,11 +120,11 @@ export default function Mini({ type, player }: MiniProps) {
className="flex justify-between gap-2 bg-accent px-2 py-1.5 cursor-pointer transform-gpu transition-all hover:brightness-75 first:rounded-t last:rounded-b"
>
<div className="flex gap-2">
<p className="text-gray-400">#{rank}</p>
<p className="text-gray-400">#{formatNumberWithCommas(rank)}</p>
<Avatar className="w-6 h-6 pointer-events-none">
<AvatarImage alt="Profile Picture" src={player.profilePicture} />
</Avatar>
<p>{player.name}</p>
<p>{playerName}</p>
</div>
<p className="text-pp">{formatPp(player.pp)}pp</p>
</Link>