Calculating correct duration, leadtime etc depending on dates
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
import { differenceInCalendarDays,isWeekend } from "date-fns"
|
||||||
|
|
||||||
import { Lang } from "@/constants/languages"
|
import { Lang } from "@/constants/languages"
|
||||||
import { selectHotelMap } from "@/constants/routes/hotelReservation"
|
import { selectHotelMap } from "@/constants/routes/hotelReservation"
|
||||||
|
|
||||||
@@ -29,6 +31,8 @@ export default async function SelectHotelPage({
|
|||||||
setLang(params.lang)
|
setLang(params.lang)
|
||||||
|
|
||||||
const tempSearchTerm = "Stockholm"
|
const tempSearchTerm = "Stockholm"
|
||||||
|
const tempArrivalDate = new Date("2024-10-25")
|
||||||
|
const tempDepartureDate = new Date("2024-10-25")
|
||||||
const intl = await getIntl()
|
const intl = await getIntl()
|
||||||
|
|
||||||
const hotels = await fetchAvailableHotels({
|
const hotels = await fetchAvailableHotels({
|
||||||
@@ -52,15 +56,15 @@ export default async function SelectHotelPage({
|
|||||||
const hotelsTrackingData: TrackingSDKHotelInfo = {
|
const hotelsTrackingData: TrackingSDKHotelInfo = {
|
||||||
availableResults: hotels.length,
|
availableResults: hotels.length,
|
||||||
searchTerm: tempSearchTerm,
|
searchTerm: tempSearchTerm,
|
||||||
arrivalDate: new Date("2025-05-02"),
|
arrivalDate: tempArrivalDate,
|
||||||
departureDate: new Date("2025-05-03"),
|
departureDate: tempDepartureDate,
|
||||||
noOfAdults: 1,
|
noOfAdults: 1, // TODO: Use values from searchParams
|
||||||
noOfChildren: 0,
|
noOfChildren: 0, // TODO: Use values from searchParams
|
||||||
noOfRooms: 1,
|
noOfRooms: 1, // TODO: Use values from searchParams
|
||||||
duration: 1,
|
duration: differenceInCalendarDays(tempDepartureDate, tempArrivalDate),
|
||||||
leadTime: 187,
|
leadTime: differenceInCalendarDays(tempArrivalDate, new Date()),
|
||||||
searchType: "hotel",
|
searchType: "destination",
|
||||||
bookingTypeofDay: "weekend",
|
bookingTypeofDay: isWeekend(tempArrivalDate) ? "weekend" : "weekday",
|
||||||
country: hotels[0].hotelData.address.country,
|
country: hotels[0].hotelData.address.country,
|
||||||
region: hotels[0].hotelData.address.city,
|
region: hotels[0].hotelData.address.city,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user