From 09384e46fd15d997ea1cccae39b0a74dd7165fc1 Mon Sep 17 00:00:00 2001 From: wrzesinski-hubert Date: Sun, 9 Aug 2020 21:54:49 +0200 Subject: [PATCH] adding groups to scheduler --- .../Scheduler/SchedulerEvents/index.tsx | 55 +++++++++---------- .../Scheduler/SchedulerRow/index.tsx | 3 - src/components/TopBar/Results/index.tsx | 2 - 3 files changed, 25 insertions(+), 35 deletions(-) diff --git a/src/components/Scheduler/SchedulerEvents/index.tsx b/src/components/Scheduler/SchedulerEvents/index.tsx index d02c2fa..0018f3b 100644 --- a/src/components/Scheduler/SchedulerEvents/index.tsx +++ b/src/components/Scheduler/SchedulerEvents/index.tsx @@ -21,15 +21,12 @@ export const SchedulerEvents = ({ const [groupsMappedToEvents, setGroupsMappedToEvents] = useState([]); - - // const groups: Array = [{ id: "5", day: "4", time: "11.45", lecturer: "dr Dorota Blinkiewicz", room: "A2-3" }, // { id: "28", day: "1", time: "13.45", lecturer: "dr Barbara Kołodziejczak", room: "D-3" }, // { id: "69", day: "4", time: "15.30", lecturer: "dr Karol Gierszewski", room: "A2-3" }]; - interface GroupTimeToEventRowMapping { - [time: string]: number + [time: string]: number; } const groupTimeToEventRowMapping: GroupTimeToEventRowMapping = { @@ -39,48 +36,46 @@ export const SchedulerEvents = ({ "13.45": 3, "15.30": 4, "17.15": 5, - } - - - + }; useEffect(() => { function mapGroupTimeToEventRow(groups: Array) { + const groupsMappedToEventsTemp = [] for (const group of groups) { - console.log(group); - const groupTime = group.time + const groupTime = group.time; const eventRow: number = groupTimeToEventRowMapping[groupTime]; - const groupMappedToEvent: any = { id: group.id, day: group.day, eventRow: eventRow, lecturer: group.lecturer, room: group.room }; - setGroupsMappedToEvents((groupsMappedToEvents: any) => [...groupsMappedToEvents, groupMappedToEvent]); + const groupMappedToEvent: any = { + id: group.id, + day: group.day, + eventRow: eventRow, + lecturer: group.lecturer, + room: group.room, + }; + groupsMappedToEventsTemp.push(groupMappedToEvent) } + setGroupsMappedToEvents(groupsMappedToEventsTemp) } mapGroupTimeToEventRow(choosenGroups); }, [choosenGroups]); - useEffect(() => { + console.log(choosenGroups) console.log(groupsMappedToEvents); - }, [groupsMappedToEvents]); - return ( - -
- { - [...Array(6)].map((_, index) => ( - { return group.eventRow === index })} - indexRow={index} - cellTop={cellTop + (10 + 70 * index)} - cellWidth={cellWidth} - /> - )) - } - - + {[...Array(6)].map((_, index) => ( + { + return group.eventRow === index; + })} + indexRow={index} + cellTop={cellTop + (10 + 70 * index)} + cellWidth={cellWidth} + /> + ))}
); }; diff --git a/src/components/Scheduler/SchedulerRow/index.tsx b/src/components/Scheduler/SchedulerRow/index.tsx index dd1f693..463b401 100644 --- a/src/components/Scheduler/SchedulerRow/index.tsx +++ b/src/components/Scheduler/SchedulerRow/index.tsx @@ -19,9 +19,6 @@ export const SchedulerRow = ({ // eventDiv.style.backgroundColor = "#1547C5"; // }; - console.log(`You passed me these of a groupzzz: ${groups}`) - - return (
{[...Array(5)].map((value, eventIndex) => ( diff --git a/src/components/TopBar/Results/index.tsx b/src/components/TopBar/Results/index.tsx index 7068d1c..27eeefb 100644 --- a/src/components/TopBar/Results/index.tsx +++ b/src/components/TopBar/Results/index.tsx @@ -101,8 +101,6 @@ export const Results: React.FC = () => { group.room = result[i].room.trim(); lecture.groups.push(group); } - console.log(result); - console.log(result[0].course.name); lecturesContext.addLecture(lecture); setOpen(false);