Added a general stats component
This commit is contained in:
@@ -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 (
|
||||
<AccordionItem value="duels">
|
||||
<Card className="py-0">
|
||||
<CardContent>
|
||||
<AccordionTrigger className="items-center py-2 hover:no-underline hover:cursor-pointer">
|
||||
<h1 className="text-xl font-bold">Duels</h1>
|
||||
<div className="flex gap-4">
|
||||
<CollapsedStats
|
||||
stats={[
|
||||
{
|
||||
title: <p>Division</p>,
|
||||
stat: (
|
||||
<p>
|
||||
{div !== null ?
|
||||
(
|
||||
<span className={`text-mc-${div.color}`}>
|
||||
{`${div.name} ${romanize(div.level)}`}
|
||||
</span>
|
||||
) :
|
||||
<span className="text-muted-foreground">-</span>}
|
||||
</p>
|
||||
)
|
||||
},
|
||||
<GeneralStats
|
||||
id="duels"
|
||||
title="Duels"
|
||||
collapsedStats={[
|
||||
{
|
||||
title: <p>Division</p>,
|
||||
stat: (
|
||||
<p>
|
||||
{div !== null ?
|
||||
(
|
||||
<span className={`text-mc-${div.color}`}>
|
||||
{`${div.name} ${romanize(div.level)}`}
|
||||
</span>
|
||||
) :
|
||||
<span className="text-muted-foreground">-</span>}
|
||||
</p>
|
||||
)
|
||||
},
|
||||
|
||||
{
|
||||
title: <p>Wins</p>,
|
||||
stat: (
|
||||
<p className="font-bold">
|
||||
{mostPlayed !== null ?
|
||||
(
|
||||
<span>
|
||||
{mostPlayed.name}
|
||||
</span>
|
||||
) :
|
||||
<span className="text-muted-foreground">-</span>}
|
||||
</p>
|
||||
)
|
||||
},
|
||||
{
|
||||
title: <p>Wins</p>,
|
||||
stat: <p className="text-muted-foreground">{formatNumber(stats.wins)}</p>
|
||||
},
|
||||
{
|
||||
title: <p>WL</p>,
|
||||
stat: <p className="text-muted-foreground">{wl}</p>
|
||||
}
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
</AccordionTrigger>
|
||||
<AccordionContent>
|
||||
<Separator className="my-4" />
|
||||
<DuelsGeneralStats stats={stats} div={div} kd={kd} wl={wl} />
|
||||
<Separator className="my-4" />
|
||||
<DuelsStatsTable stats={stats} />
|
||||
</AccordionContent>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</AccordionItem>
|
||||
{
|
||||
title: <p>Wins</p>,
|
||||
stat: (
|
||||
<p className="font-bold">
|
||||
{mostPlayed !== null ?
|
||||
(
|
||||
<span>
|
||||
{mostPlayed.name}
|
||||
</span>
|
||||
) :
|
||||
<span className="text-muted-foreground">-</span>}
|
||||
</p>
|
||||
)
|
||||
},
|
||||
{
|
||||
title: <p>Wins</p>,
|
||||
stat: <p className="text-muted-foreground">{formatNumber(stats.wins)}</p>
|
||||
},
|
||||
{
|
||||
title: <p>WL</p>,
|
||||
stat: <p className="text-muted-foreground">{wl}</p>
|
||||
}
|
||||
]}
|
||||
>
|
||||
<Separator className="my-4" />
|
||||
<DuelsGeneralStats stats={stats} div={div} kd={kd} wl={wl} />
|
||||
<Separator className="my-4" />
|
||||
<DuelsStatsTable stats={stats} />
|
||||
</GeneralStats>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user