import Image from "next/image";
import { Award, Clock3, DatabaseZap, RadioTower } from "lucide-react";
import type { DiscordMemberProfile, DiscordRole } from "@/lib/discord/discord";
import type { LevelProgress } from "@/lib/leaderboard/level-progress";
import { formatInteger, formatVoiceDuration } from "@/lib/leaderboard/ranking";
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
import { Badge } from "@/components/ui/badge";
import { DiscordAvatar, DiscordServerTag } from "@/components/avatar";
import {
Card,
CardContent,
CardDescription,
CardFooter,
CardHeader,
CardTitle,
} from "@/components/ui/card";
import { Progress } from "@/components/ui/progress";
import { Separator } from "@/components/ui/separator";
import {
discordColorToHex,
} from "@/lib/discord/profile-appearance";
type RankedXp = LevelProgress & { rank: number | null };
type RankedVoice = { totalSeconds: string; rank: number | null };
type ProfilePassportProps = {
userName: string;
userImage: string;
profile: DiscordMemberProfile | null;
profileUnavailable: boolean;
xp: RankedXp | null;
voice: RankedVoice | null;
};
const DEFAULT_ROLE_COLOR = "#99aab5";
function toHex(value: number) {
return discordColorToHex(value);
}
function initials(value: string) {
return value.trim().slice(0, 2).toLocaleUpperCase("th-TH") || "?";
}
function rankLabel(rank: number | null) {
return rank ? `#${formatInteger(String(rank))}` : "ยังไม่ติดอันดับ";
}
function RoleBadge({ role }: { role: DiscordRole }) {
const color = role.color === 0 ? DEFAULT_ROLE_COLOR : toHex(role.color);
return (
เลเวลปัจจุบัน {xp.level} XP สะสม
{formatInteger(xp.totalXp)} XP
คุณถึงเลเวลสูงสุดของระบบแล้ว
{duration}
บทบาทในเซิร์ฟเวอร์