finalize ldap

pull/403/head
Rebecca-Chou 9 months ago
parent 0c0515a3c6
commit 856f849526
  1. 39
      lib/members.ts

@ -8,19 +8,9 @@ export interface Member {
program: string;
}
const execPositions: { [name: string]: number } = {
president: 1,
"vice-president": 2,
secretary: 3,
treasurer: 4,
sysadmin: 5,
};
export async function getMembers(year: string, term: Term): Promise<Member[]> {
if (process.env.USE_LDAP?.toLowerCase() !== "true") {
return dummyMembers.sort((item1: Member, item2: Member) => {
return execPositions[item1.program] - execPositions[item2.program];
});
return dummyMembers;
}
let members: Member[] = [];
@ -43,18 +33,12 @@ export async function getMembers(year: string, term: Term): Promise<Member[]> {
return {
name: item.cn as string,
id: item.uid as string,
program:
item.position === undefined
? ""
: typeof item.position === "string"
? item.position
: (item.position[0] as string),
program: item.program === undefined ? "" : (item.program as string),
};
})
.filter((item: Member) => item.program !== "");
// .sort((item1: Member, item2: Member) => {
// return execPositions[item1.program] - execPositions[item2.program];
// });
.sort((item1: Member, item2: Member) =>
item1.name.localeCompare(item2.name)
);
} finally {
await client.unbind();
}
@ -64,18 +48,13 @@ export async function getMembers(year: string, term: Term): Promise<Member[]> {
const dummyMembers: Member[] = [
{
name: "Alice ",
id: "a12smith",
program: "sysadmin",
name: "John Smith",
id: "j12smith",
program: "MAT/Mathematics Computer Science",
},
{
name: "Jane Smith",
id: "j34smith",
program: "vice-president",
},
{
name: "John Smith",
id: "j12smith",
program: "presidentcro",
program: "MAT/Mathematics Computer Science",
},
];

Loading…
Cancel
Save