-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbookingpage.js
36 lines (27 loc) · 1.39 KB
/
bookingpage.js
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
// BOOKING PAGE
function Booking() {
const BookingContent = document.querySelector(".text");
fetch("http://localhost:3000/cart")
.then((response) => response.json())
.then((data) => {
console.log(data);
BookingContent.innerHTML = ''
if (data) {
console.log(data.Cart)
for (let i = 0; i < data.Cart.length; i++) {
console.log(data.Cart[i]);
const date = new Date(data.Cart[i].date).getTime()
const hour = String(
new Date(data.Cart[i].trip.date).getHours()).padStart(2, "0");
const minute = String(
new Date(data.Cart[i].trip.date).getMinutes()).padStart(2, "0");
BookingContent.innerHTML +=
`<div class="travelsList" id=${data.Cart[i].trip._id}>
<div class="travel">${data.Cart[i].trip.departure} > ${data.Cart[i].trip.arrival}</div>
<div class="travel-time">${hour} : ${minute}</div>
<div class="travel-price" value='${data.Cart[i].trip.price}'>${data.Cart[i].trip.price}€</div>
<div class="time-departure">Departure ${moment(data.Cart[i].trip.date).fromNow()}</div>
</div>`
}}})
}
Booking()