Merged in fix/STAY-4-late-cancellations (pull request #3247)

fix: show cancellation message for non cancellable flex booking

* fix: show cancellation message for non cancellable flex booking


Approved-by: Chuma Mcphoy (We Ahead)
This commit is contained in:
Christel Westerberg
2025-11-28 14:32:51 +00:00
parent 46fa42750f
commit 870512a7ab

View File

@@ -2,6 +2,7 @@
import { useIntl } from "react-intl"
import { AlertTypeEnum } from "@scandic-hotels/common/constants/alert"
import { CancellationRuleEnum } from "@scandic-hotels/common/constants/booking"
import { Alert } from "@scandic-hotels/design-system/Alert"
import { useMyStayStore } from "@/stores/my-stay"
@@ -14,29 +15,53 @@ interface AlertsProps extends React.PropsWithChildren {
export default function Alerts({ children, closeModal }: AlertsProps) {
const intl = useIntl()
const mainRoom = useMyStayStore((state) => state.bookedRoom)
if (!mainRoom) {
const { isCancelable, cancellationRule, mainRoom } = useMyStayStore(
(state) => ({
isCancelable: state.bookedRoom.isCancelable,
cancellationRule: state.bookedRoom.rateDefinition.cancellationRule,
mainRoom: state.bookedRoom,
})
)
// If time has passed for cancellation, or if a FLEX booking no longer is cancellable, show alert
if (
!mainRoom ||
(!isCancelable &&
cancellationRule === CancellationRuleEnum.CancellableBefore6PM)
) {
const title = intl.formatMessage({
id: "booking.cancelStay",
defaultMessage: "Cancel stay",
})
const heading = !mainRoom
? intl.formatMessage({
id: "myStay.actions.contactBooker",
defaultMessage: "Contact the person who booked the stay",
})
: intl.formatMessage({
id: "myStay.actions.tooLateToCancel",
defaultMessage: "Too close to arrival to cancel the stay",
})
const text = !mainRoom
? intl.formatMessage({
id: "myStay.actions.contactBooker.multiroom.cancel",
defaultMessage:
"As this is a multiroom stay, the cancellation has to be done by the person who made the booking. Please call 08-517 517 00 to talk to our customer service if you would need further assistance.",
})
: intl.formatMessage({
id: "myStay.actions.tooLateToCancel.text",
defaultMessage:
"Your booking cant be cancelled after 18:00 local time on the day of arrival.",
})
return (
<Modal.Content>
<Modal.Content.Header handleClose={closeModal} title={title} />
<Modal.Content.Body>
<Alert
type={AlertTypeEnum.Info}
heading={intl.formatMessage({
id: "myStay.actions.contactBooker",
defaultMessage: "Contact the person who booked the stay",
})}
text={intl.formatMessage({
id: "myStay.actions.contactBooker.multiroom.cancel",
defaultMessage:
"As this is a multiroom stay, the cancellation has to be done by the person who made the booking. Please call 08-517 517 00 to talk to our customer service if you would need further assistance.",
})}
/>
<Alert type={AlertTypeEnum.Info} heading={heading} text={text} />
</Modal.Content.Body>
<Modal.Content.Footer>
<Modal.Content.Footer.Secondary onClick={closeModal}>