Try to avoid stack overflow in js
This commit is contained in:
@@ -209,10 +209,11 @@
|
||||
}, 'json');
|
||||
},
|
||||
calculatePrice (roomCode, nights) {
|
||||
for (const room of this.availableRooms) {
|
||||
if (room.code === roomCode) {
|
||||
return room.price + (nights - room.minNights) * room.additionalNightPrice;
|
||||
}
|
||||
const room = this.availableRooms.find(obj => {
|
||||
return obj.code === roomCode;
|
||||
});
|
||||
if (room) {
|
||||
return room.price + (nights - room.minNights) * room.additionalNightPrice;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -234,7 +235,8 @@
|
||||
}
|
||||
},
|
||||
onDayCreate: (dObj, dStr, fp, dayElem) => {
|
||||
const day = dayjs(dayElem.dateObj).format('YYYY-MM-DD');
|
||||
const day = dayElem.dateObj.getFullYear() + "-" + ("0" + dayElem.dateObj.getMonth()).slice(-2)
|
||||
+ "-" + ("0"+(dayElem.dateObj.getDate()+1)).slice(-2);
|
||||
if (day in this.availableDates) {
|
||||
dayElem.classList.add('available');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user