mirror of
https://github.com/myronblair/parkerslingshotrentals
synced 2026-06-30 17:50:31 -05:00
Fix: blocked dates enforce on date input; fix CORS + no-cache on availability endpoint
This commit is contained in:
+19
-10
@@ -810,6 +810,7 @@
|
||||
<option value="weekend">Weekend — $299</option>
|
||||
</select>
|
||||
<input type="date" name="date" required />
|
||||
<div id="date-unavail-msg" style="display:none;color:#f87171;font-size:.82rem;margin-top:.25rem">That date is already booked or unavailable. Please choose another.</div>
|
||||
<textarea name="message" placeholder="Anything else we should know? (optional)"></textarea>
|
||||
|
||||
<!-- Square deposit card -->
|
||||
@@ -972,18 +973,26 @@
|
||||
// Initial load
|
||||
loadCalendar(calMonth, calYear);
|
||||
|
||||
// Keep calendar in sync when user types a date manually
|
||||
// Keep calendar in sync when user types a date manually; validate against bookedSet
|
||||
if (dateInput) {
|
||||
dateInput.addEventListener('change', () => {
|
||||
if (dateInput.value) {
|
||||
const [y, m] = dateInput.value.split('-').map(Number);
|
||||
if (m !== calMonth || y !== calYear) {
|
||||
calMonth = m; calYear = y;
|
||||
loadCalendar(calMonth, calYear);
|
||||
}
|
||||
selectedDate = dateInput.value;
|
||||
renderCalendar(calMonth, calYear);
|
||||
dateInput.addEventListener('change', async () => {
|
||||
const val = dateInput.value;
|
||||
if (!val) return;
|
||||
const [y, m] = val.split('-').map(Number);
|
||||
if (m !== calMonth || y !== calYear) {
|
||||
calMonth = m; calYear = y;
|
||||
await loadCalendar(calMonth, calYear);
|
||||
}
|
||||
const unavailMsg = document.getElementById('date-unavail-msg');
|
||||
if (bookedSet.has(val)) {
|
||||
dateInput.value = '';
|
||||
selectedDate = null;
|
||||
if (unavailMsg) { unavailMsg.style.display = 'block'; setTimeout(() => unavailMsg.style.display = 'none', 5000); }
|
||||
} else {
|
||||
selectedDate = val;
|
||||
if (unavailMsg) unavailMsg.style.display = 'none';
|
||||
}
|
||||
renderCalendar(calMonth, calYear);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user