Files
web/apps/scandic-web/components/HotelReservation/MyStay/ManageStay/index.tsx
Matilda Landström 5de2a993a7 Merged in feat/SW-1711-switch-icons (pull request #1558)
Switches out all the old icons to new ones, and moves them to the design system. The new icons are of three different types: Materialise Symbol, Nucleo, and Customized. Also adds further mapping between facilities/amenities and icons.

Approved-by: Michael Zetterberg
Approved-by: Erik Tiekstra
2025-03-27 09:42:52 +00:00

93 lines
2.3 KiB
TypeScript

"use client"
import { useIntl } from "react-intl"
import { MaterialIcon } from "@scandic-hotels/design-system/Icons"
import { useManageStayStore } from "@/stores/my-stay/manageStayStore"
import { useMyStayRoomDetailsStore } from "@/stores/my-stay/myStayRoomDetailsStore"
import Modal from "@/components/Modal"
import Button from "@/components/TempDesignSystem/Button"
import GuaranteeLateArrival from "../GuaranteeLateArrival"
import CancelStay from "./ActionPanel/Actions/CancelStay"
import ModifyStay from "./ActionPanel/Actions/ModifyStay"
import ActionPanel from "./ActionPanel"
import type { Hotel } from "@/types/hotel"
import { type CreditCard } from "@/types/user"
interface ManageStayProps {
hotel: Hotel
savedCreditCards: CreditCard[] | null
refId: string
isLoggedIn: boolean
}
export default function ManageStay({
hotel,
savedCreditCards,
refId,
isLoggedIn,
}: ManageStayProps) {
const intl = useIntl()
const {
isOpen,
activeView,
actions: { setIsOpen, handleCloseModal },
} = useManageStayStore()
const bookedRoom = useMyStayRoomDetailsStore((state) => state.bookedRoom)
const linkedReservationRooms = useMyStayRoomDetailsStore(
(state) => state.linkedReservationRooms
)
const allRoomsCancelled =
linkedReservationRooms.every((room) => room.isCancelled) &&
bookedRoom.isCancelled
function renderContent() {
switch (activeView) {
case "cancelStay":
return <CancelStay hotel={hotel} />
case "modifyStay":
return <ModifyStay isLoggedIn={isLoggedIn} />
case "guaranteeLateArrival":
return (
<GuaranteeLateArrival
savedCreditCards={savedCreditCards}
refId={refId}
/>
)
default:
return <ActionPanel hotel={hotel} />
}
}
return (
<>
<Button
variant="icon"
fullWidth
onClick={() => setIsOpen(true)}
size="small"
disabled={allRoomsCancelled}
>
{intl.formatMessage({ id: "Manage stay" })}
<MaterialIcon icon="keyboard_arrow_down" color="Icon/Inverted" />
</Button>
{isOpen && (
<Modal
isOpen={isOpen}
onToggle={handleCloseModal}
withActions
hideHeader
>
{renderContent()}
</Modal>
)}
</>
)
}