This commit is contained in:
wrzesinski-hubert 2020-09-11 08:08:49 +02:00
parent d75530887e
commit 78e54b70e4
3 changed files with 16 additions and 12 deletions

View File

@ -73,21 +73,21 @@ export const Scheduler = () => {
currentEventsIds.map((eventId: string) => {
const event = document.getElementById(eventId);
if (event) {
event.style.display = 'block';
event.style.backgroundColor = 'blue';
}
});
};
displayEvents();
}, [currentEventsIds]);
// const handleClick = (e: React.MouseEvent) => {
// const cellId = e.currentTarget.id;
// const column = cellId.slice(0, 1);
// const row = cellId.slice(1);
// const eventId = `eventCol${column}eventRow${Math.floor(parseInt(row) / 2)}`;
// setCurrentEventsIds((currentEventsIds) => [...currentEventsIds, eventId]);
// };
const handleClick = (e: React.MouseEvent) => {
const cellId = e.currentTarget.id;
// const column = cellId.slice(0, 9);
// const row = cellId.slice(1);
//const eventId = `eventCol${column}eventRow${Math.floor(parseInt(row) / 2)}`;
console.log(cellId)
setCurrentEventsIds((currentEventsIds) => [...currentEventsIds, cellId]);
};
return (
<>
@ -114,7 +114,7 @@ export const Scheduler = () => {
</TableRow>
))}
</TableBody>
<SchedulerEvents cellTop={cellTop} cellWidth={cellWidth} cellHeight={wrapperHeight / 13} />
<SchedulerEvents onClick={handleClick} cellTop={cellTop} cellWidth={cellWidth} cellHeight={wrapperHeight / 13}/>
</SchedulerWrapper>
</>
);

View File

@ -7,9 +7,10 @@ interface SchedulerEventsProps {
cellTop: number;
cellWidth: number;
cellHeight: number;
onClick: (e: React.MouseEvent) => void
}
export const SchedulerEvents = ({ cellTop, cellWidth, cellHeight }: SchedulerEventsProps) => {
export const SchedulerEvents = ({ cellTop, cellWidth, cellHeight, onClick }: SchedulerEventsProps) => {
const { basket } = useContext(coursesContext)!;
const [choosenGroupsMappedToEvents, setChoosenGroupsMappedToEvents] = useState<any>([]);
@ -50,6 +51,7 @@ export const SchedulerEvents = ({ cellTop, cellWidth, cellHeight }: SchedulerEve
<div>
{[...Array(6)].map((_, index) => (
<SchedulerRow
onClick={onClick}
key={index}
groups={choosenGroupsMappedToEvents.filter((group: any) => {
return group.eventRow === index;

View File

@ -25,13 +25,15 @@ interface SchedulerRowProps {
cellTop: number;
cellWidth: number;
cellHeight: number;
onClick: (e: React.MouseEvent) => void
}
export const SchedulerRow = ({ groups, indexRow, cellTop, cellWidth, cellHeight }: SchedulerRowProps) => {
export const SchedulerRow = ({ groups, indexRow, cellTop, cellWidth, cellHeight, onClick }: SchedulerRowProps) => {
return (
<>
{[...Array(5)].map((_, eventIndex) => (
<SchedulerEvent
onClick={onClick}
eventIndex={eventIndex}
cellTop={cellTop}
cellWidth={cellWidth}