From 0a6ec532a635bb5e075acccead90f7f53f5f8275 Mon Sep 17 00:00:00 2001 From: Liam Date: Fri, 20 Oct 2023 21:55:30 +0100 Subject: [PATCH] make score a component --- src/app/player/[id]/page.tsx | 60 ++------------------------------ src/components/Score.tsx | 66 ++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+), 58 deletions(-) create mode 100644 src/components/Score.tsx diff --git a/src/app/player/[id]/page.tsx b/src/app/player/[id]/page.tsx index 1b2c166..3741d0a 100644 --- a/src/app/player/[id]/page.tsx +++ b/src/app/player/[id]/page.tsx @@ -6,14 +6,13 @@ import Container from "@/components/Container"; import Label from "@/components/Label"; import Pagination from "@/components/Pagination"; import PlayerChart from "@/components/PlayerChart"; -import ScoreStatLabel from "@/components/ScoreStatLabel"; +import Score from "@/components/Score"; import { Spinner } from "@/components/Spinner"; import { ScoresaberPlayer } from "@/schemas/scoresaber/player"; import { ScoresaberPlayerScore } from "@/schemas/scoresaber/playerScore"; import { formatNumber } from "@/utils/number"; import { fetchScores, getPlayerInfo } from "@/utils/scoresaber/api"; import { GlobeAsiaAustraliaIcon } from "@heroicons/react/20/solid"; -import moment from "moment"; import Image from "next/image"; import { useCallback, useEffect, useState } from "react"; import ReactCountryFlag from "react-country-flag"; @@ -207,62 +206,7 @@ export default function Player({ params }: { params: { id: string } }) { const { score, leaderboard } = scoreData; return ( -
-
-
- -

#{score.rank}

-
-

- {moment(score.timeSet).fromNow()} -

-
-
- {leaderboard.songName} -
-

{leaderboard.songName}

-

- {leaderboard.songAuthorName}{" "} - - {leaderboard.levelAuthorName} - -

-
-
-
-
- -

#{score.rank}

-
-
- {score.pp > 0 && ( - - )} - -
-
-
+ ); }) )} diff --git a/src/components/Score.tsx b/src/components/Score.tsx new file mode 100644 index 0000000..2d0b2fc --- /dev/null +++ b/src/components/Score.tsx @@ -0,0 +1,66 @@ +import { ScoresaberLeaderboardInfo } from "@/schemas/scoresaber/leaderboard"; +import { ScoresaberScore } from "@/schemas/scoresaber/score"; +import { formatNumber } from "@/utils/number"; +import { GlobeAsiaAustraliaIcon } from "@heroicons/react/20/solid"; +import moment from "moment"; +import Image from "next/image"; +import ScoreStatLabel from "./ScoreStatLabel"; + +type ScoreProps = { + score: ScoresaberScore; + leaderboard: ScoresaberLeaderboardInfo; +}; + +export default function Score({ score, leaderboard }: ScoreProps) { + return ( +
+
+
+ +

#{score.rank}

+
+

+ {moment(score.timeSet).fromNow()} +

+
+
+ {leaderboard.songName} +
+

{leaderboard.songName}

+

+ {leaderboard.songAuthorName}{" "} + {leaderboard.levelAuthorName} +

+
+
+
+
+ +

#{score.rank}

+
+
+ {score.pp > 0 && ( + + )} + +
+
+
+ ); +}