reorganize start...

This commit is contained in:
2023-08-19 12:13:41 -05:00
parent c9eaadf688
commit 70a7981ca5
49 changed files with 1189 additions and 7464 deletions

35
src/lib/utils.js Normal file
View 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);
});
};