Skip to content

Commit c9be41e

Browse files
committedMay 11, 2024
2 parents 068f5a8 + df3432b commit c9be41e

File tree

6 files changed

+133
-77
lines changed

6 files changed

+133
-77
lines changed
 

‎public/onlyLocation.png

685 Bytes
Loading

‎routers/driverStatus.js

+58-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,63 @@
1-
const router = require('express').Router()
1+
const router = require('express').Router(),
2+
Ride = require('../schemas/rideSchema'),
3+
User = require('../schemas/userSchema')
24

35
router.get('/', async (req,res) => {
4-
5-
res.render("driverStatus", {user: req.user})
6+
const user = req.user
7+
if (user.type != 'Driver') return res.redirect('/status')
8+
const allRides = await Ride.find({})
9+
var myRide = {};
10+
for (let i = 0; i < allRides.length; i++) {
11+
if (allRides[i].driver == user.email) {
12+
const minTime = Math.min(...allRides[i].time)
13+
const overallIndex = allRides[i].time.indexOf(minTime)
14+
myRide.vehicle = allRides[i].vehicle
15+
myRide.dropoff = allRides[i].location[overallIndex].slice(0, 32) + '...'
16+
myRide.time = minTime
17+
myRide.longitude = allRides[i].longitude[overallIndex]
18+
myRide.latitude = allRides[i].latitude[overallIndex]
19+
}
20+
}
21+
res.render("driverStatus", {user: user, ride: myRide})
22+
})
23+
24+
router.post('/vehicle', async (req, res) => {
25+
const user = req.user
26+
const {vehicle} = req.body
27+
if (vehicle != 'bus' && vehicle != 'auto') {
28+
console.log('invalid')
29+
return res.redirect('/driverStatus')
30+
}
31+
const foundRides = await Ride.find({})
32+
for (let i = 0; i < foundRides.length; i++) {
33+
if (foundRides[i].driver == user.email) {
34+
for (let j = 0; j < foundRides[i].riders.length; j++) {
35+
console.log(j)
36+
var newFare = foundRides[i].price[j];
37+
const currentDistance = foundRides[i].distance[j]
38+
if (foundRides[i].vehicle == 'bus' && vehicle == 'auto') {
39+
newFare = (20 + (4.5 * currentDistance)).toFixed(2)
40+
} else if (foundRides[i].vehicle == 'auto' && vehicle == 'bus') {
41+
newFare = (50 + (12.5 * currentDistance)).toFixed(2)
42+
}
43+
foundRides[i].price[j] = newFare
44+
}
45+
console.log(foundRides[i])
46+
await Ride.updateOne({rideId: foundRides[i].rideId}, {
47+
$set: {
48+
vehicle: vehicle,
49+
price: foundRides[i].price
50+
}
51+
})
52+
return res.redirect('/status')
53+
}
54+
}
55+
})
56+
57+
router.get('/cancel', async (req, res) => {
58+
const user = req.user
59+
await Ride.deleteOne({driver: user.email})
60+
res.redirect('/rewards')
661
})
762

863
module.exports = router

‎routers/tempRouter.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,14 @@ const Ride = require('../schemas/rideSchema')
33
const User = require('../schemas/userSchema')
44

55
router.get('/', async (req, res) => {
6-
res.render('temp')
6+
const allUsers = await User.find({})
7+
for (let i = 0; i < allUsers.length; i++) {
8+
await User.updateOne({email: allUsers[i].email}, {
9+
$set: {
10+
status: 'free'
11+
}
12+
})
13+
}
714
})
815

916
module.exports = router

‎routers/verifyRouter.js

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const router = require('express').Router(),
22
Ride = require('../schemas/rideSchema')
33

44
router.get('/', (req, res) => {
5+
// if (req.user.type != 'Driver') return res.redirect('/status')
56
res.render('verify')
67
})
78

‎views/driverStatus.ejs

