Skip to content

Commit d78f9f2

Browse files
committed
added dev suggestions
1 parent 5f3d611 commit d78f9f2

File tree

5 files changed

+101
-65
lines changed

5 files changed

+101
-65
lines changed

src/common/orgs.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,5 @@ export const CommitteeList = [
2727
"Corporate Committee",
2828
"Marketing Committee",
2929
] as const;
30-
export const OrganizationList = ["ACM", ...SIGList, ...CommitteeList];
30+
31+
export const OrganizationList = ["ACM", ...SIGList, ...CommitteeList] as const;

src/common/roles.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ export enum AppRoles {
77
TICKETS_MANAGER = "manage:tickets",
88
IAM_ADMIN = "admin:iam",
99
IAM_INVITE_ONLY = "invite:iam",
10-
USERS_ADMIN = "admin:users",
1110
}
1211
export const allAppRoles = Object.values(AppRoles).filter(
1312
(value) => typeof value === "string",

src/common/types/iam.ts

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { OrganizationList } from "../orgs.js";
12
import { AppRoles } from "../roles.js";
23
import { z } from "zod";
34

@@ -23,7 +24,8 @@ export type InviteUserPostRequest = z.infer<typeof invitePostRequestSchema>;
2324

2425
export const groupMappingCreatePostSchema = z.object({
2526
roles: z.union([
26-
z.array(z.nativeEnum(AppRoles))
27+
z
28+
.array(z.nativeEnum(AppRoles))
2729
.min(1)
2830
.refine((items) => new Set(items).size === items.length, {
2931
message: "All roles must be unique, no duplicate values allowed",
@@ -32,7 +34,6 @@ export const groupMappingCreatePostSchema = z.object({
3234
]),
3335
});
3436

35-
3637
export type GroupMappingCreatePostRequest = z.infer<
3738
typeof groupMappingCreatePostSchema
3839
>;
@@ -65,3 +66,27 @@ export const entraGroupMembershipListResponse = z.array(
6566
export type GroupMemberGetResponse = z.infer<
6667
typeof entraGroupMembershipListResponse
6768
>;
69+
70+
const userOrgSchema = z.object({
71+
netid: z.string().min(1),
72+
org: z.enum(OrganizationList),
73+
});
74+
const userOrgsSchema = z.array(userOrgSchema);
75+
76+
const userNameSchema = z.object({
77+
netid: z.string().min(1),
78+
firstName: z.string().min(1),
79+
middleName: z.string().optional(),
80+
lastName: z.string().min(1),
81+
});
82+
const userNamesSchema = z.array(userNameSchema);
83+
84+
const userSchema = userNameSchema.merge(userOrgSchema);
85+
const usersSchema = z.array(userSchema);
86+
87+
export type UserOrg = z.infer<typeof userOrgSchema>;
88+
export type UserOrgs = z.infer<typeof userOrgsSchema>;
89+
export type UserName = z.infer<typeof userNameSchema>;
90+
export type UserNames = z.infer<typeof userNamesSchema>;
91+
export type User = z.infer<typeof userSchema>;
92+
export type Users = z.infer<typeof usersSchema>;

src/ui/Router.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ const authenticatedRouter = createBrowserRouter([
121121
element: <ViewTicketsPage />,
122122
},
123123
{
124-
path: '/users',
124+
path: '/iam/leads',
125125
element: <ScreenPage />,
126126
},
127127
// Catch-all route for authenticated users shows 404 page

src/ui/pages/screen/Screen.page.tsx

Lines changed: 71 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -12,37 +12,11 @@ import FullScreenLoader from '@ui/components/AuthContext/LoadingScreen';
1212
import { AuthGuard } from '@ui/components/AuthGuard';
1313
import { useApi } from '@ui/util/api';
1414
import { AppRoles } from '@common/roles.js';
15+
import { OrganizationList } from '@common/orgs';
16+
import { User, UserNames, UserOrgs, Users } from '@common/types/iam';
1517

1618
// const repeatOptions = ['weekly', 'biweekly'] as const;
1719

18-
const userSchema = z.object({
19-
netid: z.string().min(1),
20-
firstName: z.string().min(1),
21-
middleName: z.string().optional(),
22-
lastName: z.string().min(1),
23-
sig: z.string(),
24-
// location: z.string(),
25-
// locationLink: z.optional(z.string().url()),
26-
// host: z.string(),
27-
// featured: z.boolean().default(false),
28-
// paidEventId: z.optional(z.string().min(1)),
29-
});
30-
31-
const usersSchema = z.array(userSchema);
32-
33-
// const requestSchema = baseSchema.extend({
34-
// repeats: z.optional(z.enum(repeatOptions)),
35-
// repeatEnds: z.string().optional(),
36-
// });
37-
38-
// const getEventSchema = requestSchema.extend({
39-
// id: z.string(),
40-
// upcoming: z.boolean().optional(),
41-
// });
42-
43-
export type User = z.infer<typeof userSchema>;
44-
export type Users = z.infer<typeof usersSchema>;
45-
4620
// export type EventGetResponse = z.infer<typeof getEventSchema>;
4721
// const getEventsSchema = z.array(getEventSchema);
4822
// export type EventsGetResponse = z.infer<typeof getEventsSchema>;
@@ -68,7 +42,7 @@ export const ScreenPage: React.FC = () => {
6842
<Table.Td>{user.firstName}</Table.Td>
6943
<Table.Td>{user.middleName}</Table.Td>
7044
<Table.Td>{user.lastName}</Table.Td>
71-
<Table.Td>{user.sig}</Table.Td>
45+
<Table.Td>{user.org}</Table.Td>
7246
{/* <Table.Td>{dayjs(event.start).format('MMM D YYYY hh:mm')}</Table.Td>
7347
<Table.Td>{event.end ? dayjs(event.end).format('MMM D YYYY hh:mm') : 'N/A'}</Table.Td>
7448
<Table.Td>{event.location}</Table.Td>
@@ -112,36 +86,74 @@ export const ScreenPage: React.FC = () => {
11286
// return { ...item, upcoming: false };
11387
// });
11488

115-
// prettier-ignore
116-
const mockUserResponse: Users = [
117-
{ netid: "ethanc12", firstName: "Ethan", middleName:"Yuting", lastName: "Chang", sig: "Infra"},
118-
{ netid: "johnd01", firstName: "John", lastName: "Doe", sig: "SIGMusic" },
119-
{ netid: "sarahg23", firstName: "Sarah", middleName: "Grace", lastName: "Gonzalez", sig: "SIGQuantum" },
120-
{ netid: "miker44", firstName: "Michael", lastName: "Roberts", sig: "SIGPlan" },
121-
{ netid: "annaw02", firstName: "Anna", middleName: "Marie", lastName: "Williams", sig: "SIGMobile" },
122-
{ netid: "chrisb19", firstName: "Christopher", lastName: "Brown", sig: "SIGCHI" },
123-
{ netid: "laurenp87", firstName: "Lauren", middleName: "Patricia", lastName: "Perez", sig: "SIGPwny" },
124-
{ netid: "ethanw12", firstName: "Ethan", lastName: "Wong", sig: "SIGEcom" },
125-
{ netid: "emilyh54", firstName: "Emily", lastName: "Hernandez", sig: "SIGRobotics" },
126-
{ netid: "kevink11", firstName: "Kevin", middleName: "Lee", lastName: "Kim", sig: "Infra" },
127-
{ netid: "juliel08", firstName: "Julie", lastName: "Lopez", sig: "SIGGRAPH" },
128-
{ netid: "mattt92", firstName: "Matthew", middleName: "Thomas", lastName: "Taylor", sig: "SIGtricity" },
129-
{ netid: "rachelb03", firstName: "Rachel", lastName: "Bell", sig: "SIGSYS" },
130-
{ netid: "stephenj45", firstName: "Stephen", middleName: "James", lastName: "Johnson", sig: "SIGAIDA" },
131-
{ netid: "ashleyc28", firstName: "Ashley", lastName: "Clark", sig: "SIGNLL" },
132-
{ netid: "briand77", firstName: "Brian", lastName: "Davis", sig: "SIGMA" },
133-
{ netid: "meganf65", firstName: "Megan", lastName: "Flores", sig: "SIGPolicy" },
134-
{ netid: "danielh04", firstName: "Daniel", lastName: "Hughes", sig: "SIGARCH" },
135-
{ netid: "victorc16", firstName: "Victor", middleName: "Charles", lastName: "Carter", sig: "SIGGLUG" },
136-
{ netid: "lindam29", firstName: "Linda", lastName: "Martinez", sig: "SIGMobile" },
137-
{ netid: "paulf31", firstName: "Paul", lastName: "Fisher", sig: "SIGMusic" },
138-
{ netid: "susana80", firstName: "Susan", middleName: "Ann", lastName: "Anderson", sig: "SIGPwny" },
139-
{ netid: "markl13", firstName: "Mark", lastName: "Lewis", sig: "SIGCHI" },
140-
{ netid: "carolynb59", firstName: "Carolyn", lastName: "Barnes", sig: "SIGSYS" },
141-
{ netid: "patrickh37", firstName: "Patrick", middleName: "Henry", lastName: "Hill", sig: "SIGQuantum" },
142-
{ netid: "nataliep71", firstName: "Natalie", lastName: "Price", sig: "SIGPolicy" },
89+
// get request for user orgs
90+
const userOrgsResponse: UserOrgs = [
91+
{ netid: 'johnd01', org: 'SIGMusic' },
92+
{ netid: 'miker44', org: 'SIGPLAN' },
93+
{ netid: 'chrisb19', org: 'SIGCHI' },
94+
{ netid: 'ethanw12', org: 'SIGecom' },
95+
{ netid: 'emilyh54', org: 'SIGRobotics' },
96+
{ netid: 'juliel08', org: 'SIGGRAPH' },
97+
{ netid: 'rachelb03', org: 'GameBuilders' },
98+
{ netid: 'ashleyc28', org: 'SIGNLL' },
99+
{ netid: 'briand77', org: 'SIGma' },
100+
{ netid: 'meganf65', org: 'SIGPolicy' },
101+
{ netid: 'danielh04', org: 'SIGARCH' },
102+
{ netid: 'lindam29', org: 'SIGMobile' },
103+
{ netid: 'paulf31', org: 'SIGMusic' },
104+
{ netid: 'markl13', org: 'SIGCHI' },
105+
{ netid: 'carolynb59', org: 'ACM' },
106+
{ netid: 'nataliep71', org: 'SIGPolicy' },
107+
108+
{ netid: 'ethanc12', org: 'Infrastructure Committee' },
109+
{ netid: 'sarahg23', org: 'SIGQuantum' },
110+
{ netid: 'annaw02', org: 'SIGMobile' },
111+
{ netid: 'laurenp87', org: 'SIGPwny' },
112+
{ netid: 'kevink11', org: 'Infrastructure Committee' },
113+
{ netid: 'mattt92', org: 'SIGtricity' },
114+
{ netid: 'stephenj45', org: 'SIGAIDA' },
115+
{ netid: 'victorc16', org: 'GLUG' },
116+
{ netid: 'susana80', org: 'SIGPwny' },
117+
{ netid: 'patrickh37', org: 'SIGQuantum' },
118+
];
119+
120+
// retrieve from azure active directory (aad)
121+
const userNamesResponse: UserNames = [
122+
{ netid: 'johnd01', firstName: 'John', lastName: 'Doe' },
123+
{ netid: 'miker44', firstName: 'Michael', lastName: 'Roberts' },
124+
{ netid: 'chrisb19', firstName: 'Christopher', lastName: 'Brown' },
125+
{ netid: 'ethanw12', firstName: 'Ethan', lastName: 'Wong' },
126+
{ netid: 'emilyh54', firstName: 'Emily', lastName: 'Hernandez' },
127+
{ netid: 'juliel08', firstName: 'Julie', lastName: 'Lopez' },
128+
{ netid: 'rachelb03', firstName: 'Rachel', lastName: 'Bell' },
129+
{ netid: 'ashleyc28', firstName: 'Ashley', lastName: 'Clark' },
130+
{ netid: 'briand77', firstName: 'Brian', lastName: 'Davis' },
131+
{ netid: 'meganf65', firstName: 'Megan', lastName: 'Flores' },
132+
{ netid: 'danielh04', firstName: 'Daniel', lastName: 'Hughes' },
133+
{ netid: 'lindam29', firstName: 'Linda', lastName: 'Martinez' },
134+
{ netid: 'paulf31', firstName: 'Paul', lastName: 'Fisher' },
135+
{ netid: 'markl13', firstName: 'Mark', lastName: 'Lewis' },
136+
{ netid: 'carolynb59', firstName: 'Carolyn', lastName: 'Barnes' },
137+
{ netid: 'nataliep71', firstName: 'Natalie', lastName: 'Price' },
138+
139+
{ netid: 'ethanc12', firstName: 'Ethan', middleName: 'Yuting', lastName: 'Chang' },
140+
{ netid: 'sarahg23', firstName: 'Sarah', middleName: 'Grace', lastName: 'Gonzalez' },
141+
{ netid: 'annaw02', firstName: 'Anna', middleName: 'Marie', lastName: 'Williams' },
142+
{ netid: 'laurenp87', firstName: 'Lauren', middleName: 'Patricia', lastName: 'Perez' },
143+
{ netid: 'kevink11', firstName: 'Kevin', middleName: 'Lee', lastName: 'Kim' },
144+
{ netid: 'mattt92', firstName: 'Matthew', middleName: 'Thomas', lastName: 'Taylor' },
145+
{ netid: 'stephenj45', firstName: 'Stephen', middleName: 'James', lastName: 'Johnson' },
146+
{ netid: 'victorc16', firstName: 'Victor', middleName: 'Charles', lastName: 'Carter' },
147+
{ netid: 'susana80', firstName: 'Susan', middleName: 'Ann', lastName: 'Anderson' },
148+
{ netid: 'patrickh37', firstName: 'Patrick', middleName: 'Henry', lastName: 'Hill' },
143149
];
144-
setUserList(mockUserResponse);
150+
151+
const mergedResponse: Users = userOrgsResponse.map((orgObj) => {
152+
const nameObj = userNamesResponse.find((name) => name.netid === orgObj.netid);
153+
return { ...orgObj, ...nameObj } as User;
154+
});
155+
156+
setUserList(mergedResponse);
145157
};
146158
getUsers();
147159
}, []);
@@ -170,7 +182,6 @@ export const ScreenPage: React.FC = () => {
170182
}
171183

172184
return (
173-
// <AuthGuard resourceDef={{ service: 'core', validRoles: [AppRoles.USERS_ADMIN] }}>
174185
<AuthGuard resourceDef={{ service: 'core', validRoles: [AppRoles.IAM_ADMIN] }}>
175186
{userRemoved && (
176187
<Modal
@@ -217,7 +228,7 @@ export const ScreenPage: React.FC = () => {
217228
<Table.Th>First Name</Table.Th>
218229
<Table.Th>Middle Name</Table.Th>
219230
<Table.Th>Last Name</Table.Th>
220-
<Table.Th>Affiliated Special Interest Group</Table.Th>
231+
<Table.Th>Organization</Table.Th>
221232
<Table.Th>Actions</Table.Th>
222233
</Table.Tr>
223234
</Table.Thead>

0 commit comments

Comments
 (0)