-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ft(avail request for approval): Add feature that avails requests made…
… by users to the manager they report to - Add get requests route - Add validations - Add tests [Finishes #169258643]
- Loading branch information
Showing
22 changed files
with
236 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { userProfile } from '../database/models'; | ||
import Customize from '../helpers/Customize'; | ||
|
||
/** | ||
* @export | ||
* @class TripMiddleware | ||
*/ | ||
class TripMiddleware { | ||
/** | ||
* Get line manager for trip requests | ||
* @static | ||
* @param {object} req request object | ||
* @param {object} res response object | ||
* @param {object} next next | ||
* @memberof TripMiddleware | ||
* @returns {object} data | ||
*/ | ||
static async getLineManager(req, res, next) { | ||
const { id } = req.user; | ||
const userIdProfile = await userProfile.findOne({ where: { userId: id } }); | ||
if (!userIdProfile.managerId) { | ||
return Customize.errorMessage(req, res, 'Please update your line manager', 404); | ||
} | ||
const { managerId } = userProfile; | ||
req.body.managerId = managerId; | ||
return next(); | ||
} | ||
} | ||
export default TripMiddleware; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import database from '../database/models'; | ||
|
||
/** | ||
* Find a specific user. | ||
* @param {object} object The user object. | ||
* @returns {object} A specific user object. | ||
*/ | ||
class TripService { | ||
/** | ||
* Manager should be able to view approvals | ||
* @static | ||
* @param {object}id object | ||
* @memberof UserController | ||
* @returns {object} data | ||
*/ | ||
static async tripRequestsToSpecificManager(id) { | ||
return database.userProfile.findAll({ | ||
where: { managerId: id }, | ||
attributes: ['id', 'userId'], | ||
include: [ | ||
{ | ||
model: database.users, | ||
attributes: ['id', 'firstName', 'lastName'], | ||
as: 'user', | ||
include: [ | ||
{ | ||
model: database.tripRequests, | ||
where: { statusId: 1 }, | ||
attributes: ['id', 'tripTypeId', 'statusId'], | ||
include: [ | ||
{ | ||
model: database.trips | ||
} | ||
] | ||
} | ||
], | ||
} | ||
], | ||
}); | ||
} | ||
} | ||
|
||
export default TripService; |
Oops, something went wrong.