Merged in fix/SW-2222-next-stay-url-handling (pull request #1756)

fix(SW-2222): update next stay url to use PUBLIC_URL and adapt based on release flag

* fix(SW-2222): update next stay url to use PUBLIC_URL and adapt based on release flag

* refactor(SW-2222): change promoUrl variable to const


Approved-by: Michael Zetterberg
Approved-by: Christian Andolf
This commit is contained in:
Chuma Mcphoy (We Ahead)
2025-04-08 12:03:04 +00:00
parent fc0f0e30b1
commit c069b7cd9d

View File

@@ -3,7 +3,6 @@ import { notFound } from "next/navigation"
import { Typography } from "@scandic-hotels/design-system/Typography"
import { homeHrefs } from "@/constants/homeHrefs"
import { env } from "@/env/server"
import { dt } from "@/lib/dt"
import {
@@ -18,6 +17,7 @@ import { decrypt } from "@/server/routers/utils/encryption"
import Image from "@/components/Image"
import { getIntl } from "@/i18n"
import { getLang } from "@/i18n/serverContext"
import { getCurrentWebUrl } from "@/utils/url"
import AdditionalInfoForm from "../FindMyBooking/AdditionalInfoForm"
import accessBooking, {
@@ -86,6 +86,13 @@ export async function MyStay({ refId }: { refId: string }) {
additionalData.gallery?.heroImages[0]?.imageSizes.large ??
hotel.galleryImages[0]?.imageSizes.large
const baseUrl = env.PUBLIC_URL || "https://www.scandichotels.com"
const promoUrl = env.HIDE_FOR_NEXT_RELEASE
? new URL(getCurrentWebUrl("/", lang))
: new URL(`${baseUrl}/${lang}/`)
promoUrl.searchParams.set("hotel", hotel.operaId)
return (
<main className={styles.main}>
<div className={styles.imageContainer}>
@@ -131,7 +138,7 @@ export async function MyStay({ refId }: { refId: string }) {
id: "Get inspired and start dreaming beyond your next trip. Explore more Scandic destinations.",
})}
buttonText={intl.formatMessage({ id: "Explore Scandic hotels" })}
href={`${homeHrefs[env.NODE_ENV][lang]}?hotel=${hotel.operaId}`}
href={promoUrl.toString()}
image={hotel.hotelContent.images}
/>
</div>