Merged in fix/refetching-availability-on-select (pull request #2204)
don't use rateCode to determine if bookingCode should come from the room or the 'big' input * don't use rateCode to determine if bookingCode should come from the room or the 'big' input Approved-by: Linus Flood
This commit is contained in:
@@ -4,6 +4,7 @@ import { useSearchParams } from "next/navigation"
|
||||
import { useIntl } from "react-intl"
|
||||
|
||||
import { trpc } from "@/lib/trpc/client"
|
||||
import { selectRateRoomsAvailabilityInputSchema } from "@/server/routers/hotels/input"
|
||||
|
||||
import Alert from "@/components/TempDesignSystem/Alert"
|
||||
import useLang from "@/hooks/useLang"
|
||||
@@ -33,29 +34,32 @@ export function RoomsContainer({
|
||||
searchParamsToRecord(searchParams)
|
||||
)
|
||||
|
||||
const { data, isFetching, isError, error } =
|
||||
trpc.hotel.availability.selectRate.rooms.useQuery(
|
||||
{
|
||||
booking,
|
||||
lang,
|
||||
},
|
||||
{
|
||||
retry(failureCount, error) {
|
||||
if (error.data?.code === "BAD_REQUEST") {
|
||||
return false
|
||||
}
|
||||
const bookingInput = selectRateRoomsAvailabilityInputSchema.safeParse({
|
||||
booking,
|
||||
lang,
|
||||
})
|
||||
|
||||
return failureCount <= 3
|
||||
},
|
||||
}
|
||||
)
|
||||
const { data, isFetching, isError, error } =
|
||||
trpc.hotel.availability.selectRate.rooms.useQuery(bookingInput.data!, {
|
||||
retry(failureCount, error) {
|
||||
if (error.data?.code === "BAD_REQUEST") {
|
||||
return false
|
||||
}
|
||||
|
||||
return failureCount <= 3
|
||||
},
|
||||
enabled: bookingInput.success,
|
||||
})
|
||||
|
||||
if (isFetching) {
|
||||
return <RoomsContainerSkeleton />
|
||||
}
|
||||
|
||||
if (isError) {
|
||||
const errorMessage = getErrorMessage(error.data?.zodError?.formErrors, intl)
|
||||
if (isError || !bookingInput.success) {
|
||||
const errorMessage = getErrorMessage(
|
||||
error?.data?.zodError?.formErrors,
|
||||
intl
|
||||
)
|
||||
|
||||
return (
|
||||
<div className={styles.errorContainer}>
|
||||
|
||||
Reference in New Issue
Block a user