Guard against departure date not having min and max night attributes

This commit is contained in:
jordi fita mas 2024-02-02 02:55:09 +01:00
parent 33a1f0f4e2
commit 97fb88cc02
1 changed files with 2 additions and 2 deletions

View File

@ -11,7 +11,7 @@
return;
}
const minNights = Math.max(1, parseInt(departureDateField.dataset.minNights, 10));
const minNights = Math.max(1, parseInt(departureDateField.dataset.minNights, 10) || 0);
arrivalDate.setUTCDate(arrivalDate.getUTCDate() + minNights);
const minDate = formatDate(arrivalDate);
@ -22,7 +22,7 @@
departureDateField.value = minDate;
}
const maxNights = parseInt(departureDateField.dataset.maxNights, 10);
const maxNights = parseInt(departureDateField.dataset.maxNights, 10) || 0;
if (maxNights > 0) {
arrivalDate.setUTCDate(arrivalDate.getUTCDate() + maxNights - minNights);
const maxDate = formatDate(arrivalDate);