"use client" import { useRouter } from "next/navigation" import { useTransition } from "react" import { useIntl } from "react-intl" import { selectRate } from "@scandic-hotels/common/constants/routes/hotelReservation" import { Button } from "@scandic-hotels/design-system/Button" import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon" import { Typography } from "@scandic-hotels/design-system/Typography" import { getHotelRoom } from "@scandic-hotels/trpc/routers/booking/helpers" import { useRoomContext } from "../../../contexts/EnterDetails/RoomContext" import useLang from "../../../hooks/useLang" import { useEnterDetailsStore } from "../../../stores/enter-details" import { RoomDetailsSidePeek } from "../../RoomDetailsSidePeek" import styles from "./selectedRoom.module.css" export default function SelectedRoom() { const intl = useIntl() const lang = useLang() const router = useRouter() const [isPending, startTransition] = useTransition() const { room, idx } = useRoomContext() const { hotelId, roomCategories, searchParamsStr } = useEnterDetailsStore( (state) => ({ hotelId: state.booking.hotelId, roomCategories: state.roomCategories, searchParamsStr: state.searchParamString, }) ) function changeRoom() { const searchParams = new URLSearchParams(searchParamsStr) searchParams.set("activeRoomIndex", `${idx}`) startTransition(() => { router.push(`${selectRate(lang)}?${searchParams.toString()}`) }) } const selectedRoom = getHotelRoom(roomCategories, room.roomTypeCode) return (
{intl.formatMessage(
{
id: "enterDetails.selectedRoom.roomType.description",
defaultMessage: "{roomType}