From 27aef3982ea9e659d2b99f4b2e126eeffff4210a Mon Sep 17 00:00:00 2001 From: "Chuma Mcphoy (We Ahead)" Date: Tue, 22 Apr 2025 07:03:23 +0000 Subject: [PATCH] Merged in fix/LOY-222-find-my-booking-urls-for-prod (pull request #1817) Fix(LOY-222): Find my booking url handling * fix(LOY-222): adapt findMyBooking url based on HIDE_FOR_NEXT_RELEASE * feat(LOY-222): add current web paths for findMyBooking in multiple languages * refactor(LOY-222): better env and new url constructions * refactor(LOY-222): decouple env var handling from getCurrentWebUrl * fix(LOY-222): update findMyBooking URL construction to use baseUrl * fix(LOY-222): simplify findMyBooking URL handling for new web urls * fix(LOY-222): Update Finnish path for hotel reservation lookup * refactor(LOY-222): rename PUBLIC_URL to NEXT_PUBLIC_PUBLIC_URL for consistency Approved-by: Christian Andolf Approved-by: Linus Flood --- apps/scandic-web/.env.local.example | 6 +++--- apps/scandic-web/.env.test | 2 +- .../Stays/Soonest/EmptyUpcomingStays/index.tsx | 3 ++- .../Upcoming/EmptyUpcomingStays/index.tsx | 3 ++- .../Current/Header/MainMenu/index.tsx | 11 +++++++++-- .../Header/MainMenu/MobileMenu/index.tsx | 18 ++++++++++++++++-- .../components/Header/TopMenu/index.tsx | 17 +++++++++++++++-- .../HotelReservation/MyStay/index.tsx | 2 +- .../constants/routes/findMyBooking.js | 10 ++++++++++ apps/scandic-web/env/client.ts | 2 ++ apps/scandic-web/env/server.ts | 2 +- apps/scandic-web/server/routers/user/utils.ts | 8 +++++++- apps/scandic-web/utils/url.ts | 18 +++++++++++++----- 13 files changed, 82 insertions(+), 20 deletions(-) diff --git a/apps/scandic-web/.env.local.example b/apps/scandic-web/.env.local.example index b63130ed3..6ff94b5c3 100644 --- a/apps/scandic-web/.env.local.example +++ b/apps/scandic-web/.env.local.example @@ -43,9 +43,9 @@ NODE_OPTIONS="--openssl-legacy-provider" // OPENSSL_MODULES="/var/lang/lib/ossl-modules" to enable legacy encryption support. OPENSSL_MODULES="/var/lang/lib/ossl-modules" -PUBLIC_URL="http://localhost:3000" -AUTH_URL="$PUBLIC_URL/api/web/auth" -NEXTAUTH_URL="$PUBLIC_URL/api/web/auth" +NEXT_PUBLIC_PUBLIC_URL="http://localhost:3000" +AUTH_URL="$NEXT_PUBLIC_PUBLIC_URL/api/web/auth" +NEXTAUTH_URL="$NEXT_PUBLIC_PUBLIC_URL/api/web/auth" GOOGLE_STATIC_MAP_KEY="" GOOGLE_STATIC_MAP_SIGNATURE_SECRET="" diff --git a/apps/scandic-web/.env.test b/apps/scandic-web/.env.test index 4b34ca794..c7d2ae5eb 100644 --- a/apps/scandic-web/.env.test +++ b/apps/scandic-web/.env.test @@ -20,7 +20,7 @@ CYPRESS_CURITY_PASSWORD="test" CYPRESS_BASE_URL="test" DEPLOY_PRIME_URL="test" NEXTAUTH_SECRET="test" -PUBLIC_URL="test" +NEXT_PUBLIC_PUBLIC_URL="test" NEXTAUTH_URL="test" REVALIDATE_SECRET="test" SEAMLESS_LOGIN_DA="test" diff --git a/apps/scandic-web/components/Blocks/DynamicContent/Stays/Soonest/EmptyUpcomingStays/index.tsx b/apps/scandic-web/components/Blocks/DynamicContent/Stays/Soonest/EmptyUpcomingStays/index.tsx index 42723547e..697748e23 100644 --- a/apps/scandic-web/components/Blocks/DynamicContent/Stays/Soonest/EmptyUpcomingStays/index.tsx +++ b/apps/scandic-web/components/Blocks/DynamicContent/Stays/Soonest/EmptyUpcomingStays/index.tsx @@ -13,9 +13,10 @@ import styles from "./emptyUpcomingStays.module.css" export default async function EmptyUpcomingStaysBlock() { const intl = await getIntl() const lang = getLang() + const baseUrl = env.PUBLIC_URL || "https://www.scandichotels.com" const href = env.HIDE_FOR_NEXT_RELEASE - ? getCurrentWebUrl("/", lang) + ? getCurrentWebUrl({ path: "/", lang, baseUrl }) : `/${lang}` return ( diff --git a/apps/scandic-web/components/Blocks/DynamicContent/Stays/Upcoming/EmptyUpcomingStays/index.tsx b/apps/scandic-web/components/Blocks/DynamicContent/Stays/Upcoming/EmptyUpcomingStays/index.tsx index 42723547e..697748e23 100644 --- a/apps/scandic-web/components/Blocks/DynamicContent/Stays/Upcoming/EmptyUpcomingStays/index.tsx +++ b/apps/scandic-web/components/Blocks/DynamicContent/Stays/Upcoming/EmptyUpcomingStays/index.tsx @@ -13,9 +13,10 @@ import styles from "./emptyUpcomingStays.module.css" export default async function EmptyUpcomingStaysBlock() { const intl = await getIntl() const lang = getLang() + const baseUrl = env.PUBLIC_URL || "https://www.scandichotels.com" const href = env.HIDE_FOR_NEXT_RELEASE - ? getCurrentWebUrl("/", lang) + ? getCurrentWebUrl({ path: "/", lang, baseUrl }) : `/${lang}` return ( diff --git a/apps/scandic-web/components/Current/Header/MainMenu/index.tsx b/apps/scandic-web/components/Current/Header/MainMenu/index.tsx index 4e84895d8..f6a339e4d 100644 --- a/apps/scandic-web/components/Current/Header/MainMenu/index.tsx +++ b/apps/scandic-web/components/Current/Header/MainMenu/index.tsx @@ -4,9 +4,10 @@ import { usePathname } from "next/navigation" import { useIntl } from "react-intl" -import { findMyBooking } from "@/constants/routes/findMyBooking" +import { findMyBookingCurrentWebPath } from "@/constants/routes/findMyBooking" import { logout } from "@/constants/routes/handleAuth" import { myPages } from "@/constants/routes/myPages" +import { env } from "@/env/client" import useDropdownStore from "@/stores/main-menu" import Image from "@/components/Image" @@ -16,6 +17,7 @@ import SkeletonShimmer from "@/components/SkeletonShimmer" import Link from "@/components/TempDesignSystem/Link" import useLang from "@/hooks/useLang" import { trackClick } from "@/utils/tracking" +import { getCurrentWebUrl } from "@/utils/url" import BookingButton from "../BookingButton" @@ -38,6 +40,7 @@ export function MainMenu({ const intl = useIntl() const lang = useLang() const pathname = usePathname() + const baseUrl = env.NEXT_PUBLIC_PUBLIC_URL || "https://www.scandichotels.com" const isThreeStaticPagesPathnames = [ "/de/sponsoring", @@ -157,7 +160,11 @@ export function MainMenu({
  • {intl.formatMessage({ defaultMessage: "Find booking", diff --git a/apps/scandic-web/components/Header/MainMenu/MobileMenu/index.tsx b/apps/scandic-web/components/Header/MainMenu/MobileMenu/index.tsx index 8f401d7ea..6d8b1b66e 100644 --- a/apps/scandic-web/components/Header/MainMenu/MobileMenu/index.tsx +++ b/apps/scandic-web/components/Header/MainMenu/MobileMenu/index.tsx @@ -6,13 +6,18 @@ import { useIntl } from "react-intl" import { useMediaQuery } from "usehooks-ts" import { customerService } from "@/constants/currentWebHrefs" -import { findMyBooking } from "@/constants/routes/findMyBooking" +import { + findMyBooking, + findMyBookingCurrentWebPath, +} from "@/constants/routes/findMyBooking" +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 useLang from "@/hooks/useLang" +import { getCurrentWebUrl } from "@/utils/url" import HeaderLink from "../../HeaderLink" import TopLink from "../../TopLink" @@ -70,6 +75,15 @@ export default function MobileMenu({ defaultMessage: "Open menu", }) + const baseUrl = env.NEXT_PUBLIC_PUBLIC_URL || "https://www.scandichotels.com" + const findMyBookingUrl = env.NEXT_PUBLIC_HIDE_FOR_NEXT_RELEASE + ? getCurrentWebUrl({ + path: findMyBookingCurrentWebPath[lang], + lang, + baseUrl, + }) + : findMyBooking[lang] + return ( <>