Skip to content

Commit

Permalink
fix: original schedule conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaspalma committed Feb 8, 2025
1 parent 52965da commit ea36023
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/components/planner/schedules/LessonBox.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import classNames from 'classnames'
import { useState, useEffect } from 'react'
import { useState, useEffect, useContext } from 'react'
import LessonPopover from './LessonPopover'
import ConflictsPopover from './ConflictsPopover'
import { CourseInfo, ClassInfo, SlotInfo, ClassDescriptor, ConflictInfo } from '../../../@types'
import { getLessonBoxTime, schedulesConflict, conflictsSeverity, getLessonBoxStyles, maxHour, minHour, getClassTypeClassName, getLessonTypeLongName } from '../../../utils'
import ScheduleContext from '../../../contexts/ScheduleContext'

type Props = {
courseInfo: CourseInfo
Expand Down Expand Up @@ -41,6 +42,7 @@ const LessonBox = ({
const [isHovered, setIsHovered] = useState(false)
const [conflict, setConflict] = useState(conflicts[slotInfo.id]);
const hasConflict = conflict?.conflictingClasses?.length > 1;
const {originalExchangeSchedule} = useContext(ScheduleContext);

// Needs to change the entry with the id of this lesson to contain the correct ConflictInfo when the classes change
useEffect(() => {
Expand Down Expand Up @@ -69,7 +71,13 @@ const LessonBox = ({
}
}
}

const hasNewClasses = !newConflictInfo.conflictingClasses.every((conflictingClass) => originalExchangeSchedule.some((originalClass) => originalClass.classInfo.id === conflictingClass.classInfo.id));

if(!hasNewClasses && newConflictInfo.severe) {
newConflictInfo.severe = false;
}

setConflict(newConflictInfo);
}, [classInfo, classes, hasConflict]);

Expand Down

0 comments on commit ea36023

Please sign in to comment.