Skip to content

Use a shared NPM package for org constants #233

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@acm-uiuc:registry=https://registry.npmjs.org
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"prettier:write": "prettier --write ."
},
"dependencies": {
"@acm-uiuc/js-shared": "^2.1.0",
"@heroui/react": "2.7.6",
"axios": "^0.28.0",
"framer-motion": "^10.17.9",
Expand Down Expand Up @@ -59,4 +60,4 @@
"jackspeak": "2.1.1"
},
"packageManager": "[email protected]"
}
}
19 changes: 4 additions & 15 deletions src/app/(main)/calendar/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Suspense, useEffect, useState } from 'react';
import CalendarControls from '@/components/CalendarControls';
import { View, Views } from 'react-big-calendar';
import { transformApiDates } from '@/utils/dateutils';
import { OrganizationList } from '@/utils/organizations';
import { AllOrganizationList as OrganizationList } from '@acm-uiuc/js-shared';
import { useSearchParams } from 'next/navigation';

const defaultEvent: CalendarEventDetailProps = {
Expand Down Expand Up @@ -39,29 +39,18 @@ const Calendar = () => {
async function fetcher() {
const urls = [
`${baseurl}/api/v1/events`,
`${baseurl}/api/v1/organizations`,
];

try {
const [eventsResponse, organizationsResponse] =
const [eventsResponse] =
await Promise.allSettled(urls.map((url) => fetch(url)));
if (eventsResponse.status === 'fulfilled') {
const eventsData = await eventsResponse.value.json();
setAllEvents(transformApiDates(eventsData as IEvent[]));
} else {
setAllEvents([]); // Handle error for events fetch
}

// Handle organizations response
if (organizationsResponse.status === 'fulfilled') {
const organizationsData = await organizationsResponse.value.json();
setValidOrganizations(organizationsData as string[]);
if (!organizationsData.includes(hostFilter)) {
setHostFilter('');
}
} else {
setValidOrganizations(OrganizationList);
}
setValidOrganizations(OrganizationList);
} catch (err) {
console.error('Error in processing fetch results:', err);
setAllEvents([]); // Fallback error handling for critical failure
Expand Down Expand Up @@ -115,7 +104,7 @@ const Calendar = () => {
null,
'',
baseURL +
`/calendar?host=${e.target.value.replaceAll(' ', '+')}`,
`/calendar?host=${e.target.value.replaceAll(' ', '+')}`,
);
}
}}
Expand Down
4 changes: 1 addition & 3 deletions src/app/(open-house)/data/booths.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import {
SIGList,
CommitteeList,
PartnerList,
getOrganizationInfo,
Link,
} from '@/utils/organizations';
import { SIGList, CommitteeCoreList as CommitteeList, CommitteePartnerList as PartnerList } from '@acm-uiuc/js-shared';
import { partners } from '../data/partners';
import { boothDetails } from './details';

Expand Down
3 changes: 2 additions & 1 deletion src/components/Events/events.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import 'react-big-calendar/lib/css/react-big-calendar.css';
import './CalendarStylesOverride.css';
import { CalendarEventDetailProps } from '@/components/CalendarEventDetail/CalendarEventDetail';
import { View, NavigateAction } from 'react-big-calendar';
import { Organization, SIG, SIGList } from '@/utils/organizations';
import { Organization, SIG } from '@/utils/organizations';
import { SIGList } from '@acm-uiuc/js-shared';
import { Skeleton } from '@heroui/react';
import {
repeatMapping,
Expand Down
41 changes: 3 additions & 38 deletions src/utils/organizations.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { AllOrganizationList, SIGList } from "@acm-uiuc/js-shared";

export const getOrganizationColor = (org: Organization) => {
switch (org) {
case 'SIGPwny':
Expand Down Expand Up @@ -39,45 +41,8 @@ export const getOrganizationColor = (org: Organization) => {
}
};

export const SIGList = [
'SIGPwny',
'SIGCHI',
'GameBuilders',
'SIGAIDA',
'SIGGRAPH',
'ICPC',
'SIGMobile',
'SIGMusic',
'SIGPLAN',
'GLUG',
'SIGNLL',
'SIGma',
'SIGQuantum',
'SIGecom',
'SIGPolicy',
'SIGARCH',
'SIGRobotics',
'SIGtricity',
] as const;

export const CommitteeList = [
'Infrastructure Committee',
'Social Committee',
'Corporate Committee',
'Marketing Committee',
'Mentorship Committee',
'Academic Committee',
];
export const PartnerList = ['Reflections | Projections', 'HackIllinois'];
export const OrganizationList = [
'ACM',
...SIGList,
...CommitteeList,
...PartnerList,
];

export type SIG = (typeof SIGList)[number];
export type Organization = (typeof OrganizationList)[number];
export type Organization = (typeof AllOrganizationList)[number];

export interface Link {
link: string;
Expand Down
Loading