Unify the public site by making SectionCard and the verify status card use the same --radius-lg / --shadow-card tokens and primary-tint header as the existing CSS .content-card used by all content pages. This makes the entire (site) group visually consistent without rewriting every page, and keeps the shadcn Card in components/ui/card.tsx (used by admin) intact.
299 lines
8.6 KiB
TypeScript
299 lines
8.6 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 { SectionCard } from "@/components/home-section";
|
|
import { LanguageSwitcher } from "@/components/language-switcher";
|
|
import { Reveal } from "@/components/motion-reveal";
|
|
import { UserAvatarThumbnail } from "@/components/shared/user-avatar-thumbnail";
|
|
import { ThemeSwitcher } from "@/components/theme-switcher";
|
|
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 default async function RegisterPage() {
|
|
const th = await getTranslations("header");
|
|
const tpr = await getTranslations("pages.register");
|
|
const [hotelName, cfg, logo] = await Promise.all([
|
|
resolveHotelName(),
|
|
captchaConfig(),
|
|
siteSettings.get("cms_logo", ""),
|
|
]);
|
|
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),
|
|
cached("register_online_users", 10_000, () =>
|
|
db
|
|
.select({ username: User.username, look: User.look })
|
|
.from(User)
|
|
.where(eq(User.online, "1"))
|
|
.limit(8),
|
|
).catch(() => []),
|
|
cached("register_latest_users", 30_000, () =>
|
|
db
|
|
.select({ username: User.username, look: User.look })
|
|
.from(User)
|
|
.orderBy(desc(User.accountCreated))
|
|
.limit(8),
|
|
).catch(() => []),
|
|
]);
|
|
|
|
return (
|
|
<div className="mx-auto w-full max-w-6xl flex flex-col gap-8 pb-16">
|
|
{/* ── 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 gap-8 lg:flex-row">
|
|
{/* Left panel */}
|
|
<div className="lg:w-80 shrink-0 space-y-4">
|
|
<div
|
|
className="relative overflow-hidden rounded-2xl border p-6 text-center"
|
|
style={{
|
|
borderColor:
|
|
"color-mix(in srgb, var(--color-primary) 20%, transparent)",
|
|
background: `url(/assets/images/background.png) center/cover no-repeat`,
|
|
boxShadow: "var(--shadow-card)",
|
|
}}
|
|
>
|
|
<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 && (
|
|
<SectionCard
|
|
title={tpr("whoIsOnline")}
|
|
icon="/assets/images/icons/navigation/goody.png"
|
|
bodyClassName="p-4"
|
|
>
|
|
<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)",
|
|
}}
|
|
>
|
|
<UserAvatarThumbnail
|
|
figure={u.look}
|
|
alt=""
|
|
options={{ direction: 2 }}
|
|
className="rounded-md"
|
|
/>
|
|
<span
|
|
className="text-[8px] font-bold truncate w-full text-center leading-tight"
|
|
style={{ color: "var(--color-text-readable)" }}
|
|
>
|
|
{u.username}
|
|
</span>
|
|
</div>
|
|
))}
|
|
</div>
|
|
</SectionCard>
|
|
)}
|
|
|
|
{latestUsers.length > 0 && (
|
|
<SectionCard
|
|
title="Newest citizens"
|
|
icon="/assets/images/icons/friends.png"
|
|
bodyClassName="p-4"
|
|
>
|
|
<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)",
|
|
}}
|
|
>
|
|
<UserAvatarThumbnail
|
|
figure={u.look}
|
|
alt=""
|
|
options={{ direction: 2 }}
|
|
className="rounded-md"
|
|
/>
|
|
<span
|
|
className="text-[10px] font-bold truncate w-full text-center leading-tight"
|
|
style={{ color: "var(--color-text-readable)" }}
|
|
>
|
|
{u.username}
|
|
</span>
|
|
</div>
|
|
))}
|
|
</div>
|
|
</SectionCard>
|
|
)}
|
|
|
|
<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">
|
|
<SectionCard
|
|
title={tpr("title")}
|
|
icon="/assets/images/icons/navigation/me.png"
|
|
bodyClassName="p-6"
|
|
>
|
|
<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}
|
|
/>
|
|
</SectionCard>
|
|
</div>
|
|
</div>
|
|
</Reveal>
|
|
</div>
|
|
);
|
|
}
|