Skip to content

Commit a64e64c

Browse files
committedSep 13, 2019
feature(notify-new-request): new travel requests
- The push notification - The email notification - Create a notifications table - Install dependencies socket.io and auto-bind - Prepare the server - Set-up the project - Display New travel Requests - Add Notifications - Send Push and Email Notifications [Finishes: #167730641]
1 parent db6cfba commit a64e64c

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed
 

‎src/controllers/travelControllers.js

+14-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import socketEmission from '../services/websocket';
12
import {
23
onewayTripService,
34
showManagerPendingAppr,
@@ -6,14 +7,21 @@ import {
67
} from '../services/travelServices';
78
import { findUserByEmail } from '../services/authServices';
89
import { successResponseWithData, errorResponse } from '../utils/response';
10+
import sendVerificationEmail from '../utils/email';
911

1012
import message from '../utils/messageUtils';
1113
import statusCode from '../utils/statusCode';
1214

15+
const { emission } = socketEmission;
16+
1317
export const createOneWayTrip = async(req, res) => {
1418
try {
1519
const user = await findUserByEmail(req.userData.email);
16-
const { id, dept_id } = user.dataValues;
20+
const { id, email, dept_id } = user.dataValues;
21+
22+
if (!dept_id) {
23+
errorResponse(res, statusCode.badRequest, message.lineManager);
24+
}
1725

1826
const data = await onewayTripService({
1927
user_id: id,
@@ -22,10 +30,15 @@ export const createOneWayTrip = async(req, res) => {
2230
dept_id,
2331
});
2432

33+
const emailVerify = await sendVerificationEmail(email,
34+
'Travel Confirmation', message.notifyUser);
35+
emission('here', 'we made it');
36+
2537
successResponseWithData(
2638
res,
2739
statusCode.created,
2840
message.oneWayTripCreated,
41+
message.oneWayTripCreated,
2942
data
3043
);
3144
} catch (err) {

0 commit comments

Comments
 (0)
Please sign in to comment.