fixed hover
This commit is contained in:
120
src/components/Administrator.tsx
Normal file
120
src/components/Administrator.tsx
Normal file
@ -0,0 +1,120 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import styled from 'styled-components/macro';
|
||||
import { axiosInstance } from '../utils/axiosInstance';
|
||||
|
||||
const AdministratorWrapper = styled.div`
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
margin:0 auto;
|
||||
height:100vh;
|
||||
`;
|
||||
|
||||
const Wrap = styled.div`
|
||||
display: flex;
|
||||
flex: 1;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
`;
|
||||
|
||||
const LogoWrapper = styled.div`
|
||||
display: flex;
|
||||
flex: 1;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
`;
|
||||
|
||||
const Text = styled.div`
|
||||
font-family: 'Roboto', sans-serif;
|
||||
font-size: 5rem;
|
||||
user-select: none;
|
||||
`;
|
||||
|
||||
const Logo = styled.img`
|
||||
width: 400px;
|
||||
height: 400px;
|
||||
`;
|
||||
|
||||
const Form = styled.form`
|
||||
flex: 1;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
flex-direction: column;
|
||||
|
||||
input {
|
||||
padding: 5px;
|
||||
margin-top: 10px;
|
||||
margin-bottom: 10px;
|
||||
width: 210px;
|
||||
}
|
||||
`;
|
||||
|
||||
export const Administrator = () => {
|
||||
const today = new Date();
|
||||
const dd = String(today.getDate()).padStart(2, '0');
|
||||
const mm = String(today.getMonth() + 1).padStart(2, '0');
|
||||
const yyyy = today.getFullYear();
|
||||
|
||||
const date = yyyy + '-' + mm + '-' + dd;
|
||||
|
||||
const [selectedFile, setSelectedFile] = useState<File|null>(null);
|
||||
|
||||
const destination = `${process.env.REACT_APP_API_URL}/api/v1/configurator/config`;
|
||||
|
||||
useEffect(() => {
|
||||
}, [selectedFile]);
|
||||
|
||||
const uploadFile = async (event:React.FormEvent<HTMLFormElement>) => {
|
||||
event.preventDefault();
|
||||
const formData = new FormData();
|
||||
formData.append("file",selectedFile as Blob);
|
||||
|
||||
const response = await axiosInstance.post(`${process.env.REACT_APP_API_URL}/api/v1/configurator/config`, formData)
|
||||
|
||||
console.log(response);
|
||||
}
|
||||
|
||||
|
||||
return (
|
||||
<AdministratorWrapper>
|
||||
<Wrap>
|
||||
<LogoWrapper>
|
||||
<Logo alt="logo" src="https://plannaplan.pl/img/logo.svg" />
|
||||
<Text> plan na plan </Text>
|
||||
</LogoWrapper>
|
||||
<Form
|
||||
onSubmit={uploadFile}
|
||||
>
|
||||
<div>
|
||||
<div>Start:</div>{' '}
|
||||
<div>
|
||||
<input type="date" min={date} />
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div>Koniec:</div>{' '}
|
||||
<div>
|
||||
<input type="date" min={date} />
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<input
|
||||
type="file"
|
||||
onChange={(e) => {
|
||||
if (e.target.files && e.target.files[0]) {
|
||||
const file = e.target.files[0];
|
||||
setSelectedFile(file);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<input type="submit"/>
|
||||
</div>
|
||||
</Form>
|
||||
</Wrap>
|
||||
</AdministratorWrapper>
|
||||
);
|
||||
};
|
@ -1,13 +1,15 @@
|
||||
import React, { useContext, useState } from 'react';
|
||||
import Topbar from './Topbar';
|
||||
import { Transfer } from './Transfer';
|
||||
import { Admin } from './Admin';
|
||||
import { Deanery } from './DeaneryPanel';
|
||||
import { Scheduler } from './Scheduler';
|
||||
import { Rightbar } from './Rightbar';
|
||||
import { Administrator } from './Administrator';
|
||||
import styled from 'styled-components';
|
||||
import LoadingOverlay from 'react-loading-overlay';
|
||||
import { SyncLoader } from 'react-spinners';
|
||||
import { CASContext } from '../contexts/CASProvider';
|
||||
import { coursesContext } from '../contexts/CoursesProvider';
|
||||
const Wrapper = styled.div`
|
||||
display: flex;
|
||||
height: calc(100vh - 80px);
|
||||
@ -21,6 +23,9 @@ export const App = () => {
|
||||
const { role } = useContext(CASContext)!;
|
||||
const [isOpenTransfer, setOpenTransfer] = useState(false);
|
||||
|
||||
const { selectSchedulerEvents } = useContext(coursesContext)!;
|
||||
const schedulerEvents = selectSchedulerEvents();
|
||||
|
||||
const handleTransfer = () => {
|
||||
setOpenTransfer(!isOpenTransfer);
|
||||
};
|
||||
@ -29,17 +34,24 @@ export const App = () => {
|
||||
return (
|
||||
<>
|
||||
<LoadingOverlay active={role === undefined} spinner={<SyncLoader />}>
|
||||
<Topbar handleTransfer={handleTransfer} />
|
||||
<Transfer isOpen={isOpenTransfer} handleClose={handleTransfer} />
|
||||
<Wrapper>
|
||||
{userPrivilige === 'STUDENT' && (
|
||||
{userPrivilige !== 'ADMIN' && (
|
||||
<>
|
||||
<Scheduler />
|
||||
<Rightbar />
|
||||
<Topbar handleTransfer={handleTransfer} />
|
||||
<Transfer isOpen={isOpenTransfer} handleClose={handleTransfer} />
|
||||
<Wrapper>
|
||||
{userPrivilige === 'STUDENT' && (
|
||||
<>
|
||||
<Scheduler schedulerEvents={schedulerEvents} />
|
||||
<Rightbar />
|
||||
</>
|
||||
)}
|
||||
{userPrivilige === 'DEANERY' && <Deanery schedulerEvents={schedulerEvents} />}
|
||||
</Wrapper>
|
||||
</>
|
||||
)}
|
||||
{userPrivilige === 'DEANERY' && <Admin />}
|
||||
</Wrapper>
|
||||
{userPrivilige === 'ADMIN' && (
|
||||
<Administrator></Administrator>
|
||||
)}
|
||||
</LoadingOverlay>
|
||||
</>
|
||||
);
|
||||
|
@ -162,7 +162,7 @@ export const CourseCard = ({ course }: CourseCardProps) => {
|
||||
const [previous, setPrevious] = useState(basketCourseGroups);
|
||||
|
||||
const onGroupClick = (group: Group, courseId: number) => {
|
||||
setPrevious((prev) => (group.type === GroupType.CLASS ? { ...prev, classes: group } : { ...prev, lecture: group }));
|
||||
setPrevious((prev) => (group.type === GroupType.CLASS ? { ...prev, classes: group, prev:"classes" } : { ...prev, lecture: group,prev:"lecture" }));
|
||||
changeGroupInBasket(group, courseId);
|
||||
};
|
||||
|
||||
@ -187,22 +187,17 @@ export const CourseCard = ({ course }: CourseCardProps) => {
|
||||
onClick={() => onGroupClick(group, course.id)}
|
||||
onMouseEnter={() => {
|
||||
if (group.type === GroupType.CLASS) {
|
||||
changeGroupInBasket(group, course.id);
|
||||
changeGroupInBasket({classes: group,lecture:previous.lecture}, course.id);
|
||||
}
|
||||
if (group.type === GroupType.LECTURE) {
|
||||
changeGroupInBasket(group, course.id);
|
||||
changeGroupInBasket({lecture: group,classes:previous.classes}, course.id);
|
||||
}
|
||||
}}
|
||||
onMouseLeave={() => {
|
||||
if (hoveredGroup) {
|
||||
if (hoveredGroup.type === GroupType.CLASS && previous.classes !== undefined) {
|
||||
changeGroupInBasket(previous.classes, course.id);
|
||||
}
|
||||
if (hoveredGroup.type === GroupType.LECTURE && previous.lecture !== undefined) {
|
||||
changeGroupInBasket(previous.lecture, course.id);
|
||||
}
|
||||
changeHoveredGroup(null);
|
||||
changeGroupInBasket(previous, course.id);
|
||||
}
|
||||
changeHoveredGroup(null);
|
||||
}}
|
||||
>
|
||||
<StyledGroupType groupType={group.type}>{group.type === 'CLASS' ? 'ĆW' : 'WYK'}</StyledGroupType>
|
||||
|
@ -7,6 +7,7 @@ import { Scheduler } from './Scheduler';
|
||||
import { Rightbar } from './Rightbar';
|
||||
import { SchedulerHistory } from './SchedulerHistory';
|
||||
import { coursesContext } from '../contexts/CoursesProvider';
|
||||
import { SchedulerEvent } from '../types';
|
||||
|
||||
const LeftSide = styled.div`
|
||||
height: 100%;
|
||||
@ -96,9 +97,15 @@ const Icon = styled.img`
|
||||
margin: 5px;
|
||||
`;
|
||||
|
||||
export const Admin = () => {
|
||||
interface Deanery {
|
||||
schedulerEvents: Array<SchedulerEvent>;
|
||||
}
|
||||
|
||||
export const Deanery = ({ schedulerEvents }: Deanery) => {
|
||||
const [currentTab, setCurrentTab] = useState<null | number>(1);
|
||||
const { getNewestStudentTimetable,userID } = useContext(coursesContext)!;
|
||||
const { selectHistorySchedulerEvents } = useContext(coursesContext)!;
|
||||
const schedulerHistoryEvents = selectHistorySchedulerEvents();
|
||||
|
||||
const handleClick = (e: MouseEvent<HTMLDivElement>) => {
|
||||
setCurrentTab(Number(e.currentTarget.id));
|
||||
@ -124,11 +131,11 @@ export const Admin = () => {
|
||||
<Wrapper>
|
||||
{currentTab === 1 ? (
|
||||
<>
|
||||
<Scheduler />
|
||||
<Scheduler schedulerEvents={schedulerEvents}/>
|
||||
<Rightbar />
|
||||
</>
|
||||
) : currentTab === 2 ? (
|
||||
<SchedulerHistory />
|
||||
<SchedulerHistory schedulerHistoryEvents={schedulerHistoryEvents}/>
|
||||
) : currentTab === 3 ? (
|
||||
<StatsDiv />
|
||||
) : (
|
@ -67,7 +67,6 @@ export const Dropdown = ({ open, input, handleCloseDropdown, selectedOption }: D
|
||||
|
||||
const onUserClick = (event: MouseEvent) => {
|
||||
const target = event.currentTarget;
|
||||
console.log('target: ', target);
|
||||
//to be moved to students provider
|
||||
changeStudent(target.id);
|
||||
changeSelectedStudent(Number(target.id));
|
||||
|
@ -3,6 +3,7 @@ import { useState } from 'react';
|
||||
import { SchedulerEvents } from './SchedulerEvents';
|
||||
import { days, hours } from '../constants/index';
|
||||
import styled from 'styled-components/macro';
|
||||
import { SchedulerEvent } from '../types';
|
||||
|
||||
const SchedulerWrapper = styled.div`
|
||||
border-collapse: collapse;
|
||||
@ -61,7 +62,11 @@ const TableCell = styled.div<TableCellProps>`
|
||||
font-weight: bold;
|
||||
`;
|
||||
|
||||
export const Scheduler = () => {
|
||||
interface SchedulerProps {
|
||||
schedulerEvents: Array<SchedulerEvent>;
|
||||
}
|
||||
|
||||
export const Scheduler = ({ schedulerEvents }: SchedulerProps) => {
|
||||
const cellRef = useRef<HTMLDivElement>(null);
|
||||
const [cellWidth, setCellWidth] = useState(0);
|
||||
const [cellHeight, setCellHeight] = useState(0);
|
||||
@ -123,7 +128,7 @@ export const Scheduler = () => {
|
||||
)}
|
||||
</TableRow>
|
||||
))}
|
||||
<SchedulerEvents cellWidth={cellWidth} cellHeight={cellHeight} />
|
||||
<SchedulerEvents cellWidth={cellWidth} cellHeight={cellHeight} schedulerEvents={schedulerEvents} />
|
||||
</TableBody>
|
||||
</SchedulerWrapper>
|
||||
);
|
||||
|
@ -3,15 +3,15 @@ import { SchedulerRow } from './SchedulerRow';
|
||||
import { coursesContext } from '../contexts/CoursesProvider';
|
||||
import { selectGroupsToShow } from '../utils/index';
|
||||
import { ROWS_COUNT } from '../constants';
|
||||
import { SchedulerEvent } from '../types';
|
||||
|
||||
interface SchedulerEventsProps {
|
||||
cellWidth: number;
|
||||
cellHeight: number;
|
||||
schedulerEvents: Array<SchedulerEvent>;
|
||||
}
|
||||
|
||||
export const SchedulerEvents = ({ cellWidth, cellHeight }: SchedulerEventsProps) => {
|
||||
const { selectSchedulerEvents } = useContext(coursesContext)!;
|
||||
|
||||
const schedulerEvents = selectSchedulerEvents();
|
||||
export const SchedulerEvents = ({ cellWidth, cellHeight,schedulerEvents }: SchedulerEventsProps) => {
|
||||
|
||||
return (
|
||||
<div>
|
||||
|
@ -1,6 +1,7 @@
|
||||
import React, { useContext, useEffect, useState } from 'react';
|
||||
import styled from 'styled-components';
|
||||
import { coursesContext } from '../contexts/CoursesProvider';
|
||||
import { SchedulerEvent } from '../types';
|
||||
import { Scheduler } from './Scheduler';
|
||||
import { SchedulerHistoryNavigation } from './SchedulerHistoryNavigation';
|
||||
|
||||
@ -10,8 +11,12 @@ const Wrapper = styled.div`
|
||||
width: 100%;
|
||||
`;
|
||||
|
||||
export const SchedulerHistory = () => {
|
||||
const { timetableHistory, setBasketFromHistoryGroups } = useContext(coursesContext)!;
|
||||
interface SchedulerHistoryProps {
|
||||
schedulerHistoryEvents: Array<SchedulerEvent>;
|
||||
}
|
||||
|
||||
export const SchedulerHistory = ({schedulerHistoryEvents}:SchedulerHistoryProps) => {
|
||||
const { timetableHistory, setHistoryBasketFromHistoryGroups } = useContext(coursesContext)!;
|
||||
const [currentTimetable, setCurrentTimetable] = useState(timetableHistory.length===0 ? 0 : timetableHistory.length - 1);
|
||||
let commisionDate = timetableHistory[currentTimetable]?.commisionDate;
|
||||
|
||||
@ -28,12 +33,13 @@ export const SchedulerHistory = () => {
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
console.log('current timetable is: ', currentTimetable);
|
||||
console.log('23113knkalsdnkasdlk', timetableHistory);
|
||||
const timetable = timetableHistory[currentTimetable];
|
||||
if (timetable) {
|
||||
const { groups } = timetable;
|
||||
setBasketFromHistoryGroups(groups);
|
||||
setHistoryBasketFromHistoryGroups(groups);
|
||||
}
|
||||
else{
|
||||
setHistoryBasketFromHistoryGroups([]);
|
||||
}
|
||||
}, [currentTimetable,timetableHistory]);
|
||||
|
||||
@ -42,7 +48,7 @@ export const SchedulerHistory = () => {
|
||||
{timetableHistory.length > 0 && (
|
||||
<SchedulerHistoryNavigation commisionDate={commisionDate} SubstractCurrentTimetable={SubstractCurrentTimetable} AddCurrentTimetable={AddCurrentTimetable} />
|
||||
)}
|
||||
<Scheduler />
|
||||
<Scheduler schedulerEvents={schedulerHistoryEvents}/>
|
||||
</Wrapper>
|
||||
);
|
||||
};
|
||||
|
@ -65,8 +65,6 @@ export const SchedulerHistoryNavigation = ({
|
||||
AddCurrentTimetable,
|
||||
}: SchedulerHistoryNavigationProps) => {
|
||||
|
||||
console.log("231213231231",commisionDate)
|
||||
|
||||
return (
|
||||
<Wrapper>
|
||||
<StyledButton
|
||||
|
Reference in New Issue
Block a user