+
setSelected(!isSelected)}>
diff --git a/src/components/Dropdown.tsx b/src/components/Dropdown.tsx
index 4defa11..26186b5 100644
--- a/src/components/Dropdown.tsx
+++ b/src/components/Dropdown.tsx
@@ -1,4 +1,4 @@
-import React, { useState, useContext, useEffect, MouseEvent } from 'react';
+import React, { useState, useContext, useEffect, MouseEvent, ChangeEvent } from 'react';
import axios from 'axios';
import { Input } from '@material-ui/core';
import ClickAwayListener from '@material-ui/core/ClickAwayListener';
@@ -64,13 +64,10 @@ export const Dropdown = ({ clearInput, handleClearInput }: DropdownProps) => {
}, [input, open, basket]);
useEffect(() => {
- if (clearInput) {
- setInput('');
- handleClearInput();
- }
+ clearInput && (setInput(''), handleClearInput());
}, [clearInput]);
- const handleChange = (event: React.ChangeEvent
) => setInput(event.target.value);
+ const handleChange = (event: ChangeEvent) => setInput(event.target.value);
const handleClick = () => setOpen(true);
@@ -83,7 +80,7 @@ export const Dropdown = ({ clearInput, handleClearInput }: DropdownProps) => {
const name = target.textContent;
//porozmawiać z Filipem, żeby odrobinę przerobił endpoint
- const course: Basket = { name: name.trim(), id: parseInt(id), lecture: null, classes: null };
+ const course: Basket = { name: name.trim(), id: parseInt(id) };
addToBasket(course);
setOpen(false);
diff --git a/src/components/Rightbar.tsx b/src/components/Rightbar.tsx
index 874ec0a..d300e33 100644
--- a/src/components/Rightbar.tsx
+++ b/src/components/Rightbar.tsx
@@ -9,8 +9,8 @@ const RightbarStyled = styled.div`
padding-right: 15px;
text-align: center;
font-family: Lato;
+ height: 100%;
width: 300px;
- height: 85vh;
overflow-y: scroll;
::-webkit-scrollbar-track {
border-radius: 10px;
@@ -27,12 +27,24 @@ const RightbarStyled = styled.div`
}
`;
const RightbarTextStyled = styled.div`
+ display: flex;
+ flex-direction: column;
border-bottom: 1px solid;
`;
-export const Rightbar = () => {
- const [selectedCardId, setSelectedCardId] = useState(null);
+const SaveButton = styled.div`
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ background-color: rgb(100, 181, 246) !important;
+ border-radius: 10px;
+ cursor: pointer;
+ height: 40px;
+ background-color: red;
+ margin-bottom: 10px;
+`;
+export const Rightbar = () => {
const { courses, basket } = useContext(coursesContext)!;
const getBasketGroups = () => {
@@ -42,27 +54,18 @@ export const Rightbar = () => {
const filteredCourses = getBasketGroups();
- //działa clunky
- const onCardClick = (event: MouseEvent) => {
- const target = event.currentTarget;
- selectedCardId === target.id ? setSelectedCardId(null) : setSelectedCardId(target.id);
- };
-
//need to insert student name from db and course maybe based on current time or from db too
return (
- Hubert Wrzesiński
- Semestr zimowy 2020/2021
+
+ Hubert Wrzesiński
+ Semestr zimowy 2020/2021
+
+ SAVE
{filteredCourses.map((course, index) => (
-
+
))}
);
diff --git a/src/components/Scheduler.tsx b/src/components/Scheduler.tsx
index a4f851a..b2d7598 100644
--- a/src/components/Scheduler.tsx
+++ b/src/components/Scheduler.tsx
@@ -1,32 +1,22 @@
-import React, { useEffect, useRef } from 'react';
+import React, { useEffect, MouseEvent, useRef } from 'react';
import { useState } from 'react';
import { SchedulerEvents } from './SchedulerEvents';
import { days, hours } from '../constants/index';
-import styled from 'styled-components';
+import styled from 'styled-components/macro';
const SchedulerWrapper = styled.div`
- flex-grow: 3;
- margin-top: 20px;
border-collapse: collapse;
+ flex-grow: 1;
`;
const TableBody = styled.div`
width: 100%;
- height: 100%;
display: flex;
flex-direction: column;
`;
const TableRow = styled.div`
display: flex;
- flex-direction: row;
-`;
-
-const TableCell = styled.div`
- border: 1px solid #ddd;
- padding: 10px;
- text-align: center;
- flex: 1;
`;
const TableHead = styled.div`
@@ -34,57 +24,53 @@ const TableHead = styled.div`
width: 100%;
`;
-const TableHeadCell = styled.div`
+interface TableCellProps {
+ height: number;
+}
+
+const TableCell = styled.div`
+ height: ${({ height }) => height}px;
border: 1px solid #ddd;
- padding: 10px;
- text-align: center;
+ display: flex;
+ align-items: center;
+ justify-content: center;
flex: 1;
+ font-size: 24px;
+`;
+
+const T = styled.table`
+ width: 100%;
+ height: 100%;
`;
export const Scheduler = () => {
- const [currentEventsIds, setCurrentEventsIds] = useState>([]);
const cellRef = useRef(null);
const [cellWidth, setCellWidth] = useState(0);
const [cellTop, setCellTop] = useState(0);
+ const wrapperRef = useRef(null);
+ const [wrapperHeight, setWrapperHeight] = useState(0);
+
useEffect(() => {
const handleResize = () => {
- if (cellRef.current) {
+ if (cellRef.current && wrapperRef.current) {
setCellWidth(cellRef.current.getBoundingClientRect().width);
setCellTop(cellRef.current.getBoundingClientRect().top);
+ setWrapperHeight(wrapperRef.current.getBoundingClientRect().height);
}
};
handleResize();
window.addEventListener('resize', handleResize);
}, []);
- useEffect(() => {
- const displayEvents = () => {
- currentEventsIds.map((eventId: string) => {
- const event = document.getElementById(eventId);
- if (event) {
- event.style.display = 'block';
- }
- });
- };
- 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]);
- // };
-
return (
<>
-
+
{days.map((day, index) => (
- {day}
+
+ {day}
+
))}
@@ -92,15 +78,17 @@ export const Scheduler = () => {
{[hour, '', '', '', '', ''].map((value, indexCell) =>
indexRow === 0 && indexCell === 1 ? (
-
+
) : (
- {value}
+
+ {value}
+
),
)}
))}
-
+
>
);
diff --git a/src/components/SchedulerEvents.tsx b/src/components/SchedulerEvents.tsx
index 304d658..c0b447b 100644
--- a/src/components/SchedulerEvents.tsx
+++ b/src/components/SchedulerEvents.tsx
@@ -1,15 +1,15 @@
-import React, { useContext, useEffect, useState } from 'react';
+import React, { useContext, useEffect, useState, MouseEvent } from 'react';
import { SchedulerRow } from './SchedulerRow';
import { coursesContext } from '../contexts/CoursesProvider';
import { Group, Basket } from '../types';
-import classes from '*.module.css';
interface SchedulerEventsProps {
cellTop: number;
cellWidth: number;
+ cellHeight: number;
}
-export const SchedulerEvents = ({ cellTop, cellWidth }: SchedulerEventsProps) => {
+export const SchedulerEvents = ({ cellTop, cellWidth, cellHeight }: SchedulerEventsProps) => {
const { basket } = useContext(coursesContext)!;
const [choosenGroupsMappedToEvents, setChoosenGroupsMappedToEvents] = useState([]);
@@ -28,20 +28,21 @@ export const SchedulerEvents = ({ cellTop, cellWidth }: SchedulerEventsProps) =>
useEffect(() => {
function mapGroupTimeToEventRow(basket: Array) {
- const classes = basket.map(({ classes }) => classes).filter((cl) => cl !== null) as Array;
- const lectures = basket.map(({ lecture }) => lecture).filter((lec) => lec !== null) as Array;
+ const classes = basket.map(({ classes, name }) => ({ ...classes, name })) as Array;
+ const lectures = basket.map(({ lecture, name }) => ({ ...lecture, name })) as Array;
const merged = [...classes, ...lectures];
- if (merged.length >= 1) {
- const groupsMapped = merged.map(({ id, day, lecturer, room, time }) => ({
- id,
- day,
- lecturer,
- room,
- eventRow: groupTimeToEventRowMapping[time],
- }));
- setChoosenGroupsMappedToEvents(groupsMapped);
- }
+ //deleted if statement, maybe it is needed
+ const groupsMapped = merged.map(({ id, day, lecturer, room, time, name,type }) => ({
+ id,
+ day: day === 5 ? 4 : day,
+ lecturer,
+ room,
+ eventRow: groupTimeToEventRowMapping[time],
+ name,
+ type,
+ }));
+ setChoosenGroupsMappedToEvents(groupsMapped);
}
mapGroupTimeToEventRow(basket);
}, [basket]);
@@ -51,18 +52,25 @@ export const SchedulerEvents = ({ cellTop, cellWidth }: SchedulerEventsProps) =>
{[...Array(6)].map((_, index) => (
{
- return group.eventRow === index;
- })}
+ groups={choosenGroupsMappedToEvents.filter((group: any) => group.eventRow === index)}
indexRow={index}
cellTop={
- index == 3
- ? cellTop + (25 + 80 * index)
- : index < 3
- ? cellTop + (12 + 80 * index)
- : cellTop + (25 + 80 * index)
+ index === 0
+ ? cellTop + (cellHeight + cellHeight * 2 * index + cellHeight / 4)
+ : index === 1
+ ? cellTop + (cellHeight + cellHeight * 2 * index)
+ : index === 2
+ ? cellTop + (cellHeight + cellHeight * 2 * index - cellHeight / 4)
+ : index === 3
+ ? cellTop + (cellHeight + cellHeight * 2 * index - cellHeight / 4)
+ : index === 4
+ ? cellTop + (cellHeight + cellHeight * 2 * index - cellHeight / 2)
+ : index === 5
+ ? cellTop + (cellHeight + cellHeight * 2 * index - (cellHeight * 3) / 4)
+ : 0
}
cellWidth={cellWidth}
+ cellHeight={cellHeight}
/>
))}
diff --git a/src/components/SchedulerRow.tsx b/src/components/SchedulerRow.tsx
index 42fd6d6..9d62060 100644
--- a/src/components/SchedulerRow.tsx
+++ b/src/components/SchedulerRow.tsx
@@ -1,32 +1,87 @@
-import React from 'react';
-import { Group } from '../types';
-import styled from 'styled-components';
+import React, { MouseEvent, useEffect, useState } from 'react';
+import { Group, GroupType } from '../types';
+import styled from 'styled-components/macro';
+import Popover from '@material-ui/core/Popover';
+import Typography from '@material-ui/core/Typography';
+import { makeStyles, createStyles, Theme } from '@material-ui/core/styles';
+
+const useStyles = makeStyles((theme: Theme) =>
+ createStyles({
+ popover: {
+ pointerEvents: 'none',
+ },
+ paper: {
+ padding: theme.spacing(1),
+ marginLeft: 5,
+ textAlign: 'center',
+ },
+ }),
+);
interface SchedulerEventProps {
eventIndex: number;
cellTop: number;
cellWidth: number;
+ cellHeight: number;
}
const SchedulerEvent = styled.div