Skip to content

Commit 6c50edc

Browse files
committed
all bookings page added
1 parent 08717f3 commit 6c50edc

File tree

5 files changed

+54
-16
lines changed

5 files changed

+54
-16
lines changed

controllers/user.controller.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,19 @@ const renderTransactions=async(req,res)=>
172172
res.render('users/transactions', {body: req.body,transactions:transactions});
173173
}
174174

175+
const renderBookings=async(req,res)=>
176+
{
177+
var bookings=await bookingService.FindByUser(req.body.user_id);
178+
for(let booking of bookings)
179+
{
180+
if(booking.status!=="Completed" && (booking.end_time<=(new Date().getTime()/1000)))
181+
{
182+
await bookingService.completeBooking(booking._id);
183+
}
184+
}
185+
res.render('users/bookings', {body: req.body,bookings:bookings});
186+
};
187+
175188
module.exports={
176189
renderLogin,
177190
renderRegister,
@@ -187,5 +200,6 @@ renderAddMoney,
187200
addMoney,
188201
apiOtp,
189202
resendOTP,
190-
renderTransactions
203+
renderTransactions,
204+
renderBookings
191205
};

routes/user.route.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,7 @@ Router.route('/logout')
4242
Router.route('/transactions')
4343
.get(IsLoggedInMiddleware(),userController.renderTransactions);
4444

45+
Router.route('/bookings')
46+
.get(IsLoggedInMiddleware(),userController.renderBookings);
47+
4548
module.exports=Router;

views/partials/navbar.ejs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,6 @@
1818
</ul>
1919
<ul class="navbar-nav ms-auto">
2020
<% if(typeof body !== 'undefined'){%>
21-
<!-- <li class="nav-item">
22-
<form method="POST" action="/users/logout?_method=DELETE" id="logout-form">
23-
<a class="nav-link" href="javascript:$('#logout-form').submit();">Logout</a>
24-
</form>
25-
</li>
26-
<li class="nav-item">
27-
<a class="nav-link" aria-current="page" href="/users/changeimage"><img src="<%=body.picture_url%>" class="img-fluid"
28-
style="height: 20px; width:20px; border: 1px solid white; border-radius: 50%;">
29-
<%=body.username%></a>
30-
</li>
31-
<li class="nav-item">
32-
<a class="nav-link" aria-current="page" href="/users/addmoney"><i class="fas fa-rupee-sign"></i>&nbsp;<%=Math.round(body.money*1000)/1000%></a>
33-
</li> -->
3421
<li class="nav-item dropdown">
3522
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown"
3623
data-bs-toggle="dropdown" aria-expanded="false">

views/users/bookings.ejs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<title>Dashboard</title>
8+
<%- include('../partials/header.ejs') %>
9+
</head>
10+
<body>
11+
<%- include('../partials/navbar.ejs')%>
12+
<%- include('../partials/alerts.ejs') %>
13+
<div class="container">
14+
<center><h1>All Bookings</h1></center>
15+
16+
<h3>Your Bookings:</h3>
17+
<hr>
18+
<% for(let booking of bookings){ if(booking.status==="Completed"){continue;}%>
19+
<b>Status</b>-<%=booking.status%><br>
20+
<b>Start Time</b>-<%=new Date(booking.start_time*1000)%><br>
21+
<b>End Time</b>-<%=new Date(booking.end_time*1000)%><br>
22+
<% if(booking.status!=="Cancelled"){ %>
23+
<form action="/booking/cancel/<%=booking._id%>" method="POST">
24+
<button type="submit" class="btn btn-danger">Cancel Booking</button>
25+
</form>
26+
<% } %>
27+
<hr>
28+
<% }if(!bookings){ %>
29+
No Bookings Found!
30+
<% } %>
31+
%>
32+
</div>
33+
</body>
34+
<%- include('../partials/footer.ejs') %>

views/users/dashboard.ejs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<center><h1>Dashboard</h1>
1515
<h3>Welcome <%=body.name%></h3></center>
1616

17-
<h3>Your Bookings:</h3>
17+
<!-- <h3>Your Bookings:</h3>
1818
<hr>
1919
<% for(let booking of bookings){ if(booking.status==="Completed"){continue;}%>
2020
<b>Status</b>-<%=booking.status%><br>
@@ -29,7 +29,7 @@
2929
<% }if(!bookings){ %>
3030
No Bookings Found!
3131
<% } %>
32-
%>
32+
%> -->
3333
</div>
3434
</body>
3535
<%- include('../partials/footer.ejs') %>

0 commit comments

Comments
 (0)