Skip to content

Commit fd4a563

Browse files
authored
Use a shared NPM package for org constants (#233)
* Use JS shared * remove npmrc * fix * force yarnpkg * use latest types * don't ping /api/v1/organizations
1 parent 1212b94 commit fd4a563

File tree

7 files changed

+1997
-1475
lines changed

7 files changed

+1997
-1475
lines changed

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@acm-uiuc:registry=https://registry.npmjs.org

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"prettier:write": "prettier --write ."
1616
},
1717
"dependencies": {
18+
"@acm-uiuc/js-shared": "^2.1.0",
1819
"@heroui/react": "2.7.6",
1920
"axios": "^0.28.0",
2021
"framer-motion": "^10.17.9",
@@ -59,4 +60,4 @@
5960
"jackspeak": "2.1.1"
6061
},
6162
"packageManager": "[email protected]"
62-
}
63+
}

src/app/(main)/calendar/page.tsx

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { Suspense, useEffect, useState } from 'react';
88
import CalendarControls from '@/components/CalendarControls';
99
import { View, Views } from 'react-big-calendar';
1010
import { transformApiDates } from '@/utils/dateutils';
11-
import { OrganizationList } from '@/utils/organizations';
11+
import { AllOrganizationList as OrganizationList } from '@acm-uiuc/js-shared';
1212
import { useSearchParams } from 'next/navigation';
1313

1414
const defaultEvent: CalendarEventDetailProps = {
@@ -39,29 +39,18 @@ const Calendar = () => {
3939
async function fetcher() {
4040
const urls = [
4141
`${baseurl}/api/v1/events`,
42-
`${baseurl}/api/v1/organizations`,
4342
];
4443

4544
try {
46-
const [eventsResponse, organizationsResponse] =
45+
const [eventsResponse] =
4746
await Promise.allSettled(urls.map((url) => fetch(url)));
4847
if (eventsResponse.status === 'fulfilled') {
4948
const eventsData = await eventsResponse.value.json();
5049
setAllEvents(transformApiDates(eventsData as IEvent[]));
5150
} else {
5251
setAllEvents([]); // Handle error for events fetch
5352
}
54-
55-
// Handle organizations response
56-
if (organizationsResponse.status === 'fulfilled') {
57-
const organizationsData = await organizationsResponse.value.json();
58-
setValidOrganizations(organizationsData as string[]);
59-
if (!organizationsData.includes(hostFilter)) {
60-
setHostFilter('');
61-
}
62-
} else {
63-
setValidOrganizations(OrganizationList);
64-
}
53+
setValidOrganizations(OrganizationList);
6554
} catch (err) {
6655
console.error('Error in processing fetch results:', err);
6756
setAllEvents([]); // Fallback error handling for critical failure
@@ -115,7 +104,7 @@ const Calendar = () => {
115104
null,
116105
'',
117106
baseURL +
118-
`/calendar?host=${e.target.value.replaceAll(' ', '+')}`,
107+
`/calendar?host=${e.target.value.replaceAll(' ', '+')}`,
119108
);
120109
}
121110
}}

src/app/(open-house)/data/booths.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import {
2-
SIGList,
3-
CommitteeList,
4-
PartnerList,
52
getOrganizationInfo,
63
Link,
74
} from '@/utils/organizations';
5+
import { SIGList, CommitteeCoreList as CommitteeList, CommitteePartnerList as PartnerList } from '@acm-uiuc/js-shared';
86
import { partners } from '../data/partners';
97
import { boothDetails } from './details';
108

src/components/Events/events.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ import 'react-big-calendar/lib/css/react-big-calendar.css';
1010
import './CalendarStylesOverride.css';
1111
import { CalendarEventDetailProps } from '@/components/CalendarEventDetail/CalendarEventDetail';
1212
import { View, NavigateAction } from 'react-big-calendar';
13-
import { Organization, SIG, SIGList } from '@/utils/organizations';
13+
import { Organization, SIG } from '@/utils/organizations';
14+
import { SIGList } from '@acm-uiuc/js-shared';
1415
import { Skeleton } from '@heroui/react';
1516
import {
1617
repeatMapping,

src/utils/organizations.ts

Lines changed: 3 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { AllOrganizationList, SIGList } from "@acm-uiuc/js-shared";
2+
13
export const getOrganizationColor = (org: Organization) => {
24
switch (org) {
35
case 'SIGPwny':
@@ -39,45 +41,8 @@ export const getOrganizationColor = (org: Organization) => {
3941
}
4042
};
4143

42-
export const SIGList = [
43-
'SIGPwny',
44-
'SIGCHI',
45-
'GameBuilders',
46-
'SIGAIDA',
47-
'SIGGRAPH',
48-
'ICPC',
49-
'SIGMobile',
50-
'SIGMusic',
51-
'SIGPLAN',
52-
'GLUG',
53-
'SIGNLL',
54-
'SIGma',
55-
'SIGQuantum',
56-
'SIGecom',
57-
'SIGPolicy',
58-
'SIGARCH',
59-
'SIGRobotics',
60-
'SIGtricity',
61-
] as const;
62-
63-
export const CommitteeList = [
64-
'Infrastructure Committee',
65-
'Social Committee',
66-
'Corporate Committee',
67-
'Marketing Committee',
68-
'Mentorship Committee',
69-
'Academic Committee',
70-
];
71-
export const PartnerList = ['Reflections | Projections', 'HackIllinois'];
72-
export const OrganizationList = [
73-
'ACM',
74-
...SIGList,
75-
...CommitteeList,
76-
...PartnerList,
77-
];
78-
7944
export type SIG = (typeof SIGList)[number];
80-
export type Organization = (typeof OrganizationList)[number];
45+
export type Organization = (typeof AllOrganizationList)[number];
8146

8247
export interface Link {
8348
link: string;

0 commit comments

Comments
 (0)