Merged in fix/SW-983-map-view-cards-hover-select (pull request #971)

Fix/SW-983 map view cards hover select

Approved-by: Niclas Edenvin
This commit is contained in:
Pontus Dreij
2024-11-25 15:05:53 +00:00
10 changed files with 113 additions and 62 deletions

View File

@@ -1,5 +1,6 @@
"use client"
import { useParams } from "next/dist/client/components/navigation"
import { memo, useCallback } from "react"
import { useIntl } from "react-intl"
import { Lang } from "@/constants/languages"
@@ -25,7 +26,7 @@ import styles from "./hotelCard.module.css"
import { HotelCardListingTypeEnum } from "@/types/components/hotelReservation/selectHotel/hotelCardListingProps"
import type { HotelCardProps } from "@/types/components/hotelReservation/selectHotel/hotelCardProps"
export default function HotelCard({
function HotelCard({
hotel,
type = HotelCardListingTypeEnum.PageListing,
state = "default",
@@ -45,16 +46,17 @@ export default function HotelCard({
state,
})
const handleMouseEnter = () => {
const handleMouseEnter = useCallback(() => {
if (onHotelCardHover) {
onHotelCardHover(hotelData.name)
}
}
const handleMouseLeave = () => {
}, [onHotelCardHover, hotelData.name])
const handleMouseLeave = useCallback(() => {
if (onHotelCardHover) {
onHotelCardHover(null)
}
}
}, [onHotelCardHover])
return (
<article
@@ -142,3 +144,5 @@ export default function HotelCard({
</article>
)
}
export default memo(HotelCard)