Canged pres heads
This commit is contained in:
@@ -7,7 +7,7 @@ import Link from "next/link"
|
||||
import { useEffect, useState } from "react"
|
||||
import { Tooltip } from "react-tooltip"
|
||||
|
||||
export function PresigeousHeads({ heads }: { heads: { name: string | null, timestamp: number, sacrifice: string }[] }) {
|
||||
export function PresigeousHeads({ heads }: { heads: { username: string, timestamp: number, sacrifice: string }[] }) {
|
||||
const [pos, setPos] = useState({ x: 0, y: 0 })
|
||||
|
||||
useEffect(() => {
|
||||
@@ -27,23 +27,19 @@ export function PresigeousHeads({ heads }: { heads: { name: string | null, times
|
||||
|
||||
return (
|
||||
<div className="flex flex-wrap gap-2">
|
||||
{heads.map(({ name, sacrifice }, index) => {
|
||||
if (!name) {
|
||||
return null
|
||||
}
|
||||
|
||||
{heads.map(({ username, sacrifice }, index) => {
|
||||
const text = sacrifice.at(0) + sacrifice.split("").slice(1, sacrifice.length).join("").toLowerCase()
|
||||
|
||||
return (
|
||||
<Link href={`/player/${name}`} key={index}>
|
||||
<Link href={`/player/${username}`} key={index}>
|
||||
<Image
|
||||
data-id="presigeous-heads"
|
||||
data-tooltip-id="presigeous-heads"
|
||||
data-tooltip-content={text}
|
||||
src={`https://minotar.net/helm/${name}/24.png`}
|
||||
src={`https://minotar.net/helm/${username}/24.png`}
|
||||
width={24}
|
||||
height={24}
|
||||
alt={name}
|
||||
alt={username}
|
||||
/>
|
||||
</Link>
|
||||
)
|
||||
|
||||
@@ -19,7 +19,7 @@ type SkywarsHeadsProps = {
|
||||
divine: number
|
||||
heavenly: number
|
||||
}
|
||||
prestigeous: { name: string | null, timestamp: number, sacrifice: string }[]
|
||||
prestigeous: { username: string, timestamp: number, sacrifice: string }[]
|
||||
}
|
||||
|
||||
export function SkywarsHeads({
|
||||
@@ -50,9 +50,9 @@ export function SkywarsHeads({
|
||||
<span className="font-bold">{"Total Heads Gathered: "}</span>
|
||||
<span className="text-mc-gray">{formatNumber(heads)}</span>
|
||||
</p>
|
||||
{total_special > 0 && <HeadsBar heads={headsArray} heads_total={heads} />}
|
||||
{total_special > 0 ? <HeadsBar heads={headsArray} heads_total={heads} /> : <p>This person has no heads collected.</p>}
|
||||
<p className="font-bold">Prestigious Head Collection</p>
|
||||
<PresigeousHeads heads={prestigeous} />
|
||||
{prestigeous.length > 0 ? <PresigeousHeads heads={prestigeous} /> : <p>No prestigeous heads. Now what a skill issue.</p>}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -93,13 +93,17 @@ export default function SkyWarsStats(
|
||||
tasty: stats.heads_tasty,
|
||||
yucky: stats.heads_yucky
|
||||
}}
|
||||
prestigeous={stats.head_collection === undefined ? [] : stats.head_collection.prestigious.map(v => {
|
||||
return {
|
||||
name: v.username,
|
||||
timestamp: v.timestamp,
|
||||
sacrifice: v.sacrifice
|
||||
}
|
||||
})}
|
||||
prestigeous={stats.head_collection === undefined
|
||||
? []
|
||||
: stats.head_collection.prestigious.map(v => {
|
||||
if (v.username === null) return null
|
||||
|
||||
return {
|
||||
username: v.username,
|
||||
timestamp: v.timestamp,
|
||||
sacrifice: v.sacrifice
|
||||
}
|
||||
}).filter(v => v !== null)}
|
||||
/>
|
||||
</div>
|
||||
</AccordionContent>
|
||||
|
||||
@@ -261,7 +261,7 @@ export const skywarsStatsSchema = z.looseObject({
|
||||
heads_heavenly: z.number().default(0),
|
||||
head_collection: z.looseObject({
|
||||
prestigious: z.array(z.object({
|
||||
username: z.string().nullable(),
|
||||
username: z.string().nullable().default(null),
|
||||
timestamp: z.number(),
|
||||
mode: z.string(),
|
||||
sacrifice: z.string()
|
||||
|
||||
Reference in New Issue
Block a user