From 752c9f2a21859975addefe9b17b92ff20721934e Mon Sep 17 00:00:00 2001 From: Taken Date: Mon, 29 Sep 2025 22:37:12 +0200 Subject: [PATCH] Updated structure --- src/app/(stats)/_components/displayname.tsx | 135 ++++++++++++++++ .../guild/[value]/_components/members.tsx | 151 +----------------- .../player/[ign]/_components/displayname.tsx | 146 +---------------- 3 files changed, 147 insertions(+), 285 deletions(-) create mode 100644 src/app/(stats)/_components/displayname.tsx diff --git a/src/app/(stats)/_components/displayname.tsx b/src/app/(stats)/_components/displayname.tsx new file mode 100644 index 0000000..d1396d3 --- /dev/null +++ b/src/app/(stats)/_components/displayname.tsx @@ -0,0 +1,135 @@ +import { getColor } from "@/lib/colors" + +export function PlayerIGN( + { ign, rank, monthly, rankColor, specialRank, prefix }: { + ign: string + rank: string | undefined + monthly: string | undefined + rankColor: string | undefined + specialRank: string | undefined + prefix: string | undefined + } +) { + if (prefix === "[PIG+++]") { + return {ign} + } + + if (specialRank) { + if (specialRank === "YOUTUBER") { + return {ign} + } + + if (specialRank === "STAFF") { + return {ign} + } + } + + if (monthly === "SUPERSTAR") { + if (rankColor === "GOLD") { + return {ign} + } else { + return {ign} + } + } + + switch (rank) { + case "VIP": + return {ign} + case "VIP_PLUS": + return {ign} + case "MVP": + return {ign} + case "MVP_PLUS": + return {ign} + default: + return {ign} + } +} + +export function PlayerRank( + { rank, monthly, plusColor, rankColor, specialRank, prefix }: { + rank: string | undefined + monthly: string | undefined + plusColor?: string + rankColor: string | undefined + specialRank: string | undefined + prefix: string | undefined + } +) { + if (prefix === "[PIG+++]") { + return ( + <> + [PIG + +++ + ] + + ) + } + + if (specialRank) { + if (specialRank === "YOUTUBER") { + return ( + <> + [ + YOUTUBE + ] + + ) + } + + if (specialRank === "STAFF") { + return ( + <> + [ + + ] + + ) + } + } + + if (monthly === "SUPERSTAR") { + if (rankColor === "GOLD") { + return ( + <> + [MVP + ++ + ] + + ) + } else { + return ( + <> + [MVP + ++ + ] + + ) + } + } + + switch (rank) { + case "VIP": + return [VIP] + case "VIP_PLUS": + return ( + <> + [VIP + + + ] + + ) + case "MVP": + return [MVP] + case "MVP_PLUS": + return ( + <> + [MVP + + + ] + + ) + default: + return null + } +} diff --git a/src/app/(stats)/guild/[value]/_components/members.tsx b/src/app/(stats)/guild/[value]/_components/members.tsx index e76fd04..f391a3b 100644 --- a/src/app/(stats)/guild/[value]/_components/members.tsx +++ b/src/app/(stats)/guild/[value]/_components/members.tsx @@ -1,20 +1,19 @@ "use client" +import { PlayerIGN, PlayerRank } from "@/app/(stats)/_components/displayname" import { Card, CardContent } from "@/components/ui/card" import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table" -import { getColor } from "@/lib/colors" import { formatDate, formatNumber } from "@/lib/formatters" import { head } from "@/lib/hypixel/general" import { Guild } from "@/lib/schema/guild" import { playerForGuildSchema } from "@/lib/schema/player" -import z from "zod" - -type PlayerForGuild = z.infer import Image from "next/image" import Link from "next/link" import { useEffect, useState } from "react" import { toast } from "sonner" +import z from "zod" +type PlayerForGuild = z.infer type MemberWithPlayer = Guild["guild"]["members"][number] & { player?: PlayerForGuild["player"] loading?: boolean @@ -55,15 +54,15 @@ export function GuildMembers({ members: mem, ranks }: { members: Guild["guild"][ }) }, 100) + toast.info(`Loaded ${members.filter(member => member.player).length} out of ${members.length} guild members`, { + id: "guild.members.loader", + duration: 1000 + }) + return () => clearTimeout(timer) } }, [currentIndex, members, isLoading]) - toast.info(`Loaded ${members.filter(member => member.player).length} out of ${members.length} guild members`, { - id: "guild.members.loader", - duration: 1000 - }) - return ( @@ -140,137 +139,3 @@ function MemberCard({ member: m }: { member: MemberWithPlayer }) { ) } - -function PlayerIGN( - { ign, rank, monthly, rankColor, specialRank, prefix }: { - ign: string - rank: string | undefined - monthly: string | undefined - rankColor: string | undefined - specialRank: string | undefined - prefix: string | undefined - } -) { - if (prefix === "[PIG+++]") { - return {ign} - } - - if (specialRank) { - if (specialRank === "YOUTUBER") { - return {ign} - } - - if (specialRank === "STAFF") { - return {ign} - } - } - - if (monthly === "SUPERSTAR") { - if (rankColor === "GOLD") { - return {ign} - } else { - return {ign} - } - } - - switch (rank) { - case "VIP": - return {ign} - case "VIP_PLUS": - return {ign} - case "MVP": - return {ign} - case "MVP_PLUS": - return {ign} - default: - return {ign} - } -} - -function PlayerRank( - { rank, monthly, plusColor, rankColor, specialRank, prefix }: { - rank: string | undefined - monthly: string | undefined - plusColor?: string - rankColor: string | undefined - specialRank: string | undefined - prefix: string | undefined - } -) { - if (prefix === "[PIG+++]") { - return ( - <> - [PIG - +++ - ] - - ) - } - - if (specialRank) { - if (specialRank === "YOUTUBER") { - return ( - <> - [ - YOUTUBE - ] - - ) - } - - if (specialRank === "STAFF") { - return ( - <> - [ - - ] - - ) - } - } - - if (monthly === "SUPERSTAR") { - if (rankColor === "GOLD") { - return ( - <> - [MVP - ++ - ] - - ) - } else { - return ( - <> - [MVP - ++ - ] - - ) - } - } - - switch (rank) { - case "VIP": - return [VIP] - case "VIP_PLUS": - return ( - <> - [VIP - + - ] - - ) - case "MVP": - return [MVP] - case "MVP_PLUS": - return ( - <> - [MVP - + - ] - - ) - default: - return null - } -} diff --git a/src/app/(stats)/player/[ign]/_components/displayname.tsx b/src/app/(stats)/player/[ign]/_components/displayname.tsx index 6d303a8..21ca15c 100644 --- a/src/app/(stats)/player/[ign]/_components/displayname.tsx +++ b/src/app/(stats)/player/[ign]/_components/displayname.tsx @@ -1,22 +1,18 @@ +import { PlayerIGN, PlayerRank } from "@/app/(stats)/_components/displayname" import { getColor } from "@/lib/colors" import { head } from "@/lib/hypixel/general" -import { Player } from "@/lib/schema/player" import Image from "next/image" import Link from "next/link" import { DevBadge } from "./badge" import { OnlineStatus } from "./online-status" -type NewPackageRank = Player["player"]["newPackageRank"] -type MonthlyPackageRank = Player["player"]["monthlyPackageRank"] -type RankColor = Player["player"]["monthlyRankColor"] - export default function DisplayName( { ign, uuid, rank, monthly, rankColor, plusColor, guildTag, tagColor, specialRank, lastLogin, lastLogout, prefix }: { ign: string uuid: string - rank: NewPackageRank - monthly: MonthlyPackageRank - rankColor: RankColor + rank: string | undefined + monthly: string | undefined + rankColor: string | undefined plusColor: string | undefined guildTag: string | undefined tagColor: string | undefined @@ -50,140 +46,6 @@ export default function DisplayName( ) } -function PlayerIGN( - { ign, rank, monthly, rankColor, specialRank, prefix }: { - ign: string - rank: NewPackageRank - monthly: MonthlyPackageRank - rankColor: RankColor - specialRank: string | undefined - prefix: string | undefined - } -) { - if (prefix === "[PIG+++]") { - return {ign} - } - - if (specialRank) { - if (specialRank === "YOUTUBER") { - return {ign} - } - - if (specialRank === "STAFF") { - return {ign} - } - } - - if (monthly === "SUPERSTAR") { - if (rankColor === "GOLD") { - return {ign} - } else { - return {ign} - } - } - - switch (rank) { - case "VIP": - return {ign} - case "VIP_PLUS": - return {ign} - case "MVP": - return {ign} - case "MVP_PLUS": - return {ign} - default: - return {ign} - } -} - -function PlayerRank( - { rank, monthly, plusColor, rankColor, specialRank, prefix }: { - rank: NewPackageRank - monthly: MonthlyPackageRank - plusColor?: string - rankColor: RankColor - specialRank: string | undefined - prefix: string | undefined - } -) { - if (prefix === "[PIG+++]") { - return ( - <> - [PIG - +++ - ] - - ) - } - - if (specialRank) { - if (specialRank === "YOUTUBER") { - return ( - <> - [ - YOUTUBE - ] - - ) - } - - if (specialRank === "STAFF") { - return ( - <> - [ - - ] - - ) - } - } - - if (monthly === "SUPERSTAR") { - if (rankColor === "GOLD") { - return ( - <> - [MVP - ++ - ] - - ) - } else { - return ( - <> - [MVP - ++ - ] - - ) - } - } - - switch (rank) { - case "VIP": - return [VIP] - case "VIP_PLUS": - return ( - <> - [VIP - + - ] - - ) - case "MVP": - return [MVP] - case "MVP_PLUS": - return ( - <> - [MVP - + - ] - - ) - default: - return null - } -} - function GuildTag({ tag, tagColor, ign }: { tag?: string, tagColor?: string, ign: string }) { if (!tag) return null