Files
web/apps/scandic-web/components/HotelReservation/MyStay/ManageStay/ActionPanel/utils.ts
Bianca Widstam 696197906b Merged in fix/SW-2254-disable-download-invoice-if-flex (pull request #1775)
fix(SW-2254): disable download invoice if the booking is flex

* fix(SW-2254): disable download invoice if the booking is flex


Approved-by: Simon.Emanuelsson
2025-04-11 09:17:48 +00:00

43 lines
1.0 KiB
TypeScript

import { dt } from "@/lib/dt"
import type { Room } from "@/stores/my-stay/myStayRoomDetailsStore"
export function isDatetimePast(date: Date) {
return dt(date).hour(18).minute(0).second(0).isBefore(dt(), "seconds")
}
export function checkDateModifiable(
canChangeDate: boolean,
datetimeIsInThePast: boolean,
isCancelled: boolean,
isRewardNight: boolean
) {
return canChangeDate && !datetimeIsInThePast && !isCancelled && !isRewardNight
}
export function checkCancelable(
isCancelable: boolean,
datetimeIsInThePast: boolean,
linkedReservationRooms: Room[]
) {
const hasAnyCancelableRoom =
isCancelable || linkedReservationRooms.some((room) => room.isCancelable)
return hasAnyCancelableRoom && !datetimeIsInThePast
}
export function checkGuaranteeable(
guaranteeInfo: boolean,
isCancelled: boolean,
datetimeIsInThePast: boolean
) {
return !guaranteeInfo && !isCancelled && !datetimeIsInThePast
}
export function checkCanDownloadInvoice(
isCancelled: boolean,
isFlexBooking: boolean
) {
return !isCancelled && !isFlexBooking
}