Skip to content

Commit 0396070

Browse files
authored
Merge branch 'develop' into ft-notify-new-travel-167730641
2 parents eeda180 + 38a8594 commit 0396070

File tree

2 files changed

+89
-68
lines changed

2 files changed

+89
-68
lines changed

src/controllers/travelControllers.js

+15
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ const pendingManagerApproval = async(req, res) => {
9494
}
9595
};
9696

97+
9798
const getUserTravelStatus = async(req, res) => {
9899
const { role, id } = req.userData;
99100

@@ -111,6 +112,20 @@ const getUserTravelStatus = async(req, res) => {
111112
} catch (error) {
112113
errorResponse(res, statusCode.serverError, error);
113114
}
115+
116+
const approveTravelRequest = async (req, res) => {
117+
try {
118+
const updatedTravel = await approveTravel(req.params.travel_id);
119+
120+
successResponseWithData(
121+
res,
122+
statusCode.success,
123+
message.successfullyApproval(req.body.requesterName),
124+
updatedTravel[1][0]
125+
);
126+
} catch (err) {
127+
errorResponse(res, statusCode.serverError, err);
128+
}
114129
};
115130

116131
const approveTravelRequest = async(req, res) => {

src/utils/messageUtils.js

+74-68
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,79 @@
11
// This function handles messages
22
export default {
3-
defaultWelcome: [
4-
'Welcome to Barefoot Nomad server.',
5-
'use /api/v1 as the base path url for the APIs of this app.',
6-
],
7-
welcome: 'Welcome to Archangel Barefoot Nomad Web App API.',
8-
signupSuccess: (email) => `You have successfully registered with this email, ${email}.`,
9-
// Travel requests messages
10-
oneWayTripCreated: 'Your request has been successfully created',
11-
managerApproval: (pendingReq) => `You have ${pendingReq} requests requiring your approval`,
12-
managerNotFound: "Manager's detail missing",
13-
requestNotOpen: 'Your request is no longer open for editing.',
14-
requestUpdated: 'Your request has been successfully updated',
15-
noEmail: 'Email cannot be empty.',
16-
userApproval: 'Here are your request status',
17-
// sign-up validation messages
18-
invalidEmail: 'Please, enter a valid email address.',
19-
usedEmail: (email) => `User with this email (${email}) already exist.`,
20-
shortPassword: 'The length of the password must be 8 and above.',
21-
noDigitInPassword: 'Password must contain at least one digit.',
22-
commentNotFound: 'The comment does not exist.',
23-
dateForFuture: 'Please enter a date greater than the departure date for return date.',
24-
dateForToday: "Please your departure date must be equal to or greater than today's date.",
25-
deleteComment: 'Comment successfully deleted.',
26-
diffDepartment: 'You are not in the same department as the Travel Requester.',
27-
emptyAccommodation: 'You must select an accommodation.',
28-
emptyComment: 'comment cannot be empty.',
29-
emptyDepartureDate: 'You must state your departure date',
30-
emptyDestination: 'You must state your destination',
31-
emptyEmail: 'Email cannot be empty.',
32-
emptyFirstname: 'First name cannot be empty.',
33-
emptyLastname: 'Last name cannot be empty.',
34-
emptyOrigin: 'You must state your current city.',
35-
emptyReturnDate: 'You must state your return date',
36-
emptyTravelPurpose: 'You must state your travel purpose',
37-
emptyTravelType: 'Sorry, travel type can not be empty.',
38-
notifyUser: 'Your travel request has been successfully created and it is awaiting approval',
3+
4+
defaultWelcome: [
5+
'Welcome to Barefoot Nomad server.',
6+
'use /api/v1 as the base path url for the APIs of this app.',
7+
],
8+
welcome: 'Welcome to Archangel Barefoot Nomad Web App API.',
9+
signupSuccess: (email) => `You have successfully registered with this email, ${email}.`,
10+
// Travel requests messages
11+
oneWayTripCreated: 'Your request has been successfully created',
12+
managerApproval: (pendingReq) => `You have ${pendingReq} requests requiring your approval`,
13+
managerNotFound: "Manager's detail missing",
14+
requestNotOpen: 'Your request is no longer open for editing.',
15+
requestUpdated: 'Your request has been successfully updated',
16+
noEmail: 'Email cannot be empty.',
17+
userApproval: 'Here are your request status',
18+
// sign-up validation messages
19+
invalidEmail: 'Please, enter a valid email address.',
20+
usedEmail: (email) => `User with this email (${email}) already exist.`,
21+
shortPassword: 'The length of the password must be 8 and above.',
22+
noDigitInPassword: 'Password must contain at least one digit.',
23+
commentNotFound: 'The comment does not exist.',
24+
dateForFuture:
25+
'Please enter a date greater than the departure date for return date.',
26+
dateForToday:
27+
"Please your departure date must be equal to or greater than today's date.",
28+
deleteComment: 'Comment successfully deleted.',
29+
diffDepartment: 'You are not in the same department as the Travel Requester.',
30+
emptyAccommodation: 'You must select an accommodation.',
31+
emptyComment: 'comment cannot be empty.',
32+
emptyDepartureDate: 'You must state your departure date',
33+
emptyDestination: 'You must state your destination',
34+
emptyEmail: 'Email cannot be empty.',
35+
emptyFirstname: 'First name cannot be empty.',
36+
emptyLastname: 'Last name cannot be empty.',
37+
emptyOrigin: 'You must state your current city.',
38+
emptyReturnDate: 'You must state your return date',
39+
emptyTravelPurpose: 'You must state your travel purpose',
40+
emptyTravelType: 'Sorry, travel type can not be empty.',
41+
notifyUser: 'Your travel request has been successfully created and it is awaiting approval',
3942
lineManager: 'Line manager must be present to continue',
40-
incorrectPassword: 'Sorry, the password entered is not correct.',
41-
isNotInteger: 'You must enter a valid integer type.',
42-
isNotISODate: "Your date must be of ISO8601 standard '2019-01-10'.",
43-
invalidToken: 'Invalid Token, please login.',
44-
invalidTravelType: 'Sorry you can only make return trip request here.',
45-
invalidTravelId: 'The travel ID must be an integer value.',
46-
invalidUserId: 'Sorry you can only create the request with the id of the logged in user.',
47-
lettersAlone: 'Only letters are allowed',
48-
loginSuccess: 'You have been logged in sucessfully.',
49-
logoutSuccess: 'Logged out successfully.',
50-
nonExistentTravel: 'The travel request does not exist.',
51-
requestNotPending: 'This Travel Request is not Pending.',
52-
returnTripCreated: 'Your return trip request was created successfully.',
53-
// comment messages
54-
successComment: [
55-
'You have successfully commented on a travel request.',
56-
'You have successfully retrieved all comments for this travel request.',
57-
],
58-
travelNotFound: 'The travel request does not exist.',
59-
unauthorized: 'Not authorized.',
60-
unauthorizedAccessToTravel: 'Access denied. Accessible only by travel requester or his/her line manager.',
61-
unauthorizedCommentDelete: "comment can only be deleted by it's author",
62-
successfullyApproval: (requester) => `You have successfully approved a travel request from ${requester}.`,
63-
userEmailNotFound: (email) => `Sorry, there is no user with email ${email} in the database.`,
64-
userIdNotFound: (id) => `Sorry, there is no user with id: ${id} in the database.`,
65-
unregisteredEmail: (email) => `User with this email (${email}) not found in our database.`,
66-
wrongRole: (role) => `Sorry, you are not a/an ${role}.`,
43+
incorrectPassword: 'Sorry, the password entered is not correct.',
44+
isNotInteger: 'You must enter a valid integer type.',
45+
isNotISODate: "Your date must be of ISO8601 standard '2019-01-10'.",
46+
invalidToken: 'Invalid Token, please login.',
47+
invalidTravelType: 'Sorry you can only make return trip request here.',
48+
invalidTravelId: 'The travel ID must be an integer value.',
49+
invalidUserId:
50+
'Sorry you can only create the request with the id of the logged in user.',
51+
lettersAlone: 'Only letters are allowed',
52+
loginSuccess: 'You have been logged in sucessfully.',
53+
logoutSuccess: 'Logged out successfully.',
54+
nonExistentTravel: 'The travel request does not exist.',
55+
requestNotPending: 'This Travel Request is not Pending.',
56+
returnTripCreated: 'Your return trip request was created successfully.',
57+
// comment messages
58+
successComment: [
59+
'You have successfully commented on a travel request.',
60+
'You have successfully retrieved all comments for this travel request.',
61+
],
62+
travelNotFound: 'The travel request does not exist.',
63+
unauthorized: 'Not authorized.',
64+
unauthorizedAccessToTravel:
65+
'Access denied. Accessible only by travel requester or his/her line manager.',
66+
unauthorizedCommentDelete: "comment can only be deleted by it's author",
67+
successfullyApproval: (requester) => `You have successfully approved a travel request from ${requester}.`,
68+
userEmailNotFound: (email) => `Sorry, there is no user with email ${email} in the database.`,
69+
userIdNotFound: (id) => `Sorry, there is no user with id: ${id} in the database.`,
70+
unregisteredEmail: (email) => `User with this email (${email}) not found in our database.`,
71+
wrongRole: (role) => `Sorry, you are not a/an ${role}.`,
72+
73+
newFeedback: (accomm) => `You have successfully dropped a feedback on our accomodation facility with name, ${accomm}.`,
74+
getFeedback: (accomm) => `You have successfully retrieved feedback on our accommodation facility with name, ${accomm}.`,
75+
accommodationNotFound: 'The accommodation facility does not exist.',
76+
invalidAccommodationId: 'The Accommodation ID must be an integer value.',
77+
emptyFeedback: 'Feedback field cannot be empty.',
6778

68-
newFeedback: (accomm) => `You have successfully dropped a feedback on our accomodation facility with name, ${accomm}.`,
69-
getFeedback: (accomm) => `You have successfully retrieved feedback on our accommodation facility with name, ${accomm}.`,
70-
accommodationNotFound: 'The accommodation facility does not exist.',
71-
invalidAccommodationId: 'The Accommodation ID must be an integer value.',
72-
emptyFeedback: 'Feedback field cannot be empty.',
7379
};

0 commit comments

Comments
 (0)