Finished build battle stats
This commit is contained in:
@@ -7,6 +7,7 @@ import { NonNullStats } from "@/lib/schema/player"
|
||||
import CollapsedStats from "../../_components/CollapsedStats"
|
||||
import BuildBattleTitleProgress from "./progress"
|
||||
import BuildBattleGeneralStats from "./stats"
|
||||
import BuildBattleStatsTable from "./table"
|
||||
|
||||
export default function BuildBattleStats({ stats }: { stats: NonNullStats["BuildBattle"] }) {
|
||||
if (!stats) return null
|
||||
@@ -40,6 +41,8 @@ export default function BuildBattleStats({ stats }: { stats: NonNullStats["Build
|
||||
<Separator className="my-4" />
|
||||
<BuildBattleGeneralStats stats={stats} />
|
||||
<Separator className="my-4" />
|
||||
<BuildBattleStatsTable stats={stats} />
|
||||
<Separator className="my-4" />
|
||||
</AccordionContent>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
46
src/app/(stats)/player/[ign]/_stats/build-battle/table.tsx
Normal file
46
src/app/(stats)/player/[ign]/_stats/build-battle/table.tsx
Normal file
@@ -0,0 +1,46 @@
|
||||
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"
|
||||
import { MODES } from "@/data/hypixel/build-battle"
|
||||
import { formatNumber } from "@/lib/formatters"
|
||||
import { getBuildBattleModeName as getBuildBattleMode } from "@/lib/hypixel/build-battle/general"
|
||||
import { NonNullStats } from "@/lib/schema/player"
|
||||
|
||||
export default function BuildBattleStatsTable({ stats }: { stats: NonNullable<NonNullStats["BuildBattle"]> }) {
|
||||
return (
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>Mode</TableHead>
|
||||
<TableHead>Wins</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
<TableStat modeId="solo_normal" stats={stats} />
|
||||
<TableStat modeId="teams_normal" stats={stats} />
|
||||
<TableStat modeId="guess_the_build" stats={stats} />
|
||||
<TableStat modeId="solo_pro" stats={stats} />
|
||||
<TableStat modeId="speed_builders" stats={stats} />
|
||||
<TableStat modeId="" stats={stats} />
|
||||
</TableBody>
|
||||
</Table>
|
||||
)
|
||||
}
|
||||
|
||||
function TableStat({ modeId, stats }: { modeId: typeof MODES[number]["id"], stats: NonNullable<NonNullStats["BuildBattle"]> }) {
|
||||
const mode = getBuildBattleMode(modeId)
|
||||
|
||||
if (modeId === "") {
|
||||
return (
|
||||
<TableRow className="font-bold">
|
||||
<TableCell>{mode.name}</TableCell>
|
||||
<TableCell>{formatNumber(stats["wins"])}</TableCell>
|
||||
</TableRow>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<TableRow>
|
||||
<TableCell>{mode.name}</TableCell>
|
||||
<TableCell>{formatNumber(stats[`wins_${modeId}`])}</TableCell>
|
||||
</TableRow>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user