From 658afd0327020883cd4083989b5a3f6dd53e5459 Mon Sep 17 00:00:00 2001 From: Christel Westerberg Date: Thu, 12 Dec 2024 15:38:05 +0100 Subject: [PATCH 01/21] fix: handle cases with counterRateCode missing --- .../HotelReservation/EnterDetails/Payment/PaymentClient.tsx | 4 +++- components/HotelReservation/EnterDetails/Summary/UI/index.tsx | 2 +- types/components/hotelReservation/enterDetails/bookingData.ts | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/components/HotelReservation/EnterDetails/Payment/PaymentClient.tsx b/components/HotelReservation/EnterDetails/Payment/PaymentClient.tsx index 635f7c775..dd244b473 100644 --- a/components/HotelReservation/EnterDetails/Payment/PaymentClient.tsx +++ b/components/HotelReservation/EnterDetails/Payment/PaymentClient.tsx @@ -217,7 +217,9 @@ export default function PaymentClient({ bedType: bedTypeMap[parseInt(child.bed.toString())], })), rateCode: - user || join || membershipNo ? room.counterRateCode : room.rateCode, + (user || join || membershipNo) && room.counterRateCode + ? room.counterRateCode + : room.rateCode, roomTypeCode: bedType!.roomTypeCode, // A selection has been made in order to get to this step. guest: { firstName, diff --git a/components/HotelReservation/EnterDetails/Summary/UI/index.tsx b/components/HotelReservation/EnterDetails/Summary/UI/index.tsx index 5a84dde6e..90dc0775d 100644 --- a/components/HotelReservation/EnterDetails/Summary/UI/index.tsx +++ b/components/HotelReservation/EnterDetails/Summary/UI/index.tsx @@ -67,7 +67,7 @@ export default function SummaryUI({ } : null - const showMemberPrice = !!(isMember || join || membershipNo) + const showMemberPrice = !!(isMember || join || membershipNo) && memberPrice const diff = dt(booking.toDate).diff(booking.fromDate, "days") diff --git a/types/components/hotelReservation/enterDetails/bookingData.ts b/types/components/hotelReservation/enterDetails/bookingData.ts index c78b5c90e..12760e765 100644 --- a/types/components/hotelReservation/enterDetails/bookingData.ts +++ b/types/components/hotelReservation/enterDetails/bookingData.ts @@ -5,7 +5,7 @@ interface Room { adults: number roomTypeCode: string rateCode: string - counterRateCode: string + counterRateCode?: string children?: Child[] packages?: RoomPackageCodeEnum[] } From 8534405358603914700dbbdc48883c47794c4877 Mon Sep 17 00:00:00 2001 From: Christel Westerberg Date: Thu, 12 Dec 2024 15:41:29 +0100 Subject: [PATCH 02/21] fix: reset searchparams after errorcode from planet --- hooks/booking/usePaymentFailedToast.ts | 15 ++++++++++++++- stores/enter-details/index.ts | 18 +++++++++++++----- types/stores/enter-details.ts | 4 +++- 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/hooks/booking/usePaymentFailedToast.ts b/hooks/booking/usePaymentFailedToast.ts index 961ab0c2b..806c3d5a2 100644 --- a/hooks/booking/usePaymentFailedToast.ts +++ b/hooks/booking/usePaymentFailedToast.ts @@ -5,10 +5,14 @@ import { useCallback, useEffect } from "react" import { useIntl } from "react-intl" import { PaymentErrorCodeEnum } from "@/constants/booking" +import { useEnterDetailsStore } from "@/stores/enter-details" import { toast } from "@/components/TempDesignSystem/Toasts" export function usePaymentFailedToast() { + const updateSearchParams = useEnterDetailsStore( + (state) => state.actions.updateSeachParamString + ) const intl = useIntl() const searchParams = useSearchParams() const pathname = usePathname() @@ -43,6 +47,15 @@ export function usePaymentFailedToast() { const queryParams = new URLSearchParams(searchParams.toString()) queryParams.delete("errorCode") + + updateSearchParams(queryParams.toString()) router.push(`${pathname}?${queryParams.toString()}`) - }, [searchParams, pathname, errorCode, errorMessage, router]) + }, [ + searchParams, + pathname, + errorCode, + errorMessage, + router, + updateSearchParams, + ]) } diff --git a/stores/enter-details/index.ts b/stores/enter-details/index.ts index a469eb4f0..b2480471b 100644 --- a/stores/enter-details/index.ts +++ b/stores/enter-details/index.ts @@ -133,7 +133,7 @@ export function createDetailsStore( const currentStepIndex = state.steps.indexOf(state.currentStep) const nextStep = state.steps[currentStepIndex + 1] state.currentStep = nextStep - navigate(nextStep, searchParams) + navigate(nextStep, state.searchParamString) }) ) }, @@ -141,7 +141,7 @@ export function createDetailsStore( return set( produce((state) => { state.currentStep = step - navigate(step, searchParams) + navigate(step, state.searchParamString) }) ) }, @@ -185,7 +185,7 @@ export function createDetailsStore( const currentStepIndex = state.steps.indexOf(state.currentStep) const nextStep = state.steps[currentStepIndex + 1] state.currentStep = nextStep - navigate(nextStep, searchParams) + navigate(nextStep, state.searchParamString) }) ) }, @@ -266,7 +266,7 @@ export function createDetailsStore( const currentStepIndex = state.steps.indexOf(state.currentStep) const nextStep = state.steps[currentStepIndex + 1] state.currentStep = nextStep - navigate(nextStep, searchParams) + navigate(nextStep, state.searchParamString) }) ) }, @@ -304,11 +304,19 @@ export function createDetailsStore( const currentStepIndex = state.steps.indexOf(state.currentStep) const nextStep = state.steps[currentStepIndex + 1] state.currentStep = nextStep - navigate(nextStep, searchParams) + navigate(nextStep, state.searchParamString) + }) + ) + }, + updateSeachParamString(searchParamString) { + return set( + produce((state: DetailsState) => { + state.searchParamString = searchParamString }) ) }, }, + searchParamString: searchParams, bedType: initialState.bedType ?? undefined, booking: initialState.booking, breakfast: diff --git a/types/stores/enter-details.ts b/types/stores/enter-details.ts index 9793d902a..e507ab146 100644 --- a/types/stores/enter-details.ts +++ b/types/stores/enter-details.ts @@ -5,7 +5,7 @@ import type { DetailsSchema, SignedInDetailsSchema, } from "@/types/components/hotelReservation/enterDetails/details" -import { StepEnum } from "@/types/enums/step" +import type { StepEnum } from "@/types/enums/step" import type { DetailsProviderProps } from "../providers/enter-details" import type { Packages } from "../requests/packages" @@ -37,6 +37,7 @@ export interface DetailsState { updateBedType: (data: BedTypeSchema) => void updateBreakfast: (data: BreakfastPackage | false) => void updateDetails: (data: DetailsSchema) => void + updateSeachParamString: (searchParamString: string) => void } bedType: BedTypeSchema | undefined booking: BookingData @@ -52,6 +53,7 @@ export interface DetailsState { roomPrice: Price steps: StepEnum[] totalPrice: Price + searchParamString: string } export type InitialState = Pick & From 6dc807d0b21303cd9073017188142af6c2b4c4a1 Mon Sep 17 00:00:00 2001 From: Tobias Johansson Date: Fri, 13 Dec 2024 09:58:09 +0100 Subject: [PATCH 03/21] fix: added default image for hotel images --- server/routers/hotels/output.ts | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/server/routers/hotels/output.ts b/server/routers/hotels/output.ts index 17c7eb263..47bfb9e45 100644 --- a/server/routers/hotels/output.ts +++ b/server/routers/hotels/output.ts @@ -1,6 +1,6 @@ import { z } from "zod" -import { ChildBedTypeEnum, PaymentMethodEnum } from "@/constants/booking" +import { ChildBedTypeEnum ,type PaymentMethodEnum } from "@/constants/booking" import { dt } from "@/lib/dt" import { toLang } from "@/server/utils" @@ -99,10 +99,25 @@ const locationSchema = z.object({ }) const hotelContentSchema = z.object({ - images: z.object({ - metaData: imageMetaDataSchema, - imageSizes: imageSizesSchema, - }), + images: z + .object({ + metaData: imageMetaDataSchema, + imageSizes: imageSizesSchema, + }) + .default({ + metaData: { + title: "", + altText: "", + altText_En: "", + copyRight: "", + }, + imageSizes: { + tiny: "https://placehold.co/1280x720", + small: "https://placehold.co/1280x720", + medium: "https://placehold.co/1280x720", + large: "https://placehold.co/1280x720", + }, + }), texts: z.object({ facilityInformation: z.string().optional(), surroundingInformation: z.string(), From aa8cfe86c4a0873c0a80a9cf354cd96d16c2816a Mon Sep 17 00:00:00 2001 From: Tobias Johansson Date: Fri, 13 Dec 2024 10:02:28 +0100 Subject: [PATCH 04/21] fix: added placeholder meta data --- server/routers/hotels/output.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/server/routers/hotels/output.ts b/server/routers/hotels/output.ts index 47bfb9e45..1bffd3543 100644 --- a/server/routers/hotels/output.ts +++ b/server/routers/hotels/output.ts @@ -1,6 +1,6 @@ import { z } from "zod" -import { ChildBedTypeEnum ,type PaymentMethodEnum } from "@/constants/booking" +import { ChildBedTypeEnum, type PaymentMethodEnum } from "@/constants/booking" import { dt } from "@/lib/dt" import { toLang } from "@/server/utils" @@ -106,10 +106,10 @@ const hotelContentSchema = z.object({ }) .default({ metaData: { - title: "", - altText: "", - altText_En: "", - copyRight: "", + title: "default image", + altText: "default image", + altText_En: "default image", + copyRight: "default image", }, imageSizes: { tiny: "https://placehold.co/1280x720", From ec0c6234ef7cf05c270e5e173551b6de9fe83e0f Mon Sep 17 00:00:00 2001 From: Bianca Widstam Date: Fri, 13 Dec 2024 10:21:59 +0000 Subject: [PATCH 05/21] Merged in fix/SW-1119-select-room-same-currency (pull request #1075) fix(SW-1119): remove approx currency if same and synchronize price option height * fix(SW-1119): remove approx currency if same and synchronize price option height * fix(SW-1119): use debounce and observer for performance * fix(SW-1119): export selector variable to utils Approved-by: Pontus Dreij Approved-by: Niclas Edenvin --- .../FlexibilityOption/PriceList/index.tsx | 32 ++++---- .../RoomSelection/FlexibilityOption/index.tsx | 11 ++- .../SelectRate/RoomSelection/index.tsx | 76 +++++++++++++++++-- .../SelectRate/RoomSelection/utils.ts | 2 + 4 files changed, 95 insertions(+), 26 deletions(-) diff --git a/components/HotelReservation/SelectRate/RoomSelection/FlexibilityOption/PriceList/index.tsx b/components/HotelReservation/SelectRate/RoomSelection/FlexibilityOption/PriceList/index.tsx index a201a44b1..eff2e3717 100644 --- a/components/HotelReservation/SelectRate/RoomSelection/FlexibilityOption/PriceList/index.tsx +++ b/components/HotelReservation/SelectRate/RoomSelection/FlexibilityOption/PriceList/index.tsx @@ -28,7 +28,10 @@ export default function PriceList({ const petRoomLocalPrice = petRoomPackage?.localPrice const petRoomRequestedPrice = petRoomPackage?.requestedPrice - const showRequestedPrice = publicRequestedPrice && memberRequestedPrice + const showRequestedPrice = + publicRequestedPrice && + memberRequestedPrice && + publicRequestedPrice.currency !== publicLocalPrice.currency const searchParams = useSearchParams() const fromDate = searchParams.get("fromDate") const toDate = searchParams.get("toDate") @@ -114,27 +117,22 @@ export default function PriceList({ )} - -
-
- - {intl.formatMessage({ id: "Approx." })} - -
-
- {showRequestedPrice ? ( + {showRequestedPrice && ( +
+
+ + {intl.formatMessage({ id: "Approx." })} + +
+
{totalPublicRequestedPricePerNight}/ {totalMemberRequestedPricePerNight}{" "} {publicRequestedPrice.currency} - ) : ( - - / - EUR - )} -
-
+ + + )} ) } diff --git a/components/HotelReservation/SelectRate/RoomSelection/FlexibilityOption/index.tsx b/components/HotelReservation/SelectRate/RoomSelection/FlexibilityOption/index.tsx index 1a227d568..5e13bd1e9 100644 --- a/components/HotelReservation/SelectRate/RoomSelection/FlexibilityOption/index.tsx +++ b/components/HotelReservation/SelectRate/RoomSelection/FlexibilityOption/index.tsx @@ -7,6 +7,7 @@ import Label from "@/components/TempDesignSystem/Form/Label" import Popover from "@/components/TempDesignSystem/Popover" import Caption from "@/components/TempDesignSystem/Text/Caption" +import { rateCardEqualHeightSelector } from "../utils" import PriceTable from "./PriceList" import styles from "./flexibilityOption.module.css" @@ -26,11 +27,13 @@ export default function FlexibilityOption({ if (!product) { return ( -
+
- {name} - ({paymentTerm}) +
+ {name} + ({paymentTerm}) +