2024-06-29 19:30:06 +00:00
|
|
|
{{template "base" .}}
|
|
|
|
{{define "content"}}
|
|
|
|
<div class="container">
|
|
|
|
<div class="row">
|
|
|
|
<div class="col">
|
|
|
|
<img src="/static/images/generals-quarters.png" class="img-fluid mx-auto d-block img-thumbnail room-image"
|
|
|
|
alt="room page">
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="row">
|
|
|
|
<div class="col">
|
|
|
|
<h1 class="text-center mt-3">General's Quarters</h1>
|
|
|
|
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent sed convallis urna, vitae congue
|
|
|
|
odio. Sed pulvinar diam a odio tristique, nec porta eros suscipit. Sed lacinia ut nisl ultrices
|
|
|
|
condimentum. Vivamus imperdiet sapien sit amet mauris ornare accumsan. Proin varius imperdiet
|
|
|
|
gravida. Suspendisse posuere velit leo, sit amet egestas quam porta quis. Duis in nulla eu quam
|
|
|
|
iaculis iaculis. Etiam commodo gravida venenatis. Phasellus in vehicula est, aliquam condimentum
|
|
|
|
nisi. In id ligula lacinia, varius leo vel, tincidunt libero. Nullam cursus vel lectus at consequat.
|
|
|
|
Quisque malesuada efficitur sem et sollicitudin. Donec eget tincidunt arcu. Quisque ut posuere ex.
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="row">
|
|
|
|
<div class="d-flex justify-content-center py-3">
|
2024-06-30 08:31:15 +00:00
|
|
|
<button id="check-availability" class="btn btn-success">Check Availability</button>
|
2024-06-29 19:30:06 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{{end}}
|
2024-06-29 19:42:15 +00:00
|
|
|
{{define "js"}}
|
|
|
|
<script>
|
2024-06-30 08:31:15 +00:00
|
|
|
document.getElementById("check-availability").addEventListener('click', () => {
|
2024-06-29 19:42:15 +00:00
|
|
|
let html = `
|
2024-06-30 14:37:57 +00:00
|
|
|
<form id="check-availability-form" action="/availability-json" method="post" novalidate class="needs-validation">
|
2024-06-29 19:42:15 +00:00
|
|
|
<div id="reservation-dates-modal" class="row">
|
|
|
|
<div class="col mb-3">
|
|
|
|
<input disabled required type="text" class="form-control" name="start" id="start" placeholder="Arrival">
|
|
|
|
</div>
|
|
|
|
<div class="col mb-3">
|
|
|
|
<input disabled required type="text" class="form-control" name="end" id="end" placeholder="Departure">
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
`;
|
2024-07-10 21:32:49 +00:00
|
|
|
let attention = Prompt()
|
|
|
|
attention.custom({
|
2024-06-30 14:23:12 +00:00
|
|
|
title: "Choose your dates",
|
|
|
|
msg: html,
|
2024-06-30 14:37:57 +00:00
|
|
|
willOpen: () => {
|
|
|
|
const elem = document.getElementById('reservation-dates-modal')
|
|
|
|
const rp = new DateRangePicker(elem, {
|
|
|
|
"format": "yyyy-mm-dd",
|
|
|
|
showOnFocus: true,
|
2024-07-10 21:09:45 +00:00
|
|
|
minDate: new Date(),
|
2024-06-30 14:37:57 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
didOpen: () => {
|
|
|
|
return [
|
|
|
|
document.getElementById('start').removeAttribute("disabled"),
|
|
|
|
document.getElementById('end').removeAttribute("disabled"),
|
|
|
|
]
|
|
|
|
},
|
2024-06-30 14:23:12 +00:00
|
|
|
callback: (result) => {
|
2024-06-30 14:37:57 +00:00
|
|
|
const formElem = document.getElementById("check-availability-form");
|
|
|
|
let formData = new FormData(formElem);
|
|
|
|
formData.append("csrf_token", "{{.CSRFToken}}");
|
2024-07-10 21:09:45 +00:00
|
|
|
formData.append("room_id", "1")
|
2024-06-30 14:37:57 +00:00
|
|
|
|
|
|
|
fetch('/availability-json', {
|
|
|
|
method: "post",
|
|
|
|
body: formData,
|
|
|
|
})
|
2024-06-30 14:23:12 +00:00
|
|
|
.then(response => response.json())
|
|
|
|
.then(data => {
|
2024-07-10 21:09:45 +00:00
|
|
|
if (data.ok) {
|
|
|
|
console.log("room is available")
|
2024-07-10 21:32:49 +00:00
|
|
|
attention.custom({
|
|
|
|
icon: "success",
|
|
|
|
// TODO: use the default ok button instead
|
|
|
|
msg: '<p>Room is available</p>' +
|
|
|
|
'<p><a href="/book-room?id=' +
|
|
|
|
data.room_id +
|
|
|
|
'&s=' +
|
|
|
|
data.start_date +
|
|
|
|
'&e=' +
|
|
|
|
data.end_date +
|
|
|
|
'" class="btn btn-primary">' +
|
|
|
|
'Book now!</a></p>',
|
|
|
|
showConfirmButton: false,
|
|
|
|
});
|
2024-07-10 21:09:45 +00:00
|
|
|
} else {
|
|
|
|
console.log("room is not available")
|
2024-07-10 21:32:49 +00:00
|
|
|
attention.error({
|
|
|
|
msg: "No availability"
|
|
|
|
});
|
2024-07-10 21:09:45 +00:00
|
|
|
}
|
2024-06-30 14:23:12 +00:00
|
|
|
})
|
|
|
|
},
|
|
|
|
});
|
2024-06-29 19:42:15 +00:00
|
|
|
});
|
2024-06-30 14:23:12 +00:00
|
|
|
|
2024-06-29 19:42:15 +00:00
|
|
|
</script>
|
|
|
|
{{end}}
|