"use client" import { useIntl } from "react-intl" import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon" import { Typography } from "@scandic-hotels/design-system/Typography" import { CancellationRuleEnum } from "@/constants/booking" import { customerService } from "@/constants/currentWebHrefs" import { preliminaryReceipt } from "@/constants/routes/myStay" import { useManageStayStore } from "@/stores/my-stay/manageStayStore" import { useMyStayRoomDetailsStore } from "@/stores/my-stay/myStayRoomDetailsStore" import AddToCalendar from "@/components/HotelReservation/AddToCalendar" import { generateDateTime } from "@/components/HotelReservation/BookingConfirmation/Header/Actions/helpers" import Button from "@/components/TempDesignSystem/Button" import Link from "@/components/TempDesignSystem/Link" import Body from "@/components/TempDesignSystem/Text/Body" import Caption from "@/components/TempDesignSystem/Text/Caption" import Subtitle from "@/components/TempDesignSystem/Text/Subtitle" import useLang from "@/hooks/useLang" import { trackMyStayPageLink } from "@/utils/tracking" import AddToCalendarButton from "./Actions/AddToCalendarButton" import { checkCancelable, checkCanDownloadInvoice, checkDateModifiable, checkGuaranteeable, isDatetimePast, } from "./utils" import styles from "./actionPanel.module.css" import type { EventAttributes } from "ics" import type { Hotel } from "@/types/hotel" interface ActionPanelProps { hotel: Hotel } export default function ActionPanel({ hotel }: ActionPanelProps) { const intl = useIntl() const lang = useLang() const { actions: { setActiveView }, } = useManageStayStore() const bookedRoom = useMyStayRoomDetailsStore((state) => state.bookedRoom) const linkedReservationRooms = useMyStayRoomDetailsStore( (state) => state.linkedReservationRooms ) const { confirmationNumber, checkInDate, checkOutDate, createDateTime, canChangeDate, priceType, } = bookedRoom const datetimeIsInThePast = isDatetimePast(checkInDate) const isDateModifyable = checkDateModifiable( canChangeDate, datetimeIsInThePast, bookedRoom.isCancelled, priceType === "points" ) const isCancelable = checkCancelable( bookedRoom.isCancelable, datetimeIsInThePast, linkedReservationRooms ) const isGuaranteeable = checkGuaranteeable( !!bookedRoom.guaranteeInfo, bookedRoom.isCancelled, datetimeIsInThePast ) const canDownloadInvoice = checkCanDownloadInvoice( bookedRoom.isCancelled, bookedRoom.rateDefinition.cancellationRule === CancellationRuleEnum.CancellableBefore6PM ) const calendarEvent: EventAttributes = { busyStatus: "FREE", categories: ["booking", "hotel", "stay"], created: generateDateTime(createDateTime), description: hotel.hotelContent.texts.descriptions?.medium, end: generateDateTime(checkOutDate), endInputType: "utc", geo: { lat: hotel.location.latitude, lon: hotel.location.longitude, }, location: `${hotel.address.streetAddress}, ${hotel.address.zipCode} ${hotel.address.city} ${hotel.address.country}`, start: generateDateTime(checkInDate), startInputType: "utc", status: "CONFIRMED", title: hotel.name, url: hotel.contactInformation.websiteUrl, } const handleModifyStay = () => { trackMyStayPageLink("modify dates") setActiveView("modifyStay") } const handleCancelStay = () => { trackMyStayPageLink("cancel booking") setActiveView("cancelStay") } const handleDownloadInvoice = () => { trackMyStayPageLink("download invoice") } const handleGuaranteeLateArrival = () => { trackMyStayPageLink("guarantee late arrival") setActiveView("guaranteeLateArrival") } const handleCustomerSupport = () => { trackMyStayPageLink("customer support") } return (
( )} /> {canDownloadInvoice ? ( {intl.formatMessage({ id: "Download invoice" })} ) : (

{intl.formatMessage({ id: "Download invoice" })}

)}
{intl.formatMessage({ id: "Reference number" })} {confirmationNumber}
{hotel.name} {hotel.address.streetAddress} {hotel.address.city} {hotel.contactInformation.phoneNumber}
{intl.formatMessage({ id: "Customer support" })}
) }