File tree Expand file tree Collapse file tree 5 files changed +54
-16
lines changed
Expand file tree Collapse file tree 5 files changed +54
-16
lines changed Original file line number Diff line number Diff 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+
175188module . exports = {
176189renderLogin,
177190renderRegister,
@@ -187,5 +200,6 @@ renderAddMoney,
187200addMoney,
188201apiOtp,
189202resendOTP,
190- renderTransactions
203+ renderTransactions,
204+ renderBookings
191205} ;
Original file line number Diff line number Diff line change @@ -42,4 +42,7 @@ Router.route('/logout')
4242Router . route ( '/transactions' )
4343 . get ( IsLoggedInMiddleware ( ) , userController . renderTransactions ) ;
4444
45+ Router . route ( '/bookings' )
46+ . get ( IsLoggedInMiddleware ( ) , userController . renderBookings ) ;
47+
4548module . exports = Router ;
Original file line number Diff line number Diff line change 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" >
Original file line number Diff line number Diff line change 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' ) %>
Original file line number Diff line number Diff line change 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>
2929 <% }if(!bookings){ %>
3030 No Bookings Found!
3131 <% } %>
32- %>
32+ %> -->
3333</div >
3434</body >
3535<% - include (' ../partials/footer.ejs' ) %>
You can’t perform that action at this time.
0 commit comments