fix(SW-690): use correct naming of search params in booking
Approved-by: Bianca Widstam Approved-by: Linus Flood
This commit is contained in:
@@ -17,11 +17,11 @@ export default async function SelectRatePage({
|
|||||||
}: PageArgs<LangParams & { section: string }, SelectRateSearchParams>) {
|
}: PageArgs<LangParams & { section: string }, SelectRateSearchParams>) {
|
||||||
setLang(params.lang)
|
setLang(params.lang)
|
||||||
|
|
||||||
const selecetRoomParams = new URLSearchParams(searchParams)
|
const selectRoomParams = new URLSearchParams(searchParams)
|
||||||
const selecetRoomParamsObject =
|
const selectRoomParamsObject =
|
||||||
getHotelReservationQueryParams(selecetRoomParams)
|
getHotelReservationQueryParams(selectRoomParams)
|
||||||
const adults = selecetRoomParamsObject.room[0].adults // TODO: Handle multiple rooms
|
const adults = selectRoomParamsObject.room[0].adults // TODO: Handle multiple rooms
|
||||||
const children = selecetRoomParamsObject.room[0].child.length // TODO: Handle multiple rooms
|
const children = selectRoomParamsObject.room[0].child?.length // TODO: Handle multiple rooms
|
||||||
|
|
||||||
const [hotelData, roomConfigurations, user] = await Promise.all([
|
const [hotelData, roomConfigurations, user] = await Promise.all([
|
||||||
serverClient().hotel.hotelData.get({
|
serverClient().hotel.hotelData.get({
|
||||||
@@ -33,8 +33,8 @@ export default async function SelectRatePage({
|
|||||||
hotelId: parseInt(searchParams.hotel, 10),
|
hotelId: parseInt(searchParams.hotel, 10),
|
||||||
roomStayStartDate: searchParams.fromDate,
|
roomStayStartDate: searchParams.fromDate,
|
||||||
roomStayEndDate: searchParams.toDate,
|
roomStayEndDate: searchParams.toDate,
|
||||||
adults: adults,
|
adults,
|
||||||
children: children,
|
children,
|
||||||
}),
|
}),
|
||||||
getProfileSafely(),
|
getProfileSafely(),
|
||||||
])
|
])
|
||||||
|
|||||||
@@ -42,8 +42,8 @@ export default function BookingWidgetClient({
|
|||||||
date: {
|
date: {
|
||||||
// UTC is required to handle requests from far away timezones https://scandichotels.atlassian.net/browse/SWAP-6375 & PET-507
|
// UTC is required to handle requests from far away timezones https://scandichotels.atlassian.net/browse/SWAP-6375 & PET-507
|
||||||
// This is specifically to handle timezones falling in different dates.
|
// This is specifically to handle timezones falling in different dates.
|
||||||
from: dt().utc().format("YYYY-MM-DD"),
|
fromDate: dt().utc().format("YYYY-MM-DD"),
|
||||||
to: dt().utc().add(1, "day").format("YYYY-MM-DD"),
|
toDate: dt().utc().add(1, "day").format("YYYY-MM-DD"),
|
||||||
},
|
},
|
||||||
bookingCode: "",
|
bookingCode: "",
|
||||||
redemption: false,
|
redemption: false,
|
||||||
|
|||||||
@@ -44,22 +44,22 @@ export default function DatePickerForm({ name = "date" }: DatePickerFormProps) {
|
|||||||
function handleSelectDate(selected: Date) {
|
function handleSelectDate(selected: Date) {
|
||||||
if (isSelectingFrom) {
|
if (isSelectingFrom) {
|
||||||
setValue(name, {
|
setValue(name, {
|
||||||
from: dt(selected).format("YYYY-MM-DD"),
|
fromDate: dt(selected).format("YYYY-MM-DD"),
|
||||||
to: undefined,
|
toDate: undefined,
|
||||||
})
|
})
|
||||||
setIsSelectingFrom(false)
|
setIsSelectingFrom(false)
|
||||||
} else {
|
} else {
|
||||||
const fromDate = dt(selectedDate.from)
|
const fromDate = dt(selectedDate.fromDate)
|
||||||
const toDate = dt(selected)
|
const toDate = dt(selected)
|
||||||
if (toDate.isAfter(fromDate)) {
|
if (toDate.isAfter(fromDate)) {
|
||||||
setValue(name, {
|
setValue(name, {
|
||||||
from: selectedDate.from,
|
fromDate: selectedDate.fromDate,
|
||||||
to: toDate.format("YYYY-MM-DD"),
|
toDate: toDate.format("YYYY-MM-DD"),
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
setValue(name, {
|
setValue(name, {
|
||||||
from: toDate.format("YYYY-MM-DD"),
|
fromDate: toDate.format("YYYY-MM-DD"),
|
||||||
to: selectedDate.from,
|
toDate: selectedDate.fromDate,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
setIsSelectingFrom(true)
|
setIsSelectingFrom(true)
|
||||||
@@ -79,11 +79,11 @@ export default function DatePickerForm({ name = "date" }: DatePickerFormProps) {
|
|||||||
}
|
}
|
||||||
}, [setIsOpen])
|
}, [setIsOpen])
|
||||||
|
|
||||||
const selectedFromDate = dt(selectedDate.from)
|
const selectedFromDate = dt(selectedDate.fromDate)
|
||||||
.locale(lang)
|
.locale(lang)
|
||||||
.format("ddd D MMM")
|
.format("ddd D MMM")
|
||||||
const selectedToDate = !!selectedDate.to
|
const selectedToDate = !!selectedDate.toDate
|
||||||
? dt(selectedDate.to).locale(lang).format("ddd D MMM")
|
? dt(selectedDate.toDate).locale(lang).format("ddd D MMM")
|
||||||
: ""
|
: ""
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -93,8 +93,8 @@ export default function DatePickerForm({ name = "date" }: DatePickerFormProps) {
|
|||||||
{selectedFromDate} - {selectedToDate}
|
{selectedFromDate} - {selectedToDate}
|
||||||
</Body>
|
</Body>
|
||||||
</button>
|
</button>
|
||||||
<input {...register("date.from")} type="hidden" />
|
<input {...register("date.fromDate")} type="hidden" />
|
||||||
<input {...register("date.to")} type="hidden" />
|
<input {...register("date.toDate")} type="hidden" />
|
||||||
<div aria-modal className={styles.hideWrapper} role="dialog">
|
<div aria-modal className={styles.hideWrapper} role="dialog">
|
||||||
<DatePickerDesktop
|
<DatePickerDesktop
|
||||||
close={close}
|
close={close}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ export default function FormContent({
|
|||||||
|
|
||||||
const rooms = intl.formatMessage({ id: "Guests & Rooms" })
|
const rooms = intl.formatMessage({ id: "Guests & Rooms" })
|
||||||
|
|
||||||
const nights = dt(selectedDate.to).diff(dt(selectedDate.from), "days")
|
const nights = dt(selectedDate.toDate).diff(dt(selectedDate.fromDate), "days")
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ export const bookingWidgetSchema = z.object({
|
|||||||
bookingCode: z.string(), // Update this as required when working with booking codes component
|
bookingCode: z.string(), // Update this as required when working with booking codes component
|
||||||
date: z.object({
|
date: z.object({
|
||||||
// Update this as required once started working with Date picker in Nights component
|
// Update this as required once started working with Date picker in Nights component
|
||||||
from: z.string(),
|
fromDate: z.string(),
|
||||||
to: z.string(),
|
toDate: z.string(),
|
||||||
}),
|
}),
|
||||||
location: z.string().refine(
|
location: z.string().refine(
|
||||||
(value) => {
|
(value) => {
|
||||||
|
|||||||
@@ -105,7 +105,11 @@ export default async function HotelCard({ hotel }: HotelCardProps) {
|
|||||||
className={styles.button}
|
className={styles.button}
|
||||||
>
|
>
|
||||||
{/* TODO: Localize link and also use correct search params */}
|
{/* TODO: Localize link and also use correct search params */}
|
||||||
<Link href="/en/hotelreservation/select-rate" color="none">
|
<Link
|
||||||
|
href={`/en/hotelreservation/select-rate?hotel=${hotelData.operaId}`}
|
||||||
|
color="none"
|
||||||
|
keepSearchParams
|
||||||
|
>
|
||||||
{intl.formatMessage({ id: "See rooms" })}
|
{intl.formatMessage({ id: "See rooms" })}
|
||||||
</Link>
|
</Link>
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -51,9 +51,10 @@ export default function Link({
|
|||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|
||||||
const fullUrl = useMemo(() => {
|
const fullUrl = useMemo(() => {
|
||||||
const search =
|
if (!keepSearchParams || !searchParams.size) return href
|
||||||
keepSearchParams && searchParams.size ? `?${searchParams}` : ""
|
|
||||||
return `${href}${search}`
|
const delimiter = href.includes("?") ? "&" : "?"
|
||||||
|
return `${href}${delimiter}${searchParams}`
|
||||||
}, [href, searchParams, keepSearchParams])
|
}, [href, searchParams, keepSearchParams])
|
||||||
|
|
||||||
// TODO: Remove this check (and hook) and only return <Link /> when current web is deleted
|
// TODO: Remove this check (and hook) and only return <Link /> when current web is deleted
|
||||||
|
|||||||
@@ -7,9 +7,9 @@ interface Child {
|
|||||||
|
|
||||||
interface Room {
|
interface Room {
|
||||||
adults: number
|
adults: number
|
||||||
roomtypecode: string
|
roomcode?: string
|
||||||
ratecode: string
|
ratecode?: string
|
||||||
child: Child[]
|
child?: Child[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SelectRateSearchParams {
|
export interface SelectRateSearchParams {
|
||||||
|
|||||||
Reference in New Issue
Block a user