Merged in fix/book-607-fix-old-links-my-stay (pull request #3365)

fix: updated to use new link structure on My Stay

* fix: updated to use new link structure on My Stay

* fix(BOOK-607): hide hotel page link if link prop is missing

* comment fixes

* fix(BOOK-607): read href from window (lcalhost not allowed)


Approved-by: Matilda Landström
This commit is contained in:
Matilda Haneling
2025-12-30 08:33:52 +00:00
parent 03b1695c9e
commit 86331a6e10
6 changed files with 80 additions and 64 deletions

View File

@@ -16,14 +16,21 @@ import type { EventAttributes } from "ics"
export default function AddToCalendarAction() {
const pathName = usePathname()
const { checkInDate, checkOutDate, createDateTime, hotel } = useMyStayStore(
(state) => ({
const { checkInDate, checkOutDate, createDateTime, hotelUrl, hotel } =
useMyStayStore((state) => ({
checkInDate: state.bookedRoom.checkInDate,
checkOutDate: state.bookedRoom.checkOutDate,
createDateTime: state.bookedRoom.createDateTime,
hotel: state.hotel,
})
)
hotelUrl: state.hotelUrl,
}))
let baseUrl = typeof window !== "undefined" ? window.location.hostname : ""
if (baseUrl.includes("localhost") || !baseUrl) {
// Localhost not valid for calendar URL
baseUrl = "https://www.scandichotels.com"
}
const url = new URL(hotelUrl || "", baseUrl)
const calendarEvent: EventAttributes = {
busyStatus: "FREE",
@@ -41,7 +48,7 @@ export default function AddToCalendarAction() {
startInputType: "utc",
status: "CONFIRMED",
title: hotel.name,
url: hotel.contactInformation.websiteUrl,
url: url.toString(),
}
const disabled = dateHasPassed(