refactor: centralize hotel name fallback via FALLBACK_HOTEL_NAME
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:
1 parent
6b2819aa20
commit
e00e9ca2dc
31 files changed
+113
-56
No files matched your search
@@ -11,7 +11,6 @@ import { siteSettings } from "@/lib/services/site-settings";
|
||||
|
||||
export default async function GuestView() {
|
||||
const t = await getTranslations("pages.home");
|
||||
const _hotelName = await siteSettings.get("hotel_name", "Atom");
|
||||
const imager =
|
||||
(await siteSettings.get(
|
||||
"habbo_imaging_url",
|
||||
|
||||
@@ -3,6 +3,7 @@ import Link from "next/link";
|
||||
import { getTranslations } from "next-intl/server";
|
||||
import { Reveal } from "@/components/motion-reveal";
|
||||
import { avatarImageUrl, excerpt } from "@/lib/format";
|
||||
import { resolveHotelName } from "@/lib/hotel-name";
|
||||
import { prisma } from "@/lib/prisma";
|
||||
import { siteSettings } from "@/lib/services/site-settings";
|
||||
|
||||
@@ -20,7 +21,7 @@ export default async function UserView({
|
||||
motto,
|
||||
}: UserViewProps) {
|
||||
const t = await getTranslations("pages.home");
|
||||
const hotelName = (await siteSettings.get("hotel_name", "Atom")) ?? "Atom";
|
||||
const hotelName = await resolveHotelName();
|
||||
const imager =
|
||||
(await siteSettings.get(
|
||||
"habbo_imaging_url",
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
import { AnimatePresence, motion } from "framer-motion";
|
||||
import Image from "next/image";
|
||||
import { type ReactNode, useRef, useState } from "react";
|
||||
import { FALLBACK_HOTEL_NAME } from "@/lib/brand";
|
||||
import { mobileMenuVariants } from "@/lib/motion";
|
||||
|
||||
interface MobileNavProps {
|
||||
@@ -16,7 +17,7 @@ export function MobileNav({
|
||||
children,
|
||||
menuLabel = "Open menu",
|
||||
closeLabel = "Close menu",
|
||||
brandLabel = "Atom",
|
||||
brandLabel = FALLBACK_HOTEL_NAME,
|
||||
}: MobileNavProps) {
|
||||
const [open, setOpen] = useState(false);
|
||||
const detailsRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
@@ -3,6 +3,7 @@ import Link from "next/link";
|
||||
import { getTranslations } from "next-intl/server";
|
||||
import type { Session } from "next-auth";
|
||||
import { LanguageSwitcher } from "@/components/language-switcher";
|
||||
import { resolveHotelName } from "@/lib/hotel-name";
|
||||
import { MobileNav } from "@/components/mobile-nav";
|
||||
import { NavDropdown } from "@/components/nav-dropdown";
|
||||
import { NavbarColorPicker } from "@/components/navbar-color-picker";
|
||||
@@ -10,6 +11,7 @@ import { ThemeSwitcher } from "@/components/theme-switcher";
|
||||
|
||||
export async function Navigation({ session }: { session: Session | null }) {
|
||||
const t = await getTranslations("nav");
|
||||
const brandLabel = await resolveHotelName();
|
||||
const isStaff = (session?.user?.rank ?? 0) >= 7;
|
||||
|
||||
return (
|
||||
@@ -170,6 +172,7 @@ export async function Navigation({ session }: { session: Session | null }) {
|
||||
<MobileNav
|
||||
menuLabel={t("openMenu") || "Open menu"}
|
||||
closeLabel={t("closeMenu") || "Close menu"}
|
||||
brandLabel={brandLabel}
|
||||
>
|
||||
<Link href="/" className="nav-item">
|
||||
<Image
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
useTransition,
|
||||
} from "react";
|
||||
import { saveLogo } from "@/actions/save-logo";
|
||||
import { FALLBACK_HOTEL_NAME } from "@/lib/brand";
|
||||
import { HABBO_FONT_GROUPS } from "@/components/public/habbo-fonts";
|
||||
import {
|
||||
getFontInfo,
|
||||
@@ -17,8 +18,12 @@ import {
|
||||
} from "@/components/public/sprite-font";
|
||||
import { ContentCard } from "@/components/public/ui";
|
||||
|
||||
export default function LogoGenerator() {
|
||||
const [text, setText] = useState("Atom");
|
||||
export default function LogoGenerator({
|
||||
initialText = FALLBACK_HOTEL_NAME,
|
||||
}: {
|
||||
initialText?: string;
|
||||
}) {
|
||||
const [text, setText] = useState(initialText);
|
||||
const [styleName, setStyleName] = useState("habbo");
|
||||
const [search, setSearch] = useState("");
|
||||
const [saveStatus, setSaveStatus] = useState<
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { getTranslations } from "next-intl/server";
|
||||
import { CmsInfoPopup } from "@/components/cms-info-popup";
|
||||
import { siteSettings } from "@/lib/services/site-settings";
|
||||
import { resolveHotelName } from "@/lib/hotel-name";
|
||||
|
||||
export async function SiteFooter() {
|
||||
const hotelName = await siteSettings.get("hotel_name", "Atom");
|
||||
const hotelName = await resolveHotelName();
|
||||
const year = new Date().getFullYear();
|
||||
const t = await getTranslations("footer");
|
||||
|
||||
@@ -16,7 +16,7 @@ export async function SiteFooter() {
|
||||
}}
|
||||
>
|
||||
<div className="md:font-semibold text-[12px] md:text-[14px]">
|
||||
{t("copyright", { year, hotel: hotelName ?? "Atom" })}
|
||||
{t("copyright", { year, hotel: hotelName })}
|
||||
</div>
|
||||
<CmsInfoPopup />
|
||||
</footer>
|
||||
|
||||
@@ -3,12 +3,13 @@ import Link from "next/link";
|
||||
import { getTranslations } from "next-intl/server";
|
||||
import { cached } from "@/lib/cache";
|
||||
import { prisma } from "@/lib/prisma";
|
||||
import { resolveHotelName } from "@/lib/hotel-name";
|
||||
import { siteSettings } from "@/lib/services/site-settings";
|
||||
|
||||
export async function SiteHeader() {
|
||||
const t = await getTranslations("header");
|
||||
const [hotelName, header, logo] = await Promise.all([
|
||||
siteSettings.get("hotel_name", "Atom"),
|
||||
resolveHotelName(),
|
||||
siteSettings.get("cms_header", "/assets/images/background.png"),
|
||||
siteSettings.get("cms_logo", ""),
|
||||
]);
|
||||
@@ -77,7 +78,7 @@ export async function SiteHeader() {
|
||||
<Image
|
||||
className="drop-shadow-2xl block"
|
||||
src={logo}
|
||||
alt={hotelName ?? "Hotel"}
|
||||
alt={hotelName}
|
||||
width={200}
|
||||
height={120}
|
||||
style={{ maxHeight: 120, width: "auto", height: "auto" }}
|
||||
@@ -130,7 +131,7 @@ export async function SiteHeader() {
|
||||
className="text-sm font-bold tracking-wide"
|
||||
style={{ color: "rgba(255,255,255,0.9)" }}
|
||||
>
|
||||
{t("online", { count: online, hotel: hotelName ?? "Atom" })}
|
||||
{t("online", { count: online, hotel: hotelName })}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user