Skip to content

Commit 6186034

Browse files
authored
Create a new way to store org info (#2)
1 parent 9e37f8f commit 6186034

File tree

2 files changed

+44
-65
lines changed

2 files changed

+44
-65
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@acm-uiuc/js-shared",
3-
"version": "2.4.0",
3+
"version": "3.0.0",
44
"description": "ACM UIUC Shared JS code",
55
"main": "dist/index.js",
66
"module": "dist/index.js",

src/orgs.ts

Lines changed: 43 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,48 @@
1-
import { EnsureUniqueValues } from "util";
1+
export enum OrgType {
2+
MAIN = "main",
3+
SIG = "sig",
4+
COMMITTEE = "committee",
5+
MISC = "misc",
6+
}
27

3-
export const SIGList = [
4-
"SIGPwny",
5-
"SIGCHI",
6-
"GameBuilders",
7-
"SIGAIDA",
8-
"SIGGRAPH",
9-
"ICPC",
10-
"SIGMobile",
11-
"SIGMusic",
12-
"GLUG",
13-
"SIGNLL",
14-
"SIGma",
15-
"SIGQuantum",
16-
"SIGecom",
17-
"SIGPLAN",
18-
"SIGPolicy",
19-
"SIGARCH",
20-
"SIGRobotics",
21-
"SIGtricity",
22-
] as [string, ...string[]];
8+
export const Organizations = {
9+
"A01": { name: "ACM", type: OrgType.MAIN, shortcode: "acm" },
10+
"S01": { name: "SIGPwny", type: OrgType.SIG, shortcode: "sigpwny" },
11+
"S02": { name: "SIGCHI", type: OrgType.SIG, shortcode: "sigchi" },
12+
"S03": { name: "GameBuilders", type: OrgType.SIG, shortcode: "gamebuilders" },
13+
"S04": { name: "SIGAIDA", type: OrgType.SIG, shortcode: "sigaida" },
14+
"S05": { name: "SIGGRAPH", type: OrgType.SIG, shortcode: "siggraph" },
15+
"S06": { name: "ICPC", type: OrgType.SIG, shortcode: "icpc" },
16+
"S07": { name: "SIGMobile", type: OrgType.SIG, shortcode: "sigmobile" },
17+
"S08": { name: "SIGMusic", type: OrgType.SIG, shortcode: "sigmusic" },
18+
"S09": { name: "GLUG", type: OrgType.SIG, shortcode: "glug" },
19+
"S10": { name: "SIGNLL", type: OrgType.SIG, shortcode: "signll" },
20+
"S11": { name: "SIGma", type: OrgType.SIG, shortcode: "sigma" },
21+
"S12": { name: "SIGQuantum", type: OrgType.SIG, shortcode: "sigquantum" },
22+
"S13": { name: "SIGecom", type: OrgType.SIG, shortcode: "sigecom" },
23+
"S14": { name: "SIGPLAN", type: OrgType.SIG, shortcode: "sigplan" },
24+
"S15": { name: "SIGPolicy", type: OrgType.SIG, shortcode: "sigpolicy" },
25+
"S16": { name: "SIGARCH", type: OrgType.SIG, shortcode: "sigarch" },
26+
"S17": { name: "SIGRobotics", type: OrgType.SIG, shortcode: "sigrobotics" },
27+
"S18": { name: "SIGtricity", type: OrgType.SIG, shortcode: "sigtricity" },
2328

24-
export const CommitteeCoreList = [
25-
"Infrastructure Committee",
26-
"Social Committee",
27-
"Mentorship Committee",
28-
"Academic Committee",
29-
"Corporate Committee",
30-
"Marketing Committee",
31-
] as [string, ...string[]];
29+
"C01": { name: "Infrastructure Committee", type: OrgType.COMMITTEE, shortcode: "infra" },
30+
"C02": { name: "Social Committee", type: OrgType.COMMITTEE, shortcode: "social" },
31+
"C03": { name: "Mentorship Committee", type: OrgType.COMMITTEE, shortcode: "mentorship" },
32+
"C04": { name: "Academic Committee", type: OrgType.COMMITTEE, shortcode: "academic" },
33+
"C05": { name: "Corporate Committee", type: OrgType.COMMITTEE, shortcode: "corporate" },
34+
"C06": { name: "Marketing Committee", type: OrgType.COMMITTEE, shortcode: "marketing" },
3235

33-
export const CommitteePartnerList = ["Reflections | Projections", "HackIllinois"]
36+
"C07": { name: "Reflections | Projections", type: OrgType.COMMITTEE, shortcode: "reflproj" },
37+
"C08": { name: "HackIllinois", type: OrgType.COMMITTEE, shortcode: "hackillinois" },
38+
} as const;
3439

35-
export const CoreOrganizationList = ["ACM", ...SIGList, ...CommitteeCoreList] as [string, ...string[]];
40+
export type OrganizationId = keyof typeof Organizations;
41+
export type Organization = (typeof Organizations)[OrganizationId];
42+
export type OrganizationName = Organization["name"];
3643

37-
export const AllOrganizationList = [...CoreOrganizationList, ...CommitteePartnerList] as [string, ...string[]];
38-
39-
export type ACMOrganization = typeof AllOrganizationList[number];
40-
41-
export const OrganizationShortIdentifierMapping = {
42-
"ACM": "acm",
43-
"SIGPwny": "sigpwny",
44-
"SIGCHI": "sigchi",
45-
"GameBuilders": "gamebuilders",
46-
"SIGAIDA": "sigaida",
47-
"SIGGRAPH": "siggraph",
48-
"ICPC": "icpc",
49-
"SIGMobile": "sigmobile",
50-
"SIGMusic": "sigmusic",
51-
"GLUG": "glug",
52-
"SIGNLL": "signll",
53-
"SIGma": "sigma",
54-
"SIGQuantum": "sigquantum",
55-
"SIGecom": "sigecom",
56-
"SIGPLAN": "sigplan",
57-
"SIGPolicy": "sigpolicy",
58-
"SIGARCH": "sigarch",
59-
"SIGRobotics": "sigrobotics",
60-
"SIGtricity": "sigtricity",
61-
"Infrastructure Committee": "infra",
62-
"Social Committee": "social",
63-
"Mentorship Committee": "mentorship",
64-
"Academic Committee": "academic",
65-
"Corporate Committee": "corporate",
66-
"Marketing Committee": "marketing",
67-
"Reflections | Projections": "reflproj",
68-
"HackIllinois": "hackillinois",
69-
} as const satisfies EnsureUniqueValues<Record<ACMOrganization, string>>;
44+
export function getOrgsByType(type: OrgType): Array<Organization & { id: OrganizationId }> {
45+
return (Object.entries(Organizations) as Array<[OrganizationId, Organization]>)
46+
.filter(([_, org]) => org.type === type)
47+
.map(([id, org]) => ({ ...org, id }));
48+
}

0 commit comments

Comments
 (0)