frontend/src/components/SchedulerEvents.tsx

45 lines
1.2 KiB
TypeScript
Raw Normal View History

2020-11-21 04:02:38 +01:00
import React, { useContext } from 'react';
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;
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-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={
index === 0
2020-11-19 21:57:34 +01:00
? cellHeight / 2
: 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-12 04:13:14 +02:00
cellWidth={cellWidth}
cellHeight={cellHeight}
2020-08-12 04:13:14 +02:00
/>
))}
2020-08-09 20:44:35 +02:00
</div>
);
};