+66-70
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
}
7979
.top {
8080
width: 100%;
81-
height: 32vh;
81+
height: 27.2vh;
8282
background: #18181b;
8383
border-radius: 14px;
8484
display: flex;
@@ -88,10 +88,10 @@
8888
}
8989
.bottom {
9090
width: 100%;
91-
height: 23vh;
91+
height: 29vh;
9292
/* background: #18181b; */
9393
border-radius: 14px;
94-
gap: 1vw;
94+
gap: 1vh;
9595
display: flex;
9696
flex-direction: column;
9797
align-items: center;
@@ -102,14 +102,36 @@
102102
height: 80%;
103103
background: #18181b;
104104
border-radius: 14px;
105-
padding: 0.7vw;
105+
padding: 0.9vw;
106106
107107
display: flex;
108108
flex-direction: column;
109109
/* align-items: s; */
110110
justify-content: space-evenly;
111+
height: 24vh;
111112
112113
}
114+
.maindiv > div {
115+
background-color: #466eff;
116+
width: 100%;
117+
color: black;
118+
padding: 1vh;
119+
display: flex;
120+
justify-content: space-between;
121+
align-items: center;
122+
border-radius: 100vh;
123+
margin-top: 0.5vh;
124+
font-size: 0.9vw;
125+
}
126+
.whiteRight {
127+
background-color: white;
128+
font-size: 1vw;
129+
height: 1.2vw;
130+
width: 1.2vw;
131+
text-align: center;
132+
color: black;
133+
border-radius: 50vw;
134+
}
113135
.cancel {
114136
width: 20vw;
115137
background: #53FAAA;
@@ -122,11 +144,12 @@
122144
display: flex;
123145
flex-direction: row;
124146
align-items: flex-start;
125-
justify-content: space-around;
147+
justify-content: left;
148+
margin-left: 2.5vw;
126149
}
127150
.names {
128151
gap: 0.5vh;
129-
margin-left: -1.5vw;
152+
margin-left: 1vw;
130153
display: flex;
131154
flex-direction: column;
132155
/* width: ; */
@@ -175,7 +198,6 @@
175198
.location {
176199
display: flex;
177200
flex-direction: row;
178-
align-items: center;
179201
justify-content: center;
180202
width: 100%;
181203
gap: 1vw;
@@ -189,16 +211,17 @@
189211
width: 64%;
190212
}
191213
.image {
192-
height: 13.6vh;
214+
height: 3vh;
193215
/* width: 1.4vw; */
194216
}
195217
.unspecial {
196218
color: rgba(255, 255, 255, 0.26);
197219
font-family: Outfit;
198-
font-size: 1.9vh;
220+
font-size: 1.05vw;
199221
font-style: normal;
200222
font-weight: 400;
201223
line-height: normal;
224+
margin-bottom: 0.5vh;
202225
}
203226
p {
204227
color: #FFF;
@@ -265,8 +288,8 @@
265288
width: 10vw;
266289
}
267290
.pfp {
268-
width: 4vw !important;
269-
height: 4vw !important;
291+
width: 3vw !important;
292+
height: 3vw !important;
270293
border-radius: 2.5vw;
271294
object-fit: cover;
272295
}
@@ -292,6 +315,18 @@
292315
max-width: 90vw;
293316
transform: scale(1.6, 1.6) !important;
294317
}
318+
textarea {
319+
background-color: rgba(43, 43, 43, 0.49);
320+
width: 100%;
321+
height: 8vh;
322+
border: none;
323+
outline: none;
324+
border-radius: 1vh;
325+
resize: none;
326+
padding: 1vh;
327+
color: white;
328+
font-family: 'Outfit';
329+
}
295330
</style>
296331
</head>
297332
<body>
@@ -301,17 +336,9 @@
301336
<h1><span style="color: #466EFF;">Ride</span> Status</h1>
302337
<p>Track your journey in a few clicks!</p>
303338
</div>
304-
<div class="fullBodyOverlay" id="fullBodyOverlay" onclick="toggleOverlay(event)">
305-
<svg id="barcode"></svg>
306-
</div>
307339
<main class="main">
308340
<div class="container">
309-
<div id="map" style="position: relative">
310-
<div class="otpContainer">
311-
<p>Code for this ride</p>
312-
<svg id="barcode2"></svg>
313-
</div>
314-
</div>
341+
<div id="map" style="position: relative"></div>
315342
<div class="right">
316343
<div class="top">
317344
<div class="creds">
@@ -322,81 +349,62 @@
322349
</div>
323350
<div class="times">
324351
<p class="special"><%= ride.time %> Mins</p>
325-
<svg xmlns="http://www.w3.org/2000/svg" width="3" height="3" viewBox="0 0 3 3" fill="none">
326-
<circle cx="1.5" cy="1.5" r="1.5" fill="white" fill-opacity="0.3"/>
327-
</svg>
328-
<p class="special"><%= ride.distance %> Km</p>
329352
</div>
330353
<div class="buttons">
331354
<form action="/status/vehicle" method="POST">
332355
<input type="hidden" name="vehicle" value="auto">
333356
<% if (ride.vehicle == 'auto') { %>
334-
<button style="color: #000; background-color: #53FAAA;" type="submit" data-cursor="pointer">Auto</button>
357+
<button style="color: #000; background-color: #53FAAA; font-size: 0.75vw; padding: 1vh 1.2vh;" type="submit" data-cursor="pointer">Auto</button>
335358
<% } else { %>
336-
<button style="color: #fff; background-color: #212122;" type="submit" data-cursor="pointer">Auto</button>
359+
<button style="color: #fff; background-color: #212122; font-size: 0.75vw; padding: 1vh 1.2vh;" type="submit" data-cursor="pointer">Auto</button>
337360
<% } %>
338361
</form>
339362
<form action="/status/vehicle" method="POST">
340363
<input type="hidden" name="vehicle" value="bus">
341364
<% if (ride.vehicle == 'auto') { %>
342-
<button style="color: #fff; background-color: #212122;" type="submit" data-cursor="pointer">Bus</button>
365+
<button style="color: #fff; background-color: #212122; font-size: 0.75vw; padding: 1vh 1.2vh;" type="submit" data-cursor="pointer">Bus</button>
343366
<% } else { %>
344-
<button style="color: #000; background-color: #53FAAA;" type="submit" data-cursor="pointer">Bus</button>
367+
<button style="color: #000; background-color: #53FAAA; font-size: 0.75vw; padding: 1vh 1.2vh;" type="submit" data-cursor="pointer">Bus</button>
345368
<% } %>
346369
</form>
347370
</div>
348371
</div>
349-
<p>₹<%= ride.price %></p>
350372
</div>
351373
<div class="location">
352-
<img class="image" src="/pickup.png" class="waypoint" alt="">
374+
<img class="image" src="/onlyLocation.png" class="waypoint" alt="">
353375
<div class="points">
354376
<div class="pickup">
355-
<p class="unspecial">Pickup</p>
356-
<p style="width: 10vw; word-wrap: break-word;"><%= ride.myLocation %></p>
357-
</div>
358-
<div class="dropoff">
359-
<p class="unspecial">Dropoff</p>
360-
<p style="width: 10vw; word-wrap: break-word;"><%= ride.dropOff %></p>
377+
<p class="unspecial">Pickup At</p>
378+
<p style="width: 10vw; word-wrap: break-word;"><%= ride.dropoff %></p>
361379
</div>
362380
</div>
363381
</div>
364382
</div>
365383
<div class="bottom">
366384
<div class="maindiv" style="overflow: auto;">
367-
<h1>Grouped <span style="color: #466EFF;">Riders</span> <span style="color: rgba(244, 244, 244, 0.25);">(<%= ride.riders.length %>)</span></h1>
368-
<div class="riders">
369-
<% for (let i = 0; i < ride.riders.length; i++) { %>
370-
<div class="rider">
371-
<img class="pfp-2" src="<%= ride.riders[i].pfp %>" class="person-2" alt="">
372-
<p><%= ride.riders[i].fname + ' ' + ride.riders[i].lname %></p>
373-
</div>
374-
<% } %>
385+
<textarea placeholder="Send Message to User..."></textarea>
386+
<div>
387+
Send Message
388+
<div class="whiteRight"><i class="fas fa-angle-right"></i></div>
375389
</div>
376390
</div>
377-
<form action="/status/cancel" method="post">
391+
<div>
392+
<a href="/verify" style="text-decoration: none">
393+
<button class="cancel" data-cursor="pointer" style="margin-bottom: 1vh; background-color: #18181b; border: 1px solid rgba(255, 255, 255, 0.2); color: white;">
394+
Verify Ride
395+
</button>
396+
</a>
397+
<a href="/driverStatus/cancel" style="text-decoration: none">
378398
<button class="cancel" data-cursor="pointer">
379399
Cancel Ride
380400
</button>
401+
</a>
381402
</form>
382403
</div>
383404
</div>
384405
</div>
385406
</main>
386407
<script>
387-
JsBarcode("#barcode", "<%= ride.otp %>", {
388-
format: 'code128',
389-
displayValue: false,
390-
lineColor: "black",
391-
background: "#fff"
392-
});
393-
JsBarcode("#barcode2", "<%= ride.otp %>", {
394-
format: 'code128',
395-
displayValue: false,
396-
lineColor: "#466eff",
397-
background: "transparent",
398-
height: 55
399-
});
400408
(function showPosition() {
401409
var redMarker = L.icon({
402410
iconUrl: '/marker.png',
@@ -412,20 +420,8 @@
412420
maxZoom: 19
413421
}).addTo(map);
414422
const mapContainer = document.querySelector('.leaflet-container')
415-
const customOverlay = document.createElement('div')
416423
var marker = L.marker([<%= ride.latitude %>, <%= ride.longitude %>], {icon: redMarker}).addTo(map);
417424
})()
418-
const otpContainer = document.getElementsByClassName('otpContainer')[0]
419-
otpContainer.addEventListener('click', (e) => {
420-
document.getElementById('fullBodyOverlay').style.display = 'flex'
421-
document.getElementById('fullBodyOverlay').style.opacity = '1'
422-
})
423-
function toggleOverlay(e) {
424-
if (e.target == document.getElementById('fullBodyOverlay')) {
425-
e.target.style.display = 'none'
426-
e.target.style.opacity = '0'
427-
}
428-
}
429425
</script>
430426
</body>
431427
</html>

‎views/partials/cursor.ejs

-3
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,6 @@
100100
.logout {
101101
font-size: 1vw;
102102
}
103-
.rideStatusPageLink {
104-
color: #466eff !important;
105-
}
106103
</style>
107104
<div class="nav">
108105
<div id="cursor"></div>

0 commit comments

Comments
 (0)
Please sign in to comment.