fix: prevent phone input from running validation on mount when empty

This commit is contained in:
Simon Emanuelsson
2024-10-31 13:39:08 +01:00
parent eb0494c2a2
commit 46a1874a76
8 changed files with 56 additions and 35 deletions

View File

@@ -1,5 +1,3 @@
import { notFound } from "next/navigation"
import {
getProfileSafely,
getSelectedRoomAvailability,
@@ -12,7 +10,6 @@ import { SelectRateSearchParams } from "@/types/components/hotelReservation/sele
import { LangParams, PageArgs, SearchParams } from "@/types/params"
export default async function SummaryPage({
params,
searchParams,
}: PageArgs<LangParams, SearchParams<SelectRateSearchParams>>) {
const selectRoomParams = new URLSearchParams(searchParams)
@@ -38,25 +35,25 @@ export default async function SummaryPage({
const prices = user
? {
local: {
price: availability.memberRate?.localPrice.pricePerStay,
currency: availability.memberRate?.localPrice.currency,
},
euro: {
price: availability.memberRate?.requestedPrice?.pricePerStay,
currency: availability.memberRate?.requestedPrice?.currency,
},
}
local: {
price: availability.memberRate?.localPrice.pricePerStay,
currency: availability.memberRate?.localPrice.currency,
},
euro: {
price: availability.memberRate?.requestedPrice?.pricePerStay,
currency: availability.memberRate?.requestedPrice?.currency,
},
}
: {
local: {
price: availability.publicRate?.localPrice.pricePerStay,
currency: availability.publicRate?.localPrice.currency,
},
euro: {
price: availability.publicRate?.requestedPrice?.pricePerStay,
currency: availability.publicRate?.requestedPrice?.currency,
},
}
local: {
price: availability.publicRate?.localPrice.pricePerStay,
currency: availability.publicRate?.localPrice.currency,
},
euro: {
price: availability.publicRate?.requestedPrice?.pricePerStay,
currency: availability.publicRate?.requestedPrice?.currency,
},
}
return (
<Summary

View File

@@ -49,7 +49,8 @@ export default async function StepPage({
toDate,
} = getQueryParamsForEnterDetails(selectRoomParams)
void getBreakfastPackages(searchParams.hotel)
const breakfastInput = { adults, fromDate, hotelId, toDate }
void getBreakfastPackages(breakfastInput)
void getSelectedRoomAvailability({
hotelId: parseInt(searchParams.hotel),
adults,
@@ -74,7 +75,7 @@ export default async function StepPage({
rateCode,
roomTypeCode,
})
const breakfastPackages = await getBreakfastPackages(searchParams.hotel)
const breakfastPackages = await getBreakfastPackages(breakfastInput)
const user = await getProfileSafely()
const savedCreditCards = await getCreditCardsSafely()