import { getTranslations } from "next-intl/server"; import Link from "next/link"; import { auth } from "@/lib/auth"; import { avatarImageUrl, excerpt } from "@/lib/format"; import { prisma } from "@/lib/prisma"; import { siteSettings } from "@/lib/services/site-settings"; import { HomeLoginForm } from "@/components/auth/home-login-form"; export const dynamic = "force-dynamic"; export default async function HomePage() { const t = await getTranslations("pages.home"); const session = await auth(); const hotelName = (await siteSettings.get("hotel_name", "Atom")) ?? "Atom"; const imager = (await siteSettings.get("habbo_imaging_url", "https://www.habbo.com/habbo-imaging/avatarimage")) ?? ""; if (!session?.user) { let articles: Array<{ slug: string; title: string; shortStory: string; image: string }> = []; try { articles = await prisma.websiteArticles.findMany({ orderBy: { createdAt: "desc" }, take: 8, select: { slug: true, title: true, shortStory: true, image: true }, }); } catch {} let recentUsers: Array<{ username: string; look: string }> = []; try { recentUsers = await prisma.user.findMany({ orderBy: { lastOnline: "desc" }, take: 12, select: { username: true, look: true }, }); } catch {} return (
{/* LEFT COLUMN — 1/3 */}
{/* Login Card */}
{/* Register Button */}
Register
REGISTER NOW
{/* Recent Users */} {recentUsers.length > 0 && (

Recent Users

{recentUsers.map((u) => (
{u.username}
))}
)}
{/* RIGHT COLUMN — 2/3 */}
{/* News */}

Latest News

{articles.length === 0 ? (

No articles available

) : (
{articles.map((a) => (
{a.title}

{a.title}

{a.shortStory && (

{excerpt(a.shortStory, 80)}

)}
))}
)}
); } const dbUser = await prisma.user.findUnique({ where: { id: Number(session.user.id) }, select: { username: true, look: true }, }).catch(() => null); if (!dbUser) { return

User not found.

; } const userId = Number(session.user.id); let onlineFriends: Array<{ username: string; look: string }> = []; try { const friendships = await prisma.messengerFriendships.findMany({ where: { OR: [ { userOneId: userId }, { userTwoId: userId }, ], }, select: { userOneId: true, userTwoId: true }, }); const friendIds = friendships.map((f) => f.userOneId === userId ? f.userTwoId : f.userOneId, ); if (friendIds.length > 0) { onlineFriends = await prisma.user.findMany({ where: { id: { in: friendIds }, online: "1" }, take: 10, select: { username: true, look: true }, }); } } catch {} const [latestArticle] = await prisma.websiteArticles.findMany({ orderBy: { createdAt: "desc" }, take: 1, select: { slug: true, title: true, shortStory: true, image: true }, }).catch(() => []); return (
{/* Left column — 9/12 */}
{/* User Hero */}
{dbUser.username}
{/* Online Friends */}
Online Friends
{onlineFriends.length === 0 ? (

No friends online

) : ( onlineFriends.map((f) => ( {f.username} )) )}
{/* Right column — 3/12 */}
{latestArticle ? (

Latest Article

{latestArticle.title}

{latestArticle.title}

{latestArticle.shortStory && (

{excerpt(latestArticle.shortStory, 100)}

)}
) : null}
); }