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
43 lines
1.0 KiB
TypeScript
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
|
|
}
|