Merged in chore/refactor-paymentclient (pull request #3219)

chore: Refactor PaymentClient

* Extract function mustGuaranteeBooking

* Break apart PaymentClient


Approved-by: Joakim Jäderberg
This commit is contained in:
Anton Gunnarsson
2025-11-27 10:04:10 +00:00
parent 9937dfd002
commit c69993fa96
4 changed files with 329 additions and 137 deletions

View File

@@ -89,3 +89,37 @@ export function writePaymentInfoToSessionStorage(
export function clearPaymentInfoSessionStorage() {
sessionStorage.removeItem(paymentInfoStorageName)
}
export function mustGuaranteeBooking({
isUserLoggedIn,
booking,
rooms,
}: {
isUserLoggedIn: boolean
booking: { rooms: { counterRateCode?: string }[] }
rooms: {
room: {
memberMustBeGuaranteed?: boolean
mustBeGuaranteed: boolean
guest: {
join: boolean
membershipNo?: string
}
}
}[]
}) {
return rooms.some(({ room }, idx) => {
if (idx === 0 && isUserLoggedIn && room.memberMustBeGuaranteed) {
return true
}
if (
(room.guest.join || room.guest.membershipNo) &&
booking.rooms[idx].counterRateCode
) {
return room.memberMustBeGuaranteed
}
return room.mustBeGuaranteed
})
}