feat: SW-1588 No booking code search results UX

This commit is contained in:
Hrishikesh Vaipurkar
2025-02-17 13:47:58 +01:00
parent 8966e56820
commit a7443e5750
9 changed files with 84 additions and 32 deletions

View File

@@ -18,7 +18,6 @@ export default function TabletCodeInput({
{...register("bookingCode.value", {
onChange: (e) => updateValue(e.target.value),
})}
defaultValue={defaultValue}
autoComplete="off"
/>
)

View File

@@ -1,5 +1,6 @@
"use client"
import { useSearchParams } from "next/navigation"
import { useSession } from "next-auth/react"
import { createElement } from "react"
import { useIntl } from "react-intl"
@@ -28,9 +29,11 @@ import { AvailabilityEnum } from "@/types/components/hotelReservation/selectHote
import type { RoomCardProps } from "@/types/components/hotelReservation/selectRate/roomCard"
import { RoomPackageCodeEnum } from "@/types/components/hotelReservation/selectRate/roomFilter"
import { HotelTypeEnum } from "@/types/enums/hotelType"
import type { Product, RateDefinition } from "@/types/trpc/routers/hotel/roomAvailability"
import { RateTypeEnum } from "@/types/enums/rateType"
import { useSearchParams } from "next/navigation"
import type {
Product,
RateDefinition,
} from "@/types/trpc/routers/hotel/roomAvailability"
function getBreakfastMessage(
publicBreakfastIncluded: boolean,
@@ -181,14 +184,18 @@ export default function RoomCard({ roomConfiguration }: RoomCardProps) {
}
function getRateInfo(product: Product) {
const rateDefinition = rateDefinitions?.filter((rateDefinition) =>
rateDefinition.rateCode === product.productType.public.rateCode
const rateDefinition = rateDefinitions?.filter(
(rateDefinition) =>
rateDefinition.rateCode === product.productType.public.rateCode
)[0]
if (
!product.productType.public.rateCode &&
!product.productType.member?.rateCode
) {
const possibleRate = getRate(product.productType.public.rate, rateDefinition)
const possibleRate = getRate(
product.productType.public.rate,
rateDefinition
)
if (possibleRate) {
return {
...possibleRate,

View File

@@ -1,11 +1,12 @@
"use client"
import { useIntl } from "react-intl"
import { useSearchParams } from "next/navigation"
import { useIntl } from "react-intl"
import { alternativeHotels } from "@/constants/routes/hotelReservation"
import { useBookingCodeFilterStore } from "@/stores/bookingCode-filter"
import Alert from "@/components/TempDesignSystem/Alert"
import BookingCodeFilter from "@/components/HotelReservation/SelectHotel/BookingCodeFilter"
import Alert from "@/components/TempDesignSystem/Alert"
import { useRoomContext } from "@/contexts/Room"
import useLang from "@/hooks/useLang"
@@ -16,9 +17,8 @@ import styles from "./roomSelectionPanel.module.css"
import { AvailabilityEnum } from "@/types/components/hotelReservation/selectHotel/selectHotel"
import { AlertTypeEnum } from "@/types/enums/alert"
import { RateTypeEnum } from "@/types/enums/rateType"
import { useBookingCodeFilterStore } from "@/stores/bookingCode-filter"
import { BookingCodeFilterEnum } from "@/types/enums/bookingCodeFilter"
import { RateTypeEnum } from "@/types/enums/rateType"
export default function RoomSelectionPanel() {
const { rooms } = useRoomContext()
@@ -29,45 +29,81 @@ export default function RoomSelectionPanel() {
const noAvailableRooms = rooms.every(
(roomConfig) => roomConfig.status === AvailabilityEnum.NotAvailable
)
const activeCodeFilter = useBookingCodeFilterStore((state) => state.activeCodeFilter)
const activeCodeFilter = useBookingCodeFilterStore(
(state) => state.activeCodeFilter
)
let filteredRooms = rooms, isRegularRatesAvailableWithCode: boolean = false
let filteredRooms = rooms,
isRegularRatesAvailableWithCode: boolean = false,
noAvailabilityWithBookingCode: boolean = false
if (bookingCode) {
isRegularRatesAvailableWithCode =
!!bookingCode ?
rooms?.some((room) => {
isRegularRatesAvailableWithCode = bookingCode
? rooms?.some((room) => {
return (
room.status === "Available" &&
room.status === AvailabilityEnum.Available &&
room.products.some(
(product) =>
product.productType.public.rateType === RateTypeEnum.Regular
)
)
})
: false
: false
filteredRooms = !isRegularRatesAvailableWithCode || activeCodeFilter === BookingCodeFilterEnum.All
? rooms : rooms.filter((room) => {
return room.products.every(
(product) =>
(activeCodeFilter === BookingCodeFilterEnum.Discounted &&
product.productType.public.rateType !== RateTypeEnum.Regular) ||
(activeCodeFilter === BookingCodeFilterEnum.Regular &&
product.productType.public.rateType === RateTypeEnum.Regular)
)
})
noAvailabilityWithBookingCode = bookingCode
? !rooms?.some((room) => {
return (
room.status === AvailabilityEnum.Available &&
room.products.some(
(product) =>
product.productType.public.rateType !== RateTypeEnum.Regular
)
)
})
: false
filteredRooms =
noAvailabilityWithBookingCode ||
!isRegularRatesAvailableWithCode ||
activeCodeFilter === BookingCodeFilterEnum.All
? rooms
: rooms.filter((room) => {
return (
room.status === AvailabilityEnum.Available &&
room.products.every(
(product) =>
(activeCodeFilter === BookingCodeFilterEnum.Discounted &&
product.productType.public.rateType !==
RateTypeEnum.Regular) ||
(activeCodeFilter === BookingCodeFilterEnum.Regular &&
product.productType.public.rateType ===
RateTypeEnum.Regular)
)
)
})
}
return (
<>
{noAvailableRooms ? (
{noAvailableRooms ||
(bookingCode &&
isRegularRatesAvailableWithCode &&
noAvailabilityWithBookingCode) ? (
<div className={styles.hotelAlert}>
<Alert
type={AlertTypeEnum.Info}
heading={intl.formatMessage({ id: "No availability" })}
text={intl.formatMessage({
id: "There are no rooms available that match your request.",
})}
text={
noAvailabilityWithBookingCode
? intl.formatMessage(
{
id: "We found no available rooms using this booking code ({bookingCode}). See available rates below.",
},
{ bookingCode }
)
: intl.formatMessage({
id: "There are no rooms available that match your request.",
})
}
link={{
title: intl.formatMessage({ id: "See alternative hotels" }),
url: `${alternativeHotels(lang)}`,
@@ -77,7 +113,11 @@ export default function RoomSelectionPanel() {
</div>
) : null}
<RoomTypeFilter />
{bookingCode && isRegularRatesAvailableWithCode ? <BookingCodeFilter /> : null}
{bookingCode &&
isRegularRatesAvailableWithCode &&
!noAvailabilityWithBookingCode ? (
<BookingCodeFilter />
) : null}
<ul className={styles.roomList}>
{filteredRooms.map((roomConfiguration) => (
<RoomCard

View File

@@ -670,6 +670,7 @@
"We could not connect your accounts": "We could not connect your accounts",
"We could not connect your accounts to give you access. Please contact us and well help you resolve this issue.": "We could not connect your accounts to give you access. Please contact us and well help you resolve this issue.",
"We couldn't find a matching location for your search.": "Vi kunne ikke finde en matchende lokation til din søgning.",
"We found no available rooms using this booking code ({bookingCode}). See available rates below.": "Vi fandt desværre ingen ledige værelser. Vi fandt ingen ledige værelser med denne bookingkode ({bookingCode}). Se ledige værelser nedenfor.",
"We had an issue processing your booking. Please try again. No charges have been made.": "Vi havde et problem med at behandle din booking. Prøv venligst igen. Ingen gebyrer er blevet opkrævet.",
"We have a special gift waiting for you!": "Vi har en speciel gave, der venter på dig!",
"We look forward to your visit!": "Vi ser frem til dit besøg!",

View File

@@ -671,6 +671,7 @@
"We could not connect your accounts": "We could not connect your accounts",
"We could not connect your accounts to give you access. Please contact us and well help you resolve this issue.": "We could not connect your accounts to give you access. Please contact us and well help you resolve this issue.",
"We couldn't find a matching location for your search.": "Wir konnten keinen passenden Standort für Ihre Suche finden.",
"We found no available rooms using this booking code ({bookingCode}). See available rates below.": "Wir haben keine verfügbaren Zimmer zur Buchung mit dem Buchungscode ({bookingCode}) gefunden. Unten sehen Sie Preise, die ohne Buchungscode verfügbar sind.",
"We had an issue processing your booking. Please try again. No charges have been made.": "Wir hatten ein Problem beim Verarbeiten Ihrer Buchung. Bitte versuchen Sie es erneut. Es wurden keine Gebühren erhoben.",
"We have a special gift waiting for you!": "Wir haben ein besonderes Geschenk für Sie!",
"We look forward to your visit!": "Wir freuen uns auf Ihren Besuch!",

View File

@@ -677,6 +677,7 @@
"We could not connect your accounts": "We could not connect your accounts",
"We could not connect your accounts to give you access. Please contact us and well help you resolve this issue.": "We could not connect your accounts to give you access. Please contact us and well help you resolve this issue.",
"We couldn't find a matching location for your search.": "We couldn't find a matching location for your search.",
"We found no available rooms using this booking code ({bookingCode}). See available rates below.": "We found no available rooms using this booking code ({bookingCode}). See available rates below.",
"We had an issue processing your booking. Please try again. No charges have been made.": "We had an issue processing your booking. Please try again. No charges have been made.",
"We have a special gift waiting for you!": "We have a special gift waiting for you!",
"We look forward to your visit!": "We look forward to your visit!",

View File

@@ -671,6 +671,7 @@
"We could not connect your accounts": "We could not connect your accounts",
"We could not connect your accounts to give you access. Please contact us and well help you resolve this issue.": "We could not connect your accounts to give you access. Please contact us and well help you resolve this issue.",
"We couldn't find a matching location for your search.": "Emme löytäneet hakuasi vastaavaa sijaintia.",
"We found no available rooms using this booking code ({bookingCode}). See available rates below.": "Emme löytäneet huoneita varauskoodilla ({bookingCode}). Katso saatavilla olevat hinnat alla.",
"We had an issue processing your booking. Please try again. No charges have been made.": "Meillä oli ongelma varauksen käsittelyssä. Yritä uudelleen. Ei maksuja on tehty.",
"We have a special gift waiting for you!": "Meillä on erityinen lahja odottamassa sinua!",
"We look forward to your visit!": "Odotamme innolla vierailuasi!",

View File

@@ -667,6 +667,7 @@
"We could not connect your accounts": "We could not connect your accounts",
"We could not connect your accounts to give you access. Please contact us and well help you resolve this issue.": "We could not connect your accounts to give you access. Please contact us and well help you resolve this issue.",
"We couldn't find a matching location for your search.": "Vi finner ikke et sted som samsvarer for søket ditt.",
"We found no available rooms using this booking code ({bookingCode}). See available rates below.": "Vi fant ingen tilgjengelige rom ved bruk av denne bookingkoden. Vennligst sjekk at bookingkoden du har skrevet inn er riktig. Se tilgjengelige priser nedenfor.",
"We had an issue processing your booking. Please try again. No charges have been made.": "Vi hadde et problem med å behandle din bestilling. Vær så snill å prøv igjen. Ingen gebyrer er blevet belastet.",
"We have a special gift waiting for you!": "Vi har en spesiell gave som venter på deg!",
"We look forward to your visit!": "Vi ser frem til ditt besøk!",

View File

@@ -667,6 +667,7 @@
"We could not connect your accounts": "We could not connect your accounts",
"We could not connect your accounts to give you access. Please contact us and well help you resolve this issue.": "We could not connect your accounts to give you access. Please contact us and well help you resolve this issue.",
"We couldn't find a matching location for your search.": "Vi kunde inte hitta en plats som matchade din sökning.",
"We found no available rooms using this booking code ({bookingCode}). See available rates below.": "Din bokningskod {bookingCode} finns inte tillgänglig. Se tillgängliga rum nedan.",
"We had an issue processing your booking. Please try again. No charges have been made.": "Vi hade ett problem med att bearbeta din bokning. Vänligen försök igen. Inga avgifter har debiterats.",
"We have a special gift waiting for you!": "Vi har en speciell present som väntar på dig!",
"We look forward to your visit!": "Vi ser fram emot ditt besök!",