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

GAP-2523 #439

Merged
merged 3 commits into from
Apr 16, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,19 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {
];

async function handleRequest(body: PageBodyResponse, jwt: string) {
const superAdminOnly =
body.newUserRoles.includes(ROLE_IDS.SUPER_ADMIN) &&
!body.newUserRoles.includes(ROLE_IDS.ADMIN);

let departmentPageUrl = `/super-admin-dashboard/user/${userId}/change-department`;

const oldUserRoles = (await getUserById(userId, jwt)).roles.map((role) =>
String(role.id)
);

const newUserRoles = APPLICANT_ROLES_IDS.concat(body.newUserRoles || []);
//case where admin checkbox is disabled (role isn't auto selected)
isOwner ? newUserRoles.push(ROLE_IDS.ADMIN) : null;
//case where user is a Super Admin OR admin checkbox is disabled (role isn't auto selected)
superAdminOnly || isOwner ? newUserRoles.push(ROLE_IDS.ADMIN) : null;

const userDepartment = (await getUserById(userId, jwt)).department;

Expand Down
Loading