fix: apply logic for full prices filter
This commit is contained in:
committed by
Michael Zetterberg
parent
3942ab1ff4
commit
8a7c55edff
@@ -29,11 +29,11 @@ export default function BookingCodeFilter() {
|
||||
value: BookingCodeFilterEnum.Discounted,
|
||||
},
|
||||
{
|
||||
label: intl.formatMessage({ id: "Full price rooms" }),
|
||||
label: intl.formatMessage({ id: "Full-priced rooms" }),
|
||||
value: BookingCodeFilterEnum.Regular,
|
||||
},
|
||||
{
|
||||
label: intl.formatMessage({ id: "See all" }),
|
||||
label: intl.formatMessage({ id: "All rooms" }),
|
||||
value: BookingCodeFilterEnum.All,
|
||||
},
|
||||
]
|
||||
|
||||
@@ -44,6 +44,14 @@ export default function Campaign({
|
||||
|
||||
const night = intl.formatMessage({ id: "night" }).toUpperCase()
|
||||
|
||||
if (selectedFilter === BookingCodeFilterEnum.Discounted) {
|
||||
campaign = campaign.filter((product) => product.bookingCode)
|
||||
}
|
||||
|
||||
if (selectedFilter === BookingCodeFilterEnum.Regular) {
|
||||
campaign = campaign.filter((product) => !product.bookingCode)
|
||||
}
|
||||
|
||||
return campaign.map((product) => {
|
||||
if (!product.public) {
|
||||
return (
|
||||
|
||||
@@ -17,6 +17,7 @@ import {
|
||||
import { calculatePricePerNightPriceProduct } from "./totalPricePerNight"
|
||||
|
||||
import type { SharedRateCardProps } from "@/types/components/hotelReservation/selectRate/rates"
|
||||
import { BookingCodeFilterEnum } from "@/types/enums/bookingCodeFilter"
|
||||
import type { CodeProduct } from "@/types/trpc/routers/hotel/roomAvailability"
|
||||
|
||||
interface CodeProps extends SharedRateCardProps {
|
||||
@@ -31,11 +32,15 @@ export default function Code({
|
||||
roomTypeCode,
|
||||
}: CodeProps) {
|
||||
const intl = useIntl()
|
||||
const { roomNr, selectedRate } = useRoomContext()
|
||||
const { roomNr, selectedFilter, selectedRate } = useRoomContext()
|
||||
const bookingCode = useRatesStore((state) => state.booking.bookingCode)
|
||||
const rateTitles = useRateTitles()
|
||||
const night = intl.formatMessage({ id: "night" }).toUpperCase()
|
||||
|
||||
if (selectedFilter === BookingCodeFilterEnum.Regular) {
|
||||
return null
|
||||
}
|
||||
|
||||
return code.map((product) => {
|
||||
let bannerText = ""
|
||||
if (product.rateDefinition.breakfastIncluded) {
|
||||
|
||||
@@ -25,6 +25,7 @@ export default function Redemptions({
|
||||
|
||||
if (
|
||||
selectedFilter === BookingCodeFilterEnum.Discounted ||
|
||||
selectedFilter === BookingCodeFilterEnum.Regular ||
|
||||
!redemptions.length
|
||||
) {
|
||||
return null
|
||||
|
||||
@@ -58,11 +58,16 @@ export default function Rates({
|
||||
roomTypeCode,
|
||||
}
|
||||
const showAllRates = selectedFilter === BookingCodeFilterEnum.All
|
||||
const showRegularRates = selectedFilter === BookingCodeFilterEnum.Regular
|
||||
const hasBookingCodeRates = !!(campaign.length || code.length)
|
||||
const hasRegularRates = !!regular.length
|
||||
const notDiscountedPrice = showAllRates || showRegularRates
|
||||
const notDiscountedAndHasRates =
|
||||
notDiscountedPrice && hasBookingCodeRates && hasRegularRates
|
||||
const isFetchingAndOnlyShowingRegularRates =
|
||||
isFetchingAdditionalRate && !showRegularRates
|
||||
const showDivider =
|
||||
(showAllRates && hasBookingCodeRates && hasRegularRates) ||
|
||||
isFetchingAdditionalRate
|
||||
notDiscountedAndHasRates || isFetchingAndOnlyShowingRegularRates
|
||||
|
||||
return (
|
||||
<>
|
||||
|
||||
Reference in New Issue
Block a user