2020-11-21 04:02:38 +01:00
|
|
|
import React, { useContext } from 'react';
|
2020-08-17 22:05:13 +02:00
|
|
|
import { SchedulerRow } from './SchedulerRow';
|
|
|
|
import { coursesContext } from '../contexts/CoursesProvider';
|
2020-11-21 04:02:38 +01:00
|
|
|
import { selectGroupsToShow } from '../utils/index';
|
|
|
|
import { ROWS_COUNT } from '../constants';
|
2020-08-09 20:44:35 +02:00
|
|
|
interface SchedulerEventsProps {
|
|
|
|
cellWidth: number;
|
2020-08-29 18:52:03 +02:00
|
|
|
cellHeight: number;
|
2020-08-09 20:44:35 +02:00
|
|
|
}
|
|
|
|
|
2020-11-21 04:02:38 +01:00
|
|
|
export const SchedulerEvents = ({ cellWidth, cellHeight }: SchedulerEventsProps) => {
|
|
|
|
const { selectSchedulerEvents } = useContext(coursesContext)!;
|
2020-08-23 17:22:50 +02:00
|
|
|
|
2020-11-21 04:02:38 +01:00
|
|
|
const schedulerEvents = selectSchedulerEvents();
|
2020-08-09 21:41:52 +02:00
|
|
|
|
2020-08-09 20:44:35 +02:00
|
|
|
return (
|
|
|
|
<div>
|
2020-11-21 04:02:38 +01:00
|
|
|
{[...Array(ROWS_COUNT)].map((_, index) => (
|
2020-08-12 04:13:14 +02:00
|
|
|
<SchedulerRow
|
|
|
|
key={index}
|
2020-11-21 04:02:38 +01:00
|
|
|
groups={selectGroupsToShow(schedulerEvents, index)}
|
2020-08-12 04:13:14 +02:00
|
|
|
indexRow={index}
|
2020-11-21 04:02:38 +01:00
|
|
|
rowTop={
|
2020-08-29 18:52:03 +02:00
|
|
|
index === 0
|
2020-11-19 21:57:34 +01:00
|
|
|
? cellHeight / 2
|
2020-08-29 18:52:03 +02:00
|
|
|
: index === 1
|
2020-11-19 21:57:34 +01:00
|
|
|
? cellHeight * 4
|
|
|
|
: index === 2
|
|
|
|
? cellHeight * 7.5
|
|
|
|
: index === 3
|
|
|
|
? cellHeight * 11.5
|
|
|
|
: index === 4
|
|
|
|
? cellHeight * 15
|
|
|
|
: index === 5
|
|
|
|
? cellHeight * 18.5
|
|
|
|
: 0
|
2020-08-18 18:32:26 +02:00
|
|
|
}
|
2020-08-12 04:13:14 +02:00
|
|
|
cellWidth={cellWidth}
|
2020-08-29 18:52:03 +02:00
|
|
|
cellHeight={cellHeight}
|
2020-08-12 04:13:14 +02:00
|
|
|
/>
|
|
|
|
))}
|
2020-08-09 20:44:35 +02:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|