feat: SW-2028 Updated validations at trpc query level
This commit is contained in:
@@ -44,7 +44,6 @@ function HotelCard({
|
||||
state = "default",
|
||||
type = HotelCardListingTypeEnum.PageListing,
|
||||
bookingCode = "",
|
||||
userPoints,
|
||||
}: HotelCardProps) {
|
||||
const params = useParams()
|
||||
const lang = params.lang as Lang
|
||||
@@ -74,13 +73,7 @@ function HotelCard({
|
||||
availability.productType?.member?.rateType === RateTypeEnum.Regular
|
||||
const price = availability.productType
|
||||
|
||||
const userHasEnoughPoints =
|
||||
userPoints !== undefined
|
||||
? !!price?.redemptions?.some(
|
||||
(r) => r.localPrice.pointsPerStay < userPoints
|
||||
)
|
||||
: false
|
||||
|
||||
const userHasEnoughPoints = price?.redemptions?.some((r) => r.hasEnoughPoints)
|
||||
const notEnoughPointsLabel = intl.formatMessage({ id: "Not enough points" })
|
||||
|
||||
return (
|
||||
@@ -218,7 +211,7 @@ function HotelCard({
|
||||
))}
|
||||
</div>
|
||||
) : null}
|
||||
{userPoints !== undefined && !userHasEnoughPoints ? (
|
||||
{price?.redemptions?.length && !userHasEnoughPoints ? (
|
||||
<Tooltip
|
||||
arrow="left"
|
||||
position="bottom"
|
||||
|
||||
@@ -30,7 +30,6 @@ import { RateTypeEnum } from "@/types/enums/rateType"
|
||||
export default function HotelCardListing({
|
||||
hotelData,
|
||||
type = HotelCardListingTypeEnum.PageListing,
|
||||
userPoints,
|
||||
}: HotelCardListingProps) {
|
||||
const { data: session } = useSession()
|
||||
const isUserLoggedIn = isValidClientSession(session)
|
||||
@@ -122,7 +121,6 @@ export default function HotelCardListing({
|
||||
}
|
||||
type={type}
|
||||
bookingCode={bookingCode}
|
||||
userPoints={userPoints}
|
||||
/>
|
||||
</div>
|
||||
))
|
||||
|
||||
@@ -246,14 +246,6 @@ export async function getHotels(
|
||||
return hotels
|
||||
}
|
||||
|
||||
export async function getUserPoints() {
|
||||
const membershipCard = await serverClient().user.safeMembershipLevel()
|
||||
if (!membershipCard) {
|
||||
return undefined
|
||||
}
|
||||
return membershipCard.currentPoints
|
||||
}
|
||||
|
||||
const hotelSurroundingsFilterNames = [
|
||||
"Hotel surroundings",
|
||||
"Hotel omgivelser",
|
||||
|
||||
@@ -23,7 +23,7 @@ import { convertObjToSearchParams } from "@/utils/url"
|
||||
|
||||
import HotelCardListing from "../HotelCardListing"
|
||||
import BookingCodeFilter from "./BookingCodeFilter"
|
||||
import { getFiltersFromHotels, getHotels, getUserPoints } from "./helpers"
|
||||
import { getFiltersFromHotels, getHotels } from "./helpers"
|
||||
import HotelCount from "./HotelCount"
|
||||
import HotelFilter from "./HotelFilter"
|
||||
import HotelSorter from "./HotelSorter"
|
||||
@@ -76,11 +76,6 @@ export default async function SelectHotel({
|
||||
!!redemption
|
||||
)
|
||||
|
||||
let userPoints
|
||||
if (redemption) {
|
||||
userPoints = await getUserPoints()
|
||||
}
|
||||
|
||||
const arrivalDate = new Date(selectHotelParams.fromDate)
|
||||
const departureDate = new Date(selectHotelParams.toDate)
|
||||
|
||||
@@ -252,10 +247,7 @@ export default async function SelectHotel({
|
||||
isAllUnavailable={isAllUnavailable}
|
||||
operaId={hotels?.[0]?.hotel.operaId}
|
||||
/>
|
||||
<HotelCardListing
|
||||
hotelData={hotels}
|
||||
userPoints={userPoints ? userPoints : undefined}
|
||||
/>
|
||||
<HotelCardListing hotelData={hotels} />
|
||||
</div>
|
||||
</main>
|
||||
<Suspense key={`${suspenseKey}-tracking`} fallback={null}>
|
||||
|
||||
Reference in New Issue
Block a user