Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 5c6dd8e

Browse files
authoredSep 14, 2019
Merge branch 'develop' into ft-notify-new-travel-167730641
2 parents eeda180 + 38a8594 commit 5c6dd8e

File tree

2 files changed

+91
-0
lines changed

2 files changed

+91
-0
lines changed
 

‎src/controllers/travelControllers.js

+16
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,21 @@ 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+
}
129+
114130
};
115131

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

‎src/utils/messageUtils.js

+75
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// This function handles messages
22
export default {
3+
34
defaultWelcome: [
45
'Welcome to Barefoot Nomad server.',
56
'use /api/v1 as the base path url for the APIs of this app.',
@@ -70,4 +71,78 @@ export default {
7071
accommodationNotFound: 'The accommodation facility does not exist.',
7172
invalidAccommodationId: 'The Accommodation ID must be an integer value.',
7273
emptyFeedback: 'Feedback field cannot be empty.',
74+
75+
defaultWelcome: [
76+
'Welcome to Barefoot Nomad server.',
77+
'use /api/v1 as the base path url for the APIs of this app.',
78+
],
79+
welcome: 'Welcome to Archangel Barefoot Nomad Web App API.',
80+
signupSuccess: (email) => `You have successfully registered with this email, ${email}.`,
81+
// Travel requests messages
82+
oneWayTripCreated: 'Your request has been successfully created',
83+
managerApproval: (pendingReq) => `You have ${pendingReq} requests requiring your approval`,
84+
managerNotFound: "Manager's detail missing",
85+
requestNotOpen: 'Your request is no longer open for editing.',
86+
requestUpdated: 'Your request has been successfully updated',
87+
noEmail: 'Email cannot be empty.',
88+
userApproval: 'Here are your request status',
89+
// sign-up validation messages
90+
invalidEmail: 'Please, enter a valid email address.',
91+
usedEmail: (email) => `User with this email (${email}) already exist.`,
92+
shortPassword: 'The length of the password must be 8 and above.',
93+
noDigitInPassword: 'Password must contain at least one digit.',
94+
commentNotFound: 'The comment does not exist.',
95+
dateForFuture:
96+
'Please enter a date greater than the departure date for return date.',
97+
dateForToday:
98+
"Please your departure date must be equal to or greater than today's date.",
99+
deleteComment: 'Comment successfully deleted.',
100+
diffDepartment: 'You are not in the same department as the Travel Requester.',
101+
emptyAccommodation: 'You must select an accommodation.',
102+
emptyComment: 'comment cannot be empty.',
103+
emptyDepartureDate: 'You must state your departure date',
104+
emptyDestination: 'You must state your destination',
105+
emptyEmail: 'Email cannot be empty.',
106+
emptyFirstname: 'First name cannot be empty.',
107+
emptyLastname: 'Last name cannot be empty.',
108+
emptyOrigin: 'You must state your current city.',
109+
emptyReturnDate: 'You must state your return date',
110+
emptyTravelPurpose: 'You must state your travel purpose',
111+
emptyTravelType: 'Sorry, travel type can not be empty.',
112+
incorrectPassword: 'Sorry, the password entered is not correct.',
113+
isNotInteger: 'You must enter a valid integer type.',
114+
isNotISODate: "Your date must be of ISO8601 standard '2019-01-10'.",
115+
invalidToken: 'Invalid Token, please login.',
116+
invalidTravelType: 'Sorry you can only make return trip request here.',
117+
invalidTravelId: 'The travel ID must be an integer value.',
118+
invalidUserId:
119+
'Sorry you can only create the request with the id of the logged in user.',
120+
lettersAlone: 'Only letters are allowed',
121+
loginSuccess: 'You have been logged in sucessfully.',
122+
logoutSuccess: 'Logged out successfully.',
123+
nonExistentTravel: 'The travel request does not exist.',
124+
requestNotPending: 'This Travel Request is not Pending.',
125+
returnTripCreated: 'Your return trip request was created successfully.',
126+
// comment messages
127+
successComment: [
128+
'You have successfully commented on a travel request.',
129+
'You have successfully retrieved all comments for this travel request.',
130+
],
131+
travelNotFound: 'The travel request does not exist.',
132+
unauthorized: 'Not authorized.',
133+
unauthorizedAccessToTravel:
134+
'Access denied. Accessible only by travel requester or his/her line manager.',
135+
unauthorizedCommentDelete: "comment can only be deleted by it's author",
136+
successfullyApproval: (requester) => `You have successfully approved a travel request from ${requester}.`,
137+
userEmailNotFound: (email) => `Sorry, there is no user with email ${email} in the database.`,
138+
userIdNotFound: (id) => `Sorry, there is no user with id: ${id} in the database.`,
139+
unregisteredEmail: (email) => `User with this email (${email}) not found in our database.`,
140+
wrongRole: (role) => `Sorry, you are not a/an ${role}.`,
141+
142+
newFeedback: (accomm) => `You have successfully dropped a feedback on our accomodation facility with name, ${accomm}.`,
143+
getFeedback: (accomm) => `You have successfully retrieved feedback on our accommodation facility with name, ${accomm}.`,
144+
accommodationNotFound: 'The accommodation facility does not exist.',
145+
invalidAccommodationId: 'The Accommodation ID must be an integer value.',
146+
emptyFeedback: 'Feedback field cannot be empty.',
147+
73148
};

0 commit comments

Comments
 (0)