Providing feedback when searching by room, and connecting to the reservation page
This commit is contained in:
parent
5eb9284b6f
commit
fed901ce25
@ -245,9 +245,12 @@ func (m *Repository) PostAvailability(w http.ResponseWriter, r *http.Request) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
type responseJSON struct {
|
type jsonResponse struct {
|
||||||
OK bool `json:"ok"`
|
OK bool `json:"ok"`
|
||||||
Message string `json:"message"`
|
Message string `json:"message"`
|
||||||
|
RoomID string `json:"room_id"`
|
||||||
|
StartDate string `json:"start_date"`
|
||||||
|
EndDate string `json:"end_date"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// AvailabilityJSON is the search for availability page handler
|
// AvailabilityJSON is the search for availability page handler
|
||||||
@ -279,9 +282,12 @@ func (m *Repository) AvailabilityJSON(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
resp := responseJSON{
|
resp := jsonResponse{
|
||||||
OK: available,
|
OK: available,
|
||||||
Message: "",
|
Message: "",
|
||||||
|
StartDate: sd,
|
||||||
|
EndDate: ed,
|
||||||
|
RoomID: strconv.Itoa(roomID),
|
||||||
}
|
}
|
||||||
|
|
||||||
out, err := json.MarshalIndent(resp, "", " ")
|
out, err := json.MarshalIndent(resp, "", " ")
|
||||||
|
@ -183,16 +183,20 @@
|
|||||||
|
|
||||||
async function custom(c) {
|
async function custom(c) {
|
||||||
const {
|
const {
|
||||||
|
icon = "",
|
||||||
msg = "",
|
msg = "",
|
||||||
title = "",
|
title = "",
|
||||||
|
showConfirmButton = true,
|
||||||
} = c;
|
} = c;
|
||||||
|
|
||||||
const {value: result} = await Swal.fire({
|
const {value: result} = await Swal.fire({
|
||||||
|
icon: icon,
|
||||||
title: title,
|
title: title,
|
||||||
html: msg,
|
html: msg,
|
||||||
backdrop: false,
|
backdrop: false,
|
||||||
focusConfirm: false,
|
focusConfirm: false,
|
||||||
showCancelButton: true,
|
showCancelButton: true,
|
||||||
|
showConfirmButton: showConfirmButton,
|
||||||
willOpen: () => {
|
willOpen: () => {
|
||||||
if (c.willOpen !== undefined) {
|
if (c.willOpen !== undefined) {
|
||||||
c.willOpen();
|
c.willOpen();
|
||||||
|
@ -43,7 +43,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
`;
|
`;
|
||||||
Prompt().custom({
|
let attention = Prompt()
|
||||||
|
attention.custom({
|
||||||
title: "Choose your dates",
|
title: "Choose your dates",
|
||||||
msg: html,
|
msg: html,
|
||||||
willOpen: () => {
|
willOpen: () => {
|
||||||
@ -74,8 +75,25 @@
|
|||||||
.then(data => {
|
.then(data => {
|
||||||
if (data.ok) {
|
if (data.ok) {
|
||||||
console.log("room is available")
|
console.log("room is available")
|
||||||
|
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,
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
console.log("room is not available")
|
console.log("room is not available")
|
||||||
|
attention.error({
|
||||||
|
msg: "No availability"
|
||||||
|
});
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user