refactor: centralize hotel name fallback via FALLBACK_HOTEL_NAME
Deploy / release (push) Skipped
Deploy / deploy (push) Successful in 2m6s

Route all user-facing Atom hotel defaults through resolveHotelName (settings then HOTEL_NAME env then brand constant). Exclude Playwright e2e from tsconfig until deps are installed.

Co-authored-by: Cursor <[email protected]>
This commit is contained in:
SimoandCursor committed 2026-07-22 18:45:59 +02:00
1 parent 6b2819aa20
commit e00e9ca2dc
31 files changed
+113 -56

No files matched your search

+2 -2
View File
@@ -5,7 +5,7 @@ import { applyStaff } from "@/actions/applications";
import { ContentCard, EmptyState } from "@/components/public/ui";
import { auth } from "@/lib/auth";
import { prisma } from "@/lib/prisma";
import { siteSettings } from "@/lib/services/site-settings";
import { resolveHotelName } from "@/lib/hotel-name";
export const dynamic = "force-dynamic";
@@ -53,7 +53,7 @@ export default async function ApplyStaffPage({
: null;
const userId = Number(session.user.id);
const hotelName = (await siteSettings.get("hotel_name", "Atom")) ?? "Atom";
const hotelName = await resolveHotelName();
function formatDeadline(d: Date | null | undefined): string {
if (!d) return t("noDeadline");
+2 -2
View File
@@ -5,7 +5,7 @@ import { applyTeam } from "@/actions/applications";
import { ContentCard, EmptyState } from "@/components/public/ui";
import { auth } from "@/lib/auth";
import { prisma } from "@/lib/prisma";
import { siteSettings } from "@/lib/services/site-settings";
import { resolveHotelName } from "@/lib/hotel-name";
export const dynamic = "force-dynamic";
@@ -53,7 +53,7 @@ export default async function ApplyTeamPage({
: null;
const userId = Number(session.user.id);
const hotelName = (await siteSettings.get("hotel_name", "Atom")) ?? "Atom";
const hotelName = await resolveHotelName();
// ── Teams open for application ──────────────────────────────
// The Prisma slice exposes teams directly (no separate team-position table
+2 -2
View File
@@ -5,7 +5,7 @@ import { ContentCard } from "@/components/public/ui";
import { prisma } from "@/lib/prisma";
import { sanitize } from "@/lib/sanitize";
import { SanitizedHtml } from "@/components/shared/sanitized-html";
import { siteSettings } from "@/lib/services/site-settings";
import { resolveHotelName } from "@/lib/hotel-name";
export const revalidate = 300;
@@ -75,7 +75,7 @@ export default async function HelpCategoryPage({
if (!cat) notFound();
const hotelName = (await siteSettings.get("hotel_name", "Atom")) ?? "Atom";
const hotelName = await resolveHotelName();
// Sibling help topics, so the reader can jump between categories. Isolated
// query: a DB hiccup degrades this list to empty rather than 500-ing.
+3 -2
View File
@@ -7,13 +7,14 @@ import { cached } from "@/lib/cache";
import { avatarImageUrl } from "@/lib/format";
import { prisma } from "@/lib/prisma";
import { captchaConfig } from "@/lib/services/captcha";
import { resolveHotelName } from "@/lib/hotel-name";
import { siteSettings } from "@/lib/services/site-settings";
export default async function LoginPage() {
const t = await getTranslations("pages.login");
const th = await getTranslations("header");
const [hotelName, imagerRaw, cfg] = await Promise.all([
siteSettings.get("hotel_name", "Atom"),
resolveHotelName(),
siteSettings.get(
"habbo_imaging_url",
"https://www.habbo.com/habbo-imaging/avatarimage",
@@ -87,7 +88,7 @@ export default async function LoginPage() {
className="text-xs mt-1 mx-auto max-w-[200px] leading-relaxed"
style={{ color: "var(--color-text-muted)" }}
>
{t("welcomeBackSub", { hotelName: hotelName ?? "Atom" })}
{t("welcomeBackSub", { hotelName })}
</p>
</div>
</div>
+4 -2
View File
@@ -1,5 +1,6 @@
import LogoGenerator from "@/components/public/logo-generator";
import { ContentCard } from "@/components/public/ui";
import { resolveHotelName } from "@/lib/hotel-name";
export const metadata = { title: "Logo generator" };
@@ -9,7 +10,8 @@ export const metadata = { title: "Logo generator" };
* client-side <LogoGenerator>, which does all styling, live preview, and PNG
* export in the browser (no server data, no DB).
*/
export default function LogoPage() {
export default async function LogoPage() {
const initialText = await resolveHotelName();
return (
<main
style={{
@@ -25,7 +27,7 @@ export default function LogoPage() {
subtitle="Design a logo for your hotel — pick a font, colours and size, then download it as a PNG."
/>
<LogoGenerator />
<LogoGenerator initialText={initialText} />
</main>
);
}
+3 -2
View File
@@ -1,5 +1,6 @@
import { getTranslations } from "next-intl/server";
import { ContentCard } from "@/components/public/ui";
import { resolveHotelName } from "@/lib/hotel-name";
import { siteSettings } from "@/lib/services/site-settings";
export const revalidate = 300;
@@ -7,7 +8,7 @@ export const revalidate = 300;
export default async function MaintenancePage() {
const t = await getTranslations("pages.maintenance");
const [hotel, message] = await Promise.all([
siteSettings.get("hotel_name", "Atom"),
resolveHotelName(),
siteSettings.get(
"maintenance_message",
"We are currently performing maintenance. Please check back soon.",
@@ -18,7 +19,7 @@ export default async function MaintenancePage() {
<main style={{ maxWidth: 560, margin: "2rem auto" }}>
<ContentCard
icon="🛠️"
title={t("title", { hotel: hotel ?? "Atom" })}
title={t("title", { hotel })}
subtitle={t("subtitle")}
>
<p style={{ marginTop: 0 }}>{message}</p>
+3 -2
View File
@@ -6,6 +6,7 @@ import { claimReferral } from "@/actions/referral";
import { ContentCard, EmptyState, OnlineBadge } from "@/components/public/ui";
import { auth } from "@/lib/auth";
import { avatarImageUrl } from "@/lib/format";
import { resolveHotelName } from "@/lib/hotel-name";
import { prisma } from "@/lib/prisma";
import { siteSettings } from "@/lib/services/site-settings";
import CopyReferralButton from "./CopyReferralButton";
@@ -85,7 +86,7 @@ export default async function MePage({
"habbo_imaging_url",
"https://www.habbo.com/habbo-imaging/avatarimage",
),
siteSettings.get("hotel_name", "Atom"),
resolveHotelName(),
prisma.websiteSetting
.findUnique({
where: { key: "referrals_needed" },
@@ -251,7 +252,7 @@ export default async function MePage({
height={22}
unoptimized
/>
Enter {hotelName ?? "Hotel"}
Enter {hotelName}
</Link>
{/* ── Stat tiles ── */}
+5 -4
View File
@@ -6,6 +6,7 @@ import { cached } from "@/lib/cache";
import { avatarImageUrl } from "@/lib/format";
import { formatDate } from "@/lib/format-date";
import { prisma } from "@/lib/prisma";
import { resolveHotelName } from "@/lib/hotel-name";
import { siteSettings } from "@/lib/services/site-settings";
import { auth } from "@/lib/auth";
@@ -13,7 +14,7 @@ export const revalidate = 120;
async function getHotelData() {
const [hotelName, imagerRaw] = await Promise.all([
siteSettings.get("hotel_name", "Atom"),
resolveHotelName(),
siteSettings.get(
"habbo_imaging_url",
"https://www.habbo.com/habbo-imaging/avatarimage",
@@ -103,13 +104,13 @@ export default async function Home() {
<span className="animate-ping absolute inline-flex h-full w-full rounded-full bg-green-400 opacity-75" />
<span className="relative inline-flex rounded-full h-2 w-2 bg-green-500" />
</span>
{th("online", { count: online, hotel: hotelName ?? "Atom" })}
{th("online", { count: online, hotel: hotelName })}
</div>
<h1
className="text-4xl md:text-5xl lg:text-6xl font-black leading-[1.05] tracking-tight mb-4"
style={{ color: "var(--color-text-readable)" }}
>
{tp("welcome", { hotelName: hotelName ?? "Atom" })}
{tp("welcome", { hotelName })}
</h1>
<p
className="text-base md:text-lg leading-relaxed max-w-xl mb-8"
@@ -317,7 +318,7 @@ export default async function Home() {
}}
>
<h2 className="text-2xl md:text-3xl font-black tracking-tight mb-2" style={{ color: "var(--color-text-readable)" }}>
{tp("joinNow", { hotelName: hotelName ?? "Atom" })}
{tp("joinNow", { hotelName })}
</h2>
<p className="text-sm mb-6 max-w-sm mx-auto" style={{ color: "var(--color-text-muted)" }}>
{tp("welcomeBody")}
+3 -2
View File
@@ -7,13 +7,14 @@ import { cached } from "@/lib/cache";
import { avatarImageUrl } from "@/lib/format";
import { prisma } from "@/lib/prisma";
import { captchaConfig } from "@/lib/services/captcha";
import { resolveHotelName } from "@/lib/hotel-name";
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, imagerRaw, cfg] = await Promise.all([
siteSettings.get("hotel_name", "Hotel"),
resolveHotelName(),
siteSettings.get(
"habbo_imaging_url",
"https://www.habbo.com/habbo-imaging/avatarimage",
@@ -167,7 +168,7 @@ export default async function RegisterPage() {
</p>
</div>
<RegisterForm
hotelName={hotelName ?? "Hotel"}
hotelName={hotelName}
captcha={{
provider: cfg.provider,
siteKey: cfg.siteKey || undefined,
+2 -2
View File
@@ -12,7 +12,7 @@ import { auth } from "@/lib/auth";
import { LaravelEncrypter } from "@/lib/auth/laravel-encrypter";
import { totpKeyUri } from "@/lib/auth/totp";
import { prisma } from "@/lib/prisma";
import { siteSettings } from "@/lib/services/site-settings";
import { resolveHotelName } from "@/lib/hotel-name";
export const dynamic = "force-dynamic";
@@ -52,7 +52,7 @@ export default async function TwoFactorPage({
const hasAppKey = Boolean(env.APP_KEY);
const enabled = Boolean(user?.twoFactorConfirmedAt);
const pending = Boolean(user?.twoFactorSecret && !user?.twoFactorConfirmedAt);
const hotelName = (await siteSettings.get("hotel_name", "Atom")) ?? "Atom";
const hotelName = await resolveHotelName();
let secret = "";
let uri = "";
+2 -2
View File
@@ -1,6 +1,7 @@
import Link from "next/link";
import { getTranslations } from "next-intl/server";
import { StatusCard } from "@/components/admin/dashboard";
import { resolveHotelName } from "@/lib/hotel-name";
import { siteSettings } from "@/lib/services/site-settings";
import { EmbedSnippet } from "./embed-snippet";
@@ -18,8 +19,7 @@ export default async function AdminRadioEmbedPage() {
streamUrl = (await siteSettings.get("radio_stream_url", "")) ?? "";
radioName =
(await siteSettings.get("radio_name", null)) ??
(await siteSettings.get("hotel_name", "Radio")) ??
"Radio";
(await resolveHotelName());
nowPlayingApiUrl =
(await siteSettings.get("radio_now_playing_api_url", "")) ?? "";
} catch {
@@ -1,4 +1,5 @@
import { HABBO_GAMEDATA_HOTELS } from "@/lib/habbo-gamedata-hotel";
import { FALLBACK_HOTEL_NAME } from "@/lib/brand";
export type FieldType =
| "text"
@@ -49,7 +50,7 @@ export const SETTINGS_GROUPS: SettingsGroup[] = [
label: "Hotel name",
type: "text",
placeholder: "Epicnabbo",
defaultValue: "Atom",
defaultValue: FALLBACK_HOTEL_NAME,
},
{
key: "cms_logo",
+4 -3
View File
@@ -1,7 +1,8 @@
import { FALLBACK_HOTEL_NAME } from "@/lib/brand";
import { apiJson } from "@/lib/api";
import { resolveHotelName } from "@/lib/hotel-name";
import { prisma } from "@/lib/prisma";
import { redisCache, apiCacheKey } from "@/lib/redis-cache";
import { siteSettings } from "@/lib/services/site-settings";
export const dynamic = "force-dynamic";
@@ -30,13 +31,13 @@ export async function GET(_req: Request) {
take: 4,
}),
prisma.user.count({ where: { online: "1" } }),
siteSettings.get("hotel_name", "Atom").then((v) => v ?? "Atom"),
resolveHotelName(),
]);
return { articles, online, hotelName };
},
);
return apiJson(data);
} catch {
return apiJson({ articles: [], online: 0, hotelName: "Atom" }, { status: 200 });
return apiJson({ articles: [], online: 0, hotelName: FALLBACK_HOTEL_NAME }, { status: 200 });
}
}
+2 -3
View File
@@ -19,7 +19,7 @@ import {
} from "@/lib/services/paypal-topup";
import { rcon } from "@/lib/services/rcon";
import { sendCurrency } from "@/lib/services/send-currency";
import { siteSettings } from "@/lib/services/site-settings";
import { resolveHotelName } from "@/lib/hotel-name";
export const dynamic = "force-dynamic";
@@ -158,8 +158,7 @@ export async function POST(req: Request): Promise<Response> {
);
}
const hotelName =
(await siteSettings.get("hotel_name", env.HOTEL_NAME)) ?? env.HOTEL_NAME;
const hotelName = await resolveHotelName();
if (result.status !== "COMPLETED") {
// Record the non-completed attempt so support can trace it.
+2 -3
View File
@@ -11,7 +11,7 @@ import {
PAYPAL_CURRENCY,
} from "@/lib/services/paypal";
import { recordCreatedTopup } from "@/lib/services/paypal-topup";
import { siteSettings } from "@/lib/services/site-settings";
import { resolveHotelName } from "@/lib/hotel-name";
export const dynamic = "force-dynamic";
@@ -69,8 +69,7 @@ export async function POST(req: Request): Promise<Response> {
const credits = Math.floor(amount * creditsPerUnit());
const base = env.APP_URL.replace(/\/+$/, "");
const hotelName =
(await siteSettings.get("hotel_name", env.HOTEL_NAME)) ?? env.HOTEL_NAME;
const hotelName = await resolveHotelName();
try {
const order = await createOrder(amount, {
+4 -3
View File
@@ -4,6 +4,7 @@ import { auth } from "@/lib/auth";
import { issueSsoTicket } from "@/lib/auth/sso-ticket";
import { cached } from "@/lib/cache";
import { prisma } from "@/lib/prisma";
import { resolveHotelName } from "@/lib/hotel-name";
import { siteSettings } from "@/lib/services/site-settings";
import { ClientView } from "./client-view";
@@ -16,12 +17,12 @@ export default async function ClientPage() {
const userId = Number(session.user.id);
const [hotelName, clientUrl] = await Promise.all([
siteSettings.get("hotel_name", "Atom"),
resolveHotelName(),
siteSettings.get("nitro_client_url", ""),
]);
const ip = (await headers()).get("x-real-client-ip") ?? "0.0.0.0";
const ticket = await issueSsoTicket(prisma, userId, hotelName ?? "Atom", ip);
const ticket = await issueSsoTicket(prisma, userId, hotelName, ip);
const onlineCount = await cached("online_count", 10_000, () =>
prisma.user.count({ where: { online: "1" } }),
@@ -31,7 +32,7 @@ export default async function ClientPage() {
<ClientView
ticket={ticket}
clientUrl={clientUrl || "/nitro-client/"}
hotelName={hotelName ?? "Atom"}
hotelName={hotelName}
initialOnline={onlineCount}
/>
);
+2 -1
View File
@@ -10,6 +10,7 @@ import { PwaRegister } from "@/components/pwa-register";
import { ThemeVars } from "@/components/theme-vars";
import { SmoothScroll } from "@/components/smooth-scroll";
import { enforceSiteAccess } from "@/lib/access-guard";
import { resolveHotelName } from "@/lib/hotel-name";
import { siteSettings } from "@/lib/services/site-settings";
import "./globals.css";
@@ -29,7 +30,7 @@ const pixelFont = Pixelify_Sans({
export async function generateMetadata(): Promise<Metadata> {
const appUrl = process.env.APP_URL ?? "http://localhost:3000";
const hotel = (await siteSettings.get("hotel_name", "Atom")) ?? "Atom";
const hotel = await resolveHotelName();
const customFavicon = await siteSettings.get("cms_favicon");
const faviconUrl = customFavicon ?? "/favicon.svg";
const icons = [
+2 -1
View File
@@ -1,11 +1,12 @@
import type { MetadataRoute } from "next";
import { resolveHotelName } from "@/lib/hotel-name";
import { siteSettings } from "@/lib/services/site-settings";
// Web app manifest — makes the hotel installable as a PWA (AtomCMS exposed PWA
// settings but the rewrite ships a real, themeable manifest). Name + theme
// colour follow the live website_settings; falls back to defaults with no DB.
export default async function manifest(): Promise<MetadataRoute.Manifest> {
const name = (await siteSettings.get("hotel_name", "Atom")) ?? "Atom";
const name = await resolveHotelName();
const theme =
(await siteSettings.get("color_primary", "#f59e0b")) ?? "#f59e0b";