Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

N21-2216 Fix outdated users for team invitations #3529

Merged
merged 3 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions controllers/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const express = require('express');
const router = express.Router();
const api = require('../api');
const { setCookie } = require('../helpers/cookieHelper');
const { isUserHidden } = require('../helpers/users');

// users

Expand All @@ -16,12 +17,15 @@ router.get('/teachersOfSchool', async (req, res, next) => {
},
});

users.data = users.data.filter((user) => !isUserHidden(user, res.locals.currentSchoolData));

const result = users.data.map((user) => ({
_id: user._id,
firstName: user.firstName,
lastName: user.lastName,
schoolId: user.schoolId,
email: user.email,
outdatedSince: user.outdatedSince,
}));

return res.json(result);
Expand All @@ -43,11 +47,14 @@ router.get('/teachersWithEmail', async (req, res, next) => {
},
});

users.data = users.data.filter((user) => !isUserHidden(user, res.locals.currentSchoolData));

const result = users.data.map((user) => ({
_id: user._id,
firstName: user.firstName,
lastName: user.lastName,
schoolName: user.schoolId.name,
outdatedSince: user.outdatedSince,
}));

return res.json(result);
Expand Down
5 changes: 3 additions & 2 deletions static/scripts/teamMembers.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,8 @@ $(document).ready(() => {
},
}).done((users) => {
users.forEach((user) => {
teacherSelect.append(`<option value="${user._id}">${user.firstName} ${user.lastName}</option>`);
const fullName = `${user.firstName} ${user.lastName}${user.outdatedSince ? ' ~~' : ''}`;
teacherSelect.append(`<option value="${user._id}">${fullName}</option>`);
});
teacherSelect.trigger('chosen:updated');
}).fail(() => {
Expand Down Expand Up @@ -306,7 +307,7 @@ $(document).ready(() => {
teacherSelect.find('option').remove();

users.forEach((user) => {
const displayText = `${user.firstName} ${user.lastName} - ${user.schoolName}`;
const displayText = `${user.firstName} ${user.lastName}${user.outdatedSince ? ' ~~' : ''} - ${user.schoolName}`;
teacherSelect.append(`<option value="${user._id}">${displayText}</option>`);
});
teacherSelect.trigger('chosen:updated');
Expand Down
Loading