Merged in chore/remove-unused-env-vars (pull request #2463)

chore: Remove unused env vars and feature toggles

* Remove unused env vars and feature toggles


Approved-by: Joakim Jäderberg
This commit is contained in:
Anton Gunnarsson
2025-06-30 07:48:05 +00:00
parent bdf66af23d
commit f0def99425
38 changed files with 28 additions and 369 deletions

View File

@@ -52,10 +52,6 @@ GOOGLE_STATIC_MAP_SIGNATURE_SECRET=""
GOOGLE_STATIC_MAP_ID=""
GOOGLE_DYNAMIC_MAP_ID=""
NEXT_PUBLIC_HIDE_FOR_NEXT_RELEASE="false"
ENABLE_BOOKING_WIDGET="false"
ENABLE_BOOKING_WIDGET_HOTELRESERVATION_PATH="false"
ENABLE_SURPRISES="true"
ENABLE_DTMC="true"
@@ -64,7 +60,6 @@ SHOW_SIGNUP_FLOW="true"
USE_NEW_REWARD_MODEL="true"
SAS="1"
SAS_POINT_TRANSFER_ENABLED="true"
SAS_API_ENDPOINT=""
SAS_AUTH_ENDPOINT=""

View File

@@ -41,14 +41,10 @@ GOOGLE_STATIC_MAP_KEY="test"
GOOGLE_STATIC_MAP_SIGNATURE_SECRET="test"
GOOGLE_STATIC_MAP_ID="test"
GOOGLE_DYNAMIC_MAP_ID="test"
NEXT_PUBLIC_HIDE_FOR_NEXT_RELEASE="true"
NEXT_PUBLIC_HIDE_FOR_NEXT_RELEASE_LANG="en,sv,da,de,fi,no"
SALESFORCE_PREFERENCE_BASE_URL="test"
USE_NEW_REWARD_MODEL="true"
TZ=UTC
ENABLE_BOOKING_WIDGET="false"
ENABLE_BOOKING_WIDGET_HOTELRESERVATION_PATH="false"
ENABLE_SURPRISES="true"
SHOW_SITE_WIDE_ALERT="false"

View File

@@ -1,12 +1,5 @@
import { env } from "@/env/server"
import CurrentLoadingSpinner from "@/components/Current/LoadingSpinner"
import LoadingSpinner from "@/components/LoadingSpinner"
export default function Loading() {
if (env.NEW_SITE_LIVE_STATUS === "NOT_LIVE") {
return <CurrentLoadingSpinner />
}
return <LoadingSpinner />
}

View File

@@ -1,8 +1,5 @@
import { notFound } from "next/navigation"
import { Suspense } from "react"
import { env } from "@/env/server"
import DestinationCityPage from "@/components/ContentType/DestinationPage/DestinationCityPage"
import DestinationCityPageSkeleton from "@/components/ContentType/DestinationPage/DestinationCityPage/DestinationCityPageSkeleton"
@@ -14,10 +11,6 @@ export default async function DestinationCityPagePage(
props: PageArgs<{}, { view?: "map"; filterFromUrl?: string }>
) {
const searchParams = await props.searchParams
if (env.NEW_SITE_LIVE_STATUS === "NOT_LIVE") {
return notFound()
}
return (
<Suspense fallback={<DestinationCityPageSkeleton />}>
<DestinationCityPage

View File

@@ -1,8 +1,5 @@
import { notFound } from "next/navigation"
import { Suspense } from "react"
import { env } from "@/env/server"
import DestinationCountryPage from "@/components/ContentType/DestinationPage/DestinationCountryPage"
import DestinationCountryPageSkeleton from "@/components/ContentType/DestinationPage/DestinationCountryPage/DestinationCountryPageSkeleton"
@@ -14,10 +11,6 @@ export default async function DestinationCountryPagePage(
props: PageArgs<LangParams, { view?: "map"; filterFromUrl?: string }>
) {
const searchParams = await props.searchParams
if (env.NEW_SITE_LIVE_STATUS === "NOT_LIVE") {
return notFound()
}
return (
<Suspense fallback={<DestinationCountryPageSkeleton />}>
<DestinationCountryPage

View File

@@ -1,7 +1,3 @@
import { notFound } from "next/navigation"
import { env } from "@/env/server"
import DestinationOverviewPage from "@/components/ContentType/DestinationPage/DestinationOverviewPage"
import type { LangParams, PageArgs } from "@/types/params"
@@ -9,9 +5,5 @@ import type { LangParams, PageArgs } from "@/types/params"
export { generateMetadata } from "@/utils/metadata/generateMetadata"
export default function DestinationOverviewPagePage({}: PageArgs<LangParams>) {
if (env.NEW_SITE_LIVE_STATUS === "NOT_LIVE") {
return notFound()
}
return <DestinationOverviewPage />
}

View File

@@ -1,6 +1,5 @@
import { notFound } from "next/navigation"
import { env } from "@/env/server"
import { getHotelPage } from "@/lib/trpc/memoizedRequests"
import HotelMapPage from "@/components/ContentType/HotelMapPage"
@@ -15,10 +14,6 @@ export default async function HotelPagePage(
props: PageArgs<{}, { subpage?: string; view?: "map" }>
) {
const searchParams = await props.searchParams
if (env.NEW_SITE_LIVE_STATUS === "NOT_LIVE") {
return notFound()
}
const hotelPageData = await getHotelPage()
if (!hotelPageData) {

View File

@@ -1,7 +1,3 @@
import { notFound } from "next/navigation"
import { env } from "@/env/server"
import StartPage from "@/components/ContentType/StartPage"
import { parseBookingWidgetSearchParams } from "@/utils/url"
@@ -13,10 +9,6 @@ export default async function StartPagePage(
props: PageArgs<{}, NextSearchParams>
) {
const searchParams = await props.searchParams
if (env.NEW_SITE_LIVE_STATUS === "NOT_LIVE") {
return notFound()
}
const booking = parseBookingWidgetSearchParams(searchParams)
return <StartPage booking={booking} />

View File

@@ -1,13 +1,8 @@
import { env } from "@/env/server"
import type { LangParams, PageArgs } from "@/types/params"
export async function generateMetadata(props: PageArgs<LangParams>) {
const params = await props.params;
export async function generateMetadata() {
return {
robots: {
index: env.isLangLive(params.lang),
follow: env.isLangLive(params.lang),
index: true,
follow: true,
},
}
}

View File

@@ -1,4 +1,3 @@
import { env } from "@/env/server"
import { getDestinationCityPage } from "@/lib/trpc/memoizedRequests"
import { BookingWidget } from "@/components/BookingWidget"
@@ -10,9 +9,6 @@ export default async function BookingWidgetDestinationCityPage(
props: PageArgs<{}, NextSearchParams>
) {
const searchParams = await props.searchParams
if (env.NEW_SITE_LIVE_STATUS === "NOT_LIVE") {
return null
}
const { bookingCode } = searchParams
const pageData = await getDestinationCityPage()

View File

@@ -1,4 +1,3 @@
import { env } from "@/env/server"
import { getHotel, getHotelPage } from "@/lib/trpc/memoizedRequests"
import { BookingWidget } from "@/components/BookingWidget"
@@ -11,9 +10,6 @@ export default async function BookingWidgetHotelPage(
props: PageArgs<{}, NextSearchParams & { subpage?: string }>
) {
const searchParams = await props.searchParams
if (env.NEW_SITE_LIVE_STATUS === "NOT_LIVE") {
return null
}
const hotelPageData = await getHotelPage()
const hotelData = await getHotel({

View File

@@ -1,5 +1,3 @@
import { env } from "@/env/server"
import { BookingWidget } from "@/components/BookingWidget"
import { parseBookingWidgetSearchParams } from "@/utils/url"
@@ -8,11 +6,7 @@ import type { LangParams, NextSearchParams, PageArgs } from "@/types/params"
export default async function BookingWidgetPage(
props: PageArgs<LangParams, NextSearchParams>
) {
const params = await props.params
const searchParams = await props.searchParams
if (!env.isLangLive(params.lang)) {
return null
}
const booking = parseBookingWidgetSearchParams(searchParams)

View File

@@ -8,7 +8,6 @@ import Script from "next/script"
import { Lang } from "@scandic-hotels/common/constants/language"
import { env } from "@/env/server"
import TrpcProvider from "@/lib/trpc/Provider"
import TokenRefresher from "@/components/Auth/TokenRefresher"
@@ -32,9 +31,6 @@ export default async function RootLayout(
const { children } = props
if (!env.SAS_ENABLED) {
return null
}
setLang(params.lang)
const messages = await getMessages(params.lang)

View File

@@ -1,7 +1,5 @@
import { notFound } from "next/navigation"
import { env } from "@/env/server"
import { getSitemapDataById } from "@/utils/sitemap"
import type { NextRequest } from "next/server"
@@ -12,10 +10,6 @@ export async function GET(
_request: NextRequest,
context: { params: Promise<{ sitemapId: string }> }
) {
if (env.NEW_SITE_LIVE_STATUS !== "ALL_LANGUAGES_LIVE") {
return notFound()
}
const params = await context.params
const sitemapId = params.sitemapId

View File

@@ -1,5 +1,3 @@
import { notFound } from "next/navigation"
import { env } from "@/env/server"
import { getLastUpdated, getSitemapIds } from "@/utils/sitemap"
@@ -7,10 +5,6 @@ import { getLastUpdated, getSitemapIds } from "@/utils/sitemap"
export const dynamic = "force-dynamic"
export async function GET() {
if (env.NEW_SITE_LIVE_STATUS !== "ALL_LANGUAGES_LIVE") {
return notFound()
}
console.log(`[SITEMAP] Fetching sitemap`)
const lastUpdated = await getLastUpdated()

View File

@@ -10,7 +10,6 @@ import {
SAS_EUROBONUS_TIER_TO_NAME_MAP,
TIER_TO_FRIEND_MAP,
} from "@/constants/membershipLevels"
import { env } from "@/env/server"
import { getProfileWithExtendedPartnerData } from "@/lib/trpc/memoizedRequests"
import SectionContainer from "@/components/Section/Container"
@@ -36,10 +35,6 @@ export default async function SASLinkedAccount({
subtitle,
link,
}: Props) {
if (!env.SAS_ENABLED) {
return null
}
const intl = await getIntl()
return (

View File

@@ -23,7 +23,7 @@ export default async function SASTransferPoints({
subtitle,
link,
}: Props) {
if (!env.SAS_ENABLED || !env.SAS_POINT_TRANSFER_ENABLED) {
if (!env.SAS_POINT_TRANSFER_ENABLED) {
return null
}

View File

@@ -1,8 +1,5 @@
import { getCurrentWebUrl } from "@scandic-hotels/common/utils/url"
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
import { env } from "@/env/server"
import Link from "@/components/TempDesignSystem/Link"
import Title from "@/components/TempDesignSystem/Text/Title"
import { getIntl } from "@/i18n"
@@ -13,11 +10,8 @@ import styles from "./emptyUpcomingStays.module.css"
export default async function EmptyUpcomingStaysBlock() {
const intl = await getIntl()
const lang = await getLang()
const baseUrl = env.PUBLIC_URL || "https://www.scandichotels.com"
const href = !env.isLangLive(lang)
? getCurrentWebUrl({ path: "/", lang, baseUrl })
: `/${lang}`
const href = `/${lang}`
return (
<section className={styles.container}>

View File

@@ -2,8 +2,6 @@ import { Suspense } from "react"
import { DynamicContentEnum } from "@scandic-hotels/trpc/types/dynamicContent"
import { env } from "@/env/server"
import HowItWorks from "@/components/Blocks/DynamicContent/HowItWorks"
import LoyaltyLevels from "@/components/Blocks/DynamicContent/LoyaltyLevels"
import Overview from "@/components/Blocks/DynamicContent/Overview"
@@ -41,9 +39,7 @@ function DynamicContentBlocks(props: DynamicContentProps) {
case DynamicContentEnum.Blocks.components.earn_and_burn:
return <EarnAndBurn {...dynamic_content} />
case DynamicContentEnum.Blocks.components.expiring_points:
return env.NEW_SITE_LIVE_STATUS === "NOT_LIVE" ? null : (
<ExpiringPoints {...dynamic_content} />
)
return <ExpiringPoints {...dynamic_content} />
case DynamicContentEnum.Blocks.components.how_it_works:
return <HowItWorks dynamic_content={dynamic_content} />
case DynamicContentEnum.Blocks.components.jobylon_feed:

View File

@@ -4,7 +4,6 @@
import { useCallback, useEffect, useRef, useState } from "react"
import { languages } from "@/constants/languages"
import { env } from "@/env/client"
import Link from "@/components/TempDesignSystem/Link"
import useLang from "@/hooks/useLang"
@@ -84,19 +83,11 @@ export default function Desktop({ urls }: LanguageSwitcherProps) {
className={`${styles.li} ${currentLanguage === key ? styles.active : ""}`}
>
{urls[key as Lang]?.isExternal ? (
<Link
className={styles.link}
href={url}
rel={env.isLangLive(key as Lang) ? undefined : "nofollow"}
>
<Link className={styles.link} href={url}>
{languages[key as Lang]}
</Link>
) : (
<a
className={styles.link}
href={url}
rel={env.isLangLive(key as Lang) ? undefined : "nofollow"}
>
<a className={styles.link} href={url}>
{languages[key as Lang]}
</a>
)}

View File

@@ -4,7 +4,6 @@
import { useState } from "react"
import { languages } from "@/constants/languages"
import { env } from "@/env/client"
import useLang from "@/hooks/useLang"
@@ -47,11 +46,7 @@ export default function Mobile({ urls }: LanguageSwitcherProps) {
if (url) {
return (
<li key={key} className={styles.li}>
<a
href={url}
className={styles.link}
rel={env.isLangLive(key as Lang) ? undefined : "nofollow"}
>
<a href={url} className={styles.link}>
{languages[key as Lang]}
</a>
</li>

View File

@@ -1,9 +1,5 @@
import { env } from "@/env/server"
import { getFooter } from "@/lib/trpc/memoizedRequests"
import CurrentFooter from "@/components/Current/Footer"
import { getLang } from "@/i18n/serverContext"
import FooterDetails from "./Details"
import FooterNavigation from "./Navigation"
@@ -14,11 +10,6 @@ export function preload() {
}
export default async function Footer() {
const lang = await getLang()
if (!env.isLangLive(lang)) {
return <CurrentFooter />
}
preload()
return (

View File

@@ -5,20 +5,14 @@ import { Dialog, Modal } from "react-aria-components"
import { useIntl } from "react-intl"
import { useMediaQuery } from "usehooks-ts"
import {
findMyBooking,
findMyBookingCurrentWebPath,
} from "@scandic-hotels/common/constants/routes/findMyBooking"
import { getCurrentWebUrl } from "@scandic-hotels/common/utils/url"
import { findMyBooking } from "@scandic-hotels/common/constants/routes/findMyBooking"
import { customerService } from "@/constants/webHrefs"
import { env } from "@/env/client"
import useDropdownStore from "@/stores/main-menu"
import { IconName } from "@/components/Icons/iconName"
import LanguageSwitcher from "@/components/LanguageSwitcher"
import { useHandleKeyUp } from "@/hooks/useHandleKeyUp"
import { useIsLangLive } from "@/hooks/useIsLangLive"
import useLang from "@/hooks/useLang"
import HeaderLink from "../../HeaderLink"
@@ -34,7 +28,6 @@ export default function MobileMenu({
topLink,
isLoggedIn,
}: React.PropsWithChildren<MobileMenuProps>) {
const isLangLive = useIsLangLive()
const lang = useLang()
const intl = useIntl()
const {
@@ -78,14 +71,7 @@ export default function MobileMenu({
defaultMessage: "Open menu",
})
const baseUrl = env.NEXT_PUBLIC_PUBLIC_URL || "https://www.scandichotels.com"
const findMyBookingUrl = !isLangLive
? getCurrentWebUrl({
path: findMyBookingCurrentWebPath[lang],
lang,
baseUrl,
})
: findMyBooking[lang]
const findMyBookingUrl = findMyBooking[lang]
return (
<>

View File

@@ -1,10 +1,5 @@
import {
findMyBooking,
findMyBookingCurrentWebPath,
} from "@scandic-hotels/common/constants/routes/findMyBooking"
import { getCurrentWebUrl } from "@scandic-hotels/common/utils/url"
import { findMyBooking } from "@scandic-hotels/common/constants/routes/findMyBooking"
import { env } from "@/env/server"
import { getHeader } from "@/lib/trpc/memoizedRequests"
import { IconName } from "@/components/Icons/iconName"
@@ -31,14 +26,7 @@ export default async function TopMenu() {
}
const lang = await getLang()
const baseUrl = env.PUBLIC_URL || "https://www.scandichotels.com"
const findMyBookingUrl = !env.isLangLive(lang)
? getCurrentWebUrl({
path: findMyBookingCurrentWebPath[lang],
lang,
baseUrl,
})
: findMyBooking[lang]
const findMyBookingUrl = findMyBooking[lang]
return (
<div className={styles.topMenu}>

View File

@@ -1,12 +1,7 @@
import { Suspense } from "react"
import { env } from "@/env/server"
import { getHeader, getName } from "@/lib/trpc/memoizedRequests"
import CurrentHeader from "@/components/Current/Header"
import { getLang } from "@/i18n/serverContext"
import HeaderFallback from "../Current/Header/HeaderFallback"
import MainMenu from "./MainMenu"
import TopMenu, { TopMenuSkeleton } from "./TopMenu"
@@ -14,16 +9,6 @@ import styles from "./header.module.css"
export default async function Header() {
void getName()
const lang = await getLang()
if (!env.isLangLive(lang)) {
return (
<Suspense fallback={<HeaderFallback />}>
<CurrentHeader />
</Suspense>
)
}
void getHeader()
return (

View File

@@ -3,7 +3,6 @@ import { notFound } from "next/navigation"
import { dt } from "@scandic-hotels/common/dt"
import * as maskValue from "@scandic-hotels/common/utils/maskValue"
import { getCurrentWebUrl } from "@scandic-hotels/common/utils/url"
import { Typography } from "@scandic-hotels/design-system/Typography"
import { BreakfastPackageEnum } from "@scandic-hotels/trpc/enums/breakfast"
import { parseRefId } from "@scandic-hotels/trpc/utils/refId"
@@ -169,9 +168,7 @@ export default async function MyStay(props: {
hotel.galleryImages[0]?.imageSizes.large
const baseUrl = env.PUBLIC_URL || "https://www.scandichotels.com"
const promoUrl = !env.isLangLive(lang)
? new URL(getCurrentWebUrl({ path: "/", lang }))
: new URL(`${baseUrl}/${lang}/`)
const promoUrl = new URL(`${baseUrl}/${lang}/`)
promoUrl.searchParams.set("hotel", hotel.operaId)

View File

@@ -7,7 +7,6 @@ import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
import { Typography } from "@scandic-hotels/design-system/Typography"
import { languages } from "@/constants/languages"
import { env } from "@/env/client"
import Link from "@/components/TempDesignSystem/Link"
import Subtitle from "@/components/TempDesignSystem/Text/Subtitle"
@@ -57,7 +56,6 @@ export default function LanguageSwitcherContent({
<Link
className={styles.link}
href={replaceUrlPart(pathname, url)}
rel={env.isLangLive(key) ? undefined : "nofollow"}
onClick={() => onLanguageSwitch(key)}
variant="languageSwitcher"
keepSearchParams

View File

@@ -1,24 +1,12 @@
import { createEnv } from "@t3-oss/env-nextjs"
import { z } from "zod"
import { getLiveStatus } from "./getLiveStatus"
import { isLangLive } from "./isLangLive"
import type { Lang } from "@scandic-hotels/common/constants/language"
const _env = createEnv({
export const env = createEnv({
client: {
NEXT_PUBLIC_NODE_ENV: z.enum(["development", "test", "production"]),
NEXT_PUBLIC_PORT: z.string().default("3000"),
NEXT_PUBLIC_SENTRY_ENVIRONMENT: z.string().default("development"),
NEXT_PUBLIC_SENTRY_CLIENT_SAMPLERATE: z.coerce.number().default(0.001),
NEXT_PUBLIC_NEW_SITE_LIVE_FOR_LANGS: z
.string()
.regex(/^([a-z]{2},)*([a-z]{2}){0,1}$/)
.transform((val) => {
return val.split(",")
})
.default(""),
NEXT_PUBLIC_PUBLIC_URL: z.string().optional(),
},
emptyStringAsUndefined: true,
@@ -28,15 +16,6 @@ const _env = createEnv({
NEXT_PUBLIC_SENTRY_ENVIRONMENT: process.env.NEXT_PUBLIC_SENTRY_ENVIRONMENT,
NEXT_PUBLIC_SENTRY_CLIENT_SAMPLERATE:
process.env.NEXT_PUBLIC_SENTRY_CLIENT_SAMPLERATE,
NEXT_PUBLIC_NEW_SITE_LIVE_FOR_LANGS:
process.env.NEXT_PUBLIC_NEW_SITE_LIVE_FOR_LANGS,
NEXT_PUBLIC_PUBLIC_URL: process.env.NEXT_PUBLIC_PUBLIC_URL,
},
})
export const env = {
..._env,
NEW_SITE_LIVE_STATUS: getLiveStatus(_env),
isLangLive: (lang: Lang) =>
isLangLive(lang, _env.NEXT_PUBLIC_NEW_SITE_LIVE_FOR_LANGS),
}

View File

@@ -1,53 +0,0 @@
import { Lang } from "@scandic-hotels/common/constants/language"
export function getLiveStatus(
internalEnv:
| {
NEW_SITE_LIVE_FOR_LANGS: string[]
}
| {
NEXT_PUBLIC_NEW_SITE_LIVE_FOR_LANGS: string[]
}
): "ALL_LANGUAGES_LIVE" | "SOME_LANGUAGES_LIVE" | "NOT_LIVE" {
const configuredLangs = getConfiguredLangs(internalEnv)
if (!configuredLangs) {
return "NOT_LIVE"
}
const allLangs = Object.keys(Lang)
const liveLangs = allLangs.filter((lang) => configuredLangs.includes(lang))
if (liveLangs.length === 0) {
return "NOT_LIVE"
}
if (
liveLangs.length === allLangs.length &&
allLangs.every((lang) => liveLangs.includes(lang))
) {
return "ALL_LANGUAGES_LIVE"
}
return "SOME_LANGUAGES_LIVE"
}
function getConfiguredLangs<T extends {}>(env: T): string[] | undefined {
if (
!(
"NEW_SITE_LIVE_FOR_LANGS" in env ||
"NEXT_PUBLIC_NEW_SITE_LIVE_FOR_LANGS" in env
)
) {
return undefined
}
const configuredLangs =
"NEW_SITE_LIVE_FOR_LANGS" in env
? env.NEW_SITE_LIVE_FOR_LANGS
: env.NEXT_PUBLIC_NEW_SITE_LIVE_FOR_LANGS
if (!Array.isArray(configuredLangs)) {
throw new Error("Misconfigured environment variable, expected array")
}
return configuredLangs
}

View File

@@ -1,18 +0,0 @@
import { describe, expect, it } from "@jest/globals"
import { Lang } from "@scandic-hotels/common/constants/language"
import { isLangLive } from "./isLangLive"
describe("hideForNextRelease", () => {
it("should return true if en is part of live languages", () => {
expect(isLangLive(Lang.en, ["en", "sv"])).toBe(true)
expect(isLangLive(Lang.en, ["en"])).toBe(true)
})
it("should return false if en is not part of live languages", () => {
expect(isLangLive(Lang.en, [])).toBe(false)
expect(isLangLive(Lang.en, ["sv"])).toBe(false)
expect(isLangLive(Lang.en, ["sv,fi"])).toBe(false)
})
})

View File

@@ -1,5 +0,0 @@
import type { Lang } from "@scandic-hotels/common/constants/language"
export function isLangLive(lang: Lang, liveLangs: string[]): boolean {
return liveLangs.includes(lang)
}

View File

@@ -1,14 +1,9 @@
import { createEnv } from "@t3-oss/env-nextjs"
import { z } from "zod"
import { getLiveStatus } from "./getLiveStatus"
import { isLangLive } from "./isLangLive"
import type { Lang } from "@scandic-hotels/common/constants/language"
const TWENTYFOUR_HOURS = 24 * 60 * 60
const _env = createEnv({
export const env = createEnv({
/**
* Due to t3-env only checking typeof window === "undefined"
* and Netlify running Deno, window is never "undefined"
@@ -112,13 +107,6 @@ const _env = createEnv({
GOOGLE_STATIC_MAP_SIGNATURE_SECRET: z.string(),
GOOGLE_DYNAMIC_MAP_ID: z.string(),
GOOGLE_STATIC_MAP_ID: z.string(),
ENABLE_BOOKING_WIDGET: z
.string()
// only allow "true" or "false"
.refine((s) => s === "true" || s === "false")
// transform to boolean
.transform((s) => s === "true")
.default("false"),
ENABLE_SURPRISES: z
.string()
// only allow "true" or "false"
@@ -155,11 +143,6 @@ const _env = createEnv({
SAS_AUTH_ENDPOINT: z.string().default(""),
SAS_OCP_APIM: z.string().default(""),
SAS_AUTH_CLIENTID: z.string().default(""),
SAS_ENABLED: z
.string()
.refine((s) => s === "1" || s === "0")
.transform((s) => s === "1")
.default("0"),
SAS_POINT_TRANSFER_ENABLED: z
.string()
// only allow "true" or "false"
@@ -192,17 +175,6 @@ const _env = createEnv({
.transform((s) => s === "true")
.default("true"),
WARMUP_TOKEN: z.string().optional(),
/**
* Include the languages that should be hidden for the next release
* Should be in the format of "en,da,de,fi,no,sv" or empty
*/
NEW_SITE_LIVE_FOR_LANGS: z
.string()
.regex(/^([a-z]{2},)*([a-z]{2}){0,1}$/)
.transform((val) => {
return val.split(",")
})
.default(""),
DTMC_ENTRA_ID_CLIENT: z.string(),
DTMC_ENTRA_ID_ISSUER: z.string(),
/**
@@ -284,7 +256,6 @@ const _env = createEnv({
GOOGLE_STATIC_MAP_ID: process.env.GOOGLE_STATIC_MAP_ID,
GOOGLE_DYNAMIC_MAP_ID: process.env.GOOGLE_DYNAMIC_MAP_ID,
USE_NEW_REWARD_MODEL: process.env.USE_NEW_REWARD_MODEL,
ENABLE_BOOKING_WIDGET: process.env.ENABLE_BOOKING_WIDGET,
ENABLE_SURPRISES: process.env.ENABLE_SURPRISES,
ENABLE_DTMC: process.env.ENABLE_DTMC,
SHOW_SITE_WIDE_ALERT: process.env.SHOW_SITE_WIDE_ALERT,
@@ -295,7 +266,6 @@ const _env = createEnv({
SAS_AUTH_ENDPOINT: process.env.SAS_AUTH_ENDPOINT,
SAS_OCP_APIM: process.env.SAS_OCP_APIM,
SAS_AUTH_CLIENTID: process.env.SAS_AUTH_CLIENTID,
SAS_ENABLED: process.env.SAS,
SAS_POINT_TRANSFER_ENABLED: process.env.SAS_POINT_TRANSFER_ENABLED,
CACHE_TIME_HOTELS: process.env.CACHE_TIME_HOTELS,
@@ -307,7 +277,6 @@ const _env = createEnv({
GIT_SHA: process.env.GIT_SHA,
ENABLE_WARMUP_HOTEL: process.env.ENABLE_WARMUP_HOTEL,
WARMUP_TOKEN: process.env.WARMUP_TOKEN,
NEW_SITE_LIVE_FOR_LANGS: process.env.NEXT_PUBLIC_NEW_SITE_LIVE_FOR_LANGS,
DTMC_ENTRA_ID_CLIENT: process.env.DTMC_ENTRA_ID_CLIENT,
DTMC_ENTRA_ID_ISSUER: process.env.DTMC_ENTRA_ID_ISSUER,
@@ -316,12 +285,6 @@ const _env = createEnv({
},
})
export const env = {
..._env,
NEW_SITE_LIVE_STATUS: getLiveStatus(_env),
isLangLive: (lang: Lang) => isLangLive(lang, _env.NEW_SITE_LIVE_FOR_LANGS),
} as const
function replaceTopLevelDomain(url: string, domain: string) {
return url.replaceAll("{topleveldomain}", domain)
}

View File

@@ -1,10 +0,0 @@
"use client"
import { env } from "@/env/client"
import useLang from "./useLang"
export function useIsLangLive(): boolean {
const lang = useLang()
return env.isLangLive(lang)
}

View File

@@ -9,8 +9,6 @@ import useStickyPositionStore, {
import { debounce } from "@/utils/debounce"
import { useIsLangLive } from "./useIsLangLive"
interface UseStickyPositionProps {
ref?: React.RefObject<HTMLElement | null>
name?: StickyElementNameEnum
@@ -47,7 +45,6 @@ export default function useStickyPosition({
getAllElements,
} = useStickyPositionStore()
const isLangLive = useIsLangLive()
/* Used for Current mobile header since that doesn't use this hook.
*
* Instead, calculate if the mobile header is shown and add the height of
@@ -125,13 +122,11 @@ export default function useStickyPosition({
updateHeights()
// Only do this special handling if we have the current header
if (!isLangLive) {
if (document.body.clientWidth > 950) {
setBaseTopOffset(0)
} else {
setBaseTopOffset(52.41) // The height of current mobile header
}
}
}, 100)
resizeObserver = new ResizeObserver(debouncedResizeHandler)
@@ -144,7 +139,7 @@ export default function useStickyPosition({
resizeObserver.unobserve(document.body)
}
}
}, [updateHeights, isLangLive])
}, [updateHeights])
return {
currentHeight: ref?.current?.offsetHeight || null,

View File

@@ -7,7 +7,6 @@ import { getDescription } from "./description"
import { getImage } from "./image"
import { getTitle } from "./title"
import type { Lang } from "@scandic-hotels/common/constants/language"
import type { Metadata } from "next"
import type { AlternateURLs } from "next/dist/lib/metadata/types/alternative-urls-types"
@@ -20,12 +19,10 @@ import type {
export async function generateMetadata({
searchParams,
params,
}: PageArgs<
LangParams & ContentTypeParams & UIDParams,
{ subpage?: string; filterFromUrl?: string }
>) {
const { lang } = await params
const { subpage, filterFromUrl, ...otherSearchParams } = await searchParams
// If there are other (real) search params, we don't want to index the page as this will
// cause duplicate content issues.
@@ -41,8 +38,8 @@ export async function generateMetadata({
if (!rawMetadata) {
return {
robots: {
index: env.isLangLive(lang),
follow: env.isLangLive(lang),
index: true,
follow: true,
},
}
}
@@ -57,15 +54,14 @@ export async function generateMetadata({
...metadata,
robots: {
...(metadata.robots ?? {}),
index: isIndexable(metadata.robots?.index, lang, alternates),
follow: isIndexable(metadata.robots?.follow, lang, alternates),
index: isIndexable(metadata.robots?.index, alternates),
follow: isIndexable(metadata.robots?.follow, alternates),
},
}
}
function isIndexable(
pageIndexableFromSettings: boolean | null | undefined,
lang: Lang,
alternates: AlternateURLs | null
) {
// This is a special case for whitelisting the scandic friends pages, this can be removed when all pages are live
@@ -76,7 +72,7 @@ function isIndexable(
}
// If we are live we want to index the page, but if the page has been marked as noindex in contentstack we don't
return (pageIndexableFromSettings ?? true) && env.isLangLive(lang)
return pageIndexableFromSettings ?? true
}
function getUrl(alternates: AlternateURLs | null): string | null {

View File

@@ -25,11 +25,6 @@ const _env = createEnv({
SAS_AUTH_ENDPOINT: z.string().default(""),
SAS_OCP_APIM: z.string().default(""),
SAS_AUTH_CLIENTID: z.string().default(""),
SAS_ENABLED: z
.string()
.refine((s) => s === "1" || s === "0")
.transform((s) => s === "1")
.default("0"),
CACHE_TIME_HOTELS: z.coerce
.number()
.default(TWENTYFOUR_HOURS)
@@ -74,7 +69,6 @@ const _env = createEnv({
SAS_AUTH_ENDPOINT: process.env.SAS_AUTH_ENDPOINT,
SAS_OCP_APIM: process.env.SAS_OCP_APIM,
SAS_AUTH_CLIENTID: process.env.SAS_AUTH_CLIENTID,
SAS_ENABLED: process.env.SAS,
CACHE_TIME_HOTELS: process.env.CACHE_TIME_HOTELS,
CACHE_TIME_CITY_SEARCH: process.env.CACHE_TIME_CITY_SEARCH,
NODE_ENV: process.env.NODE_ENV,

View File

@@ -3,7 +3,6 @@ import { cache } from "react"
import * as routes from "@scandic-hotels/common/constants/routes/myPages"
import { safeTry } from "@scandic-hotels/common/utils/safeTry"
import { env } from "../../../../env/server"
import { getEurobonusMembership } from "../../user/helpers"
import type { Lang } from "@scandic-hotels/common/constants/language"
@@ -67,9 +66,7 @@ export const getPrimaryLinks = cache(
const isScandicXSASActive = (loyalty: UserLoyalty) => {
const eurobonusMembership = getEurobonusMembership(loyalty)
const isLinked = Boolean(eurobonusMembership)
return env.SAS_ENABLED && isLinked
return Boolean(eurobonusMembership)
}
const showTeamMemberCard = cache(async () => {

View File

@@ -2,7 +2,6 @@ import { myStay } from "@scandic-hotels/common/constants/routes/myStay"
import { dt } from "@scandic-hotels/common/dt"
import { createCounter } from "@scandic-hotels/common/telemetry"
import * as maskValue from "@scandic-hotels/common/utils/maskValue"
import { getCurrentWebUrl } from "@scandic-hotels/common/utils/url"
import { env } from "../../../env/server"
import * as api from "../../api"
@@ -340,15 +339,7 @@ export async function updateStaysBookingUrl(
const baseUrl = env.PUBLIC_URL || "https://www.scandichotels.com"
// Construct Booking URL.
const bookingUrl = !env.isLangLive(lang)
? new URL(
getCurrentWebUrl({
path: myBookingPath[lang],
lang,
baseUrl,
})
)
: new URL(myStay[lang], baseUrl)
const bookingUrl = new URL(myStay[lang], baseUrl)
// Add search parameters.
if (encryptedBookingValue) {