Try to avoid stack overflow in js
This commit is contained in:
@@ -209,10 +209,11 @@
|
|||||||
}, 'json');
|
}, 'json');
|
||||||
},
|
},
|
||||||
calculatePrice (roomCode, nights) {
|
calculatePrice (roomCode, nights) {
|
||||||
for (const room of this.availableRooms) {
|
const room = this.availableRooms.find(obj => {
|
||||||
if (room.code === roomCode) {
|
return obj.code === roomCode;
|
||||||
return room.price + (nights - room.minNights) * room.additionalNightPrice;
|
});
|
||||||
}
|
if (room) {
|
||||||
|
return room.price + (nights - room.minNights) * room.additionalNightPrice;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -234,7 +235,8 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
onDayCreate: (dObj, dStr, fp, dayElem) => {
|
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) {
|
if (day in this.availableDates) {
|
||||||
dayElem.classList.add('available');
|
dayElem.classList.add('available');
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user