From ce0227d3ad947253031122a2e7e2807ec7f96fa4 Mon Sep 17 00:00:00 2001 From: Pinapelz Date: Fri, 7 Nov 2025 12:56:30 -0800 Subject: chore: change ScoreDisplayProps and Score to be shared types --- .../components/displays/DancearoundScoreDisplay.tsx | 19 +------------------ .../src/components/displays/DancerushScoreDisplay.tsx | 18 +----------------- frontend/src/components/displays/DivaScoreDisplay.tsx | 19 +------------------ .../src/components/displays/GenericScoreDisplay.tsx | 19 +------------------ .../components/displays/MusicDiverScoreDisplay.tsx | 18 +----------------- .../src/components/displays/NostalgiaScoreDisplay.tsx | 19 +------------------ .../components/displays/ReflecBeatScoreDisplay.tsx | 19 +------------------ frontend/src/types/game.ts | 18 ++++++++++++++++++ 8 files changed, 25 insertions(+), 124 deletions(-) diff --git a/frontend/src/components/displays/DancearoundScoreDisplay.tsx b/frontend/src/components/displays/DancearoundScoreDisplay.tsx index 28ba9ed..b426d96 100644 --- a/frontend/src/components/displays/DancearoundScoreDisplay.tsx +++ b/frontend/src/components/displays/DancearoundScoreDisplay.tsx @@ -1,30 +1,13 @@ import React from "react"; import {Link} from "react-router"; import { globalSkipKeys } from "../../types/constants"; +import type {Score, ScoreDisplayProps} from "../../types/game"; import lampExcellent from "../../assets/games/dancearound/grade_excellent.webp"; import lampFullcombo from "../../assets/games/dancearound/grade_fullcombo.webp"; import lampClear from "../../assets/games/dancearound/grade_clear.webp"; import lampFailure from "../../assets/games/dancearound/grade_failed.webp"; import SHA1 from "crypto-js/sha1"; -interface Score { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - [key: string]: any; - timestamp: string | number; - username?: string; -} - -interface ScoreDisplayProps { - scores: Score[]; - viewMode: "cards" | "table"; - sortField: string; - sortDirection: "asc" | "desc"; - onSort: (field: string) => void; - onDelete?: (scoreId: number) => void; - showUsername?: boolean; - hideTitleArtist?: boolean; -} - const DancearoundScoreDisplay: React.FC = ({ scores, viewMode, diff --git a/frontend/src/components/displays/DancerushScoreDisplay.tsx b/frontend/src/components/displays/DancerushScoreDisplay.tsx index d1350ad..2aaebf4 100644 --- a/frontend/src/components/displays/DancerushScoreDisplay.tsx +++ b/frontend/src/components/displays/DancerushScoreDisplay.tsx @@ -1,29 +1,13 @@ import React from "react"; import {Link} from "react-router"; import { globalSkipKeys } from "../../types/constants"; +import type {Score, ScoreDisplayProps} from "../../types/game"; import dancerushEasyImg from "../../assets/games/dancerush/easy.webp"; import dancerushNormalImg from "../../assets/games/dancerush/normal.webp"; import p1_img from "../../assets/games/dancerush/1_p.webp"; import p2_img from "../../assets/games/dancerush/2_p.webp"; import SHA1 from "crypto-js/sha1"; -interface Score { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - [key: string]: any; - timestamp: string | number; - username?: string; -} - -interface ScoreDisplayProps { - scores: Score[]; - viewMode: "cards" | "table"; - sortField: string; - sortDirection: "asc" | "desc"; - onSort: (field: string) => void; - onDelete?: (scoreId: number) => void; - showUsername?: boolean; - hideTitleArtist?: boolean; -} const DancerushScoreDisplay: React.FC = ({ scores, diff --git a/frontend/src/components/displays/DivaScoreDisplay.tsx b/frontend/src/components/displays/DivaScoreDisplay.tsx index ddbdf0c..a7b4824 100644 --- a/frontend/src/components/displays/DivaScoreDisplay.tsx +++ b/frontend/src/components/displays/DivaScoreDisplay.tsx @@ -1,6 +1,7 @@ import React from "react"; import {Link} from "react-router"; import { globalSkipKeys } from "../../types/constants"; +import type {Score, ScoreDisplayProps} from "../../types/game"; import SHA1 from "crypto-js/sha1"; import easyImg from "../../assets/games/diva/easy.webp"; import normalImg from "../../assets/games/diva/normal.webp"; @@ -14,24 +15,6 @@ import greatImg from "../../assets/games/diva/great.webp"; import excellentImg from "../../assets/games/diva/excellent.webp"; -interface Score { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - [key: string]: any; - timestamp: string | number; - username?: string; -} - -interface ScoreDisplayProps { - scores: Score[]; - viewMode: "cards" | "table"; - sortField: string; - sortDirection: "asc" | "desc"; - onSort: (field: string) => void; - onDelete?: (scoreId: number) => void; - showUsername?: boolean; - hideTitleArtist?: boolean; -} - const DivaScoreDisplay: React.FC = ({ scores, viewMode, diff --git a/frontend/src/components/displays/GenericScoreDisplay.tsx b/frontend/src/components/displays/GenericScoreDisplay.tsx index 6132a19..defeb82 100644 --- a/frontend/src/components/displays/GenericScoreDisplay.tsx +++ b/frontend/src/components/displays/GenericScoreDisplay.tsx @@ -2,24 +2,7 @@ import React from "react"; import SHA1 from "crypto-js/sha1"; import { Link } from "react-router"; import { globalSkipKeys } from "../../types/constants"; - -interface Score { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - [key: string]: any; - timestamp: string | number; - username?: string; -} - -interface ScoreDisplayProps { - scores: Score[]; - viewMode: "cards" | "table"; - sortField: string; - sortDirection: "asc" | "desc"; - onSort: (field: string) => void; - onDelete?: (scoreId: number) => void; - showUsername?: boolean; - hideTitleArtist?: boolean; -} +import type {Score, ScoreDisplayProps} from "../../types/game"; const ScoreDisplay: React.FC = ({ scores, diff --git a/frontend/src/components/displays/MusicDiverScoreDisplay.tsx b/frontend/src/components/displays/MusicDiverScoreDisplay.tsx index dcc57e3..282268a 100644 --- a/frontend/src/components/displays/MusicDiverScoreDisplay.tsx +++ b/frontend/src/components/displays/MusicDiverScoreDisplay.tsx @@ -2,24 +2,8 @@ import React from "react"; import SHA1 from "crypto-js/sha1"; import { Link } from "react-router"; import { globalSkipKeys } from "../../types/constants"; +import type {Score, ScoreDisplayProps} from "../../types/game"; -interface Score { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - [key: string]: any; - timestamp: string | number; - username?: string; -} - -interface ScoreDisplayProps { - scores: Score[]; - viewMode: "cards" | "table"; - sortField: string; - sortDirection: "asc" | "desc"; - onSort: (field: string) => void; - onDelete?: (scoreId: number) => void; - showUsername?: boolean; - hideTitleArtist?: boolean; -} const MusicDiverDisplay: React.FC = ({ scores, diff --git a/frontend/src/components/displays/NostalgiaScoreDisplay.tsx b/frontend/src/components/displays/NostalgiaScoreDisplay.tsx index 063d449..370aa8e 100644 --- a/frontend/src/components/displays/NostalgiaScoreDisplay.tsx +++ b/frontend/src/components/displays/NostalgiaScoreDisplay.tsx @@ -1,26 +1,9 @@ import React from "react"; import SHA1 from "crypto-js/sha1"; import { Link } from "react-router"; +import type {Score, ScoreDisplayProps} from "../../types/game"; import { globalSkipKeys } from "../../types/constants"; -interface Score { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - [key: string]: any; - timestamp: string | number; - username?: string; -} - -interface ScoreDisplayProps { - scores: Score[]; - viewMode: "cards" | "table"; - sortField: string; - sortDirection: "asc" | "desc"; - onSort: (field: string) => void; - onDelete?: (scoreId: number) => void; - showUsername?: boolean; - hideTitleArtist?: boolean; -} - const NostalgiaScoreDisplay: React.FC = ({ scores, viewMode, diff --git a/frontend/src/components/displays/ReflecBeatScoreDisplay.tsx b/frontend/src/components/displays/ReflecBeatScoreDisplay.tsx index 9de1403..63aa2a9 100644 --- a/frontend/src/components/displays/ReflecBeatScoreDisplay.tsx +++ b/frontend/src/components/displays/ReflecBeatScoreDisplay.tsx @@ -2,24 +2,7 @@ import React from "react"; import SHA1 from "crypto-js/sha1"; import { Link } from "react-router"; import { globalSkipKeys } from "../../types/constants"; - -interface Score { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - [key: string]: any; - timestamp: string | number; - username?: string; -} - -interface ScoreDisplayProps { - scores: Score[]; - viewMode: "cards" | "table"; - sortField: string; - sortDirection: "asc" | "desc"; - onSort: (field: string) => void; - onDelete?: (scoreId: number) => void; - showUsername?: boolean; - hideTitleArtist?: boolean; -} +import type {Score, ScoreDisplayProps} from "../../types/game"; const ReflecBeatScoreDisplay: React.FC = ({ scores, diff --git a/frontend/src/types/game.ts b/frontend/src/types/game.ts index 3c595ea..1f46fea 100644 --- a/frontend/src/types/game.ts +++ b/frontend/src/types/game.ts @@ -3,3 +3,21 @@ export interface SupportedGame { formattedName: string; description: string; } + +export interface Score { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + [key: string]: any; + timestamp: string | number; + username?: string; +} + +export interface ScoreDisplayProps { + scores: Score[]; + viewMode: "cards" | "table"; + sortField: string; + sortDirection: "asc" | "desc"; + onSort: (field: string) => void; + onDelete?: (scoreId: number) => void; + showUsername?: boolean; + hideTitleArtist?: boolean; +} -- cgit v1.2.3