reorganize start...
This commit is contained in:
35
src/lib/utils.js
Normal file
35
src/lib/utils.js
Normal file
@@ -0,0 +1,35 @@
|
||||
exports.teamsnapAvailabilitiesSort = (a, b) => {
|
||||
status_code_sort = [
|
||||
teamsnap.AVAILABILITIES.YES,
|
||||
teamsnap.AVAILABILITIES.MAYBE,
|
||||
teamsnap.AVAILABILITIES.NO,
|
||||
teamsnap.AVAILABILITIES.NONE,
|
||||
];
|
||||
a_sort = status_code_sort.indexOf(a.statusCode);
|
||||
b_sort = status_code_sort.indexOf(b.statusCode);
|
||||
if (a_sort > b_sort) {
|
||||
return 1;
|
||||
}
|
||||
if (a_sort < b_sort) {
|
||||
return -1;
|
||||
}
|
||||
if (a_sort == b_sort) {
|
||||
if (a.member.lastName < b.member.lastName) {
|
||||
return -1;
|
||||
}
|
||||
if (a.member.lastName > b.member.lastName) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
exports.initTeamsnap = (req, res, next) => {
|
||||
if (!teamsnap.isAuthed()) {
|
||||
teamsnap.init(process.env["TEAMSNAP_CLIENT_ID"]);
|
||||
teamsnap.auth(req.user.accessToken);
|
||||
}
|
||||
teamsnap.loadCollections((err) => {
|
||||
teamsnap.enablePersistence();
|
||||
next(req, res, next);
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user