import { count, eq } from "drizzle-orm"; import { headers } from "next/headers"; import Image from "next/image"; import { getTranslations } from "next-intl/server"; import { AuthShell } from "@/components/auth/auth-shell"; import { BrandFrank } from "@/components/auth/brand-frank"; import { LoginForm } from "@/components/auth/login-form"; import Link from "@/components/link"; import { Reveal } from "@/components/motion-reveal"; import { UserAvatarThumbnail } from "@/components/shared/user-avatar-thumbnail"; import { cached } from "@/lib/cache"; import { db, User } from "@/lib/db"; import { resolveHotelName } from "@/lib/hotel-name"; import { captchaConfig } from "@/lib/services/captcha"; import { siteSettings } from "@/lib/services/site-settings"; export const metadata = { title: "Sign in", }; export default async function LoginPage() { const t = await getTranslations("pages.login"); const th = await getTranslations("header"); const thp = await getTranslations("pages.home"); const [hotelName, cfg, logo] = await Promise.all([ resolveHotelName(), captchaConfig(), siteSettings.get("cms_logo", ""), ]); const nonce = (await headers()).get("x-nonce") ?? undefined; const [online, totalUsers, recentUsers] = await Promise.all([ cached("online_count", 10_000, () => db .select({ total: count() }) .from(User) .where(eq(User.online, "1")) .then((rows) => rows[0]?.total ?? 0), ).catch(() => 0), cached("total_users", 300_000, () => db .select({ total: count() }) .from(User) .then((rows) => rows[0]?.total ?? 0), ).catch(() => 0), db .select({ username: User.username, look: User.look }) .from(User) .where(eq(User.online, "1")) .limit(6) .catch(() => []), ]); const onlineLabel = th("online", { count: online, hotel: "" }).trim(); return (
{t("noAccount") ?? "No account?"}{" "} {t("createOne") ?? "Create one"}

} side={
{onlineLabel}

{t("welcomeBack")}
{hotelName}

{t("welcomeBackSub", { hotelName })}

{online}

{onlineLabel}

{recentUsers.length > 0 && (
{recentUsers.slice(0, 5).map((u) => ( ))}
)}
{totalUsers}

{thp("statsCitizens")}

} >

{t("title")}

{t("subtitle")}

); }