Merged in feat/sw-2879-booking-widget-to-booking-flow-package (pull request #2532)
feat(SW-2879): Move BookingWidget to booking-flow package * Fix lockfile * Fix styling * a tiny little booking widget test * Tiny fixes * Merge branch 'master' into feat/sw-2879-booking-widget-to-booking-flow-package * Remove unused scripts * lint:fix * Merge branch 'master' into feat/sw-2879-booking-widget-to-booking-flow-package * Tiny lint fixes * update test * Update Input in booking-flow * Clean up comments etc * Merge branch 'master' into feat/sw-2879-booking-widget-to-booking-flow-package * Setup tracking context for booking-flow * Add missing use client * Fix temp tracking function * Pass booking to booking-widget * Remove comment * Add use client to booking widget tracking provider * Add use client to tracking functions * Merge branch 'master' into feat/sw-2879-booking-widget-to-booking-flow-package * Move debug page * Merge branch 'master' into feat/sw-2879-booking-widget-to-booking-flow-package * Merge branch 'master' into feat/sw-2879-booking-widget-to-booking-flow-package * Merge branch 'master' into feat/sw-2879-booking-widget-to-booking-flow-package Approved-by: Bianca Widstam
This commit is contained in:
@@ -1,15 +0,0 @@
|
||||
import { create } from "zustand"
|
||||
|
||||
import { BookingCodeFilterEnum } from "@/types/enums/bookingCodeFilter"
|
||||
|
||||
interface BookingCodeFilterState {
|
||||
activeCodeFilter: keyof typeof BookingCodeFilterEnum
|
||||
setFilter: (filter: BookingCodeFilterEnum) => void
|
||||
}
|
||||
|
||||
export const useBookingCodeFilterStore = create<BookingCodeFilterState>(
|
||||
(set) => ({
|
||||
activeCodeFilter: BookingCodeFilterEnum.Discounted,
|
||||
setFilter: (filter) => set({ activeCodeFilter: filter }),
|
||||
})
|
||||
)
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
|
||||
import { detailsStorageName } from "."
|
||||
|
||||
import type { BookingWidgetSearchData } from "@scandic-hotels/booking-flow/BookingWidget"
|
||||
import type { Packages } from "@scandic-hotels/trpc/types/packages"
|
||||
import type {
|
||||
CorporateChequeProduct,
|
||||
@@ -20,7 +21,6 @@ import type {
|
||||
VoucherProduct,
|
||||
} from "@scandic-hotels/trpc/types/roomAvailability"
|
||||
|
||||
import type { BookingWidgetSearchData } from "@/types/components/bookingWidget"
|
||||
import type { BreakfastPackage } from "@/types/components/hotelReservation/breakfast"
|
||||
import { type RoomRate } from "@/types/components/hotelReservation/enterDetails/details"
|
||||
import type { Price } from "@/types/components/hotelReservation/price"
|
||||
|
||||
@@ -3,9 +3,10 @@ import { produce } from "immer"
|
||||
import { useContext } from "react"
|
||||
import { create, useStore } from "zustand"
|
||||
|
||||
import { getDefaultCountryFromLang } from "@/constants/languages"
|
||||
import { dt } from "@scandic-hotels/common/dt"
|
||||
|
||||
import { getDefaultCountryFromLang } from "@/constants/languages"
|
||||
|
||||
import { DetailsContext } from "@/contexts/Details"
|
||||
|
||||
import {
|
||||
@@ -16,6 +17,8 @@ import {
|
||||
writeToSessionStorage,
|
||||
} from "./helpers"
|
||||
|
||||
import type { Lang } from "@scandic-hotels/common/constants/language"
|
||||
|
||||
import type { BreakfastPackages } from "@/types/components/hotelReservation/breakfast"
|
||||
import type { Price } from "@/types/components/hotelReservation/price"
|
||||
import { StepEnum } from "@/types/enums/step"
|
||||
@@ -25,7 +28,6 @@ import type {
|
||||
RoomState,
|
||||
} from "@/types/stores/enter-details"
|
||||
import type { SafeUser } from "@/types/user"
|
||||
import type { Lang } from "@/constants/routes/hotelReservation"
|
||||
|
||||
const defaultGuestState = {
|
||||
countryCode: "",
|
||||
|
||||
@@ -2,12 +2,13 @@ import { produce } from "immer"
|
||||
import { useContext } from "react"
|
||||
import { create, useStore } from "zustand"
|
||||
|
||||
import { BookingCodeFilterEnum } from "@scandic-hotels/booking-flow/stores/bookingCode-filter"
|
||||
import { serializeBookingSearchParams } from "@scandic-hotels/booking-flow/utils/url"
|
||||
import { SEARCH_TYPE_REDEMPTION } from "@scandic-hotels/trpc/constants/booking"
|
||||
import { RoomPackageCodeEnum } from "@scandic-hotels/trpc/enums/roomFilter"
|
||||
import { AvailabilityEnum } from "@scandic-hotels/trpc/enums/selectHotel"
|
||||
|
||||
import { RatesContext } from "@/contexts/Rates"
|
||||
import { serializeBookingSearchParams } from "@/utils/url"
|
||||
|
||||
import {
|
||||
findDefaultCurrency,
|
||||
@@ -18,7 +19,6 @@ import {
|
||||
import type { Package, Packages } from "@scandic-hotels/trpc/types/packages"
|
||||
import type { PriceProduct } from "@scandic-hotels/trpc/types/roomAvailability"
|
||||
|
||||
import { BookingCodeFilterEnum } from "@/types/enums/bookingCodeFilter"
|
||||
import type { InitialState, RatesState } from "@/types/stores/rates"
|
||||
|
||||
export function createRatesStore({
|
||||
|
||||
@@ -1,84 +0,0 @@
|
||||
import { create } from "zustand"
|
||||
|
||||
export enum StickyElementNameEnum {
|
||||
SITEWIDE_ALERT = "SITEWIDE_ALERT",
|
||||
BOOKING_WIDGET = "BOOKING_WIDGET",
|
||||
MEETING_PACKAGE_WIDGET = "MEETING_PACKAGE_WIDGET",
|
||||
HOTEL_TAB_NAVIGATION = "HOTEL_TAB_NAVIGATION",
|
||||
HOTEL_STATIC_MAP = "HOTEL_STATIC_MAP",
|
||||
DESTINATION_SIDEBAR = "DESTINATION_SIDEBAR",
|
||||
}
|
||||
|
||||
export interface StickyElement {
|
||||
height: number
|
||||
ref: React.RefObject<HTMLElement | null>
|
||||
group: string
|
||||
priority: number
|
||||
name: StickyElementNameEnum
|
||||
}
|
||||
|
||||
interface StickyStore {
|
||||
stickyElements: StickyElement[]
|
||||
registerSticky: (
|
||||
ref: React.RefObject<HTMLElement | null>,
|
||||
name: StickyElementNameEnum,
|
||||
group: string
|
||||
) => void
|
||||
unregisterSticky: (ref: React.RefObject<HTMLElement | null>) => void
|
||||
updateHeights: () => void
|
||||
getAllElements: () => Array<StickyElement>
|
||||
}
|
||||
|
||||
// Map to define priorities based on StickyElementNameEnum
|
||||
const priorityMap: Record<StickyElementNameEnum, number> = {
|
||||
[StickyElementNameEnum.SITEWIDE_ALERT]: 1,
|
||||
[StickyElementNameEnum.BOOKING_WIDGET]: 2,
|
||||
|
||||
[StickyElementNameEnum.HOTEL_TAB_NAVIGATION]: 3,
|
||||
[StickyElementNameEnum.HOTEL_STATIC_MAP]: 3,
|
||||
|
||||
[StickyElementNameEnum.MEETING_PACKAGE_WIDGET]: 3,
|
||||
[StickyElementNameEnum.DESTINATION_SIDEBAR]: 3,
|
||||
}
|
||||
|
||||
const useStickyPositionStore = create<StickyStore>((set, get) => ({
|
||||
stickyElements: [],
|
||||
registerSticky: (ref, name, group) => {
|
||||
const priority = priorityMap[name] || 0
|
||||
|
||||
set((state) => {
|
||||
const newStickyElement: StickyElement = {
|
||||
height: ref.current?.offsetHeight || 0,
|
||||
ref,
|
||||
group,
|
||||
priority,
|
||||
name,
|
||||
}
|
||||
|
||||
const updatedStickyElements = [
|
||||
...state.stickyElements,
|
||||
newStickyElement,
|
||||
].sort((a, b) => a.priority - b.priority)
|
||||
|
||||
return {
|
||||
stickyElements: updatedStickyElements,
|
||||
}
|
||||
})
|
||||
},
|
||||
unregisterSticky: (ref) => {
|
||||
set((state) => ({
|
||||
stickyElements: state.stickyElements.filter((el) => el.ref !== ref),
|
||||
}))
|
||||
},
|
||||
updateHeights: () => {
|
||||
set((state) => ({
|
||||
stickyElements: state.stickyElements.map((el) => ({
|
||||
...el,
|
||||
height: el.ref.current?.offsetHeight || el.height,
|
||||
})),
|
||||
}))
|
||||
},
|
||||
getAllElements: () => get().stickyElements,
|
||||
}))
|
||||
|
||||
export default useStickyPositionStore
|
||||
@@ -5,7 +5,7 @@ import { create } from "zustand"
|
||||
import {
|
||||
parseBookingWidgetSearchParams,
|
||||
searchParamsToRecord,
|
||||
} from "@/utils/url"
|
||||
} from "@scandic-hotels/booking-flow/utils/url"
|
||||
|
||||
import { checkIsSameBooking } from "./enter-details/helpers"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user