60 lines
2.9 KiB
TypeScript
60 lines
2.9 KiB
TypeScript
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, romanize } from "@/lib/hypixel/general"
|
|
import { getLevelColor, getPrestige, getPrestigeColor } from "@/lib/hypixel/pit/general"
|
|
import { getPitLevel } from "@/lib/hypixel/pit/level"
|
|
import { NonNullStats } from "@/lib/schema/player"
|
|
import CollapsedStats from "../../_components/CollapsedStats"
|
|
|
|
export default function PitStats({ stats }: { stats: NonNullStats["Pit"] }) {
|
|
if (!stats) return null
|
|
|
|
const kd = formatNumber(devide(stats.kills, stats.deaths))
|
|
const prestige = getPrestige(stats)
|
|
const level = getPitLevel(stats.profile.xp, prestige)
|
|
const prestigeColor = getPrestigeColor(prestige)
|
|
const levelColor = getLevelColor(level)
|
|
|
|
return (
|
|
<AccordionItem value="pit">
|
|
<Card className="py-0">
|
|
<CardContent>
|
|
<AccordionTrigger className="items-center py-2 hover:no-underline hover:cursor-pointer">
|
|
<h1 className="text-xl font-bold">Pit</h1>
|
|
<div className="flex gap-4">
|
|
<CollapsedStats
|
|
stats={[
|
|
{
|
|
title: <p>Level</p>,
|
|
stat: (
|
|
<p className="font-bold">
|
|
<span className={`text-mc-${prestigeColor}`}>[</span>
|
|
<span className="text-mc-yellow">{romanize(prestige)}</span>
|
|
<span className={`text-mc-${levelColor}`}>{`-${level}`}</span>
|
|
<span className={`text-mc-${prestigeColor}`}>]</span>
|
|
</p>
|
|
)
|
|
},
|
|
{
|
|
title: <p>Kills</p>,
|
|
stat: <p className="text-muted-foreground">{formatNumber(stats.kills)}</p>
|
|
},
|
|
{
|
|
title: <p>KD</p>,
|
|
stat: <p className="text-muted-foreground">{kd}</p>
|
|
}
|
|
]}
|
|
/>
|
|
</div>
|
|
</AccordionTrigger>
|
|
<AccordionContent>
|
|
<Separator className="my-4" />
|
|
</AccordionContent>
|
|
</CardContent>
|
|
</Card>
|
|
</AccordionItem>
|
|
)
|
|
}
|