- Clone import: defer FurnitureData.json writes and append all entries in a single batched write instead of one read-modify-write per item, removing the main serialization bottleneck for large batches. - Clone import: raise SSE batch concurrency cap from 5 to 10 and bump the clone client/route default from 2 to 6. - Add a flush hook to runSseBatch so callers can batch deferred work before batch_complete is emitted, and surface flush errors as an error event. - Enable Next.js Cache Components (instant: false opt-out) and silence the related build warnings in next.config.ts. - Switch isomorphic-dompurify to dompurify and refresh dependencies.
405 lines
11 KiB
TypeScript
405 lines
11 KiB
TypeScript
import { count, desc, eq } from "drizzle-orm";
|
|
import { headers } from "next/headers";
|
|
import Image from "next/image";
|
|
import Link from "next/link";
|
|
import { getTranslations } from "next-intl/server";
|
|
import { RegisterForm } from "@/components/auth/register-form";
|
|
import { Clock } from "@/components/clock";
|
|
import { LanguageSwitcher } from "@/components/language-switcher";
|
|
import { Reveal } from "@/components/motion-reveal";
|
|
import { ThemeSwitcher } from "@/components/theme-switcher";
|
|
import { cached } from "@/lib/cache";
|
|
import { db, User } from "@/lib/db";
|
|
import { avatarImageUrl } from "@/lib/format";
|
|
import { resolveHotelName } from "@/lib/hotel-name";
|
|
import { captchaConfig } from "@/lib/services/captcha";
|
|
import { siteSettings } from "@/lib/services/site-settings";
|
|
|
|
// TODO: Cache Components adoption. Refactor this route so this opt-out can be removed.
|
|
// See: https://nextjs.org/docs/app/guides/migrating-to-cache-components
|
|
export const instant = false;
|
|
|
|
export default async function RegisterPage() {
|
|
const th = await getTranslations("header");
|
|
const tpr = await getTranslations("pages.register");
|
|
const [hotelName, imagerRaw, cfg, logo] = await Promise.all([
|
|
resolveHotelName(),
|
|
siteSettings.get(
|
|
"habbo_imaging_url",
|
|
"https://www.habbo.com/habbo-imaging/avatarimage",
|
|
),
|
|
captchaConfig(),
|
|
siteSettings.get("radio_social_discord", ""),
|
|
siteSettings.get("cms_logo", ""),
|
|
]);
|
|
const imager = imagerRaw ?? "https://www.habbo.com/habbo-imaging/avatarimage";
|
|
const nonce = (await headers()).get("x-nonce") ?? undefined;
|
|
|
|
const [online, recentUsers, latestUsers] = 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),
|
|
db
|
|
.select({ username: User.username, look: User.look })
|
|
.from(User)
|
|
.where(eq(User.online, "1"))
|
|
.limit(8)
|
|
.catch(() => []),
|
|
db
|
|
.select({ username: User.username, look: User.look })
|
|
.from(User)
|
|
.orderBy(desc(User.accountCreated))
|
|
.limit(8)
|
|
.catch(() => []),
|
|
]);
|
|
|
|
return (
|
|
<div className="flex flex-col gap-10 pb-14">
|
|
{/* ── Top Bar ── */}
|
|
<Reveal>
|
|
<div
|
|
className="relative flex items-center justify-between rounded-xl border px-5 py-3"
|
|
style={{
|
|
background:
|
|
"color-mix(in srgb, var(--color-surface) 60%, transparent)",
|
|
backdropFilter: "blur(14px)",
|
|
WebkitBackdropFilter: "blur(14px)",
|
|
borderColor:
|
|
"color-mix(in srgb, var(--color-text-muted) 8%, transparent)",
|
|
}}
|
|
>
|
|
<div className="flex items-center gap-3">
|
|
{logo ? (
|
|
<Image
|
|
src={logo}
|
|
alt={hotelName}
|
|
width={100}
|
|
height={28}
|
|
className="shrink-0 object-contain"
|
|
unoptimized
|
|
style={{ maxHeight: 28, width: "auto", height: "auto" }}
|
|
/>
|
|
) : (
|
|
<Image
|
|
src="/assets/images/icons/lighthouse.png"
|
|
alt={hotelName}
|
|
width={28}
|
|
height={28}
|
|
className="shrink-0"
|
|
unoptimized
|
|
/>
|
|
)}
|
|
<span
|
|
className="text-sm font-extrabold uppercase tracking-wide"
|
|
style={{ color: "var(--color-text-readable)" }}
|
|
>
|
|
{hotelName}
|
|
</span>
|
|
</div>
|
|
<div
|
|
className="flex items-center gap-1.5 rounded-lg px-2 py-1"
|
|
style={{
|
|
background:
|
|
"color-mix(in srgb, var(--color-text-muted) 4%, transparent)",
|
|
}}
|
|
>
|
|
<LanguageSwitcher />
|
|
<div
|
|
className="w-px h-5"
|
|
style={{
|
|
background:
|
|
"color-mix(in srgb, var(--color-text-muted) 12%, transparent)",
|
|
}}
|
|
/>
|
|
<Clock />
|
|
<div
|
|
className="w-px h-5"
|
|
style={{
|
|
background:
|
|
"color-mix(in srgb, var(--color-text-muted) 12%, transparent)",
|
|
}}
|
|
/>
|
|
<ThemeSwitcher />
|
|
</div>
|
|
</div>
|
|
</Reveal>
|
|
<Reveal>
|
|
<div className="flex flex-col lg:flex-row gap-10 stagger-children">
|
|
{/* Left panel */}
|
|
<div className="lg:w-80 shrink-0 space-y-4">
|
|
<div
|
|
className="relative overflow-hidden rounded-2xl border p-6 text-center card-premium"
|
|
style={{
|
|
borderColor:
|
|
"color-mix(in srgb, var(--color-primary) 20%, transparent)",
|
|
background: `url(/assets/images/background.png) center/cover no-repeat`,
|
|
}}
|
|
>
|
|
<div
|
|
className="absolute inset-0"
|
|
style={{
|
|
background:
|
|
"linear-gradient(135deg, color-mix(in srgb, var(--color-surface) 85%, transparent) 0%, color-mix(in srgb, var(--color-surface) 40%, transparent) 100%)",
|
|
}}
|
|
/>
|
|
<div className="relative">
|
|
<Image
|
|
src="/assets/images/FrankwithBag.gif"
|
|
alt="Frank"
|
|
width={130}
|
|
height={170}
|
|
className="object-contain mx-auto drop-shadow-xl animate-float"
|
|
unoptimized
|
|
priority
|
|
/>
|
|
<div
|
|
className="inline-flex items-center gap-2 px-3.5 py-1 rounded-full text-xs font-bold uppercase tracking-wider mt-4 mb-3 border"
|
|
style={{
|
|
borderColor:
|
|
"color-mix(in srgb, var(--color-primary) 18%, transparent)",
|
|
background:
|
|
"color-mix(in srgb, var(--color-primary) 10%, transparent)",
|
|
color:
|
|
"var(--color-primary-readable, var(--color-primary))",
|
|
}}
|
|
>
|
|
<span className="w-2 h-2 rounded-full bg-green-500" />
|
|
{tpr("usersOnline", { count: online })}
|
|
</div>
|
|
<h1
|
|
className="text-xl font-black"
|
|
style={{
|
|
color: "var(--color-text-readable)",
|
|
fontFamily: "var(--font-nunito)",
|
|
}}
|
|
>
|
|
{tpr("title")} — {hotelName}
|
|
</h1>
|
|
<p
|
|
className="text-xs mt-1 mx-auto max-w-[200px] leading-relaxed"
|
|
style={{ color: "var(--color-text-muted)" }}
|
|
>
|
|
{th("tagline")}
|
|
</p>
|
|
</div>
|
|
</div>
|
|
|
|
{recentUsers.length > 0 && (
|
|
<div
|
|
className="overflow-hidden rounded-xl border"
|
|
style={{
|
|
borderColor:
|
|
"color-mix(in srgb, var(--color-text-muted) 12%, transparent)",
|
|
}}
|
|
>
|
|
<div
|
|
className="flex items-center gap-2.5 px-4 py-3"
|
|
style={{
|
|
background:
|
|
"linear-gradient(140deg, #0A1F0A 0%, #0F2D0F 20%, #153C15 40%, #1B4A1B 60%, #205820 75%, #1A4A1A 90%, #143814 100%)",
|
|
}}
|
|
>
|
|
<Image
|
|
src="/assets/images/icons/navigation/goody.png"
|
|
alt=""
|
|
width={18}
|
|
height={18}
|
|
unoptimized
|
|
/>
|
|
<h3
|
|
className="text-sm font-bold text-white"
|
|
style={{ fontFamily: "var(--font-nunito)" }}
|
|
>
|
|
{tpr("whoIsOnline")}
|
|
</h3>
|
|
</div>
|
|
<div
|
|
className="p-4"
|
|
style={{
|
|
background:
|
|
"color-mix(in srgb, var(--color-surface) 70%, transparent)",
|
|
}}
|
|
>
|
|
<div className="grid grid-cols-4 gap-1.5">
|
|
{recentUsers.map((u) => (
|
|
<div
|
|
key={u.username}
|
|
className="flex flex-col items-center gap-0.5 p-1.5 rounded-lg"
|
|
style={{
|
|
background:
|
|
"color-mix(in srgb, var(--color-primary) 4%, transparent)",
|
|
}}
|
|
>
|
|
<Image
|
|
src={avatarImageUrl(imager, u.look, {
|
|
headOnly: true,
|
|
direction: 2,
|
|
size: "s",
|
|
})}
|
|
alt=""
|
|
width={26}
|
|
height={32}
|
|
className="rounded-md"
|
|
unoptimized
|
|
/>
|
|
<span
|
|
className="text-[8px] font-bold truncate w-full text-center leading-tight"
|
|
style={{ color: "var(--color-text-readable)" }}
|
|
>
|
|
{u.username}
|
|
</span>
|
|
</div>
|
|
))}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
)}
|
|
|
|
{latestUsers.length > 0 && (
|
|
<div
|
|
className="overflow-hidden rounded-xl border"
|
|
style={{
|
|
borderColor:
|
|
"color-mix(in srgb, var(--color-text-muted) 12%, transparent)",
|
|
}}
|
|
>
|
|
<div
|
|
className="flex items-center gap-2.5 px-4 py-3"
|
|
style={{
|
|
background:
|
|
"linear-gradient(140deg, #5a2d82 0%, #6b3a9e 20%, #7d47b8 40%, #8f54d0 60%, #7d47b8 75%, #6b3a9e 90%, #5a2d82 100%)",
|
|
}}
|
|
>
|
|
<Image
|
|
src="/assets/images/icons/friends.png"
|
|
alt=""
|
|
width={18}
|
|
height={18}
|
|
unoptimized
|
|
/>
|
|
<h3
|
|
className="text-sm font-bold text-white"
|
|
style={{ fontFamily: "var(--font-nunito)" }}
|
|
>
|
|
Newest citizens
|
|
</h3>
|
|
</div>
|
|
<div
|
|
className="p-4"
|
|
style={{
|
|
background:
|
|
"color-mix(in srgb, var(--color-surface) 70%, transparent)",
|
|
}}
|
|
>
|
|
<div className="grid grid-cols-4 gap-1.5">
|
|
{latestUsers.map((u) => (
|
|
<div
|
|
key={u.username}
|
|
className="flex flex-col items-center gap-0.5 p-1.5 rounded-lg"
|
|
style={{
|
|
background:
|
|
"color-mix(in srgb, var(--color-primary) 4%, transparent)",
|
|
}}
|
|
>
|
|
<Image
|
|
src={avatarImageUrl(imager, u.look, {
|
|
headOnly: true,
|
|
direction: 2,
|
|
})}
|
|
alt=""
|
|
width={52}
|
|
height={64}
|
|
className="rounded-md"
|
|
unoptimized
|
|
/>
|
|
<span
|
|
className="text-[10px] font-bold truncate w-full text-center leading-tight"
|
|
style={{ color: "var(--color-text-readable)" }}
|
|
>
|
|
{u.username}
|
|
</span>
|
|
</div>
|
|
))}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
)}
|
|
|
|
<p
|
|
className="text-xs text-center"
|
|
style={{ color: "var(--color-text-muted)" }}
|
|
>
|
|
{tpr("alreadyHaveAccountPre")}{" "}
|
|
<Link
|
|
href="/login"
|
|
className="font-extrabold hover:underline"
|
|
style={{
|
|
color: "var(--color-primary-readable, var(--color-primary))",
|
|
}}
|
|
>
|
|
{tpr("alreadyHaveAccountLink")}
|
|
</Link>
|
|
</p>
|
|
</div>
|
|
|
|
{/* Right: form */}
|
|
<div className="flex-1">
|
|
<div
|
|
className="overflow-hidden rounded-xl border"
|
|
style={{
|
|
borderColor:
|
|
"color-mix(in srgb, var(--color-text-muted) 12%, transparent)",
|
|
}}
|
|
>
|
|
<div
|
|
className="flex items-center gap-2.5 px-4 py-3"
|
|
style={{
|
|
background:
|
|
"linear-gradient(140deg, #1a3a5c 0%, #1e4a6e 20%, #2a5a80 40%, #3a6a90 60%, #4a7aa0 75%, #3a6a90 90%, #2a5a80 100%)",
|
|
}}
|
|
>
|
|
<Image
|
|
src="/assets/images/icons/navigation/me.png"
|
|
alt=""
|
|
width={18}
|
|
height={18}
|
|
unoptimized
|
|
/>
|
|
<h2
|
|
className="text-sm font-bold text-white"
|
|
style={{ fontFamily: "var(--font-nunito)" }}
|
|
>
|
|
{tpr("title")}
|
|
</h2>
|
|
</div>
|
|
<div
|
|
className="p-6"
|
|
style={{ backgroundColor: "var(--color-surface)" }}
|
|
>
|
|
<p
|
|
className="text-sm mb-6"
|
|
style={{ color: "var(--color-text-muted)" }}
|
|
>
|
|
{tpr("subtitle")}
|
|
</p>
|
|
<RegisterForm
|
|
hotelName={hotelName}
|
|
captcha={{
|
|
provider: cfg.provider,
|
|
siteKey: cfg.siteKey || undefined,
|
|
}}
|
|
nonce={nonce}
|
|
/>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</Reveal>
|
|
</div>
|
|
);
|
|
}
|