feat: SW-1588 No booking code search results UX
This commit is contained in:
@@ -18,7 +18,6 @@ export default function TabletCodeInput({
|
|||||||
{...register("bookingCode.value", {
|
{...register("bookingCode.value", {
|
||||||
onChange: (e) => updateValue(e.target.value),
|
onChange: (e) => updateValue(e.target.value),
|
||||||
})}
|
})}
|
||||||
defaultValue={defaultValue}
|
|
||||||
autoComplete="off"
|
autoComplete="off"
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
|
import { useSearchParams } from "next/navigation"
|
||||||
import { useSession } from "next-auth/react"
|
import { useSession } from "next-auth/react"
|
||||||
import { createElement } from "react"
|
import { createElement } from "react"
|
||||||
import { useIntl } from "react-intl"
|
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 type { RoomCardProps } from "@/types/components/hotelReservation/selectRate/roomCard"
|
||||||
import { RoomPackageCodeEnum } from "@/types/components/hotelReservation/selectRate/roomFilter"
|
import { RoomPackageCodeEnum } from "@/types/components/hotelReservation/selectRate/roomFilter"
|
||||||
import { HotelTypeEnum } from "@/types/enums/hotelType"
|
import { HotelTypeEnum } from "@/types/enums/hotelType"
|
||||||
import type { Product, RateDefinition } from "@/types/trpc/routers/hotel/roomAvailability"
|
|
||||||
import { RateTypeEnum } from "@/types/enums/rateType"
|
import { RateTypeEnum } from "@/types/enums/rateType"
|
||||||
import { useSearchParams } from "next/navigation"
|
import type {
|
||||||
|
Product,
|
||||||
|
RateDefinition,
|
||||||
|
} from "@/types/trpc/routers/hotel/roomAvailability"
|
||||||
|
|
||||||
function getBreakfastMessage(
|
function getBreakfastMessage(
|
||||||
publicBreakfastIncluded: boolean,
|
publicBreakfastIncluded: boolean,
|
||||||
@@ -181,14 +184,18 @@ export default function RoomCard({ roomConfiguration }: RoomCardProps) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getRateInfo(product: Product) {
|
function getRateInfo(product: Product) {
|
||||||
const rateDefinition = rateDefinitions?.filter((rateDefinition) =>
|
const rateDefinition = rateDefinitions?.filter(
|
||||||
|
(rateDefinition) =>
|
||||||
rateDefinition.rateCode === product.productType.public.rateCode
|
rateDefinition.rateCode === product.productType.public.rateCode
|
||||||
)[0]
|
)[0]
|
||||||
if (
|
if (
|
||||||
!product.productType.public.rateCode &&
|
!product.productType.public.rateCode &&
|
||||||
!product.productType.member?.rateCode
|
!product.productType.member?.rateCode
|
||||||
) {
|
) {
|
||||||
const possibleRate = getRate(product.productType.public.rate, rateDefinition)
|
const possibleRate = getRate(
|
||||||
|
product.productType.public.rate,
|
||||||
|
rateDefinition
|
||||||
|
)
|
||||||
if (possibleRate) {
|
if (possibleRate) {
|
||||||
return {
|
return {
|
||||||
...possibleRate,
|
...possibleRate,
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
"use client"
|
"use client"
|
||||||
import { useIntl } from "react-intl"
|
|
||||||
import { useSearchParams } from "next/navigation"
|
import { useSearchParams } from "next/navigation"
|
||||||
|
import { useIntl } from "react-intl"
|
||||||
|
|
||||||
import { alternativeHotels } from "@/constants/routes/hotelReservation"
|
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 BookingCodeFilter from "@/components/HotelReservation/SelectHotel/BookingCodeFilter"
|
||||||
|
import Alert from "@/components/TempDesignSystem/Alert"
|
||||||
import { useRoomContext } from "@/contexts/Room"
|
import { useRoomContext } from "@/contexts/Room"
|
||||||
import useLang from "@/hooks/useLang"
|
import useLang from "@/hooks/useLang"
|
||||||
|
|
||||||
@@ -16,9 +17,8 @@ import styles from "./roomSelectionPanel.module.css"
|
|||||||
|
|
||||||
import { AvailabilityEnum } from "@/types/components/hotelReservation/selectHotel/selectHotel"
|
import { AvailabilityEnum } from "@/types/components/hotelReservation/selectHotel/selectHotel"
|
||||||
import { AlertTypeEnum } from "@/types/enums/alert"
|
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 { BookingCodeFilterEnum } from "@/types/enums/bookingCodeFilter"
|
||||||
|
import { RateTypeEnum } from "@/types/enums/rateType"
|
||||||
|
|
||||||
export default function RoomSelectionPanel() {
|
export default function RoomSelectionPanel() {
|
||||||
const { rooms } = useRoomContext()
|
const { rooms } = useRoomContext()
|
||||||
@@ -29,15 +29,18 @@ export default function RoomSelectionPanel() {
|
|||||||
const noAvailableRooms = rooms.every(
|
const noAvailableRooms = rooms.every(
|
||||||
(roomConfig) => roomConfig.status === AvailabilityEnum.NotAvailable
|
(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) {
|
if (bookingCode) {
|
||||||
isRegularRatesAvailableWithCode =
|
isRegularRatesAvailableWithCode = bookingCode
|
||||||
!!bookingCode ?
|
? rooms?.some((room) => {
|
||||||
rooms?.some((room) => {
|
|
||||||
return (
|
return (
|
||||||
room.status === "Available" &&
|
room.status === AvailabilityEnum.Available &&
|
||||||
room.products.some(
|
room.products.some(
|
||||||
(product) =>
|
(product) =>
|
||||||
product.productType.public.rateType === RateTypeEnum.Regular
|
product.productType.public.rateType === RateTypeEnum.Regular
|
||||||
@@ -46,28 +49,61 @@ export default function RoomSelectionPanel() {
|
|||||||
})
|
})
|
||||||
: false
|
: false
|
||||||
|
|
||||||
filteredRooms = !isRegularRatesAvailableWithCode || activeCodeFilter === BookingCodeFilterEnum.All
|
noAvailabilityWithBookingCode = bookingCode
|
||||||
? rooms : rooms.filter((room) => {
|
? !rooms?.some((room) => {
|
||||||
return room.products.every(
|
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) =>
|
(product) =>
|
||||||
(activeCodeFilter === BookingCodeFilterEnum.Discounted &&
|
(activeCodeFilter === BookingCodeFilterEnum.Discounted &&
|
||||||
product.productType.public.rateType !== RateTypeEnum.Regular) ||
|
product.productType.public.rateType !==
|
||||||
|
RateTypeEnum.Regular) ||
|
||||||
(activeCodeFilter === BookingCodeFilterEnum.Regular &&
|
(activeCodeFilter === BookingCodeFilterEnum.Regular &&
|
||||||
product.productType.public.rateType === RateTypeEnum.Regular)
|
product.productType.public.rateType ===
|
||||||
|
RateTypeEnum.Regular)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{noAvailableRooms ? (
|
{noAvailableRooms ||
|
||||||
|
(bookingCode &&
|
||||||
|
isRegularRatesAvailableWithCode &&
|
||||||
|
noAvailabilityWithBookingCode) ? (
|
||||||
<div className={styles.hotelAlert}>
|
<div className={styles.hotelAlert}>
|
||||||
<Alert
|
<Alert
|
||||||
type={AlertTypeEnum.Info}
|
type={AlertTypeEnum.Info}
|
||||||
heading={intl.formatMessage({ id: "No availability" })}
|
heading={intl.formatMessage({ id: "No availability" })}
|
||||||
text={intl.formatMessage({
|
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.",
|
id: "There are no rooms available that match your request.",
|
||||||
})}
|
})
|
||||||
|
}
|
||||||
link={{
|
link={{
|
||||||
title: intl.formatMessage({ id: "See alternative hotels" }),
|
title: intl.formatMessage({ id: "See alternative hotels" }),
|
||||||
url: `${alternativeHotels(lang)}`,
|
url: `${alternativeHotels(lang)}`,
|
||||||
@@ -77,7 +113,11 @@ export default function RoomSelectionPanel() {
|
|||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
<RoomTypeFilter />
|
<RoomTypeFilter />
|
||||||
{bookingCode && isRegularRatesAvailableWithCode ? <BookingCodeFilter /> : null}
|
{bookingCode &&
|
||||||
|
isRegularRatesAvailableWithCode &&
|
||||||
|
!noAvailabilityWithBookingCode ? (
|
||||||
|
<BookingCodeFilter />
|
||||||
|
) : null}
|
||||||
<ul className={styles.roomList}>
|
<ul className={styles.roomList}>
|
||||||
{filteredRooms.map((roomConfiguration) => (
|
{filteredRooms.map((roomConfiguration) => (
|
||||||
<RoomCard
|
<RoomCard
|
||||||
|
|||||||
@@ -670,6 +670,7 @@
|
|||||||
"We could not connect your accounts": "We could not connect your accounts",
|
"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 we’ll help you resolve this issue.": "We could not connect your accounts to give you access. Please contact us and we’ll help you resolve this issue.",
|
"We could not connect your accounts to give you access. Please contact us and we’ll help you resolve this issue.": "We could not connect your accounts to give you access. Please contact us and we’ll 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 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 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 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!",
|
"We look forward to your visit!": "Vi ser frem til dit besøg!",
|
||||||
|
|||||||
@@ -671,6 +671,7 @@
|
|||||||
"We could not connect your accounts": "We could not connect your accounts",
|
"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 we’ll help you resolve this issue.": "We could not connect your accounts to give you access. Please contact us and we’ll help you resolve this issue.",
|
"We could not connect your accounts to give you access. Please contact us and we’ll help you resolve this issue.": "We could not connect your accounts to give you access. Please contact us and we’ll 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 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 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 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!",
|
"We look forward to your visit!": "Wir freuen uns auf Ihren Besuch!",
|
||||||
|
|||||||
@@ -677,6 +677,7 @@
|
|||||||
"We could not connect your accounts": "We could not connect your accounts",
|
"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 we’ll help you resolve this issue.": "We could not connect your accounts to give you access. Please contact us and we’ll help you resolve this issue.",
|
"We could not connect your accounts to give you access. Please contact us and we’ll help you resolve this issue.": "We could not connect your accounts to give you access. Please contact us and we’ll 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 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 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 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!",
|
"We look forward to your visit!": "We look forward to your visit!",
|
||||||
|
|||||||
@@ -671,6 +671,7 @@
|
|||||||
"We could not connect your accounts": "We could not connect your accounts",
|
"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 we’ll help you resolve this issue.": "We could not connect your accounts to give you access. Please contact us and we’ll help you resolve this issue.",
|
"We could not connect your accounts to give you access. Please contact us and we’ll help you resolve this issue.": "We could not connect your accounts to give you access. Please contact us and we’ll help you resolve this issue.",
|
||||||
"We couldn't find a matching location for your search.": "Emme löytäneet hakuasi vastaavaa sijaintia.",
|
"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 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 have a special gift waiting for you!": "Meillä on erityinen lahja odottamassa sinua!",
|
||||||
"We look forward to your visit!": "Odotamme innolla vierailuasi!",
|
"We look forward to your visit!": "Odotamme innolla vierailuasi!",
|
||||||
|
|||||||
@@ -667,6 +667,7 @@
|
|||||||
"We could not connect your accounts": "We could not connect your accounts",
|
"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 we’ll help you resolve this issue.": "We could not connect your accounts to give you access. Please contact us and we’ll help you resolve this issue.",
|
"We could not connect your accounts to give you access. Please contact us and we’ll help you resolve this issue.": "We could not connect your accounts to give you access. Please contact us and we’ll 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 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 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 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!",
|
"We look forward to your visit!": "Vi ser frem til ditt besøk!",
|
||||||
|
|||||||
@@ -667,6 +667,7 @@
|
|||||||
"We could not connect your accounts": "We could not connect your accounts",
|
"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 we’ll help you resolve this issue.": "We could not connect your accounts to give you access. Please contact us and we’ll help you resolve this issue.",
|
"We could not connect your accounts to give you access. Please contact us and we’ll help you resolve this issue.": "We could not connect your accounts to give you access. Please contact us and we’ll 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 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 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 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!",
|
"We look forward to your visit!": "Vi ser fram emot ditt besök!",
|
||||||
|
|||||||
Reference in New Issue
Block a user