import Link from "next/link"; import Image from "next/image"; import { auth, signOut } from "@/lib/auth"; import { avatarImageUrl } from "@/lib/format"; import { prisma } from "@/lib/prisma"; import { siteSettings } from "@/lib/services/site-settings"; function Currency({ icon, amount, label }: { icon: string; amount: number; label: string }) { return (
{amount.toLocaleString()} {" "} {label}
); } export async function TopHeader() { const session = await auth(); if (!session?.user?.id) return null; const id = Number(session.user.id); let credits = 0; let duckets = 0; let diamonds = 0; let look = ""; try { const [user, currencies] = await Promise.all([ prisma.user.findUnique({ where: { id }, select: { credits: true, look: true } }), prisma.usersCurrency.findMany({ where: { userId: id } }), ]); credits = user?.credits ?? 0; look = user?.look ?? ""; for (const c of currencies) { if (c.type === 0) duckets = c.amount; if (c.type === 5) diamonds = c.amount; } } catch { // render without live balances } const imager = (await siteSettings.get("habbo_imaging_url", "https://www.habbo.com/habbo-imaging/avatarimage")) ?? ""; const avatar = avatarImageUrl(imager, look, { headOnly: true, direction: 2 }); const isStaff = (session.user.rank ?? 0) >= 7; return (
{isStaff ? (
Administration
Admin panel Commandocentrum Logs Logo generator
) : null}
{session.user.name}
My dashboard My profile User settings Two-factor Login activity
{ "use server"; await signOut({ redirectTo: "/" }); }} >
); }