-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhotels.js
More file actions
46 lines (37 loc) · 1.94 KB
/
hotels.js
File metadata and controls
46 lines (37 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
fetch('https://hotelbooking.stepprojects.ge/api/Hotels/GetAll')
.then((response) => response.json())
.then((data) => {
const roomsContainer = document.getElementById("hotels");
data.forEach((hotel) => {
const card = document.createElement("div");
card.className = "hotelrooms";
const firstRoom = hotel.rooms && hotel.rooms.length > 0 ? hotel.rooms[0] : null;
const price = `${hotel.rooms.pricePerNight}`
const image = hotel.featuredImage;
card.innerHTML = `
<img src="${image}" alt="${hotel.name}" style="width: 100%; height: 200px; object-fit: cover;">
<h2>${hotel.name}</h2>
<p><strong>მისამართი:</strong> ${hotel.address}</p>
<p><strong>ქალაქი:</strong> ${hotel.city}</p>
<button style="padding: 10px 15px; margin-top: 10px; background: linear-gradient(135deg, #76f6ff, #1c367e); border: none; border-radius: 5px; cursor: pointer; font-weight: 600; transition: 0.3s; width: 100%;">
<a href="Rooms.html?hotelId=${hotel.id}" style="color: white; text-decoration: none; display: block; width: 100%;">ოთახების ნახვა</a>
</button>
`;
document.createElement("button").appendChild(card);
roomsContainer.appendChild(card);
})
});
const burgerBtn = document.getElementById("burgerBtn");
const navBar = document.getElementById("Nav-Bar");
burgerBtn.addEventListener("click", () => {
navBar.classList.toggle("show");
});
// <p><strong>ოთახების რაოდენობა:</strong> ${hotel.rooms ? hotel.rooms.length : 0}</p>
document.getElementById("citySelect").addEventListener("change", (e) => {
const selectedCity = e.target.value;
let filteredRooms = [...allRooms];
if (selectedCity !== "all") {
filteredRooms = allRooms.filter(room => room.city === selectedCity);
}
renderRooms(filteredRooms);
});