adding groups to scheduler
This commit is contained in:
parent
f6da0d9c72
commit
09384e46fd
@ -21,15 +21,12 @@ export const SchedulerEvents = ({
|
|||||||
|
|
||||||
const [groupsMappedToEvents, setGroupsMappedToEvents] = useState<any>([]);
|
const [groupsMappedToEvents, setGroupsMappedToEvents] = useState<any>([]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// const groups: Array<Group> = [{ id: "5", day: "4", time: "11.45", lecturer: "dr Dorota Blinkiewicz", room: "A2-3" },
|
// const groups: Array<Group> = [{ 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: "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" }];
|
// { id: "69", day: "4", time: "15.30", lecturer: "dr Karol Gierszewski", room: "A2-3" }];
|
||||||
|
|
||||||
|
|
||||||
interface GroupTimeToEventRowMapping {
|
interface GroupTimeToEventRowMapping {
|
||||||
[time: string]: number
|
[time: string]: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
const groupTimeToEventRowMapping: GroupTimeToEventRowMapping = {
|
const groupTimeToEventRowMapping: GroupTimeToEventRowMapping = {
|
||||||
@ -39,48 +36,46 @@ export const SchedulerEvents = ({
|
|||||||
"13.45": 3,
|
"13.45": 3,
|
||||||
"15.30": 4,
|
"15.30": 4,
|
||||||
"17.15": 5,
|
"17.15": 5,
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
function mapGroupTimeToEventRow(groups: Array<Group>) {
|
function mapGroupTimeToEventRow(groups: Array<Group>) {
|
||||||
|
const groupsMappedToEventsTemp = []
|
||||||
for (const group of groups) {
|
for (const group of groups) {
|
||||||
console.log(group);
|
const groupTime = group.time;
|
||||||
const groupTime = group.time
|
|
||||||
const eventRow: number = groupTimeToEventRowMapping[groupTime];
|
const eventRow: number = groupTimeToEventRowMapping[groupTime];
|
||||||
const groupMappedToEvent: any = { id: group.id, day: group.day, eventRow: eventRow, lecturer: group.lecturer, room: group.room };
|
const groupMappedToEvent: any = {
|
||||||
setGroupsMappedToEvents((groupsMappedToEvents: any) => [...groupsMappedToEvents, groupMappedToEvent]);
|
id: group.id,
|
||||||
|
day: group.day,
|
||||||
|
eventRow: eventRow,
|
||||||
|
lecturer: group.lecturer,
|
||||||
|
room: group.room,
|
||||||
|
};
|
||||||
|
groupsMappedToEventsTemp.push(groupMappedToEvent)
|
||||||
}
|
}
|
||||||
|
setGroupsMappedToEvents(groupsMappedToEventsTemp)
|
||||||
}
|
}
|
||||||
mapGroupTimeToEventRow(choosenGroups);
|
mapGroupTimeToEventRow(choosenGroups);
|
||||||
}, [choosenGroups]);
|
}, [choosenGroups]);
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
console.log(choosenGroups)
|
||||||
console.log(groupsMappedToEvents);
|
console.log(groupsMappedToEvents);
|
||||||
|
|
||||||
}, [groupsMappedToEvents]);
|
}, [groupsMappedToEvents]);
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
{
|
{[...Array(6)].map((_, index) => (
|
||||||
[...Array(6)].map((_, index) => (
|
<SchedulerRow
|
||||||
<SchedulerRow
|
key={index}
|
||||||
key={index}
|
groups={groupsMappedToEvents.filter((group: any) => {
|
||||||
groups={groupsMappedToEvents.filter((group: any) => { return group.eventRow === index })}
|
return group.eventRow === index;
|
||||||
indexRow={index}
|
})}
|
||||||
cellTop={cellTop + (10 + 70 * index)}
|
indexRow={index}
|
||||||
cellWidth={cellWidth}
|
cellTop={cellTop + (10 + 70 * index)}
|
||||||
/>
|
cellWidth={cellWidth}
|
||||||
))
|
/>
|
||||||
}
|
))}
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -19,9 +19,6 @@ export const SchedulerRow = ({
|
|||||||
// eventDiv.style.backgroundColor = "#1547C5";
|
// eventDiv.style.backgroundColor = "#1547C5";
|
||||||
// };
|
// };
|
||||||
|
|
||||||
console.log(`You passed me these of a groupzzz: ${groups}`)
|
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
{[...Array(5)].map((value, eventIndex) => (
|
{[...Array(5)].map((value, eventIndex) => (
|
||||||
|
@ -101,8 +101,6 @@ export const Results: React.FC = () => {
|
|||||||
group.room = result[i].room.trim();
|
group.room = result[i].room.trim();
|
||||||
lecture.groups.push(group);
|
lecture.groups.push(group);
|
||||||
}
|
}
|
||||||
console.log(result);
|
|
||||||
console.log(result[0].course.name);
|
|
||||||
|
|
||||||
lecturesContext.addLecture(lecture);
|
lecturesContext.addLecture(lecture);
|
||||||
setOpen(false);
|
setOpen(false);
|
||||||
|
Loading…
Reference in New Issue
Block a user