Merged in feat/SW-3540-fix-hotel-details-link-to-go- (pull request #2959)
feat SW-3540 Fixed route for hotel details link in sidepeek Approved-by: Anton Gunnarsson
This commit is contained in:
@@ -7,6 +7,8 @@ import { IconName } from "@scandic-hotels/design-system/Icons/iconName"
|
|||||||
import { Typography } from "@scandic-hotels/design-system/Typography"
|
import { Typography } from "@scandic-hotels/design-system/Typography"
|
||||||
import { trackAccordionClick } from "@scandic-hotels/tracking/componentEvents"
|
import { trackAccordionClick } from "@scandic-hotels/tracking/componentEvents"
|
||||||
|
|
||||||
|
import { useBookingFlowConfig } from "../../../bookingFlowConfig/bookingFlowConfigContext"
|
||||||
|
import { routeToScandicWebUrl } from "../../../utils/routeToScandicWebUrl"
|
||||||
import AdditionalAmenities from "../../AdditionalAmenities"
|
import AdditionalAmenities from "../../AdditionalAmenities"
|
||||||
import Contact from "../../Contact"
|
import Contact from "../../Contact"
|
||||||
import BreakfastAccordionItem from "../../SidePeekAccordions/BreakfastAccordionItem"
|
import BreakfastAccordionItem from "../../SidePeekAccordions/BreakfastAccordionItem"
|
||||||
@@ -33,6 +35,9 @@ export function HotelSidePeekContent({
|
|||||||
additionalHotelData,
|
additionalHotelData,
|
||||||
}: HotelSidePeekContentProps) {
|
}: HotelSidePeekContentProps) {
|
||||||
const intl = useIntl()
|
const intl = useIntl()
|
||||||
|
const isScandicPartner = useBookingFlowConfig().variant !== "scandic"
|
||||||
|
const hotelUrl =
|
||||||
|
isScandicPartner && hotel.url ? routeToScandicWebUrl(hotel.url) : hotel.url
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.content}>
|
<div className={styles.content}>
|
||||||
@@ -58,9 +63,9 @@ export function HotelSidePeekContent({
|
|||||||
/>
|
/>
|
||||||
<AdditionalAmenities amenities={hotel.detailedFacilities} />
|
<AdditionalAmenities amenities={hotel.detailedFacilities} />
|
||||||
</Accordion>
|
</Accordion>
|
||||||
{hotel.url ? (
|
{hotelUrl ? (
|
||||||
<ButtonLink
|
<ButtonLink
|
||||||
href={hotel.url}
|
href={hotelUrl}
|
||||||
variant="Secondary"
|
variant="Secondary"
|
||||||
size="Medium"
|
size="Medium"
|
||||||
typography="Body/Paragraph/mdBold"
|
typography="Body/Paragraph/mdBold"
|
||||||
|
|||||||
12
packages/booking-flow/lib/utils/routeToScandicWebUrl.ts
Normal file
12
packages/booking-flow/lib/utils/routeToScandicWebUrl.ts
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
export function routeToScandicWebUrl(url: string) {
|
||||||
|
const scandicWebUrl = `https://www.scandichotels.com`
|
||||||
|
let updatedUrl = url
|
||||||
|
if (/^(https?:)?\/\//i.test(url)) {
|
||||||
|
const parsedUrl = new URL(url)
|
||||||
|
parsedUrl.host = "www.scandichotels.com"
|
||||||
|
updatedUrl = parsedUrl.href
|
||||||
|
} else {
|
||||||
|
updatedUrl = scandicWebUrl + url
|
||||||
|
}
|
||||||
|
return updatedUrl
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user