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 (
No articles available
) : ({excerpt(a.shortStory, 80)}
)}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 (No friends online
) : ( onlineFriends.map((f) => ({excerpt(latestArticle.shortStory, 100)}
)}