diff --git a/.env.development b/.env.development index 0f66bff550..38904617a3 100644 --- a/.env.development +++ b/.env.development @@ -4,8 +4,8 @@ # VITE_API_URL=https://360Api.gordon.edu/ # @TRAIN - VITE_API_URL=https://360ApiTrain.gordon.edu/ +# VITE_API_URL=https://360ApiTrain.gordon.edu/ # @LOCALHOST -# VITE_API_URL=http://localhost:51660/ + VITE_API_URL=http://localhost:51634/ diff --git a/package-lock.json b/package-lock.json index ae0094ab25..05bc1a07cb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -23,7 +23,7 @@ "lodash": "^4.17.21", "prop-types": ">=15.7.2", "react": "^18.3.1", - "react-big-calendar": "^1.10.3", + "react-big-calendar": "^1.19.2", "react-chartjs-2": "^5.2.0", "react-cropper": "^2.3.3", "react-csv": "^2.0.3", @@ -8555,9 +8555,10 @@ } }, "node_modules/react-big-calendar": { - "version": "1.10.3", - "resolved": "https://registry.npmjs.org/react-big-calendar/-/react-big-calendar-1.10.3.tgz", - "integrity": "sha512-LmIWlFfGUn8yt4RxcVkGNmjM3GcWynr1bfDwKrrz4KKj517+DH3OGmQzErURN6Zb0OB88HF4oH2dvDHpBQJgIw==", + "version": "1.19.2", + "resolved": "https://registry.npmjs.org/react-big-calendar/-/react-big-calendar-1.19.2.tgz", + "integrity": "sha512-2orH+TOXPJBlQGwSl9ZnTK2WZR9OfVf0r1s8mnbpjvtENZfmWHP6nXqxmten1vkvzOMqefVGjh5GurM27HHOZw==", + "license": "MIT", "dependencies": { "@babel/runtime": "^7.20.7", "clsx": "^1.2.1", @@ -8577,8 +8578,8 @@ "uncontrollable": "^7.2.1" }, "peerDependencies": { - "react": "^16.14.0 || ^17 || ^18", - "react-dom": "^16.14.0 || ^17 || ^18" + "react": "^16.14.0 || ^17 || ^18 || ^19", + "react-dom": "^16.14.0 || ^17 || ^18 || ^19" } }, "node_modules/react-chartjs-2": { diff --git a/package.json b/package.json index 3dacd5ef46..1828b3b907 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "lodash": "^4.17.21", "prop-types": ">=15.7.2", "react": "^18.3.1", - "react-big-calendar": "^1.10.3", + "react-big-calendar": "^1.19.2", "react-chartjs-2": "^5.2.0", "react-cropper": "^2.3.3", "react-csv": "^2.0.3", diff --git a/src/components/Profile/components/SchedulePanel/ScheduleHeader.module.scss b/src/components/Profile/components/SchedulePanel/ScheduleHeader.module.scss index d8dbf449ca..fe8f07e18e 100644 --- a/src/components/Profile/components/SchedulePanel/ScheduleHeader.module.scss +++ b/src/components/Profile/components/SchedulePanel/ScheduleHeader.module.scss @@ -30,3 +30,8 @@ border-top-right-radius: 4px; } } + +.quad-course { + max-width: 50%; + background-color: red; +} diff --git a/src/components/Profile/components/SchedulePanel/components/ScheduleCalendar/ScheduleCalendar.scss b/src/components/Profile/components/SchedulePanel/components/ScheduleCalendar/ScheduleCalendar.scss index ec529f2f89..edadeacdfd 100644 --- a/src/components/Profile/components/SchedulePanel/components/ScheduleCalendar/ScheduleCalendar.scss +++ b/src/components/Profile/components/SchedulePanel/components/ScheduleCalendar/ScheduleCalendar.scss @@ -293,3 +293,18 @@ button.rbc-input::-moz-focus-inner { border-bottom: 1px solid var(--mui-palette-neutral-dark); flex-shrink: 0; } + +.subterm { + max-width: 55% !important; + padding-left: 2px; + filter: brightness(145%); + left: auto !important; +} + +.subterm1 { + left: 0%; +} + +.subterm2 { + right: 0%; +} diff --git a/src/components/Profile/components/SchedulePanel/components/ScheduleCalendar/index.tsx b/src/components/Profile/components/SchedulePanel/components/ScheduleCalendar/index.tsx index 4c46823bf1..db1bb34e1f 100644 --- a/src/components/Profile/components/SchedulePanel/components/ScheduleCalendar/index.tsx +++ b/src/components/Profile/components/SchedulePanel/components/ScheduleCalendar/index.tsx @@ -3,6 +3,7 @@ import { CourseEvent, Schedule, scheduleCalendarResources } from 'services/sched import './ScheduleCalendar.css'; import { format, getDay, startOfWeek } from 'date-fns'; import { enUS } from 'date-fns/locale'; +import EventWrapper from 'react-big-calendar/lib/addons/dragAndDrop'; const locales = { 'en-US': enUS, @@ -20,6 +21,10 @@ type Props = { onSelectEvent: (event: CourseEvent) => void; }; +const EventWrapperCustom = ({ label }: { label: CourseEvent }) => { + return test {label.title}; +}; + const GordonScheduleCalendar = ({ schedule, onSelectEvent }: Props) => { const dayStart = new Date(); dayStart.setHours(8, 0, 0, 0); @@ -35,12 +40,31 @@ const GordonScheduleCalendar = ({ schedule, onSelectEvent }: Props) => { : course.location.includes('null') ? (title = tempTitle) : (title = tempTitle + `\n${course.location}`); + return { ...course, title }; }); + console.log(courseFormat); + return ( { + const firstQuadOfSemester = ['Fall 1', 'Spring 1', 'Summer 1']; + const secondQuadOfSemester = ['Fall 2', 'Spring 2', 'Summer 2']; + let subtermClassNames = ['subterm']; + console.log(event.subtermCode); + console.log(secondQuadOfSemester.includes(event.subtermCode)); + if (firstQuadOfSemester.includes(event.subtermCode)) { + subtermClassNames.push('subterm1'); + } else if (secondQuadOfSemester.includes(event.subtermCode)) { + subtermClassNames.push('subterm2'); + } else { + return {}; + } + return { className: subtermClassNames.join(' ') }; + }} events={courseFormat} localizer={localizer} min={dayStart} diff --git a/src/components/Profile/components/SchedulePanel/index.tsx b/src/components/Profile/components/SchedulePanel/index.tsx index 135b8a6382..0eb9d64596 100644 --- a/src/components/Profile/components/SchedulePanel/index.tsx +++ b/src/components/Profile/components/SchedulePanel/index.tsx @@ -17,6 +17,7 @@ import styles from './ScheduleHeader.module.css'; import scheduleService, { CourseEvent, Schedule } from 'services/schedule'; import sessionService from 'services/session'; import { Profile } from 'services/user'; +import { AuthError } from 'services/error'; type Props = { profile: Profile; @@ -38,17 +39,22 @@ const GordonSchedulePanel = ({ profile, myProf }: Props) => { Promise.all([ scheduleService.getAllSessionSchedules(profile.AD_Username), sessionService.getCurrent(), - ]).then(([allSessionSchedules, currentSession]) => { - setAllSchedules(allSessionSchedules); - const defaultSchedule = - // If there is a schedule for the current session, make it d4fault - allSessionSchedules.find((s) => s.session.SessionCode === currentSession.SessionCode) ?? - // Otherwise, use the most recent session - allSessionSchedules[0]; - setSelectedSchedule(defaultSchedule); - setLoading(false); - }); + ]) + .then(([allSessionSchedules, currentSession]) => { + setAllSchedules(allSessionSchedules); + const defaultSchedule = + // If there is a schedule for the current session, make it d4fault + allSessionSchedules.find((s) => s.session.SessionCode === currentSession.SessionCode) ?? + // Otherwise, use the most recent session + allSessionSchedules[0]; + setSelectedSchedule(defaultSchedule); + setLoading(false); + }) + .catch((reason: AuthError) => { + setLoading(false); + }); }, [profile.AD_Username]); + const toggleIsScheduleOpen = () => { setIsScheduleOpen((wasOpen) => { localStorage.setItem(scheduleOpenKey, String(!wasOpen)); diff --git a/src/components/Profile/index.tsx b/src/components/Profile/index.tsx index 0c04c4816c..d6efee492e 100644 --- a/src/components/Profile/index.tsx +++ b/src/components/Profile/index.tsx @@ -40,6 +40,7 @@ const Profile = ({ profile, myProf }: Props) => { const viewerIsPolice = useAuthGroups(AuthGroup.Police); const [canReadStudentSchedules, setCanReadStudentSchedules] = useState(); const profileIsStudent = profile.PersonType?.includes('stu'); + const profileIsStaff = profile.Type == 'Staff'; // should we create an dict enum of the possible values? const createSnackbar = useCallback( (message: string, severity: AlertColor, link?: string, linkText?: string) => { @@ -84,11 +85,12 @@ const Profile = ({ profile, myProf }: Props) => { )} - {(myProf || !profileIsStudent || canReadStudentSchedules) && ( + { + // is it only faculty that have schedule? could we say if faculty instead here? - )} + } diff --git a/src/services/schedule.ts b/src/services/schedule.ts index c9b7b43807..6ba022e1fd 100644 --- a/src/services/schedule.ts +++ b/src/services/schedule.ts @@ -19,6 +19,7 @@ type DbCourse = { BEGIN_TIME?: string; /** A timespan of the format HH:mm:ss, stringified */ END_TIME?: string; + SUB_TERM_CDE?: string; Role: string; }; @@ -62,6 +63,7 @@ export type CourseEvent = { name: string; title: string; location: string; + subtermCode: string; start: Date; end: Date; allDay?: boolean; @@ -89,6 +91,7 @@ function formatCoursesFromDb(courses: DbCourse[]): CourseEvent[] { name: course.CRS_TITLE.trim(), title: course.CRS_CDE.trim(), location: course.BLDG_CDE + '\u00A0' + course.ROOM_CDE, + subtermCode: course.SUB_TERM_CDE, }; if (course.ROOM_CDE === 'ASY') {