feat (SW-2864): Move booking router to trpc package * Add env to trpc package * Add eslint to trpc package * Apply lint rules * Use direct imports from trpc package * Add lint-staged config to trpc * Move lang enum to common * Restructure trpc package folder structure * WIP first step * update internal imports in trpc * Fix most errors in scandic-web Just 100 left... * Move Props type out of trpc * Fix CategorizedFilters types * Move more schemas in hotel router * Fix deps * fix getNonContentstackUrls * Fix import error * Fix entry error handling * Fix generateMetadata metrics * Fix alertType enum * Fix duplicated types * lint:fix * Merge branch 'master' into feat/sw-2863-move-contentstack-router-to-trpc-package * Fix broken imports * Move booking router to trpc package * Merge branch 'master' into feat/sw-2864-move-hotels-router-to-trpc-package Approved-by: Linus Flood
102 lines
3.1 KiB
TypeScript
102 lines
3.1 KiB
TypeScript
"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 { useEnterDetailsStore } from "@/stores/enter-details"
|
|
|
|
import Footnote from "@/components/TempDesignSystem/Text/Footnote"
|
|
import Subtitle from "@/components/TempDesignSystem/Text/Subtitle"
|
|
import { useRoomContext } from "@/contexts/Details/Room"
|
|
import useLang from "@/hooks/useLang"
|
|
|
|
import ToggleSidePeek from "./ToggleSidePeek"
|
|
|
|
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, searchParamsStr } = useEnterDetailsStore((state) => ({
|
|
hotelId: state.booking.hotelId,
|
|
searchParamsStr: state.searchParamString,
|
|
}))
|
|
|
|
function changeRoom() {
|
|
const searchParams = new URLSearchParams(searchParamsStr)
|
|
|
|
searchParams.set("modifyRateIndex", `${idx}`)
|
|
startTransition(() => {
|
|
router.push(`${selectRate(lang)}?${searchParams.toString()}`)
|
|
})
|
|
}
|
|
|
|
return (
|
|
<div className={styles.wrapper} data-available={room.isAvailable}>
|
|
<div className={styles.main}>
|
|
<div className={styles.headerContainer}>
|
|
<Footnote
|
|
className={styles.title}
|
|
asChild
|
|
textTransform="uppercase"
|
|
type="label"
|
|
color="uiTextHighContrast"
|
|
>
|
|
<h2>
|
|
{intl.formatMessage({
|
|
defaultMessage: "Room",
|
|
})}
|
|
</h2>
|
|
</Footnote>
|
|
<Subtitle
|
|
type="two"
|
|
className={styles.description}
|
|
color="uiTextHighContrast"
|
|
>
|
|
{intl.formatMessage(
|
|
{
|
|
defaultMessage: "{roomType} <rate>{rateDescription}</rate>",
|
|
},
|
|
{
|
|
roomType: room.roomType,
|
|
rateDescription: room.cancellationText,
|
|
rate: ([str]) => {
|
|
return str ? <span className={styles.rate}>{str}</span> : null
|
|
},
|
|
}
|
|
)}
|
|
</Subtitle>
|
|
<Button
|
|
variant="Text"
|
|
size="Small"
|
|
onPress={changeRoom}
|
|
isDisabled={isPending}
|
|
typography="Body/Supporting text (caption)/smBold"
|
|
>
|
|
<MaterialIcon icon="edit_square" size={20} color="CurrentColor" />
|
|
{intl.formatMessage({
|
|
defaultMessage: "Change",
|
|
})}
|
|
</Button>
|
|
</div>
|
|
{room.roomTypeCode && (
|
|
<div className={styles.details}>
|
|
<ToggleSidePeek
|
|
hotelId={hotelId}
|
|
roomTypeCode={room.roomTypeCode}
|
|
/>
|
|
</div>
|
|
)}
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|