feat(BOOK-414): Added hotel branding themes to hotelpages
Approved-by: Matilda Landström
This commit is contained in:
28
apps/scandic-web/utils/theme/index.ts
Normal file
28
apps/scandic-web/utils/theme/index.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { headers } from "next/headers"
|
||||
|
||||
import { PageContentTypeEnum } from "@scandic-hotels/trpc/enums/contentType"
|
||||
|
||||
import { env } from "@/env/server"
|
||||
|
||||
import { DEFAULT_THEME } from "./types"
|
||||
import { getHotelTheme } from "./utils"
|
||||
|
||||
import type { Lang } from "@scandic-hotels/common/constants/language"
|
||||
|
||||
export async function getThemeClass(lang: Lang): Promise<string> {
|
||||
if (!env.HOTEL_BRANDING) {
|
||||
return DEFAULT_THEME
|
||||
}
|
||||
|
||||
const headersList = await headers()
|
||||
const contentType = headersList.get("x-contenttype") || ""
|
||||
|
||||
const isHotelPage =
|
||||
contentType && contentType === PageContentTypeEnum.hotelPage
|
||||
|
||||
if (isHotelPage) {
|
||||
return await getHotelTheme(lang)
|
||||
}
|
||||
|
||||
return DEFAULT_THEME
|
||||
}
|
||||
Reference in New Issue
Block a user