Merged in fix/SW-2884-select-hotel-page-users-are-di (pull request #2438)
fix: SW-2884 Fixed Alternative hotels map navigation issues * fix: SW-2884 Fixed Alternative hotels map navigation issues * fix: SW-2884 Optmized code Approved-by: Arvid Norlin
This commit is contained in:
@@ -15,7 +15,10 @@ import { Divider } from "@scandic-hotels/design-system/Divider"
|
|||||||
import HotelLogoIcon from "@scandic-hotels/design-system/Icons/HotelLogoIcon"
|
import HotelLogoIcon from "@scandic-hotels/design-system/Icons/HotelLogoIcon"
|
||||||
import { Typography } from "@scandic-hotels/design-system/Typography"
|
import { Typography } from "@scandic-hotels/design-system/Typography"
|
||||||
|
|
||||||
import { selectHotelMap } from "@/constants/routes/hotelReservation"
|
import {
|
||||||
|
alternativeHotelsMap,
|
||||||
|
selectHotelMap,
|
||||||
|
} from "@/constants/routes/hotelReservation"
|
||||||
import { useHotelsMapStore } from "@/stores/hotels-map"
|
import { useHotelsMapStore } from "@/stores/hotels-map"
|
||||||
|
|
||||||
import BookingCodeChip from "@/components/BookingCodeChip"
|
import BookingCodeChip from "@/components/BookingCodeChip"
|
||||||
@@ -49,6 +52,7 @@ function HotelCard({
|
|||||||
state = "default",
|
state = "default",
|
||||||
type = HotelCardListingTypeEnum.PageListing,
|
type = HotelCardListingTypeEnum.PageListing,
|
||||||
bookingCode = "",
|
bookingCode = "",
|
||||||
|
isAlternative,
|
||||||
}: HotelCardProps) {
|
}: HotelCardProps) {
|
||||||
const params = useParams()
|
const params = useParams()
|
||||||
const searchParams = useSearchParams()
|
const searchParams = useSearchParams()
|
||||||
@@ -65,11 +69,14 @@ function HotelCard({
|
|||||||
state,
|
state,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const mapUrl = isAlternative
|
||||||
|
? alternativeHotelsMap(lang)
|
||||||
|
: selectHotelMap(lang)
|
||||||
const handleAddressClick = (event: React.MouseEvent) => {
|
const handleAddressClick = (event: React.MouseEvent) => {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
disengage() // Disengage the current hotel to avoid the hover state from being active when clicking on the address
|
disengage() // Disengage the current hotel to avoid the hover state from being active when clicking on the address
|
||||||
activate(hotel.name)
|
activate(hotel.name)
|
||||||
router.push(`${selectHotelMap(lang)}?${searchParams.toString()}`)
|
router.push(`${mapUrl}?${searchParams.toString()}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
const addressStr = `${hotel.address.streetAddress}, ${hotel.address.city}`
|
const addressStr = `${hotel.address.streetAddress}, ${hotel.address.city}`
|
||||||
@@ -126,7 +133,7 @@ function HotelCard({
|
|||||||
size="small"
|
size="small"
|
||||||
textDecoration="underline"
|
textDecoration="underline"
|
||||||
onClick={handleAddressClick}
|
onClick={handleAddressClick}
|
||||||
href={selectHotelMap(lang)}
|
href={mapUrl}
|
||||||
keepSearchParams
|
keepSearchParams
|
||||||
aria-label={intl.formatMessage({
|
aria-label={intl.formatMessage({
|
||||||
defaultMessage: "See on map",
|
defaultMessage: "See on map",
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ export default function HotelCardListing({
|
|||||||
hotelData,
|
hotelData,
|
||||||
unfilteredHotelCount,
|
unfilteredHotelCount,
|
||||||
type = HotelCardListingTypeEnum.PageListing,
|
type = HotelCardListingTypeEnum.PageListing,
|
||||||
|
isAlternative,
|
||||||
}: HotelCardListingProps) {
|
}: HotelCardListingProps) {
|
||||||
const { data: session } = useSession()
|
const { data: session } = useSession()
|
||||||
const isUserLoggedIn = isValidClientSession(session)
|
const isUserLoggedIn = isValidClientSession(session)
|
||||||
@@ -133,6 +134,7 @@ export default function HotelCardListing({
|
|||||||
}
|
}
|
||||||
type={type}
|
type={type}
|
||||||
bookingCode={bookingCode}
|
bookingCode={bookingCode}
|
||||||
|
isAlternative={isAlternative}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
))
|
))
|
||||||
|
|||||||
@@ -108,6 +108,7 @@ export async function SelectHotelMapContainer({
|
|||||||
cityCoordinates={cityCoordinates}
|
cityCoordinates={cityCoordinates}
|
||||||
bookingCode={bookingCode ?? ""}
|
bookingCode={bookingCode ?? ""}
|
||||||
isBookingCodeRateAvailable={isBookingCodeRateAvailable}
|
isBookingCodeRateAvailable={isBookingCodeRateAvailable}
|
||||||
|
isAlternativeHotels={isAlternativeHotels}
|
||||||
/>
|
/>
|
||||||
<TrackingSDK pageData={pageTrackingData} hotelInfo={hotelsTrackingData} />
|
<TrackingSDK pageData={pageTrackingData} hotelInfo={hotelsTrackingData} />
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -6,7 +6,10 @@ import { useMediaQuery } from "usehooks-ts"
|
|||||||
|
|
||||||
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
|
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
|
||||||
|
|
||||||
import { selectHotel } from "@/constants/routes/hotelReservation"
|
import {
|
||||||
|
alternativeHotels,
|
||||||
|
selectHotel,
|
||||||
|
} from "@/constants/routes/hotelReservation"
|
||||||
import { useBookingCodeFilterStore } from "@/stores/bookingCode-filter"
|
import { useBookingCodeFilterStore } from "@/stores/bookingCode-filter"
|
||||||
import { useHotelFilterStore } from "@/stores/hotel-filters"
|
import { useHotelFilterStore } from "@/stores/hotel-filters"
|
||||||
import { useHotelsMapStore } from "@/stores/hotels-map"
|
import { useHotelsMapStore } from "@/stores/hotels-map"
|
||||||
@@ -41,6 +44,7 @@ export default function SelectHotelContent({
|
|||||||
filterList,
|
filterList,
|
||||||
bookingCode,
|
bookingCode,
|
||||||
isBookingCodeRateAvailable,
|
isBookingCodeRateAvailable,
|
||||||
|
isAlternativeHotels,
|
||||||
}: Omit<SelectHotelMapProps, "apiKey">) {
|
}: Omit<SelectHotelMapProps, "apiKey">) {
|
||||||
const lang = useLang()
|
const lang = useLang()
|
||||||
const intl = useIntl()
|
const intl = useIntl()
|
||||||
@@ -122,6 +126,9 @@ export default function SelectHotelContent({
|
|||||||
[map, getHotelCards, isAboveMobile]
|
[map, getHotelCards, isAboveMobile]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const closeMapUrl = isAlternativeHotels
|
||||||
|
? alternativeHotels(lang)
|
||||||
|
: selectHotel(lang)
|
||||||
const closeButton = (
|
const closeButton = (
|
||||||
<Button
|
<Button
|
||||||
intent="inverted"
|
intent="inverted"
|
||||||
@@ -130,7 +137,7 @@ export default function SelectHotelContent({
|
|||||||
className={styles.closeButton}
|
className={styles.closeButton}
|
||||||
asChild
|
asChild
|
||||||
>
|
>
|
||||||
<Link href={selectHotel(lang)} keepSearchParams prefetch>
|
<Link href={closeMapUrl} keepSearchParams prefetch>
|
||||||
<MaterialIcon icon="close" size={20} color="CurrentColor" />
|
<MaterialIcon icon="close" size={20} color="CurrentColor" />
|
||||||
{intl.formatMessage({
|
{intl.formatMessage({
|
||||||
defaultMessage: "Close the map",
|
defaultMessage: "Close the map",
|
||||||
@@ -164,7 +171,7 @@ export default function SelectHotelContent({
|
|||||||
className={styles.filterContainerCloseButton}
|
className={styles.filterContainerCloseButton}
|
||||||
asChild
|
asChild
|
||||||
>
|
>
|
||||||
<Link href={selectHotel(lang)} keepSearchParams>
|
<Link href={closeMapUrl} keepSearchParams>
|
||||||
<MaterialIcon icon="arrow_back" color="CurrentColor" size={20} />
|
<MaterialIcon icon="arrow_back" color="CurrentColor" size={20} />
|
||||||
{intl.formatMessage({ defaultMessage: "Back" })}
|
{intl.formatMessage({ defaultMessage: "Back" })}
|
||||||
</Link>
|
</Link>
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ export default function SelectHotelMap({
|
|||||||
cityCoordinates,
|
cityCoordinates,
|
||||||
bookingCode,
|
bookingCode,
|
||||||
isBookingCodeRateAvailable,
|
isBookingCodeRateAvailable,
|
||||||
|
isAlternativeHotels,
|
||||||
}: SelectHotelMapProps) {
|
}: SelectHotelMapProps) {
|
||||||
return (
|
return (
|
||||||
<APIProvider apiKey={apiKey}>
|
<APIProvider apiKey={apiKey}>
|
||||||
@@ -26,6 +27,7 @@ export default function SelectHotelMap({
|
|||||||
filterList={filterList}
|
filterList={filterList}
|
||||||
bookingCode={bookingCode}
|
bookingCode={bookingCode}
|
||||||
isBookingCodeRateAvailable={isBookingCodeRateAvailable}
|
isBookingCodeRateAvailable={isBookingCodeRateAvailable}
|
||||||
|
isAlternativeHotels={isAlternativeHotels}
|
||||||
/>
|
/>
|
||||||
</APIProvider>
|
</APIProvider>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ export default async function SelectHotel({
|
|||||||
bookingCode={bookingCode}
|
bookingCode={bookingCode}
|
||||||
isBookingCodeRateNotAvailable={!isBookingCodeRateAvailable}
|
isBookingCodeRateNotAvailable={!isBookingCodeRateAvailable}
|
||||||
/>
|
/>
|
||||||
<HotelCardListing hotelData={hotels} />
|
<HotelCardListing hotelData={hotels} isAlternative={isAlternative} />
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ export type HotelCardListingProps = {
|
|||||||
hotelData: HotelResponse[]
|
hotelData: HotelResponse[]
|
||||||
unfilteredHotelCount?: number
|
unfilteredHotelCount?: number
|
||||||
type?: HotelCardListingTypeEnum
|
type?: HotelCardListingTypeEnum
|
||||||
|
isAlternative?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface NullableHotelData extends Omit<HotelData, "hotelData"> {
|
export interface NullableHotelData extends Omit<HotelData, "hotelData"> {
|
||||||
|
|||||||
@@ -7,4 +7,5 @@ export type HotelCardProps = {
|
|||||||
type?: HotelCardListingTypeEnum
|
type?: HotelCardListingTypeEnum
|
||||||
state?: "default" | "active"
|
state?: "default" | "active"
|
||||||
bookingCode?: string | null
|
bookingCode?: string | null
|
||||||
|
isAlternative?: boolean
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ export interface SelectHotelMapProps {
|
|||||||
cityCoordinates: Coordinates
|
cityCoordinates: Coordinates
|
||||||
bookingCode: string | undefined
|
bookingCode: string | undefined
|
||||||
isBookingCodeRateAvailable?: boolean
|
isBookingCodeRateAvailable?: boolean
|
||||||
|
isAlternativeHotels?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
type ImageSizes = z.infer<typeof imageSchema>["imageSizes"]
|
type ImageSizes = z.infer<typeof imageSchema>["imageSizes"]
|
||||||
|
|||||||
Reference in New Issue
Block a user