import Image from "next/image"; import Link from "next/link"; import { redirect } from "next/navigation"; import { getTranslations } from "next-intl/server"; import { cached } from "@/lib/cache"; import { avatarImageUrl } from "@/lib/format"; import { formatDate } from "@/lib/format-date"; import { prisma } from "@/lib/prisma"; import { resolveHotelName } from "@/lib/hotel-name"; import { siteSettings } from "@/lib/services/site-settings"; import { auth } from "@/lib/auth"; import { ThemeSwitcher } from "@/components/theme-switcher"; import { LanguageSwitcher } from "@/components/language-switcher"; export const revalidate = 120; async function getHotelData() { const [hotelName, imagerRaw] = await Promise.all([ resolveHotelName(), siteSettings.get( "habbo_imaging_url", "https://www.habbo.com/habbo-imaging/avatarimage", ), ]); const imager = imagerRaw ?? "https://www.habbo.com/habbo-imaging/avatarimage"; const [online, users, rooms, articles, recentUsers, recentPhotos, latestUsers] = await Promise.all([ cached("online_count", 10_000, () => prisma.user.count({ where: { online: "1" } }), ).catch(() => 0), cached("total_users", 30_000, () => prisma.user.count()).catch(() => 0), cached("total_rooms", 30_000, () => prisma.rooms.count()).catch(() => 0), prisma.websiteArticles .findMany({ orderBy: { createdAt: "desc" }, take: 5 }) .catch(() => []), prisma.user .findMany({ where: { online: "1" }, select: { username: true, look: true }, take: 30, }) .catch(() => []), prisma.cameraWeb .findMany({ orderBy: { timestamp: "desc" }, take: 4 }) .catch(() => []), prisma.user .findMany({ orderBy: { accountCreated: "desc" }, select: { username: true, look: true }, take: 8, }) .catch(() => []), ]); return { hotelName, imager, online, users, rooms, articles, recentUsers, recentPhotos, latestUsers, }; } export default async function Home() { const session = await auth(); if (session?.user?.id) redirect("/me"); const tp = await getTranslations("pages.home"); const th = await getTranslations("header"); const { hotelName, imager, online, users, rooms, articles, recentUsers, recentPhotos, latestUsers, } = await getHotelData(); return (
{/* ── Toolbar ── */}
{/* ── 1. Hero ── */}
{th("online", { count: online, hotel: hotelName })}

{tp("welcome", { hotelName })}

{th("tagline")}

{tp("register")} {th("login")}
Frank
{/* ── 2. Stats ── */}
{[ { value: online.toLocaleString(), label: tp("statsOnline"), icon: "/assets/images/icons/navigation/home.png" }, { value: users.toLocaleString(), label: tp("statsCitizens"), icon: "/assets/images/icons/navigation/me.png" }, { value: rooms.toLocaleString(), label: tp("statsRooms"), icon: "/assets/images/icons/catalog.png" }, ].map((s) => (
{s.value}
{s.label}
))}
{/* ── 3. Features ── */}
{[ { img: "/assets/images/icons/star.gif", title: tp("featuresAvatar"), desc: tp("featuresAvatarDesc") }, { img: "/assets/images/icons/catalog.png", title: tp("featuresFurniture"), desc: tp("featuresFurnitureDesc") }, { img: "/assets/images/icons/navigation/community.png", title: tp("featuresCommunity"), desc: tp("featuresCommunityDesc") }, { img: "/assets/images/icons/navigation/bb.png", title: tp("featuresGames"), desc: tp("featuresGamesDesc") }, ].map((f) => (

{f.title}

{f.desc}

))}
{/* ── 4. Newest citizens ── */} {latestUsers.length > 0 && (

{tp("latestUsers", { count: users.toLocaleString() })}

{latestUsers.map((u) => (
{u.username}
{u.username}
))}
)} {/* ── 5. News ── */}

{tp("latestNews")}

{tp("allNews")}
{articles.length > 0 ? (
{articles.slice(0, 4).map((a) => (
{a.image ? ( ) : (
)}

{a.title}

{formatDate(a.createdAt, "date", "")}

))}
) : (

{tp("noArticles")}

)}
{/* ── 6. Online users row ── */} {recentUsers.length > 0 && (

{tp("recentUsers")}

{recentUsers.slice(0, 10).map((u) => (
{u.username} {u.username}
))}
)} {/* ── 7. Bottom CTA ── */}

{tp("joinNow", { hotelName })}

{tp("welcomeBody")}

{tp("register")}
{/* ── 8. Recent photos (compact) ── */} {recentPhotos.length > 0 && (

{tp("recentPhotos")}

{recentPhotos.slice(0, 4).map((p) => ( ))}
)}
); }