|
|
|
@ -2,7 +2,7 @@ import { format } from 'date-fns'
|
|
|
|
|
|
|
|
|
|
import _ from 'lodash'
|
|
|
|
|
import { useEffect, useRef, useState } from 'preact/hooks'
|
|
|
|
|
import { normalizeCourseName, WEEK_DAYS } from '../../utils.jsx'
|
|
|
|
|
import { prettyCourseName, WEEK_DAYS } from '../../utils.jsx'
|
|
|
|
|
|
|
|
|
|
export const Course = ({ events, selection, setSelection, hideOtherCourses }) => {
|
|
|
|
|
const selectionSet = new Set(selection)
|
|
|
|
@ -11,6 +11,12 @@ export const Course = ({ events, selection, setSelection, hideOtherCourses }) =>
|
|
|
|
|
|
|
|
|
|
const eventsByCourse = _.groupBy(_.sortBy(visibleEvents, 'id'), 'id')
|
|
|
|
|
|
|
|
|
|
const profsPerCourse = _.mapValues(eventsByCourse, events =>
|
|
|
|
|
_.uniq(events.flatMap(event => event.docenti))
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
console.log(profsPerCourse)
|
|
|
|
|
|
|
|
|
|
const [currentlyHovered, setCurrentlyHovered] = useState(null)
|
|
|
|
|
const element = useRef()
|
|
|
|
|
|
|
|
|
@ -51,14 +57,14 @@ export const Course = ({ events, selection, setSelection, hideOtherCourses }) =>
|
|
|
|
|
else setSelection(selection.filter(selId => selId !== id))
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<div class="title">{normalizeCourseName(courseEvents[0].name)}</div>
|
|
|
|
|
<div class="docenti">{courseEvents[0].docenti.join(', ')}</div>
|
|
|
|
|
<div class="title">{prettyCourseName(courseEvents[0].name)}</div>
|
|
|
|
|
<div class="docenti">{profsPerCourse[id].join(', ')}</div>
|
|
|
|
|
<div class="events">
|
|
|
|
|
{courseEvents.map(course => (
|
|
|
|
|
<div>
|
|
|
|
|
{WEEK_DAYS[course.start.getDay()]}{' '}
|
|
|
|
|
{format(course.start, 'H:mm')} –{' '}
|
|
|
|
|
{format(course.end, 'H:mm')} {course.aula}
|
|
|
|
|
{format(course.start, 'H:mm')}–
|
|
|
|
|
{format(course.end, 'H:mm')} {course.aule.join(', ')}
|
|
|
|
|
</div>
|
|
|
|
|
))}
|
|
|
|
|
</div>
|
|
|
|
|