Merge pull request 'statistics' (#57) from statistics into master
Reviewed-on: http://git.plannaplan.pl/y0rune/frontend/pulls/57 Reviewed-by: Maciej <glowackimaciej97@gmail.com>
This commit is contained in:
commit
69d05b7a78
51
src/assets/logout.svg
Normal file
51
src/assets/logout.svg
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||||
|
<!-- Generator: Adobe Illustrator 19.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||||
|
<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||||
|
viewBox="0 0 512 512" style="enable-background:new 0 0 512 512;" xml:space="preserve">
|
||||||
|
<g>
|
||||||
|
<g>
|
||||||
|
<path d="M255.15,468.625H63.787c-11.737,0-21.262-9.526-21.262-21.262V64.638c0-11.737,9.526-21.262,21.262-21.262H255.15
|
||||||
|
c11.758,0,21.262-9.504,21.262-21.262S266.908,0.85,255.15,0.85H63.787C28.619,0.85,0,29.47,0,64.638v382.724
|
||||||
|
c0,35.168,28.619,63.787,63.787,63.787H255.15c11.758,0,21.262-9.504,21.262-21.262
|
||||||
|
C276.412,478.129,266.908,468.625,255.15,468.625z"/>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
<g>
|
||||||
|
<path d="M505.664,240.861L376.388,113.286c-8.335-8.25-21.815-8.143-30.065,0.213s-8.165,21.815,0.213,30.065l92.385,91.173
|
||||||
|
H191.362c-11.758,0-21.262,9.504-21.262,21.262c0,11.758,9.504,21.263,21.262,21.263h247.559l-92.385,91.173
|
||||||
|
c-8.377,8.25-8.441,21.709-0.213,30.065c4.167,4.21,9.653,6.336,15.139,6.336c5.401,0,10.801-2.041,14.926-6.124l129.276-127.575
|
||||||
|
c4.04-3.997,6.336-9.441,6.336-15.139C512,250.302,509.725,244.88,505.664,240.861z"/>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
</g>
|
||||||
|
<g>
|
||||||
|
</g>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 1.3 KiB |
1
src/assets/switch.svg
Normal file
1
src/assets/switch.svg
Normal file
@ -0,0 +1 @@
|
|||||||
|
<svg id="bold" enable-background="new 0 0 24 24" height="512" viewBox="0 0 24 24" width="512" xmlns="http://www.w3.org/2000/svg"><path d="m23.25 15c-.414 0-.75-.336-.75-.75 0-2.895-2.355-5.25-5.25-5.25h-7.25v3.25c0 .66-.794.994-1.268.542l-5.5-5.25c-.148-.141-.232-.337-.232-.542s.084-.401.232-.542l5.5-5.25c.476-.454 1.268-.116 1.268.542v3.25h6.25c4.273 0 7.75 3.477 7.75 7.75v1.5c0 .414-.336.75-.75.75z"/><path d="m14 22.25v-3.25h-6.25c-4.273 0-7.75-3.477-7.75-7.75v-1.5c0-.414.336-.75.75-.75s.75.336.75.75c0 2.895 2.355 5.25 5.25 5.25h7.25v-3.25c0-.657.791-.998 1.268-.542l5.5 5.25c.148.141.232.337.232.542s-.084.401-.232.542l-5.5 5.25c-.477.454-1.268.116-1.268-.542z"/></svg>
|
After Width: | Height: | Size: 678 B |
1
src/assets/transfer.svg
Normal file
1
src/assets/transfer.svg
Normal file
@ -0,0 +1 @@
|
|||||||
|
<svg id="bold" enable-background="new 0 0 24 24" height="512" viewBox="0 0 24 24" width="512" xmlns="http://www.w3.org/2000/svg"><path d="m20.25 11c-.414 0-.75-.336-.75-.75v-4.5c0-.689-.561-1.25-1.25-1.25h-7.5c-.414 0-.75-.336-.75-.75s.336-.75.75-.75h7.5c1.517 0 2.75 1.233 2.75 2.75v4.5c0 .414-.336.75-.75.75z"/><path d="m20.25 11c-.192 0-.384-.073-.53-.22l-1.75-1.75c-.214-.214-.279-.537-.163-.817s.39-.463.693-.463h3.5c.303 0 .577.183.693.463s.052.603-.163.817l-1.75 1.75c-.146.147-.338.22-.53.22z"/><path d="m11.25 21h-5.5c-1.517 0-2.75-1.233-2.75-2.75v-4.5c0-.414.336-.75.75-.75s.75.336.75.75v4.5c0 .689.561 1.25 1.25 1.25h5.5c.414 0 .75.336.75.75s-.336.75-.75.75z"/><path d="m5.5 16.25h-3.5c-.303 0-.577-.183-.693-.463s-.052-.603.163-.817l1.75-1.75c.293-.293.768-.293 1.061 0l1.75 1.75c.214.214.279.537.163.817s-.391.463-.694.463z"/><circle cx="5" cy="2.5" r="2.5"/><path d="m7.25 6h-4.5c-1.517 0-2.75 1.233-2.75 2.75v.5c0 .414.336.75.75.75h8.5c.414 0 .75-.336.75-.75v-.5c0-1.517-1.233-2.75-2.75-2.75z"/><path d="m19 19c-1.378 0-2.5-1.122-2.5-2.5s1.122-2.5 2.5-2.5 2.5 1.122 2.5 2.5-1.122 2.5-2.5 2.5z"/><path d="m23.25 24h-8.5c-.414 0-.75-.336-.75-.75v-.5c0-1.517 1.233-2.75 2.75-2.75h4.5c1.517 0 2.75 1.233 2.75 2.75v.5c0 .414-.336.75-.75.75z"/></svg>
|
After Width: | Height: | Size: 1.2 KiB |
@ -1,10 +1,12 @@
|
|||||||
import { format } from 'date-fns';
|
import { format } from 'date-fns';
|
||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState, useContext } from 'react';
|
||||||
import styled from 'styled-components/macro';
|
import styled from 'styled-components/macro';
|
||||||
import { axiosInstance } from '../utils/axiosInstance';
|
import { axiosInstance } from '../utils/axiosInstance';
|
||||||
import { useSnackbar } from 'notistack';
|
import { useSnackbar } from 'notistack';
|
||||||
import CloseIcon from '@material-ui/icons/Close';
|
import CloseIcon from '@material-ui/icons/Close';
|
||||||
import { SyncLoader } from 'react-spinners';
|
import { SyncLoader } from 'react-spinners';
|
||||||
|
import { CASContext } from '../contexts/CASProvider';
|
||||||
|
import LogoutIcon from '../assets/logout.svg';
|
||||||
|
|
||||||
const StyledCloseIcon = styled(CloseIcon)`
|
const StyledCloseIcon = styled(CloseIcon)`
|
||||||
color: #000000;
|
color: #000000;
|
||||||
@ -14,6 +16,18 @@ const StyledCloseIcon = styled(CloseIcon)`
|
|||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
const Icon = styled.img`
|
||||||
|
width: 40px;
|
||||||
|
margin-left: 40px;
|
||||||
|
cursor: pointer;
|
||||||
|
@media only screen and (max-width: 670px) {
|
||||||
|
width: 35px;
|
||||||
|
}
|
||||||
|
position:absolute;
|
||||||
|
top:10px;
|
||||||
|
right:10px;
|
||||||
|
`;
|
||||||
|
|
||||||
const SaveButton = styled.button`
|
const SaveButton = styled.button`
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
@ -24,6 +38,7 @@ const SaveButton = styled.button`
|
|||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
height: 40px;
|
height: 40px;
|
||||||
|
margin:10px;
|
||||||
&:hover {
|
&:hover {
|
||||||
color: #ffffff;
|
color: #ffffff;
|
||||||
box-shadow: 0px 5px 4px 0px rgba(0, 0, 0, 0.24);
|
box-shadow: 0px 5px 4px 0px rgba(0, 0, 0, 0.24);
|
||||||
@ -52,6 +67,7 @@ const LogoWrapper = styled.div`
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
margin-top:-50px;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const Text = styled.div`
|
const Text = styled.div`
|
||||||
@ -80,7 +96,22 @@ const Form = styled.form`
|
|||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
const DownloadSection = styled.div`
|
||||||
|
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 = () => {
|
export const Administrator = () => {
|
||||||
|
const { logout } = useContext(CASContext)!;
|
||||||
const { enqueueSnackbar } = useSnackbar();
|
const { enqueueSnackbar } = useSnackbar();
|
||||||
const { closeSnackbar } = useSnackbar();
|
const { closeSnackbar } = useSnackbar();
|
||||||
|
|
||||||
@ -98,6 +129,27 @@ export const Administrator = () => {
|
|||||||
const [endSecondDate, setEndSecondDate] = useState<Date | null>(null);
|
const [endSecondDate, setEndSecondDate] = useState<Date | null>(null);
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
|
|
||||||
|
const downloadFile = async () => {
|
||||||
|
|
||||||
|
const {data} = await axiosInstance.get(`${process.env.REACT_APP_API_URL}/api/v1/commisions/export/csv`,{responseType:"blob"});
|
||||||
|
|
||||||
|
console.log("123",xd);
|
||||||
|
|
||||||
|
const downloadUrl = window.URL.createObjectURL(new Blob([data]));
|
||||||
|
|
||||||
|
const link = document.createElement('a');
|
||||||
|
|
||||||
|
link.href = downloadUrl;
|
||||||
|
|
||||||
|
link.setAttribute('download', 'file.csv');
|
||||||
|
|
||||||
|
document.body.appendChild(link);
|
||||||
|
|
||||||
|
link.click();
|
||||||
|
|
||||||
|
link.remove();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
const uploadFile = async (event: React.FormEvent<HTMLFormElement>) => {
|
const uploadFile = async (event: React.FormEvent<HTMLFormElement>) => {
|
||||||
const action = (key: any) => (
|
const action = (key: any) => (
|
||||||
@ -138,12 +190,12 @@ export const Administrator = () => {
|
|||||||
formData,
|
formData,
|
||||||
config,
|
config,
|
||||||
);
|
);
|
||||||
enqueueSnackbar('Plan został zapisany', {
|
enqueueSnackbar('Ustawienia zostały zapisane', {
|
||||||
variant: 'success',
|
variant: 'success',
|
||||||
action,
|
action,
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
enqueueSnackbar('Zapisywanie planu nie powiodło się', {
|
enqueueSnackbar('Ustawienia nie zostały zapisane', {
|
||||||
variant: 'error',
|
variant: 'error',
|
||||||
action,
|
action,
|
||||||
});
|
});
|
||||||
@ -152,13 +204,18 @@ export const Administrator = () => {
|
|||||||
setLoading(false);
|
setLoading(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const xd = true;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AdministratorWrapper>
|
<AdministratorWrapper>
|
||||||
|
<Icon alt="logout" src={LogoutIcon} onClick={logout}/>
|
||||||
<Wrap>
|
<Wrap>
|
||||||
<LogoWrapper>
|
<LogoWrapper>
|
||||||
<Logo alt="logo" src="https://plannaplan.pl/img/logo.svg" />
|
<Logo alt="logo" src="https://plannaplan.pl/img/logo.svg" />
|
||||||
<Text> plan na plan </Text>
|
<Text> plan na plan </Text>
|
||||||
</LogoWrapper>
|
</LogoWrapper>
|
||||||
|
{xd === true ? (
|
||||||
|
<div>
|
||||||
<Form onSubmit={uploadFile}>
|
<Form onSubmit={uploadFile}>
|
||||||
<div>
|
<div>
|
||||||
<div>Start pierwszej tury:</div>{' '}
|
<div>Start pierwszej tury:</div>{' '}
|
||||||
@ -197,6 +254,12 @@ export const Administrator = () => {
|
|||||||
<SaveButton type="submit">{loading === false ? 'Zapisz' : <SyncLoader />} </SaveButton>
|
<SaveButton type="submit">{loading === false ? 'Zapisz' : <SyncLoader />} </SaveButton>
|
||||||
</div>
|
</div>
|
||||||
</Form>
|
</Form>
|
||||||
|
<DownloadSection>
|
||||||
|
<SaveButton onClick={downloadFile}>Pobierz dane.csv</SaveButton>
|
||||||
|
</DownloadSection>
|
||||||
|
</div>
|
||||||
|
) : (<div></div>
|
||||||
|
)}
|
||||||
</Wrap>
|
</Wrap>
|
||||||
</AdministratorWrapper>
|
</AdministratorWrapper>
|
||||||
);
|
);
|
||||||
|
@ -37,7 +37,7 @@ export const App = () => {
|
|||||||
{userPrivilige !== 'ADMIN' && (
|
{userPrivilige !== 'ADMIN' && (
|
||||||
<>
|
<>
|
||||||
<Topbar handleTransfer={handleTransfer} />
|
<Topbar handleTransfer={handleTransfer} />
|
||||||
<Transfer isOpen={isOpenTransfer} handleClose={handleTransfer} />
|
<Transfer isTransferOpen={isOpenTransfer} handleClose={handleTransfer} />
|
||||||
<Wrapper>
|
<Wrapper>
|
||||||
{userPrivilige === 'STUDENT' && (
|
{userPrivilige === 'STUDENT' && (
|
||||||
<>
|
<>
|
||||||
@ -49,9 +49,7 @@ export const App = () => {
|
|||||||
</Wrapper>
|
</Wrapper>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
{userPrivilige === 'ADMIN' && (
|
{userPrivilige === 'ADMIN' && <Administrator></Administrator>}
|
||||||
<Administrator></Administrator>
|
|
||||||
)}
|
|
||||||
</LoadingOverlay>
|
</LoadingOverlay>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
@ -158,7 +158,7 @@ export const CourseCard = ({ course }: CourseCardProps) => {
|
|||||||
} = useContext(coursesContext)!;
|
} = useContext(coursesContext)!;
|
||||||
const [isSelected, setSelected] = useState(true);
|
const [isSelected, setSelected] = useState(true);
|
||||||
const groups = [...course.lectures!, ...course.classes!];
|
const groups = [...course.lectures!, ...course.classes!];
|
||||||
const basketCourseGroups = useMemo(() => selectBasketCourseGroups(course.id), []);
|
const basketCourseGroups = useMemo(() => selectBasketCourseGroups(course.name), []);
|
||||||
const [previous, setPrevious] = useState(basketCourseGroups);
|
const [previous, setPrevious] = useState(basketCourseGroups);
|
||||||
|
|
||||||
const onGroupClick = (group: Group, courseId: number) => {
|
const onGroupClick = (group: Group, courseId: number) => {
|
||||||
|
@ -2,7 +2,8 @@ import React, { useState, MouseEvent,useContext } from 'react';
|
|||||||
import styled from 'styled-components/macro';
|
import styled from 'styled-components/macro';
|
||||||
import Plan from '../assets/plan.svg';
|
import Plan from '../assets/plan.svg';
|
||||||
import History from '../assets/history.svg';
|
import History from '../assets/history.svg';
|
||||||
import Statistics from '../assets/statistics.svg';
|
import StatisticsIcon from '../assets/statistics.svg';
|
||||||
|
import { Statistics } from './Statistics';
|
||||||
import { Scheduler } from './Scheduler';
|
import { Scheduler } from './Scheduler';
|
||||||
import { Rightbar } from './Rightbar';
|
import { Rightbar } from './Rightbar';
|
||||||
import { SchedulerHistory } from './SchedulerHistory';
|
import { SchedulerHistory } from './SchedulerHistory';
|
||||||
@ -124,7 +125,7 @@ export const Deanery = ({ schedulerEvents }: Deanery) => {
|
|||||||
Historia Zmian
|
Historia Zmian
|
||||||
</LeftPanelElement>
|
</LeftPanelElement>
|
||||||
<LeftPanelElement id={'3'} isCurrentTab={currentTab === 3} onClick={handleClick}>
|
<LeftPanelElement id={'3'} isCurrentTab={currentTab === 3} onClick={handleClick}>
|
||||||
<Icon alt="statistics" src={Statistics} />
|
<Icon alt="statistics" src={StatisticsIcon} />
|
||||||
Statystyki
|
Statystyki
|
||||||
</LeftPanelElement>
|
</LeftPanelElement>
|
||||||
</LeftSide>
|
</LeftSide>
|
||||||
@ -137,7 +138,7 @@ export const Deanery = ({ schedulerEvents }: Deanery) => {
|
|||||||
) : currentTab === 2 ? (
|
) : currentTab === 2 ? (
|
||||||
<SchedulerHistory schedulerHistoryEvents={schedulerHistoryEvents}/>
|
<SchedulerHistory schedulerHistoryEvents={schedulerHistoryEvents}/>
|
||||||
) : currentTab === 3 ? (
|
) : currentTab === 3 ? (
|
||||||
<StatsDiv />
|
<StatsDiv><Statistics/></StatsDiv>
|
||||||
) : (
|
) : (
|
||||||
<LogoWrapper>
|
<LogoWrapper>
|
||||||
<Logo alt="logo" src="https://plannaplan.pl/img/logo.svg" />
|
<Logo alt="logo" src="https://plannaplan.pl/img/logo.svg" />
|
||||||
|
111
src/components/DropdownModal.tsx
Normal file
111
src/components/DropdownModal.tsx
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
import React, { useState, useContext, useEffect, MouseEvent, useMemo } from 'react';
|
||||||
|
import { coursesContext } from '../contexts/CoursesProvider';
|
||||||
|
import { studentsContext } from '../contexts/StudentsProvider';
|
||||||
|
import { Course, Student } from '../types';
|
||||||
|
import styled from 'styled-components';
|
||||||
|
|
||||||
|
const DropdownContainer = styled.div`
|
||||||
|
position: relative;
|
||||||
|
z-index: 99999999;
|
||||||
|
max-height: 396px;
|
||||||
|
border-radius: 3px;
|
||||||
|
overflow-y: auto;
|
||||||
|
opacity: 0.97;
|
||||||
|
box-shadow: 0.05em 0.2em 0.6em rgba(0, 0, 0, 0.2);
|
||||||
|
scroll-snap-type: y mandatory;
|
||||||
|
scroll-behavior: smooth;
|
||||||
|
::-webkit-scrollbar-track {
|
||||||
|
background-color: #f2f4f7;
|
||||||
|
border-radius: 10px;
|
||||||
|
}
|
||||||
|
::-webkit-scrollbar {
|
||||||
|
background-color: #f2f4f7;
|
||||||
|
width: 5px;
|
||||||
|
border-style: none;
|
||||||
|
}
|
||||||
|
::-webkit-scrollbar-thumb {
|
||||||
|
border-radius: 10px;
|
||||||
|
background-color: #4b4b4b;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
const CourseContainer = styled.div`
|
||||||
|
padding: 5px;
|
||||||
|
padding-left: 20px;
|
||||||
|
background-color: #f2f4f7;
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: 500;
|
||||||
|
scroll-snap-align: end;
|
||||||
|
:hover {
|
||||||
|
background-color: #eceef4;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
interface DropdownProps {
|
||||||
|
open: boolean;
|
||||||
|
input: string;
|
||||||
|
handleCloseDropdown: () => void;
|
||||||
|
handleSelectedGroupChange: (event: React.ChangeEvent<{ value: unknown }>) => void;
|
||||||
|
selectedOption: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const DropdownModal = ({
|
||||||
|
open,
|
||||||
|
input,
|
||||||
|
handleCloseDropdown,
|
||||||
|
selectedOption,
|
||||||
|
handleSelectedGroupChange,
|
||||||
|
}: DropdownProps) => {
|
||||||
|
const { courses, selectBasketNames } = useContext(coursesContext)!;
|
||||||
|
const basketNames = useMemo(() => selectBasketNames(), [selectBasketNames]);
|
||||||
|
const [filteredCourses, setFilteredCourses] = useState<Array<Course>>([]);
|
||||||
|
|
||||||
|
const onCourseClick = (event: MouseEvent) => {
|
||||||
|
const target = event.currentTarget;
|
||||||
|
if (target.id && target.textContent) {
|
||||||
|
const course = filteredCourses.find(({ id }) => id.toString() === target.id)!;
|
||||||
|
|
||||||
|
handleSelectedGroupChange((course as unknown) as any);
|
||||||
|
handleCloseDropdown();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const filterCourses = (input: string) => {
|
||||||
|
const filteredCourses = courses.filter(
|
||||||
|
({ name }) =>
|
||||||
|
name
|
||||||
|
.toLowerCase()
|
||||||
|
.normalize('NFD')
|
||||||
|
.replace(/[\u0300-\u036f]/g, '')
|
||||||
|
.includes(
|
||||||
|
input
|
||||||
|
.toLowerCase()
|
||||||
|
.normalize('NFD')
|
||||||
|
.replace(/[\u0300-\u036f]/g, ''),
|
||||||
|
) && !basketNames.includes(name),
|
||||||
|
);
|
||||||
|
setFilteredCourses(filteredCourses);
|
||||||
|
};
|
||||||
|
filterCourses(input);
|
||||||
|
}, [basketNames, courses, input]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<DropdownContainer>
|
||||||
|
{open && (
|
||||||
|
<>
|
||||||
|
{
|
||||||
|
<div>
|
||||||
|
{filteredCourses.map(({ name, id }, index) => (
|
||||||
|
<CourseContainer key={index} id={id.toString()} onClick={onCourseClick}>
|
||||||
|
<p>{name} </p>
|
||||||
|
</CourseContainer>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</DropdownContainer>
|
||||||
|
);
|
||||||
|
};
|
@ -84,7 +84,6 @@ export const SelectMenu = ({changeSelectedOption,changeDropdownOpen, selectedOpt
|
|||||||
<Wrapper onClick={() => {changeDropdownOpen(false)}}>
|
<Wrapper onClick={() => {changeDropdownOpen(false)}}>
|
||||||
<Header
|
<Header
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
console.log('clicked');
|
|
||||||
setIsOpen(!isOpen);
|
setIsOpen(!isOpen);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
94
src/components/Statistics.tsx
Normal file
94
src/components/Statistics.tsx
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
import React, { useState, useContext } from 'react';
|
||||||
|
import Collapse from '@material-ui/core/Collapse';
|
||||||
|
import { ReactComponent as Expand } from '../assets/expand.svg';
|
||||||
|
import { Course, Group, GroupType } from '../types/index';
|
||||||
|
import { coursesContext } from '../contexts/CoursesProvider';
|
||||||
|
import styled, { css } from 'styled-components';
|
||||||
|
import { makeStyles } from '@material-ui/core/styles';
|
||||||
|
import DeleteIcon from '@material-ui/icons/Delete';
|
||||||
|
import { useMemo } from 'react';
|
||||||
|
import { dayMapping } from '../constants';
|
||||||
|
|
||||||
|
const StatisticsWrapper = styled.div`
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
width: 100%;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const Row = styled.div`
|
||||||
|
display: flex;
|
||||||
|
width: 100%;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const StatisticBox = styled.div`
|
||||||
|
background-color:white;
|
||||||
|
width: 200px;
|
||||||
|
height: 200px;
|
||||||
|
margin: 10px;
|
||||||
|
border: 1px solid #000000;
|
||||||
|
border-radius: 38px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: space-around;
|
||||||
|
align-items: center;
|
||||||
|
font-size: 22px;
|
||||||
|
padding:2px;
|
||||||
|
box-shadow: 0px 2px 2px 0px rgba(0, 0, 0, 0.75);
|
||||||
|
`;
|
||||||
|
|
||||||
|
const StatisticNumber = styled.p`
|
||||||
|
font-size: 52px;
|
||||||
|
margin-top: 40px;
|
||||||
|
margin-bottom:0px;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const StatisticText = styled.p`
|
||||||
|
font-size: 18px;
|
||||||
|
text-align:center;
|
||||||
|
align-items:center;
|
||||||
|
justify-content:center;
|
||||||
|
`;
|
||||||
|
|
||||||
|
export const Statistics = () => {
|
||||||
|
return (
|
||||||
|
<StatisticsWrapper>
|
||||||
|
<Row>
|
||||||
|
<StatisticBox>
|
||||||
|
<StatisticNumber>65</StatisticNumber>
|
||||||
|
<StatisticText>Utworzonych grup</StatisticText>
|
||||||
|
</StatisticBox>
|
||||||
|
<StatisticBox>
|
||||||
|
{' '}
|
||||||
|
<StatisticNumber>280</StatisticNumber>
|
||||||
|
<StatisticText>Zapisanych studentów do grup</StatisticText>
|
||||||
|
</StatisticBox>
|
||||||
|
<StatisticBox>
|
||||||
|
{' '}
|
||||||
|
<StatisticNumber>24</StatisticNumber>
|
||||||
|
<StatisticText>Studentów niezapisanych do żadnej grupy</StatisticText>
|
||||||
|
</StatisticBox>
|
||||||
|
</Row>
|
||||||
|
<Row>
|
||||||
|
<StatisticBox>
|
||||||
|
{' '}
|
||||||
|
<StatisticNumber>150</StatisticNumber>
|
||||||
|
<StatisticText>Studentów z zaakceptowanym planem</StatisticText>
|
||||||
|
</StatisticBox>
|
||||||
|
<StatisticBox>
|
||||||
|
{' '}
|
||||||
|
<StatisticNumber>130</StatisticNumber>
|
||||||
|
<StatisticText>Studentów bez zaakceptowanego pełengo planu</StatisticText>
|
||||||
|
</StatisticBox>
|
||||||
|
<StatisticBox>
|
||||||
|
{' '}
|
||||||
|
<StatisticNumber>0</StatisticNumber>
|
||||||
|
<StatisticText>Zamkniętych grup</StatisticText>
|
||||||
|
</StatisticBox>
|
||||||
|
</Row>
|
||||||
|
</StatisticsWrapper>
|
||||||
|
);
|
||||||
|
};
|
@ -1,6 +1,7 @@
|
|||||||
import React, { useState, MouseEvent, ChangeEvent, useEffect, useCallback, useContext, useRef } from 'react';
|
import React, { useState, MouseEvent, ChangeEvent, useEffect, useCallback, useContext, useRef } from 'react';
|
||||||
import { ReactComponent as Close } from '../assets/close.svg';
|
import { ReactComponent as Close } from '../assets/close.svg';
|
||||||
import ProfileIcon from '../assets/account.svg';
|
import LogoutIcon from '../assets/logout.svg';
|
||||||
|
import TransferIcon from '../assets/transfer.svg';
|
||||||
import { Profile } from './Profile';
|
import { Profile } from './Profile';
|
||||||
import { Dropdown } from './Dropdown';
|
import { Dropdown } from './Dropdown';
|
||||||
import styled from 'styled-components/macro';
|
import styled from 'styled-components/macro';
|
||||||
@ -113,7 +114,7 @@ const IconWrapper = styled.div`
|
|||||||
|
|
||||||
const Icon = styled.img`
|
const Icon = styled.img`
|
||||||
width: 40px;
|
width: 40px;
|
||||||
margin: 5px;
|
margin-left: 40px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
@media only screen and (max-width: 670px) {
|
@media only screen and (max-width: 670px) {
|
||||||
width: 35px;
|
width: 35px;
|
||||||
@ -137,6 +138,7 @@ interface TopbarProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default function ({ handleTransfer }: TopbarProps) {
|
export default function ({ handleTransfer }: TopbarProps) {
|
||||||
|
const { logout } = useContext(CASContext)!;
|
||||||
const { selectedStudent } = useContext(studentsContext)!;
|
const { selectedStudent } = useContext(studentsContext)!;
|
||||||
const { role } = useContext(CASContext)!;
|
const { role } = useContext(CASContext)!;
|
||||||
const [clearInput, setClearInput] = useState(false);
|
const [clearInput, setClearInput] = useState(false);
|
||||||
@ -213,10 +215,10 @@ export default function ({ handleTransfer }: TopbarProps) {
|
|||||||
<SelectedStudent>{selectedStudent?.email.replace(/@st.amu.edu.pl/, '')}</SelectedStudent>
|
<SelectedStudent>{selectedStudent?.email.replace(/@st.amu.edu.pl/, '')}</SelectedStudent>
|
||||||
|
|
||||||
{/* <Text>Maciej Głowacki</Text> */}
|
{/* <Text>Maciej Głowacki</Text> */}
|
||||||
{/* <Icon alt="transfer" src={Transfer} onClick={handleTransfer} /> */}
|
<Icon alt="transfer" src={TransferIcon} onClick={handleTransfer} />
|
||||||
{/* <Icon alt="change_language" src={isPolish ? EnglishIcon : PolishIcon} onClick={onLangChange} /> */}
|
{/* <Icon alt="change_language" src={isPolish ? EnglishIcon : PolishIcon} onClick={onLangChange} /> */}
|
||||||
<Icon alt="profile" src={ProfileIcon} onClick={handleProfile} />
|
<Icon alt="logout" src={LogoutIcon} onClick={logout} />
|
||||||
<Profile anchorEl={anchorEl} handleClose={handleCloseProfile} />
|
{/* <Profile anchorEl={anchorEl} handleClose={handleCloseProfile} /> */}
|
||||||
</IconWrapper>
|
</IconWrapper>
|
||||||
</Topbar>
|
</Topbar>
|
||||||
);
|
);
|
||||||
|
@ -1,13 +1,21 @@
|
|||||||
import React from 'react';
|
import React, { ChangeEvent, useContext, useEffect, MouseEvent, useState } from 'react';
|
||||||
import Modal from '@material-ui/core/Modal';
|
import Modal from '@material-ui/core/Modal';
|
||||||
import Fade from '@material-ui/core/Fade';
|
import Fade from '@material-ui/core/Fade';
|
||||||
import Input from '@material-ui/core/Input';
|
|
||||||
import { makeStyles } from '@material-ui/core/styles';
|
import { makeStyles } from '@material-ui/core/styles';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
|
import { FormControl, MenuItem, Select, useControlled, useEventCallback } from '@material-ui/core';
|
||||||
|
import { axiosInstance } from '../utils/axiosInstance';
|
||||||
|
import { Group } from '../types';
|
||||||
|
import { coursesContext } from '../contexts/CoursesProvider';
|
||||||
|
import { Dropdown } from './Dropdown';
|
||||||
|
import { DropdownModal } from './DropdownModal';
|
||||||
|
import { dayMapping } from '../constants';
|
||||||
|
import TransferIcon from '../assets/switch.svg';
|
||||||
|
import DeleteIcon from '@material-ui/icons/Delete';
|
||||||
|
|
||||||
interface TransferProps {
|
interface TransferProps {
|
||||||
handleClose: (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
|
handleClose: (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
|
||||||
isOpen: boolean;
|
isTransferOpen: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const useStyles = makeStyles({
|
const useStyles = makeStyles({
|
||||||
@ -21,35 +29,49 @@ const useStyles = makeStyles({
|
|||||||
|
|
||||||
const TransferStyled = styled.div`
|
const TransferStyled = styled.div`
|
||||||
display: flex;
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
flex-direction: row;
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
outline: none;
|
outline: none;
|
||||||
min-width: 35%;
|
min-width: 35%;
|
||||||
height: 70%;
|
height: 70%;
|
||||||
padding-top: 40px;
|
padding-top: 40px;
|
||||||
background: #006b96;
|
background: white;
|
||||||
box-shadow: 0px 0px 0px 4px #006b96;
|
box-shadow: 0px 0px 0px 4px #006b96;
|
||||||
border: 4px solid #ffc400;
|
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
border-top-left-radius: 5px;
|
border-radius: 5px;
|
||||||
border-bottom-right-radius: 5px;
|
letter-spacing: 0.2ch;
|
||||||
text-transform: uppercase;
|
`;
|
||||||
letter-spacing: 0.3ch;
|
|
||||||
|
const BinIcon = styled(DeleteIcon)`
|
||||||
|
max-width: 30px;
|
||||||
|
min-width: 30px;
|
||||||
|
cursor: pointer;
|
||||||
|
&:hover {
|
||||||
|
fill: white;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
const InputWrapper = styled.div`
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
flex: 1;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const TransferGiveStyled = styled.div`
|
const TransferGiveStyled = styled.div`
|
||||||
flex-grow: 1;
|
flex: 1;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
text-transform: uppercase;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const TransferReceiveStyled = styled.div`
|
const TransferReceiveStyled = styled.div`
|
||||||
flex-grow: 1;
|
flex: 1;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
text-transform: uppercase;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const TransferTextStyled = styled.div`
|
const TransferTextStyled = styled.div`
|
||||||
@ -68,44 +90,302 @@ const TransferInputStyled = styled.div`
|
|||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
text-transform: none;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export const Transfer = ({ handleClose, isOpen }: TransferProps) => {
|
const SaveWrapper = styled.div`
|
||||||
|
margin-top: 40px;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const SaveButton = styled.div`
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
user-select: none;
|
||||||
|
background-color: #43a047;
|
||||||
|
border-radius: 10px;
|
||||||
|
cursor: pointer;
|
||||||
|
height: 40px;
|
||||||
|
width: 150px;
|
||||||
|
font-size: 12px;
|
||||||
|
letter-spacing: 0.1ch;
|
||||||
|
line-height: normal;
|
||||||
|
&:hover {
|
||||||
|
color: #ffffff;
|
||||||
|
box-shadow: 0px 5px 4px 0px rgba(0, 0, 0, 0.24);
|
||||||
|
}
|
||||||
|
|
||||||
|
&:active {
|
||||||
|
background-color: #54c457;
|
||||||
|
}
|
||||||
|
|
||||||
|
text-transform: uppercase;
|
||||||
|
box-shadow: 3px 3px 3px 0px rgba(0, 0, 0, 0.75);
|
||||||
|
`;
|
||||||
|
|
||||||
|
const ExchangesWrapper = styled.div`
|
||||||
|
flex: 4;
|
||||||
|
overflow-y: scroll;
|
||||||
|
width: 100%;
|
||||||
|
::-webkit-scrollbar-track {
|
||||||
|
border-radius: 10px;
|
||||||
|
}
|
||||||
|
::-webkit-scrollbar {
|
||||||
|
width: 5px;
|
||||||
|
border-style: none;
|
||||||
|
}
|
||||||
|
::-webkit-scrollbar-thumb {
|
||||||
|
border-radius: 10px;
|
||||||
|
background-color: #4b4b4b;
|
||||||
|
}
|
||||||
|
border-top: 1px solid;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const ExchangesRow = styled.div`
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const Icon = styled.img`
|
||||||
|
width: 20px;
|
||||||
|
cursor: pointer;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const Exchange = styled.div`
|
||||||
|
background-color: #b5d2e0;
|
||||||
|
border-radius: 10px;
|
||||||
|
width: 280px;
|
||||||
|
margin: 10px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
`;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export const Transfer = ({ handleClose, isTransferOpen }: TransferProps) => {
|
||||||
|
const { basket, selectBasketCourses } = useContext(coursesContext)!;
|
||||||
|
// const basketCourseGroups = useMemo(() => selectBasketCourseGroups(course.name), []);
|
||||||
|
const basketCourses = selectBasketCourses();
|
||||||
|
|
||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
|
// const groups = selectGroups();
|
||||||
|
const [input, setInput] = useState('');
|
||||||
|
const [open, setOpen] = useState(false);
|
||||||
|
|
||||||
|
const [assignmentsClasses, setAssignmentsClasses] = useState<Array<any>>([]);
|
||||||
|
const [selectedAssignmentsClasses, setSelectedAssignmentsClasses] = useState<any>('');
|
||||||
|
const [selectedGroup, setSelectedGroup] = useState<any>('');
|
||||||
|
const [groups, setGroups] = useState<any>([]);
|
||||||
|
const [exchanges, setExchanges] = useState<any>(null);
|
||||||
|
const [save, setSave] = useState(false);
|
||||||
|
// const allGroups
|
||||||
|
const handleSelectedAssignmentsGroupChange = (event: React.ChangeEvent<{ value: unknown }>) => {
|
||||||
|
setSelectedAssignmentsClasses(event.target.value as any);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleGroupsChange = (event: React.ChangeEvent<{ value: unknown }>) => {
|
||||||
|
setSelectedGroup(event.target.value as any);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleChange = (event: ChangeEvent<HTMLInputElement>) => setInput(event.target.value);
|
||||||
|
const handleShowDropdown = () => setOpen(true);
|
||||||
|
|
||||||
|
const handleCloseDropdown = () => setOpen(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (selectedAssignmentsClasses) {
|
||||||
|
const allGroups = basketCourses.filter((el) => el.name === selectedAssignmentsClasses.name);
|
||||||
|
const allClasses = allGroups[0]?.classes;
|
||||||
|
if (allClasses) {
|
||||||
|
const filteredClasses = allClasses.filter((el: any) => {
|
||||||
|
return el.time !== selectedAssignmentsClasses.time;
|
||||||
|
});
|
||||||
|
setGroups(filteredClasses);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, [selectedAssignmentsClasses]);
|
||||||
|
|
||||||
|
const getExchanges = async () => {
|
||||||
|
try {
|
||||||
|
const { data } = await axiosInstance.get(`${process.env.REACT_APP_API_URL}/api/v1/exchanges/exchange/all`);
|
||||||
|
setExchanges(data);
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const getAssignmentsGroups = async () => {
|
||||||
|
try {
|
||||||
|
const { data } = await axiosInstance.get(`${process.env.REACT_APP_API_URL}/api/v1/commisions/user/assignments`);
|
||||||
|
const classes = data.filter((el: any) => el.type === 'CLASS');
|
||||||
|
setAssignmentsClasses(classes);
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
getExchanges();
|
||||||
|
getAssignmentsGroups();
|
||||||
|
}, [isTransferOpen, save]);
|
||||||
|
|
||||||
|
const createExchange = async (groupsIds: Array<number>) => {
|
||||||
|
try {
|
||||||
|
const response = await axiosInstance.post(
|
||||||
|
`${process.env.REACT_APP_API_URL}/api/v1/exchanges/exchange`,
|
||||||
|
JSON.stringify({ assignment: groupsIds[0], group: groupsIds[1] }),
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
|
setSelectedGroup('');
|
||||||
|
setSelectedAssignmentsClasses('');
|
||||||
|
setSave(!save);
|
||||||
|
};
|
||||||
|
|
||||||
|
const getExchange = async (event: MouseEvent) => {
|
||||||
|
const target = event.currentTarget;
|
||||||
|
try {
|
||||||
|
const response = await axiosInstance.post(
|
||||||
|
`${process.env.REACT_APP_API_URL}/api/v1/exchanges/exchange/${target.id}`,
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
const deleteExchange = async (id: number) => {
|
||||||
|
try {
|
||||||
|
const response = await axiosInstance.delete(`${process.env.REACT_APP_API_URL}/api/v1/exchanges/exchange/${id}`);
|
||||||
|
getExchanges();
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Modal
|
<Modal
|
||||||
className={classes.wrapper}
|
className={classes.wrapper}
|
||||||
open={isOpen}
|
open={isTransferOpen}
|
||||||
onClose={handleClose}
|
onClose={handleClose}
|
||||||
aria-labelledby="simple-modal-title"
|
aria-labelledby="simple-modal-title"
|
||||||
aria-describedby="simple-modal-description"
|
aria-describedby="simple-modal-description"
|
||||||
>
|
>
|
||||||
<Fade in={isOpen}>
|
<Fade in={isTransferOpen}>
|
||||||
<TransferStyled>
|
<TransferStyled>
|
||||||
|
<InputWrapper>
|
||||||
<TransferGiveStyled>
|
<TransferGiveStyled>
|
||||||
<TransferTextStyled>Oddam</TransferTextStyled>
|
<TransferTextStyled>Oddam</TransferTextStyled>
|
||||||
<TransferInputStyled>
|
<TransferInputStyled>
|
||||||
{' '}
|
<FormControl>
|
||||||
<Input
|
<Select
|
||||||
|
labelId="demo-simple-select-label"
|
||||||
|
id="assignments-groups"
|
||||||
|
value={selectedAssignmentsClasses}
|
||||||
|
onChange={handleSelectedAssignmentsGroupChange}
|
||||||
placeholder="Wyszukaj..."
|
placeholder="Wyszukaj..."
|
||||||
inputProps={{ 'aria-label': 'description' }}
|
style={{ width: '200px' }}
|
||||||
className="top-bar__input-field"
|
>
|
||||||
/>
|
{assignmentsClasses.map((el: any, index: number) => {
|
||||||
|
return (
|
||||||
|
<MenuItem
|
||||||
|
key={index}
|
||||||
|
value={el}
|
||||||
|
style={{
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'center',
|
||||||
|
textAlign: 'center',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{`${el.name} `}
|
||||||
|
<br></br>
|
||||||
|
{`(${dayMapping[el.day]} ${el.time} - ${el.endTime})`}
|
||||||
|
</MenuItem>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</Select>
|
||||||
|
</FormControl>
|
||||||
</TransferInputStyled>
|
</TransferInputStyled>
|
||||||
</TransferGiveStyled>
|
</TransferGiveStyled>
|
||||||
|
<SaveWrapper>
|
||||||
|
{' '}
|
||||||
|
<SaveButton
|
||||||
|
onClick={() => {
|
||||||
|
createExchange([selectedAssignmentsClasses.id, selectedGroup.id]);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Zaproponuj wymianę
|
||||||
|
</SaveButton>
|
||||||
|
</SaveWrapper>
|
||||||
<TransferReceiveStyled>
|
<TransferReceiveStyled>
|
||||||
<TransferTextStyled>Przyjmę</TransferTextStyled>
|
<TransferTextStyled>Przyjmę</TransferTextStyled>
|
||||||
<TransferInputStyled>
|
<TransferInputStyled>
|
||||||
{' '}
|
<FormControl disabled={selectedAssignmentsClasses ? false : true}>
|
||||||
<Input
|
<Select
|
||||||
|
labelId="demo-simple-select-label"
|
||||||
|
id="assignments-groups"
|
||||||
|
value={selectedGroup}
|
||||||
|
onChange={handleGroupsChange}
|
||||||
placeholder="Wyszukaj..."
|
placeholder="Wyszukaj..."
|
||||||
inputProps={{ 'aria-label': 'description' }}
|
style={{ width: '200px' }}
|
||||||
className="top-bar__input-field"
|
>
|
||||||
/>
|
{groups.map((el: any, index: number) => {
|
||||||
|
return (
|
||||||
|
<MenuItem
|
||||||
|
key={index}
|
||||||
|
value={el}
|
||||||
|
style={{
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'center',
|
||||||
|
textAlign: 'center',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{`${selectedAssignmentsClasses.name} `}
|
||||||
|
<br></br>
|
||||||
|
{`(${dayMapping[el.day]} ${el.time} - ${el.endTime})`}
|
||||||
|
</MenuItem>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</Select>
|
||||||
|
</FormControl>
|
||||||
</TransferInputStyled>
|
</TransferInputStyled>
|
||||||
</TransferReceiveStyled>
|
</TransferReceiveStyled>
|
||||||
|
</InputWrapper>
|
||||||
|
|
||||||
|
<ExchangesWrapper>
|
||||||
|
{exchanges ? (
|
||||||
|
exchanges.map((name: any, index: number) => (
|
||||||
|
<ExchangesRow key={index}>
|
||||||
|
{' '}
|
||||||
|
<Exchange>
|
||||||
|
{name.ownedAssignment.lecturer} <br></br> {dayMapping[name.ownedAssignment.day]} <br></br>{' '}
|
||||||
|
{name.ownedAssignment.time} - {name.ownedAssignment.endTime}
|
||||||
|
</Exchange>
|
||||||
|
<Icon alt="transfer" src={TransferIcon} onClick={getExchange} />
|
||||||
|
<Exchange>
|
||||||
|
{name.desiredGroup.lecturer} <br></br> {dayMapping[name.desiredGroup.day]} <br></br>{' '}
|
||||||
|
{name.desiredGroup.time} - {name.desiredGroup.endTime}
|
||||||
|
</Exchange>{' '}
|
||||||
|
<BinIcon
|
||||||
|
onClick={(e) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
const id = Number(e.currentTarget.id);
|
||||||
|
deleteExchange(id);
|
||||||
|
}}
|
||||||
|
id={name.id}
|
||||||
|
></BinIcon>
|
||||||
|
</ExchangesRow>
|
||||||
|
))
|
||||||
|
) : (
|
||||||
|
<div></div>
|
||||||
|
)}
|
||||||
|
</ExchangesWrapper>
|
||||||
</TransferStyled>
|
</TransferStyled>
|
||||||
</Fade>
|
</Fade>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
26
src/components/__tests__/Statistics.test.jsx
Normal file
26
src/components/__tests__/Statistics.test.jsx
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { cleanup, fireEvent, waitForElement, screen } from '@testing-library/react';
|
||||||
|
import '@testing-library/jest-dom/extend-expect';
|
||||||
|
import { customRender } from '../../customRender';
|
||||||
|
import Topbar from '../Topbar';
|
||||||
|
import { Statistics } from '../Statistics';
|
||||||
|
|
||||||
|
beforeAll(() => {
|
||||||
|
delete window.location;
|
||||||
|
window.location = { replace: jest.fn() };
|
||||||
|
});
|
||||||
|
|
||||||
|
afterAll(() => {
|
||||||
|
window.location = location;
|
||||||
|
});
|
||||||
|
|
||||||
|
test('renders component', async () => {
|
||||||
|
customRender(<Statistics/>);
|
||||||
|
expect(screen.getByText(/Studentów bez zaakceptowanego pełengo planu/i)).toBeInTheDocument();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('renders component', async () => {
|
||||||
|
customRender(<Statistics/>);
|
||||||
|
expect(screen.getByText(/Zapisanych sutdentów do grup/i)).toBeInTheDocument();
|
||||||
|
});
|
||||||
|
|
@ -32,7 +32,8 @@ interface CourseContext {
|
|||||||
selectHistorySchedulerEvents: () => Array<SchedulerEvent>;
|
selectHistorySchedulerEvents: () => Array<SchedulerEvent>;
|
||||||
selectBasketNames: () => Array<string>;
|
selectBasketNames: () => Array<string>;
|
||||||
selectBasketCourses: () => Array<Course>;
|
selectBasketCourses: () => Array<Course>;
|
||||||
selectBasketCourseGroups: (courseId: number) => { lecture: Group | undefined; classes: Group | undefined };
|
selectBasketCourseGroups: (courseName: string) => { lecture: Group | undefined; classes: Group | undefined };
|
||||||
|
selectGroups: () => Array<Group>;
|
||||||
getNewestStudentTimetable: (studentId: string) => void;
|
getNewestStudentTimetable: (studentId: string) => void;
|
||||||
getStudentTimetablesHistory: (studentId: string) => void;
|
getStudentTimetablesHistory: (studentId: string) => void;
|
||||||
changeDataLoading: (isLoading: boolean) => void;
|
changeDataLoading: (isLoading: boolean) => void;
|
||||||
@ -99,9 +100,8 @@ export const CoursesProvider = ({ children }: CoursesProviderProps) => {
|
|||||||
}, [] as Array<SchedulerEvent>);
|
}, [] as Array<SchedulerEvent>);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const selectBasketCourseGroups = (courseName: string) => {
|
||||||
const selectBasketCourseGroups = (courseId: number) => {
|
const course = basket.find(({ name }) => name === courseName);
|
||||||
const course = basket.find(({ id }) => id === courseId);
|
|
||||||
if (course !== undefined) {
|
if (course !== undefined) {
|
||||||
return { lecture: course.lecture, classes: course.classes };
|
return { lecture: course.lecture, classes: course.classes };
|
||||||
} else {
|
} else {
|
||||||
@ -109,6 +109,11 @@ export const CoursesProvider = ({ children }: CoursesProviderProps) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const selectGroups = () => {
|
||||||
|
const groups = [];
|
||||||
|
return (courses as unknown) as Array<Group>;
|
||||||
|
};
|
||||||
|
|
||||||
const changeHoveredGroup = (group: Group | null) => setHoveredGroup(group);
|
const changeHoveredGroup = (group: Group | null) => setHoveredGroup(group);
|
||||||
|
|
||||||
const changeDataLoading = (isLoading: boolean) => setIsDataLoading(isLoading);
|
const changeDataLoading = (isLoading: boolean) => setIsDataLoading(isLoading);
|
||||||
@ -150,13 +155,13 @@ export const CoursesProvider = ({ children }: CoursesProviderProps) => {
|
|||||||
`${process.env.REACT_APP_API_URL}/api/v1/commisions/user/${userID}`,
|
`${process.env.REACT_APP_API_URL}/api/v1/commisions/user/${userID}`,
|
||||||
JSON.stringify(basketIds),
|
JSON.stringify(basketIds),
|
||||||
);
|
);
|
||||||
enqueueSnackbar('Ustawienia zostały zapisane', {
|
enqueueSnackbar('Plan został zapisany', {
|
||||||
variant: 'success',
|
variant: 'success',
|
||||||
action,
|
action,
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('error: ', e);
|
console.log('error: ', e);
|
||||||
enqueueSnackbar('Ustawienia nie zostały zapisane', {
|
enqueueSnackbar('Zapisywanie planu nie powiodło się', {
|
||||||
variant: 'error',
|
variant: 'error',
|
||||||
action,
|
action,
|
||||||
});
|
});
|
||||||
@ -166,11 +171,14 @@ export const CoursesProvider = ({ children }: CoursesProviderProps) => {
|
|||||||
|
|
||||||
const changeGroupInBasket = (choosenGroup: any, courseId: number) => {
|
const changeGroupInBasket = (choosenGroup: any, courseId: number) => {
|
||||||
const basketCourse = basket.filter((course) => course.id === courseId)[0];
|
const basketCourse = basket.filter((course) => course.id === courseId)[0];
|
||||||
if (choosenGroup.lecture && choosenGroup.classes)
|
if (choosenGroup.lecture && choosenGroup.classes) {
|
||||||
{
|
const prev = choosenGroup.prev === 'lecture' ? choosenGroup.lecture : choosenGroup.classes;
|
||||||
const prev = choosenGroup.prev==="lecture"?choosenGroup.lecture : choosenGroup.classes
|
|
||||||
setBasket(
|
setBasket(
|
||||||
basket.map((basket) => (basket.id === basketCourse.id ? { ...basket, lecture: choosenGroup.lecture, classes:choosenGroup.classes } : basket)),
|
basket.map((basket) =>
|
||||||
|
basket.id === basketCourse.id
|
||||||
|
? { ...basket, lecture: choosenGroup.lecture, classes: choosenGroup.classes }
|
||||||
|
: basket,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
changeHoveredGroup(prev);
|
changeHoveredGroup(prev);
|
||||||
}
|
}
|
||||||
@ -296,6 +304,7 @@ export const CoursesProvider = ({ children }: CoursesProviderProps) => {
|
|||||||
selectBasketNames,
|
selectBasketNames,
|
||||||
selectBasketCourses,
|
selectBasketCourses,
|
||||||
selectBasketCourseGroups,
|
selectBasketCourseGroups,
|
||||||
|
selectGroups,
|
||||||
getNewestStudentTimetable,
|
getNewestStudentTimetable,
|
||||||
changeStudent,
|
changeStudent,
|
||||||
getStudentTimetablesHistory,
|
getStudentTimetablesHistory,
|
||||||
|
@ -4130,6 +4130,11 @@ data-urls@^1.0.0, data-urls@^1.1.0:
|
|||||||
whatwg-mimetype "^2.2.0"
|
whatwg-mimetype "^2.2.0"
|
||||||
whatwg-url "^7.0.0"
|
whatwg-url "^7.0.0"
|
||||||
|
|
||||||
|
date-fns@^2.16.1:
|
||||||
|
version "2.16.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-2.16.1.tgz#05775792c3f3331da812af253e1a935851d3834b"
|
||||||
|
integrity sha512-sAJVKx/FqrLYHAQeN7VpJrPhagZc9R4ImZIWYRFZaaohR3KzmuK88touwsSwSVT8Qcbd4zoDsnGfX4GFB4imyQ==
|
||||||
|
|
||||||
debug@2.6.9, debug@^2.2.0, debug@^2.3.3, debug@^2.6.0, debug@^2.6.9:
|
debug@2.6.9, debug@^2.2.0, debug@^2.3.3, debug@^2.6.0, debug@^2.6.9:
|
||||||
version "2.6.9"
|
version "2.6.9"
|
||||||
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f"
|
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f"
|
||||||
|
Loading…
Reference in New Issue
Block a user