From ac4b10464754517ccf2d0b46110012e49fbcc073 Mon Sep 17 00:00:00 2001 From: Linus Flood Date: Fri, 18 Oct 2024 14:49:12 +0200 Subject: [PATCH] Calculating correct duration, leadtime etc depending on dates --- .../hotelreservation/select-hotel/page.tsx | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/app/[lang]/(live)/(public)/hotelreservation/select-hotel/page.tsx b/app/[lang]/(live)/(public)/hotelreservation/select-hotel/page.tsx index 881d270bc..039ed68a6 100644 --- a/app/[lang]/(live)/(public)/hotelreservation/select-hotel/page.tsx +++ b/app/[lang]/(live)/(public)/hotelreservation/select-hotel/page.tsx @@ -1,3 +1,5 @@ +import { differenceInCalendarDays,isWeekend } from "date-fns" + import { Lang } from "@/constants/languages" import { selectHotelMap } from "@/constants/routes/hotelReservation" @@ -29,6 +31,8 @@ export default async function SelectHotelPage({ setLang(params.lang) const tempSearchTerm = "Stockholm" + const tempArrivalDate = new Date("2024-10-25") + const tempDepartureDate = new Date("2024-10-25") const intl = await getIntl() const hotels = await fetchAvailableHotels({ @@ -52,15 +56,15 @@ export default async function SelectHotelPage({ const hotelsTrackingData: TrackingSDKHotelInfo = { availableResults: hotels.length, searchTerm: tempSearchTerm, - arrivalDate: new Date("2025-05-02"), - departureDate: new Date("2025-05-03"), - noOfAdults: 1, - noOfChildren: 0, - noOfRooms: 1, - duration: 1, - leadTime: 187, - searchType: "hotel", - bookingTypeofDay: "weekend", + arrivalDate: tempArrivalDate, + departureDate: tempDepartureDate, + noOfAdults: 1, // TODO: Use values from searchParams + noOfChildren: 0, // TODO: Use values from searchParams + noOfRooms: 1, // TODO: Use values from searchParams + duration: differenceInCalendarDays(tempDepartureDate, tempArrivalDate), + leadTime: differenceInCalendarDays(tempArrivalDate, new Date()), + searchType: "destination", + bookingTypeofDay: isWeekend(tempArrivalDate) ? "weekend" : "weekday", country: hotels[0].hotelData.address.country, region: hotels[0].hotelData.address.city, }