From cdb500bac223cbddd271976951708a42dcb77650 Mon Sep 17 00:00:00 2001
From: Taken
Date: Wed, 10 Sep 2025 19:36:14 +0200
Subject: [PATCH] Added a general stats component
---
.../player/[ign]/_stats/GeneralStats.tsx | 31 ++++
.../player/[ign]/_stats/bedwars/bedwars.tsx | 86 +++++------
.../_stats/build-battle/build-battle.tsx | 58 +++-----
.../_stats/copsandcrims/copsandcrims.tsx | 74 ++++-----
.../player/[ign]/_stats/duels/duels.tsx | 108 ++++++--------
.../[ign]/_stats/megawalls/megawalls.tsx | 90 +++++------
.../_stats/murder-mystery/murder-mystery.tsx | 58 +++-----
.../(stats)/player/[ign]/_stats/pit/pit.tsx | 62 ++++----
.../player/[ign]/_stats/skywars/skywars.tsx | 140 ++++++++----------
.../[ign]/_stats/tnt-games/tnt-games.tsx | 40 ++---
.../(stats)/player/[ign]/_stats/uhc/uhc.tsx | 64 ++++----
.../[ign]/_stats/woolgames/woolgames.tsx | 26 +---
12 files changed, 369 insertions(+), 468 deletions(-)
create mode 100644 src/app/(stats)/player/[ign]/_stats/GeneralStats.tsx
diff --git a/src/app/(stats)/player/[ign]/_stats/GeneralStats.tsx b/src/app/(stats)/player/[ign]/_stats/GeneralStats.tsx
new file mode 100644
index 0000000..9c47203
--- /dev/null
+++ b/src/app/(stats)/player/[ign]/_stats/GeneralStats.tsx
@@ -0,0 +1,31 @@
+import { AccordionContent, AccordionItem, AccordionTrigger } from "@/components/ui/accordion"
+import { Card, CardContent } from "@/components/ui/card"
+import { ReactNode } from "react"
+import CollapsedStats from "../_components/CollapsedStats"
+
+export default function GeneralStats(
+ { id, title, children, collapsedStats }: {
+ id: string
+ title: string
+ children: ReactNode
+ collapsedStats: Parameters[0]["stats"]
+ }
+) {
+ return (
+
+
+
+
+ {title}
+
+
+
+
+
+ {children}
+
+
+
+
+ )
+}
diff --git a/src/app/(stats)/player/[ign]/_stats/bedwars/bedwars.tsx b/src/app/(stats)/player/[ign]/_stats/bedwars/bedwars.tsx
index 6451745..9e298b4 100644
--- a/src/app/(stats)/player/[ign]/_stats/bedwars/bedwars.tsx
+++ b/src/app/(stats)/player/[ign]/_stats/bedwars/bedwars.tsx
@@ -1,11 +1,9 @@
-import { AccordionContent, AccordionItem, AccordionTrigger } from "@/components/ui/accordion"
-import { Card, CardContent } from "@/components/ui/card"
import { Separator } from "@/components/ui/separator"
import { formatNumber } from "@/lib/formatters"
import { getBedwarsLevelForExp, getTotalBedwarsExpForLevel } from "@/lib/hypixel/bedwars/level"
import { devide, getProgress } from "@/lib/hypixel/general"
import { NonNullStats } from "@/lib/schema/player"
-import CollapsedStats from "../../_components/CollapsedStats"
+import GeneralStats from "../GeneralStats"
import { BedwarsLevel, BedwarsProgress } from "./components"
import BedwarsGeneralStats from "./stats"
import BedwarsStatTable from "./table"
@@ -27,51 +25,41 @@ export default function BedwarsStats({ stats }: { stats: NonNullStats["Bedwars"]
const ceilingXp = next - current
return (
-
-
-
-
- BedWars
-
-
Level,
- stat:
- },
- {
- title: WS
,
- stat: {stats.winstreak ?? "?"}
- },
- {
- title: KD
,
- stat: {kd}
- },
- {
- title: FKD
,
- stat: {fkd}
- },
- {
- title: WL
,
- stat: {wl}
- },
- {
- title: BBL
,
- stat: {bbl}
- }
- ]}
- />
-
-
-
-
-
-
-
-
-
-
-
-
+ Level
,
+ stat:
+ },
+ {
+ title: WS
,
+ stat: {stats.winstreak ?? "?"}
+ },
+ {
+ title: KD
,
+ stat: {kd}
+ },
+ {
+ title: FKD
,
+ stat: {fkd}
+ },
+ {
+ title: WL
,
+ stat: {wl}
+ },
+ {
+ title: BBL
,
+ stat: {bbl}
+ }
+ ]}
+ >
+
+
+
+
+
+
)
}
diff --git a/src/app/(stats)/player/[ign]/_stats/build-battle/build-battle.tsx b/src/app/(stats)/player/[ign]/_stats/build-battle/build-battle.tsx
index 85a6b92..83d7854 100644
--- a/src/app/(stats)/player/[ign]/_stats/build-battle/build-battle.tsx
+++ b/src/app/(stats)/player/[ign]/_stats/build-battle/build-battle.tsx
@@ -1,11 +1,9 @@
-import { AccordionContent, AccordionItem, AccordionTrigger } from "@/components/ui/accordion"
-import { Card, CardContent } from "@/components/ui/card"
import { Separator } from "@/components/ui/separator"
import { formatNumber } from "@/lib/formatters"
import { getBuildBattleRank } from "@/lib/hypixel/build-battle/general"
import { NonNullStats } from "@/lib/schema/player"
import { cn } from "@/lib/utils"
-import CollapsedStats from "../../_components/CollapsedStats"
+import GeneralStats from "../GeneralStats"
import BuildBattleTitleProgress from "./progress"
import BuildBattleGeneralStats from "./stats"
import BuildBattleStatsTable from "./table"
@@ -16,37 +14,27 @@ export default function BuildBattleStats({ stats }: { stats: NonNullStats["Build
const rank = getBuildBattleRank(stats.score)
return (
-
-
-
-
- Build Battle
-
-
Title,
- stat: {rank.name}
- },
- {
- title: Wins
,
- stat: {formatNumber(stats.wins)}
- }
- ]}
- />
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ Title,
+ stat: {rank.name}
+ },
+ {
+ title: Wins
,
+ stat: {formatNumber(stats.wins)}
+ }
+ ]}
+ >
+
+
+
+
+
+
+
+
)
}
diff --git a/src/app/(stats)/player/[ign]/_stats/copsandcrims/copsandcrims.tsx b/src/app/(stats)/player/[ign]/_stats/copsandcrims/copsandcrims.tsx
index ea92df9..53be132 100644
--- a/src/app/(stats)/player/[ign]/_stats/copsandcrims/copsandcrims.tsx
+++ b/src/app/(stats)/player/[ign]/_stats/copsandcrims/copsandcrims.tsx
@@ -1,11 +1,9 @@
-import { AccordionContent, AccordionItem, AccordionTrigger } from "@/components/ui/accordion"
-import { Card, CardContent } from "@/components/ui/card"
import { Separator } from "@/components/ui/separator"
import { formatNumber } from "@/lib/formatters"
import { getCopsAndCrimsScoreColor } from "@/lib/hypixel/copsandcrims/general"
import { devide } from "@/lib/hypixel/general"
import { NonNullStats } from "@/lib/schema/player"
-import CollapsedStats from "../../_components/CollapsedStats"
+import GeneralStats from "../GeneralStats"
import CopsAndCrimsGeneralStats from "./stats"
import CopsAndCrimsStatTable from "./table"
import CopsAndCrimsWeaponStats from "./weapons"
@@ -22,45 +20,35 @@ export default function CopsAndCrimsStats({ stats }: { stats: NonNullStats["Cops
const scoreColor = getCopsAndCrimsScoreColor(score)
return (
-
-
-
-
- Cops And Crims
-
-
Score,
- stat: {formatNumber(score)}
- },
- {
- title: Kills
,
- stat: {formatNumber(kills)}
- },
- {
- title: KD
,
- stat: {kd}
- },
- {
- title: Wins
,
- stat: {formatNumber(wins)}
- }
- ]}
- />
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ Score,
+ stat: {formatNumber(score)}
+ },
+ {
+ title: Kills
,
+ stat: {formatNumber(kills)}
+ },
+ {
+ title: KD
,
+ stat: {kd}
+ },
+ {
+ title: Wins
,
+ stat: {formatNumber(wins)}
+ }
+ ]}
+ >
+
+
+
+
+
+
+
+
)
}
diff --git a/src/app/(stats)/player/[ign]/_stats/duels/duels.tsx b/src/app/(stats)/player/[ign]/_stats/duels/duels.tsx
index 06796d6..815c36b 100644
--- a/src/app/(stats)/player/[ign]/_stats/duels/duels.tsx
+++ b/src/app/(stats)/player/[ign]/_stats/duels/duels.tsx
@@ -1,11 +1,9 @@
-import { AccordionContent, AccordionItem, AccordionTrigger } from "@/components/ui/accordion"
-import { Card, CardContent } from "@/components/ui/card"
import { Separator } from "@/components/ui/separator"
import { formatNumber } from "@/lib/formatters"
import { getAllDuelsDivisions, getDuelsMostPlayed } from "@/lib/hypixel/duels/duels"
import { devide, romanize } from "@/lib/hypixel/general"
import { NonNullStats } from "@/lib/schema/player"
-import CollapsedStats from "../../_components/CollapsedStats"
+import GeneralStats from "../GeneralStats"
import DuelsGeneralStats from "./stats"
import DuelsStatsTable from "./table"
@@ -18,63 +16,53 @@ export default function DuelsStats({ stats }: { stats: NonNullStats["Duels"] })
const mostPlayed = getDuelsMostPlayed(stats)
return (
-
-
-
-
- Duels
-
-
Division,
- stat: (
-
- {div !== null ?
- (
-
- {`${div.name} ${romanize(div.level)}`}
-
- ) :
- -}
-
- )
- },
+ Division,
+ stat: (
+
+ {div !== null ?
+ (
+
+ {`${div.name} ${romanize(div.level)}`}
+
+ ) :
+ -}
+
+ )
+ },
- {
- title: Wins
,
- stat: (
-
- {mostPlayed !== null ?
- (
-
- {mostPlayed.name}
-
- ) :
- -}
-
- )
- },
- {
- title: Wins
,
- stat: {formatNumber(stats.wins)}
- },
- {
- title: WL
,
- stat: {wl}
- }
- ]}
- />
-
-
-
-
-
-
-
-
-
-
-
+ {
+ title: Wins
,
+ stat: (
+
+ {mostPlayed !== null ?
+ (
+
+ {mostPlayed.name}
+
+ ) :
+ -}
+
+ )
+ },
+ {
+ title: Wins
,
+ stat: {formatNumber(stats.wins)}
+ },
+ {
+ title: WL
,
+ stat: {wl}
+ }
+ ]}
+ >
+
+
+
+
+
)
}
diff --git a/src/app/(stats)/player/[ign]/_stats/megawalls/megawalls.tsx b/src/app/(stats)/player/[ign]/_stats/megawalls/megawalls.tsx
index 5f337f5..070e409 100644
--- a/src/app/(stats)/player/[ign]/_stats/megawalls/megawalls.tsx
+++ b/src/app/(stats)/player/[ign]/_stats/megawalls/megawalls.tsx
@@ -1,12 +1,10 @@
-import { AccordionContent, AccordionItem, AccordionTrigger } from "@/components/ui/accordion"
-import { Card, CardContent } from "@/components/ui/card"
import { Separator } from "@/components/ui/separator"
import { formatNumber } from "@/lib/formatters"
import { devide } from "@/lib/hypixel/general"
import { getMegaWallsDifficultyColor, getMegawallsMostPlayed } from "@/lib/hypixel/megawalls/general"
import { NonNullStats } from "@/lib/schema/player"
import { cn } from "@/lib/utils"
-import CollapsedStats from "../../_components/CollapsedStats"
+import GeneralStats from "../GeneralStats"
import MegaWallsGeneralStats from "./stats"
import { MegaWallsClassesTable, MegaWallsModesTable } from "./table"
@@ -20,53 +18,43 @@ export default function MegaWallsStats({ stats }: { stats: NonNullStats["MegaWal
const difficultyColor = getMegaWallsDifficultyColor(mostPlayed !== null ? mostPlayed.difficulty : 1)
return (
-
-
-
-
- Mega Walls
-
-
Main,
- stat: (
-
- {mostPlayed !== null ? mostPlayed.name : "Unknown"}
-
- )
- },
- {
- title: KD
,
- stat: {kd}
- },
- {
- title: FKD
,
- stat: {fkd}
- },
- {
- title: Wins
,
- stat: {formatNumber(stats.wins)}
- },
- {
- title: WL
,
- stat: {wl}
- }
- ]}
- />
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ Main,
+ stat: (
+
+ {mostPlayed !== null ? mostPlayed.name : "Unknown"}
+
+ )
+ },
+ {
+ title: KD
,
+ stat: {kd}
+ },
+ {
+ title: FKD
,
+ stat: {fkd}
+ },
+ {
+ title: Wins
,
+ stat: {formatNumber(stats.wins)}
+ },
+ {
+ title: WL
,
+ stat: {wl}
+ }
+ ]}
+ >
+
+
+
+
+
+
+
+
)
}
diff --git a/src/app/(stats)/player/[ign]/_stats/murder-mystery/murder-mystery.tsx b/src/app/(stats)/player/[ign]/_stats/murder-mystery/murder-mystery.tsx
index 71ff3c4..9e76282 100644
--- a/src/app/(stats)/player/[ign]/_stats/murder-mystery/murder-mystery.tsx
+++ b/src/app/(stats)/player/[ign]/_stats/murder-mystery/murder-mystery.tsx
@@ -1,9 +1,7 @@
-import { AccordionContent, AccordionItem, AccordionTrigger } from "@/components/ui/accordion"
-import { Card, CardContent } from "@/components/ui/card"
import { Separator } from "@/components/ui/separator"
import { formatNumber } from "@/lib/formatters"
import { NonNullStats } from "@/lib/schema/player"
-import CollapsedStats from "../../_components/CollapsedStats"
+import GeneralStats from "../GeneralStats"
import InfectionStats from "./infection"
import MurderMysteryGeneralStats from "./stats"
import MurderMysteryStatTable from "./table"
@@ -12,37 +10,27 @@ export default function MurderMysteryStats({ stats }: { stats: NonNullStats["Mur
if (!stats) return null
return (
-
-
-
-
- Murder Mystery
-
-
Kills,
- stat: {formatNumber(stats.kills)}
- },
- {
- title: Wins
,
- stat: {formatNumber(stats.wins)}
- }
- ]}
- />
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ Kills,
+ stat: {formatNumber(stats.kills)}
+ },
+ {
+ title: Wins
,
+ stat: {formatNumber(stats.wins)}
+ }
+ ]}
+ >
+
+
+
+
+
+
+
+
)
}
diff --git a/src/app/(stats)/player/[ign]/_stats/pit/pit.tsx b/src/app/(stats)/player/[ign]/_stats/pit/pit.tsx
index a7abe33..2a77f68 100644
--- a/src/app/(stats)/player/[ign]/_stats/pit/pit.tsx
+++ b/src/app/(stats)/player/[ign]/_stats/pit/pit.tsx
@@ -1,11 +1,9 @@
-import { AccordionContent, AccordionItem, AccordionTrigger } from "@/components/ui/accordion"
-import { Card, CardContent } from "@/components/ui/card"
import { Separator } from "@/components/ui/separator"
import { formatNumber } from "@/lib/formatters"
import { devide } from "@/lib/hypixel/general"
import { getPitPrestige } from "@/lib/hypixel/pit/general"
import { NonNullStats } from "@/lib/schema/player"
-import CollapsedStats from "../../_components/CollapsedStats"
+import GeneralStats from "../GeneralStats"
import PitLevel from "./level"
import PitProgress from "./progress"
import PitGeneralStats from "./stats"
@@ -17,39 +15,29 @@ export default function PitStats({ stats }: { stats: NonNullStats["Pit"] }) {
const prestige = getPitPrestige(stats)
return (
-
-
-
-
- Pit
-
-
Level,
- stat:
- },
- {
- title: Kills
,
- stat: {formatNumber(stats.kills)}
- },
- {
- title: KD
,
- stat: {kd}
- }
- ]}
- />
-
-
-
-
-
-
-
-
-
-
-
-
+ Level,
+ stat:
+ },
+ {
+ title: Kills
,
+ stat: {formatNumber(stats.kills)}
+ },
+ {
+ title: KD
,
+ stat: {kd}
+ }
+ ]}
+ >
+
+
+
+
+
+
)
}
diff --git a/src/app/(stats)/player/[ign]/_stats/skywars/skywars.tsx b/src/app/(stats)/player/[ign]/_stats/skywars/skywars.tsx
index 2fae7a7..314f4c0 100644
--- a/src/app/(stats)/player/[ign]/_stats/skywars/skywars.tsx
+++ b/src/app/(stats)/player/[ign]/_stats/skywars/skywars.tsx
@@ -1,11 +1,9 @@
-import { AccordionContent, AccordionItem, AccordionTrigger } from "@/components/ui/accordion"
-import { Card, CardContent } from "@/components/ui/card"
import { Separator } from "@/components/ui/separator"
import { formatNumber } from "@/lib/formatters"
import { devide, getProgress } from "@/lib/hypixel/general"
import { getSkywarsLevel, getSkywarsXpForLevel } from "@/lib/hypixel/skywars/level"
import { NonNullStats } from "@/lib/schema/player"
-import CollapsedStats from "../../_components/CollapsedStats"
+import GeneralStats from "../GeneralStats"
import { AngelOfDeath, ShardProgress, SkywarsHeads, SkywarsLevel, SkywarsProgress } from "./components"
import SkyWarsGeneralStats from "./stats"
import SkywarsStatTable from "./table"
@@ -34,79 +32,69 @@ export default function SkyWarsStats(
const shardProgress = getProgress(0, stats.shard, 20000)
return (
-
-
-
-
- SkyWars
-
-
Level,
- stat:
- },
- {
- title: KD
,
- stat: {kd}
- },
- {
- title: Wins
,
- stat: {formatNumber(stats.wins)}
- },
- {
- title: WL
,
- stat: {wl}
- }
- ]}
- />
-
-
-
-
-
-
-
-
-
-
-
-
-
{
- if (v.username === null) return null
+ Level,
+ stat:
+ },
+ {
+ title: KD
,
+ stat: {kd}
+ },
+ {
+ title: Wins
,
+ stat: {formatNumber(stats.wins)}
+ },
+ {
+ title: WL
,
+ stat: {wl}
+ }
+ ]}
+ >
+
+
+
+
+
+
+
+
+
+
{
+ if (v.username === null) return null
- return {
- username: v.username,
- timestamp: v.timestamp,
- sacrifice: v.sacrifice
- }
- }).filter(v => v !== null)}
- />
-
-
-
-
-
+ return {
+ username: v.username,
+ timestamp: v.timestamp,
+ sacrifice: v.sacrifice
+ }
+ }).filter(v => v !== null)}
+ />
+
+
)
}
diff --git a/src/app/(stats)/player/[ign]/_stats/tnt-games/tnt-games.tsx b/src/app/(stats)/player/[ign]/_stats/tnt-games/tnt-games.tsx
index 4eca443..1a97de2 100644
--- a/src/app/(stats)/player/[ign]/_stats/tnt-games/tnt-games.tsx
+++ b/src/app/(stats)/player/[ign]/_stats/tnt-games/tnt-games.tsx
@@ -1,8 +1,6 @@
-import { AccordionContent, AccordionItem, AccordionTrigger } from "@/components/ui/accordion"
-import { Card, CardContent } from "@/components/ui/card"
import { Separator } from "@/components/ui/separator"
import { NonNullStats } from "@/lib/schema/player"
-import CollapsedStats from "../../_components/CollapsedStats"
+import GeneralStats from "../GeneralStats"
import TNTGamesGeneralStats from "./stats"
import TNTWizardsStats from "./wizards"
@@ -10,28 +8,18 @@ export default function TNTGamesStats({ stats }: { stats: NonNullStats["TNTGames
if (!stats) return null
return (
-
-
-
-
- TNT Games
-
-
Wins,
- stat: {stats.wins}
- }]}
- />
-
-
-
-
-
-
-
-
-
-
-
+ Wins,
+ stat: {stats.wins}
+ }]}
+ >
+
+
+
+
+
)
}
diff --git a/src/app/(stats)/player/[ign]/_stats/uhc/uhc.tsx b/src/app/(stats)/player/[ign]/_stats/uhc/uhc.tsx
index 63b7266..284de1c 100644
--- a/src/app/(stats)/player/[ign]/_stats/uhc/uhc.tsx
+++ b/src/app/(stats)/player/[ign]/_stats/uhc/uhc.tsx
@@ -1,12 +1,10 @@
-import { AccordionContent, AccordionItem, AccordionTrigger } from "@/components/ui/accordion"
-import { Card, CardContent } from "@/components/ui/card"
import { Separator } from "@/components/ui/separator"
import { formatNumber } from "@/lib/formatters"
import { devide } from "@/lib/hypixel/general"
import { getUHCStatsCombined } from "@/lib/hypixel/uhc/general"
import { getUhcStarValue } from "@/lib/hypixel/uhc/level"
import { NonNullStats } from "@/lib/schema/player"
-import CollapsedStats from "../../_components/CollapsedStats"
+import GeneralStats from "../GeneralStats"
import UHCProgress from "./progress"
import UHCGeneralStats from "./stats"
import UHCStatTable from "./table"
@@ -19,40 +17,30 @@ export default function UHCStats({ stats }: { stats: NonNullStats["UHC"] }) {
const star = getUhcStarValue(stats.score)
return (
-
-
-
-
- UHC
-
-
Star,
- stat: {`[${star}✫]`}
- },
- {
- title: KD
,
- stat: {kd}
- },
- {
- title: Wins
,
- stat: {formatNumber(combined.wins)}
- }
- ]}
- />
-
-
-
-
-
-
-
-
-
-
-
-
-
+ Star,
+ stat: {`[${star}✫]`}
+ },
+ {
+ title: KD
,
+ stat: {kd}
+ },
+ {
+ title: Wins
,
+ stat: {formatNumber(combined.wins)}
+ }
+ ]}
+ >
+
+
+
+
+
+
+
)
}
diff --git a/src/app/(stats)/player/[ign]/_stats/woolgames/woolgames.tsx b/src/app/(stats)/player/[ign]/_stats/woolgames/woolgames.tsx
index 8dc5350..8f81850 100644
--- a/src/app/(stats)/player/[ign]/_stats/woolgames/woolgames.tsx
+++ b/src/app/(stats)/player/[ign]/_stats/woolgames/woolgames.tsx
@@ -1,27 +1,17 @@
-import { AccordionContent, AccordionItem, AccordionTrigger } from "@/components/ui/accordion"
-import { Card, CardContent } from "@/components/ui/card"
import { Separator } from "@/components/ui/separator"
import { NonNullStats } from "@/lib/schema/player"
-import CollapsedStats from "../../_components/CollapsedStats"
+import GeneralStats from "../GeneralStats"
export default function WoolGamesStats({ stats }: { stats: NonNullStats["WoolGames"] }) {
if (!stats) return null
return (
-
-
-
-
- Wool Games
-
-
-
-
-
-
-
-
-
-
+
+
+
)
}