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';
2021-01-12 22:59:12 +01:00
import { SchedulerEvent } from '../types';
2020-08-09 20:44:35 +02:00
interface SchedulerEventsProps {
cellWidth: number;
cellHeight: number;
2021-01-12 22:59:12 +01:00
schedulerEvents: Array<SchedulerEvent>;
2020-08-09 20:44:35 +02:00
}
2021-01-12 22:59:12 +01:00
export const SchedulerEvents = ({ cellWidth, cellHeight,schedulerEvents }: SchedulerEventsProps) => {
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>
);
};