From 8e00769c643bdc3a9833e4695cf359620bcd5b36 Mon Sep 17 00:00:00 2001 From: Hrishikesh Vaipurkar Date: Thu, 4 Sep 2025 08:14:50 +0000 Subject: [PATCH] Merged in chore/SW-3395-move-bookingconfirmationprovider (pull request #2757) chore(SW-3395): Moved BookingConfirmationProvider to booking-flow package * chore(SW-3395): Moved BookingConfirmationProvider to booking-flow package Approved-by: Anton Gunnarsson --- .../BookingConfirmation/PaymentDetails/index.tsx | 3 +-- .../BookingConfirmation/PriceDetails/index.tsx | 3 +-- .../BookingConfirmation/PriceDetails/mapToPrice.ts | 3 +-- .../BookingConfirmation/Receipt/Room/index.tsx | 2 +- .../BookingConfirmation/Receipt/TotalPrice/index.tsx | 3 +-- .../BookingConfirmation/Receipt/index.tsx | 3 +-- .../Rooms/LinkedReservation/index.tsx | 3 +-- .../BookingConfirmation/Rooms/Room/index.tsx | 2 +- .../BookingConfirmation/Tracking/index.tsx | 6 ++---- .../BookingConfirmation/Tracking/tracking.ts | 3 +-- .../HotelReservation/BookingConfirmation/index.tsx | 2 +- .../hotelReservation/bookingConfirmation/receipt.ts | 2 +- .../booking-flow/lib}/contexts/BookingConfirmation.ts | 2 +- .../lib}/providers/BookingConfirmationProvider.tsx | 9 ++++----- .../lib}/stores/booking-confirmation/index.ts | 4 ++-- .../lib}/types/contexts/booking-confirmation.ts | 2 +- .../lib}/types/providers/booking-confirmation.ts | 0 .../lib}/types/stores/booking-confirmation.ts | 0 packages/booking-flow/package.json | 3 +++ 19 files changed, 24 insertions(+), 31 deletions(-) rename {apps/scandic-web => packages/booking-flow/lib}/contexts/BookingConfirmation.ts (61%) rename {apps/scandic-web => packages/booking-flow/lib}/providers/BookingConfirmationProvider.tsx (89%) rename {apps/scandic-web => packages/booking-flow/lib}/stores/booking-confirmation/index.ts (92%) rename {apps/scandic-web => packages/booking-flow/lib}/types/contexts/booking-confirmation.ts (51%) rename {apps/scandic-web => packages/booking-flow/lib}/types/providers/booking-confirmation.ts (100%) rename {apps/scandic-web => packages/booking-flow/lib}/types/stores/booking-confirmation.ts (100%) diff --git a/apps/scandic-web/components/HotelReservation/BookingConfirmation/PaymentDetails/index.tsx b/apps/scandic-web/components/HotelReservation/BookingConfirmation/PaymentDetails/index.tsx index f44bfd1ac..494a4fc1d 100644 --- a/apps/scandic-web/components/HotelReservation/BookingConfirmation/PaymentDetails/index.tsx +++ b/apps/scandic-web/components/HotelReservation/BookingConfirmation/PaymentDetails/index.tsx @@ -2,12 +2,11 @@ import { useIntl } from "react-intl" +import { useBookingConfirmationStore } from "@scandic-hotels/booking-flow/stores/booking-confirmation" import Body from "@scandic-hotels/design-system/Body" import SkeletonShimmer from "@scandic-hotels/design-system/SkeletonShimmer" import Subtitle from "@scandic-hotels/design-system/Subtitle" -import { useBookingConfirmationStore } from "@/stores/booking-confirmation" - import styles from "./paymentDetails.module.css" export default function PaymentDetails() { diff --git a/apps/scandic-web/components/HotelReservation/BookingConfirmation/PriceDetails/index.tsx b/apps/scandic-web/components/HotelReservation/BookingConfirmation/PriceDetails/index.tsx index 74074faeb..8daa62f5c 100644 --- a/apps/scandic-web/components/HotelReservation/BookingConfirmation/PriceDetails/index.tsx +++ b/apps/scandic-web/components/HotelReservation/BookingConfirmation/PriceDetails/index.tsx @@ -1,10 +1,9 @@ "use client" import PriceDetailsModal from "@scandic-hotels/booking-flow/components/PriceDetailsModal" +import { useBookingConfirmationStore } from "@scandic-hotels/booking-flow/stores/booking-confirmation" import { CurrencyEnum } from "@scandic-hotels/common/constants/currency" import { dt } from "@scandic-hotels/common/dt" -import { useBookingConfirmationStore } from "@/stores/booking-confirmation" - import { mapToPrice } from "./mapToPrice" import type { Price } from "@/types/components/hotelReservation/price" diff --git a/apps/scandic-web/components/HotelReservation/BookingConfirmation/PriceDetails/mapToPrice.ts b/apps/scandic-web/components/HotelReservation/BookingConfirmation/PriceDetails/mapToPrice.ts index 1c47bd121..8d28804a2 100644 --- a/apps/scandic-web/components/HotelReservation/BookingConfirmation/PriceDetails/mapToPrice.ts +++ b/apps/scandic-web/components/HotelReservation/BookingConfirmation/PriceDetails/mapToPrice.ts @@ -7,10 +7,9 @@ import { packageSchema, } from "@scandic-hotels/trpc/routers/hotels/schemas/packages" +import type { Room } from "@scandic-hotels/booking-flow/types/stores/booking-confirmation" import type { Package } from "@scandic-hotels/trpc/types/packages" -import type { Room } from "@/types/stores/booking-confirmation" - export function mapToPrice(rooms: (Room | null)[], nights: number) { return rooms .filter((room): room is Room => !!room) diff --git a/apps/scandic-web/components/HotelReservation/BookingConfirmation/Receipt/Room/index.tsx b/apps/scandic-web/components/HotelReservation/BookingConfirmation/Receipt/Room/index.tsx index 68d2493cf..80d59628a 100644 --- a/apps/scandic-web/components/HotelReservation/BookingConfirmation/Receipt/Room/index.tsx +++ b/apps/scandic-web/components/HotelReservation/BookingConfirmation/Receipt/Room/index.tsx @@ -3,6 +3,7 @@ import { cx } from "class-variance-authority" import { useIntl } from "react-intl" +import { useBookingConfirmationStore } from "@scandic-hotels/booking-flow/stores/booking-confirmation" import { formatPrice } from "@scandic-hotels/common/utils/numberFormatting" import { Button } from "@scandic-hotels/design-system/Button" import { Divider } from "@scandic-hotels/design-system/Divider" @@ -12,7 +13,6 @@ import { Typography } from "@scandic-hotels/design-system/Typography" import { ChildBedTypeEnum } from "@scandic-hotels/trpc/enums/childBedTypeEnum" import { CancellationRuleEnum } from "@/constants/booking" -import { useBookingConfirmationStore } from "@/stores/booking-confirmation" import { getFeatureDescription } from "@/components/HotelReservation/utils/getRoomFeatureDescription" diff --git a/apps/scandic-web/components/HotelReservation/BookingConfirmation/Receipt/TotalPrice/index.tsx b/apps/scandic-web/components/HotelReservation/BookingConfirmation/Receipt/TotalPrice/index.tsx index d041bf241..4f8547264 100644 --- a/apps/scandic-web/components/HotelReservation/BookingConfirmation/Receipt/TotalPrice/index.tsx +++ b/apps/scandic-web/components/HotelReservation/BookingConfirmation/Receipt/TotalPrice/index.tsx @@ -3,13 +3,12 @@ import { cx } from "class-variance-authority" import { useIntl } from "react-intl" +import { useBookingConfirmationStore } from "@scandic-hotels/booking-flow/stores/booking-confirmation" import { BookingCodeChip } from "@scandic-hotels/design-system/BookingCodeChip" import { Divider } from "@scandic-hotels/design-system/Divider" import SkeletonShimmer from "@scandic-hotels/design-system/SkeletonShimmer" import { Typography } from "@scandic-hotels/design-system/Typography" -import { useBookingConfirmationStore } from "@/stores/booking-confirmation" - import PriceDetails from "../../PriceDetails" import styles from "./totalPrice.module.css" diff --git a/apps/scandic-web/components/HotelReservation/BookingConfirmation/Receipt/index.tsx b/apps/scandic-web/components/HotelReservation/BookingConfirmation/Receipt/index.tsx index bad1b95ef..b5716aae6 100644 --- a/apps/scandic-web/components/HotelReservation/BookingConfirmation/Receipt/index.tsx +++ b/apps/scandic-web/components/HotelReservation/BookingConfirmation/Receipt/index.tsx @@ -2,14 +2,13 @@ import { useIntl } from "react-intl" +import { useBookingConfirmationStore } from "@scandic-hotels/booking-flow/stores/booking-confirmation" import { longDateFormat } from "@scandic-hotels/common/constants/dateFormats" import { dt } from "@scandic-hotels/common/dt" import { Divider } from "@scandic-hotels/design-system/Divider" import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon" import { Typography } from "@scandic-hotels/design-system/Typography" -import { useBookingConfirmationStore } from "@/stores/booking-confirmation" - import useLang from "@/hooks/useLang" import Room from "./Room" diff --git a/apps/scandic-web/components/HotelReservation/BookingConfirmation/Rooms/LinkedReservation/index.tsx b/apps/scandic-web/components/HotelReservation/BookingConfirmation/Rooms/LinkedReservation/index.tsx index d13a90673..857466fc2 100644 --- a/apps/scandic-web/components/HotelReservation/BookingConfirmation/Rooms/LinkedReservation/index.tsx +++ b/apps/scandic-web/components/HotelReservation/BookingConfirmation/Rooms/LinkedReservation/index.tsx @@ -3,12 +3,11 @@ import { useEffect } from "react" import { useIntl } from "react-intl" +import { useBookingConfirmationStore } from "@scandic-hotels/booking-flow/stores/booking-confirmation" import { CurrencyEnum } from "@scandic-hotels/common/constants/currency" import { formatPrice } from "@scandic-hotels/common/utils/numberFormatting" import { trpc } from "@scandic-hotels/trpc/client" -import { useBookingConfirmationStore } from "@/stores/booking-confirmation" - import useLang from "@/hooks/useLang" import { mapRoomState } from "../../utils" diff --git a/apps/scandic-web/components/HotelReservation/BookingConfirmation/Rooms/Room/index.tsx b/apps/scandic-web/components/HotelReservation/BookingConfirmation/Rooms/Room/index.tsx index 76e748a5a..1424d4ca8 100644 --- a/apps/scandic-web/components/HotelReservation/BookingConfirmation/Rooms/Room/index.tsx +++ b/apps/scandic-web/components/HotelReservation/BookingConfirmation/Rooms/Room/index.tsx @@ -3,6 +3,7 @@ import { useIntl } from "react-intl" import { RoomDetailsSidePeek } from "@scandic-hotels/booking-flow/components/RoomDetailsSidePeek" +import { useBookingConfirmationStore } from "@scandic-hotels/booking-flow/stores/booking-confirmation" import { changeOrCancelDateFormat, longDateFormat, @@ -15,7 +16,6 @@ import { Typography } from "@scandic-hotels/design-system/Typography" import { getHotelRoom } from "@scandic-hotels/trpc/routers/booking/helpers" import { CancellationRuleEnum } from "@/constants/booking" -import { useBookingConfirmationStore } from "@/stores/booking-confirmation" import useLang from "@/hooks/useLang" diff --git a/apps/scandic-web/components/HotelReservation/BookingConfirmation/Tracking/index.tsx b/apps/scandic-web/components/HotelReservation/BookingConfirmation/Tracking/index.tsx index 67720d6f9..37a47955d 100644 --- a/apps/scandic-web/components/HotelReservation/BookingConfirmation/Tracking/index.tsx +++ b/apps/scandic-web/components/HotelReservation/BookingConfirmation/Tracking/index.tsx @@ -3,8 +3,7 @@ import { useEffect, useState } from "react" import { useSearchHistory } from "@scandic-hotels/booking-flow/hooks/useSearchHistory" - -import { useBookingConfirmationStore } from "@/stores/booking-confirmation" +import { useBookingConfirmationStore } from "@scandic-hotels/booking-flow/stores/booking-confirmation" import TrackingSDK from "@/components/TrackingSDK" import useLang from "@/hooks/useLang" @@ -12,10 +11,9 @@ import useLang from "@/hooks/useLang" import { clearPaymentInfoSessionStorage } from "../../EnterDetails/Payment/helpers" import { getTracking } from "./tracking" +import type { Room } from "@scandic-hotels/booking-flow/types/stores/booking-confirmation" import type { BookingConfirmation } from "@scandic-hotels/trpc/types/bookingConfirmation" -import type { Room } from "@/types/stores/booking-confirmation" - export default function Tracking({ bookingConfirmation, refId, diff --git a/apps/scandic-web/components/HotelReservation/BookingConfirmation/Tracking/tracking.ts b/apps/scandic-web/components/HotelReservation/BookingConfirmation/Tracking/tracking.ts index a18560648..7d9e9232e 100644 --- a/apps/scandic-web/components/HotelReservation/BookingConfirmation/Tracking/tracking.ts +++ b/apps/scandic-web/components/HotelReservation/BookingConfirmation/Tracking/tracking.ts @@ -19,12 +19,11 @@ import { CancellationRuleEnum } from "@/constants/booking" import { readPaymentInfoFromSessionStorage } from "@/components/HotelReservation/EnterDetails/Payment/helpers" import { getSpecialRoomType } from "@/utils/specialRoomType" +import type { Room } from "@scandic-hotels/booking-flow/types/stores/booking-confirmation" import type { Lang } from "@scandic-hotels/common/constants/language" import type { BookingConfirmation } from "@scandic-hotels/trpc/types/bookingConfirmation" import type { RateDefinition } from "@scandic-hotels/trpc/types/roomAvailability" -import type { Room } from "@/types/stores/booking-confirmation" - function getRate(cancellationRule: RateDefinition["cancellationRule"] | null) { switch (cancellationRule) { case "CancellableBefore6PM": diff --git a/apps/scandic-web/components/HotelReservation/BookingConfirmation/index.tsx b/apps/scandic-web/components/HotelReservation/BookingConfirmation/index.tsx index a6b0e32cc..8baa14eff 100644 --- a/apps/scandic-web/components/HotelReservation/BookingConfirmation/index.tsx +++ b/apps/scandic-web/components/HotelReservation/BookingConfirmation/index.tsx @@ -1,5 +1,6 @@ import { notFound } from "next/navigation" +import BookingConfirmationProvider from "@scandic-hotels/booking-flow/providers/BookingConfirmationProvider" import { filterOverlappingDates } from "@scandic-hotels/booking-flow/utils/SelectRate" import { AlertTypeEnum } from "@scandic-hotels/common/constants/alert" import { dt } from "@scandic-hotels/common/dt" @@ -15,7 +16,6 @@ import Receipt from "@/components/HotelReservation/BookingConfirmation/Receipt" import Rooms from "@/components/HotelReservation/BookingConfirmation/Rooms" import SidePanel from "@/components/HotelReservation/SidePanel" import { getIntl } from "@/i18n" -import BookingConfirmationProvider from "@/providers/BookingConfirmationProvider" import Confirmation from "./Confirmation" import Tracking from "./Tracking" diff --git a/apps/scandic-web/types/components/hotelReservation/bookingConfirmation/receipt.ts b/apps/scandic-web/types/components/hotelReservation/bookingConfirmation/receipt.ts index cb0743510..2162e3f66 100644 --- a/apps/scandic-web/types/components/hotelReservation/bookingConfirmation/receipt.ts +++ b/apps/scandic-web/types/components/hotelReservation/bookingConfirmation/receipt.ts @@ -1,4 +1,4 @@ -import type { Room } from "@/types/stores/booking-confirmation" +import type { Room } from "@scandic-hotels/booking-flow/types/stores/booking-confirmation" export interface BookingConfirmationReceiptRoomProps { room: Room diff --git a/apps/scandic-web/contexts/BookingConfirmation.ts b/packages/booking-flow/lib/contexts/BookingConfirmation.ts similarity index 61% rename from apps/scandic-web/contexts/BookingConfirmation.ts rename to packages/booking-flow/lib/contexts/BookingConfirmation.ts index f94e38cb7..b434caa1d 100644 --- a/apps/scandic-web/contexts/BookingConfirmation.ts +++ b/packages/booking-flow/lib/contexts/BookingConfirmation.ts @@ -1,6 +1,6 @@ import { createContext } from "react" -import type { BookingConfirmationStore } from "@/types/contexts/booking-confirmation" +import type { BookingConfirmationStore } from "../types/contexts/booking-confirmation" export const BookingConfirmationContext = createContext(null) diff --git a/apps/scandic-web/providers/BookingConfirmationProvider.tsx b/packages/booking-flow/lib/providers/BookingConfirmationProvider.tsx similarity index 89% rename from apps/scandic-web/providers/BookingConfirmationProvider.tsx rename to packages/booking-flow/lib/providers/BookingConfirmationProvider.tsx index b55284458..d8cda2ef7 100644 --- a/apps/scandic-web/providers/BookingConfirmationProvider.tsx +++ b/packages/booking-flow/lib/providers/BookingConfirmationProvider.tsx @@ -6,12 +6,11 @@ import { useIntl } from "react-intl" import { CurrencyEnum } from "@scandic-hotels/common/constants/currency" import { formatPrice } from "@scandic-hotels/common/utils/numberFormatting" -import { createBookingConfirmationStore } from "@/stores/booking-confirmation" +import { BookingConfirmationContext } from "../contexts/BookingConfirmation" +import { createBookingConfirmationStore } from "../stores/booking-confirmation" -import { BookingConfirmationContext } from "@/contexts/BookingConfirmation" - -import type { BookingConfirmationStore } from "@/types/contexts/booking-confirmation" -import type { BookingConfirmationProviderProps } from "@/types/providers/booking-confirmation" +import type { BookingConfirmationStore } from "../types/contexts/booking-confirmation" +import type { BookingConfirmationProviderProps } from "../types/providers/booking-confirmation" export default function BookingConfirmationProvider({ bookingCode, diff --git a/apps/scandic-web/stores/booking-confirmation/index.ts b/packages/booking-flow/lib/stores/booking-confirmation/index.ts similarity index 92% rename from apps/scandic-web/stores/booking-confirmation/index.ts rename to packages/booking-flow/lib/stores/booking-confirmation/index.ts index ec954f648..e5eda0520 100644 --- a/apps/scandic-web/stores/booking-confirmation/index.ts +++ b/packages/booking-flow/lib/stores/booking-confirmation/index.ts @@ -1,12 +1,12 @@ import { useContext } from "react" import { create, useStore } from "zustand" -import { BookingConfirmationContext } from "@/contexts/BookingConfirmation" +import { BookingConfirmationContext } from "../../contexts/BookingConfirmation" import type { BookingConfirmationState, InitialState, -} from "@/types/stores/booking-confirmation" +} from "../../types/stores/booking-confirmation" export function createBookingConfirmationStore(initialState: InitialState) { return create()((set) => ({ diff --git a/apps/scandic-web/types/contexts/booking-confirmation.ts b/packages/booking-flow/lib/types/contexts/booking-confirmation.ts similarity index 51% rename from apps/scandic-web/types/contexts/booking-confirmation.ts rename to packages/booking-flow/lib/types/contexts/booking-confirmation.ts index bd008c4c4..220a744e6 100644 --- a/apps/scandic-web/types/contexts/booking-confirmation.ts +++ b/packages/booking-flow/lib/types/contexts/booking-confirmation.ts @@ -1,4 +1,4 @@ -import type { createBookingConfirmationStore } from "@/stores/booking-confirmation" +import type { createBookingConfirmationStore } from "../../stores/booking-confirmation" export type BookingConfirmationStore = ReturnType< typeof createBookingConfirmationStore diff --git a/apps/scandic-web/types/providers/booking-confirmation.ts b/packages/booking-flow/lib/types/providers/booking-confirmation.ts similarity index 100% rename from apps/scandic-web/types/providers/booking-confirmation.ts rename to packages/booking-flow/lib/types/providers/booking-confirmation.ts diff --git a/apps/scandic-web/types/stores/booking-confirmation.ts b/packages/booking-flow/lib/types/stores/booking-confirmation.ts similarity index 100% rename from apps/scandic-web/types/stores/booking-confirmation.ts rename to packages/booking-flow/lib/types/stores/booking-confirmation.ts diff --git a/packages/booking-flow/package.json b/packages/booking-flow/package.json index d99034772..4604a4608 100644 --- a/packages/booking-flow/package.json +++ b/packages/booking-flow/package.json @@ -45,11 +45,14 @@ "./contexts/SelectRate/types": "./lib/contexts/SelectRate/types.ts", "./hooks/useSearchHistory": "./lib/hooks/useSearchHistory.ts", "./pages/*": "./lib/pages/*.tsx", + "./providers/BookingConfirmationProvider": "./lib/providers/BookingConfirmationProvider.tsx", "./searchType": "./lib/misc/searchType.ts", "./stores/bookingCode-filter": "./lib/stores/bookingCode-filter.ts", "./stores/hotels-map": "./lib/stores/hotels-map.ts", + "./stores/booking-confirmation": "./lib/stores/booking-confirmation/index.ts", "./types/components/selectRate/selectRate": "./lib/types/components/selectRate/selectRate.ts", "./types/stores/rates": "./lib/types/stores/rates.ts", + "./types/stores/booking-confirmation": "./lib/types/stores/booking-confirmation.ts", "./utils/isSameBooking": "./lib/utils/isSameBooking.ts", "./utils/url": "./lib/utils/url.ts", "./utils/SelectRate": "./lib/utils/SelectRate/index.tsx",