Skip to content

Commit

Permalink
Use context value on LessonBox
Browse files Browse the repository at this point in the history
  • Loading branch information
Process-ing committed Feb 3, 2025
1 parent 99f41db commit 7aba7e2
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions 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 ConflictsContext from '../../../contexts/ConflictsContext'

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 { tClassConflicts } = useContext(ConflictsContext);

// Needs to change the entry with the id of this lesson to contain the correct ConflictInfo when the classes change
useEffect(() => {
Expand All @@ -59,7 +61,7 @@ const LessonBox = ({
const slot = classDescriptor.classInfo.slots[j];
if (schedulesConflict(slotInfo, slot)) {
// The highest severity of the all the conflicts is the overall severity
newConflictInfo.severe = conflictsSeverity(slotInfo, slot, Number(import.meta.env.VITE_APP_T_CLASS_CONFLICTS) != 0) == 2 || newConflictInfo.severe;
newConflictInfo.severe = conflictsSeverity(slotInfo, slot, tClassConflicts) == 2 || newConflictInfo.severe;
const newClassDescriptor = {
classInfo: classDescriptor.classInfo,
courseInfo: classDescriptor.courseInfo,
Expand Down

0 comments on commit 7aba7e2

Please sign in to comment.