Added mega walls card

This commit is contained in:
2025-09-07 11:36:19 +02:00
parent 4612222207
commit 33d02113da
6 changed files with 195 additions and 1 deletions

View File

@@ -0,0 +1,64 @@
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 { getDifficultyColor, getMostPlayed } from "@/lib/hypixel/megawalls/general"
import { NonNullStats } from "@/lib/schema/player"
import { cn } from "@/lib/utils"
import CollapsedStats from "../../_components/CollapsedStats"
export default function MegaWallsStats({ stats }: { stats: NonNullStats["MegaWalls"] }) {
if (!stats) return null
const kd = formatNumber(devide(stats.kills, stats.deaths))
const fkd = formatNumber(devide(stats.final_kills, stats.final_deaths))
const wl = formatNumber(devide(stats.wins, stats.losses))
const mostPlayed = getMostPlayed(stats)
const difficultyColor = getDifficultyColor(mostPlayed !== null ? mostPlayed.difficulty : 1)
return (
<AccordionItem value="megawalls">
<Card className="py-0">
<CardContent>
<AccordionTrigger className="items-center py-2 hover:no-underline hover:cursor-pointer">
<h1 className="text-xl font-bold">Mega Walls</h1>
<div className="flex gap-4">
<CollapsedStats
stats={[
{
title: <p>Main</p>,
stat: (
<p className={cn("font-bold", mostPlayed && `text-mc-${difficultyColor}`)}>
{mostPlayed !== null ? mostPlayed.name : "Unknown"}
</p>
)
},
{
title: <p>KD</p>,
stat: <p>{kd}</p>
},
{
title: <p>FKD</p>,
stat: <p>{fkd}</p>
},
{
title: <p>Wins</p>,
stat: <p>{formatNumber(stats.wins)}</p>
},
{
title: <p>WL</p>,
stat: <p>{wl}</p>
}
]}
/>
</div>
</AccordionTrigger>
<AccordionContent>
<Separator className="my-4" />
</AccordionContent>
</CardContent>
</Card>
</AccordionItem>
)
}