Compare commits
13 Commits
084fe15d38
...
statistics
Author | SHA1 | Date | |
---|---|---|---|
|
3eaaa2ef10 | ||
|
4091525f61 | ||
|
4ac917649a | ||
|
f319e022fe | ||
|
0ecdc6db20 | ||
|
a72fb6b12c | ||
|
49d9c6acdd | ||
|
cf042413d6 | ||
|
2c77eb47a9 | ||
|
d1fb48f7fe | ||
|
a5d3beddb5 | ||
|
adaf44f2f7 | ||
|
f013ef54ee |
@@ -7,6 +7,7 @@ import CloseIcon from '@material-ui/icons/Close';
|
|||||||
import { SyncLoader } from 'react-spinners';
|
import { SyncLoader } from 'react-spinners';
|
||||||
import { CASContext } from '../contexts/CASProvider';
|
import { CASContext } from '../contexts/CASProvider';
|
||||||
import LogoutIcon from '../assets/logout.svg';
|
import LogoutIcon from '../assets/logout.svg';
|
||||||
|
import LogoPlanNaPlan from '../assets/logo.svg';
|
||||||
|
|
||||||
const StyledCloseIcon = styled(CloseIcon)`
|
const StyledCloseIcon = styled(CloseIcon)`
|
||||||
color: #000000;
|
color: #000000;
|
||||||
@@ -58,12 +59,12 @@ const Wrap = styled.div`
|
|||||||
flex: 1;
|
flex: 1;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
margin:20px;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const LogoWrapper = styled.div`
|
const LogoWrapper = styled.div`
|
||||||
display: flex;
|
display: flex;
|
||||||
flex: 1;
|
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@@ -74,6 +75,7 @@ const Text = styled.div`
|
|||||||
font-family: 'Roboto', sans-serif;
|
font-family: 'Roboto', sans-serif;
|
||||||
font-size: 5rem;
|
font-size: 5rem;
|
||||||
user-select: none;
|
user-select: none;
|
||||||
|
margin-bottom:60px;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const Logo = styled.img`
|
const Logo = styled.img`
|
||||||
@@ -133,8 +135,6 @@ export const Administrator = () => {
|
|||||||
|
|
||||||
const {data} = await axiosInstance.get(`${process.env.REACT_APP_API_URL}/api/v1/commisions/export/csv`,{responseType:"blob"});
|
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 downloadUrl = window.URL.createObjectURL(new Blob([data]));
|
||||||
|
|
||||||
const link = document.createElement('a');
|
const link = document.createElement('a');
|
||||||
@@ -211,7 +211,7 @@ export const Administrator = () => {
|
|||||||
<Icon alt="logout" src={LogoutIcon} onClick={logout}/>
|
<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={LogoPlanNaPlan} />
|
||||||
<Text> plan na plan </Text>
|
<Text> plan na plan </Text>
|
||||||
</LogoWrapper>
|
</LogoWrapper>
|
||||||
{xd === true ? (
|
{xd === true ? (
|
||||||
|
@@ -105,7 +105,8 @@ export const Dropdown = ({ open, input, handleCloseDropdown, selectedOption }: D
|
|||||||
input
|
input
|
||||||
.toLowerCase()
|
.toLowerCase()
|
||||||
.normalize('NFD')
|
.normalize('NFD')
|
||||||
.replace(/[\u0300-\u036f]/g, ''),
|
.replace(/[\u0300-\u036f]/g, '')
|
||||||
|
.replace(/\s/g, ''),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
setFilteredStudents(filteredUsers);
|
setFilteredStudents(filteredUsers);
|
||||||
@@ -119,9 +120,10 @@ export const Dropdown = ({ open, input, handleCloseDropdown, selectedOption }: D
|
|||||||
<>
|
<>
|
||||||
{selectedOption === 'studenci' ? (
|
{selectedOption === 'studenci' ? (
|
||||||
<div>
|
<div>
|
||||||
{filteredStudents.map(({ email, id }, index) => (
|
{filteredStudents.map(({ surname, name, email, id }, index) => (
|
||||||
<CourseContainer key={index} id={id.toString()} onClick={onUserClick}>
|
<CourseContainer key={index} id={id.toString()} onClick={onUserClick}>
|
||||||
<p>{email}</p>
|
{name=== ''? <p>{email}</p> :<p>{name} {surname}</p>}
|
||||||
|
|
||||||
</CourseContainer>
|
</CourseContainer>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
@@ -3,6 +3,7 @@ import { CourseCard } from './CourseCard';
|
|||||||
import { coursesContext } from '../contexts/CoursesProvider';
|
import { coursesContext } from '../contexts/CoursesProvider';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
import { debounce } from '../utils/index';
|
import { debounce } from '../utils/index';
|
||||||
|
import { SyncLoader } from 'react-spinners';
|
||||||
|
|
||||||
const RightbarWrapper = styled.div`
|
const RightbarWrapper = styled.div`
|
||||||
padding: 15px;
|
padding: 15px;
|
||||||
@@ -46,13 +47,13 @@ const SaveButton = styled.div`
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
export const Rightbar = () => {
|
export const Rightbar = () => {
|
||||||
const { selectBasketCourses, saveBasket, userID } = useContext(coursesContext)!;
|
const { selectBasketCourses, saveBasket, userID, isSavingLoading } = useContext(coursesContext)!;
|
||||||
|
|
||||||
const basketCourses = selectBasketCourses();
|
const basketCourses = selectBasketCourses();
|
||||||
const handleSave = debounce(() => saveBasket(userID), 500);
|
const handleSave = debounce(() => saveBasket(userID), 500);
|
||||||
return (
|
return (
|
||||||
<RightbarWrapper>
|
<RightbarWrapper>
|
||||||
<SaveButton onClick={handleSave}>ZAPISZ</SaveButton>
|
<SaveButton onClick={()=> {!isSavingLoading && handleSave() }}> {isSavingLoading ? <SyncLoader size={9}/> : "ZAPISZ"}</SaveButton>
|
||||||
{basketCourses.map((course) => (
|
{basketCourses.map((course) => (
|
||||||
<CourseCard course={course} key={course.id} />
|
<CourseCard course={course} key={course.id} />
|
||||||
))}
|
))}
|
||||||
|
@@ -1,9 +1,11 @@
|
|||||||
import React, { useLayoutEffect, useRef } from 'react';
|
import React, { useContext, useLayoutEffect, useRef } from 'react';
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { SchedulerEvents } from './SchedulerEvents';
|
import { SchedulerEvents } from './SchedulerEvents';
|
||||||
import { days, hours } from '../constants/index';
|
import { days, hours } from '../constants/index';
|
||||||
import styled from 'styled-components/macro';
|
import styled from 'styled-components/macro';
|
||||||
import { SchedulerEvent } from '../types';
|
import { SchedulerEvent } from '../types';
|
||||||
|
import { coursesContext } from '../contexts/CoursesProvider';
|
||||||
|
import Tooltip from '@material-ui/core/Tooltip';
|
||||||
|
|
||||||
const SchedulerWrapper = styled.div`
|
const SchedulerWrapper = styled.div`
|
||||||
border-collapse: collapse;
|
border-collapse: collapse;
|
||||||
@@ -17,6 +19,7 @@ const SchedulerWrapper = styled.div`
|
|||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
box-shadow: 3px 3px 3px -2px rgba(0, 0, 0, 0.59);
|
box-shadow: 3px 3px 3px -2px rgba(0, 0, 0, 0.59);
|
||||||
|
position:relative;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const TableBody = styled.div`
|
const TableBody = styled.div`
|
||||||
@@ -62,6 +65,27 @@ const TableCell = styled.div<TableCellProps>`
|
|||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
const TourWrapper = styled.div`
|
||||||
|
display: flex;
|
||||||
|
justify-content:center;
|
||||||
|
align-items:center;
|
||||||
|
position:absolute;
|
||||||
|
top:8px;
|
||||||
|
right:8px;
|
||||||
|
min-width: 10px;
|
||||||
|
padding: 3px 7px;
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 700;
|
||||||
|
color: black;
|
||||||
|
line-height: 1;
|
||||||
|
vertical-align: middle;
|
||||||
|
white-space: nowrap;
|
||||||
|
text-align: center;
|
||||||
|
background-color: #FFDC61;
|
||||||
|
border-radius: 10px;
|
||||||
|
font-size:18px;
|
||||||
|
`;
|
||||||
|
|
||||||
interface SchedulerProps {
|
interface SchedulerProps {
|
||||||
schedulerEvents: Array<SchedulerEvent>;
|
schedulerEvents: Array<SchedulerEvent>;
|
||||||
}
|
}
|
||||||
@@ -70,7 +94,8 @@ export const Scheduler = ({ schedulerEvents }: SchedulerProps) => {
|
|||||||
const cellRef = useRef<HTMLDivElement>(null);
|
const cellRef = useRef<HTMLDivElement>(null);
|
||||||
const [cellWidth, setCellWidth] = useState(0);
|
const [cellWidth, setCellWidth] = useState(0);
|
||||||
const [cellHeight, setCellHeight] = useState(0);
|
const [cellHeight, setCellHeight] = useState(0);
|
||||||
|
const { tour } = useContext(coursesContext)!;
|
||||||
|
|
||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
const handleResize = () => {
|
const handleResize = () => {
|
||||||
if (cellRef.current) {
|
if (cellRef.current) {
|
||||||
@@ -130,6 +155,19 @@ export const Scheduler = ({ schedulerEvents }: SchedulerProps) => {
|
|||||||
))}
|
))}
|
||||||
<SchedulerEvents cellWidth={cellWidth} cellHeight={cellHeight} schedulerEvents={schedulerEvents} />
|
<SchedulerEvents cellWidth={cellWidth} cellHeight={cellHeight} schedulerEvents={schedulerEvents} />
|
||||||
</TableBody>
|
</TableBody>
|
||||||
|
<TourWrapper>
|
||||||
|
<Tooltip title="Pierwsza Tura Zapisów">
|
||||||
|
<div style={{cursor: 'help'}}>{tour === 'FIRST_TOUR' && '1'}</div>
|
||||||
|
</Tooltip>
|
||||||
|
<Tooltip title="Druga Tura Zapisów">
|
||||||
|
<div style={{cursor: 'help'}}>{tour === 'SECOND_TOUR' && '2'}</div>
|
||||||
|
</Tooltip>
|
||||||
|
<Tooltip title="Zapisywanie wyłączone">
|
||||||
|
<div style={{cursor: 'help'}}>{tour === 'NO_TOUR' && 'X'}</div>
|
||||||
|
</Tooltip>
|
||||||
|
|
||||||
|
|
||||||
|
</TourWrapper>
|
||||||
</SchedulerWrapper>
|
</SchedulerWrapper>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@@ -204,6 +204,7 @@ export const SchedulerRow = ({ groups, indexRow, rowTop, cellWidth, cellHeight }
|
|||||||
</TextWrapper>
|
</TextWrapper>
|
||||||
) : (
|
) : (
|
||||||
<TextWrapper style={{ flexDirection: 'column' }}>
|
<TextWrapper style={{ flexDirection: 'column' }}>
|
||||||
|
{groups[index].isAccepted===true && <Icon alt="transfer" src={TickIcon} />}
|
||||||
<div style={{ alignSelf: 'flex-end' }}>
|
<div style={{ alignSelf: 'flex-end' }}>
|
||||||
{groups[index].takenPlaces}/{groups[index].capacity}
|
{groups[index].takenPlaces}/{groups[index].capacity}
|
||||||
</div>
|
</div>
|
||||||
@@ -239,10 +240,10 @@ export const SchedulerRow = ({ groups, indexRow, rowTop, cellWidth, cellHeight }
|
|||||||
<PopoverSpan>Sala zajęć</PopoverSpan>: {groups[index].room}
|
<PopoverSpan>Sala zajęć</PopoverSpan>: {groups[index].room}
|
||||||
</p>
|
</p>
|
||||||
<p style={{ margin: '2px 0 2px 0' }}>
|
<p style={{ margin: '2px 0 2px 0' }}>
|
||||||
<PopoverSpan>Kod przedmiotu: </PopoverSpan>ACB129
|
<PopoverSpan>Kod przedmiotu: </PopoverSpan> {groups[index].symbol}
|
||||||
</p>
|
</p>
|
||||||
<p style={{ margin: '2px 0 2px 0' }}>
|
<p style={{ margin: '2px 0 2px 0' }}>
|
||||||
<PopoverSpan>Kod grupy: </PopoverSpan>FVJ753
|
<PopoverSpan>Numer grupy: </PopoverSpan> {groups[index].grNr}
|
||||||
</p>
|
</p>
|
||||||
<p style={{ margin: '2px 0 2px 0', color:"green"}}>
|
<p style={{ margin: '2px 0 2px 0', color:"green"}}>
|
||||||
<b>{groups[index].isAccepted===true && "Przedmiot został zaakceptowany"}</b>
|
<b>{groups[index].isAccepted===true && "Przedmiot został zaakceptowany"}</b>
|
||||||
|
@@ -24,6 +24,7 @@ const Wrapper = styled.div`
|
|||||||
border-top-left-radius: 6px;
|
border-top-left-radius: 6px;
|
||||||
border-bottom-left-radius: 6px;
|
border-bottom-left-radius: 6px;
|
||||||
user-select: none;
|
user-select: none;
|
||||||
|
z-index:100;
|
||||||
`;
|
`;
|
||||||
const Header = styled.div`
|
const Header = styled.div`
|
||||||
display: flex;
|
display: flex;
|
||||||
|
@@ -133,10 +133,6 @@ export const Statistics = () => {
|
|||||||
|
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
console.log(loaded);
|
|
||||||
}, [loaded]);
|
|
||||||
|
|
||||||
return <StatisticsWrapper>{loaded === false ? <SyncLoader />:<><Row>
|
return <StatisticsWrapper>{loaded === false ? <SyncLoader />:<><Row>
|
||||||
<StatisticBox>
|
<StatisticBox>
|
||||||
<StatisticNumber>{createdGroupsNumber}</StatisticNumber>
|
<StatisticNumber>{createdGroupsNumber}</StatisticNumber>
|
||||||
|
@@ -9,7 +9,8 @@ import ClickAwayListener from 'react-click-away-listener';
|
|||||||
import { SelectMenu } from './SelectMenu';
|
import { SelectMenu } from './SelectMenu';
|
||||||
import { studentsContext } from '../contexts/StudentsProvider';
|
import { studentsContext } from '../contexts/StudentsProvider';
|
||||||
import { CASContext } from '../contexts/CASProvider';
|
import { CASContext } from '../contexts/CASProvider';
|
||||||
import { render } from 'react-dom';
|
import Tooltip from '@material-ui/core/Tooltip';
|
||||||
|
import LogoPlanNaPlan from '../assets/logo.svg';
|
||||||
|
|
||||||
const Topbar = styled.div`
|
const Topbar = styled.div`
|
||||||
background-color: #e3e5ed;
|
background-color: #e3e5ed;
|
||||||
@@ -180,7 +181,7 @@ export default function ({ handleTransfer }: TopbarProps) {
|
|||||||
return (
|
return (
|
||||||
<Topbar>
|
<Topbar>
|
||||||
<LogoWrapper>
|
<LogoWrapper>
|
||||||
<Logo alt="logo" src="https://plannaplan.pl/img/logo.svg" />
|
<Logo alt="logo" src={LogoPlanNaPlan} />
|
||||||
<Text> plan na plan </Text>
|
<Text> plan na plan </Text>
|
||||||
</LogoWrapper>
|
</LogoWrapper>
|
||||||
<FlexboxColumn>
|
<FlexboxColumn>
|
||||||
@@ -214,12 +215,18 @@ export default function ({ handleTransfer }: TopbarProps) {
|
|||||||
</ClickAwayListener>
|
</ClickAwayListener>
|
||||||
</FlexboxColumn>
|
</FlexboxColumn>
|
||||||
<IconWrapper>
|
<IconWrapper>
|
||||||
<SelectedStudent>{selectedStudent?.email.replace(/@st.amu.edu.pl/, '')}</SelectedStudent>
|
<SelectedStudent>{selectedStudent?.surname === '' ? selectedStudent?.email.replace(/@st.amu.edu.pl/, '') : selectedStudent?.surname}</SelectedStudent>
|
||||||
|
|
||||||
{/* <Text>Maciej Głowacki</Text> */}
|
{/* <Text>Maciej Głowacki</Text> */}
|
||||||
{userPrivilige==="STUDENT" && <Icon alt="transfer" src={TransferIcon} onClick={handleTransfer} />}
|
{userPrivilige === 'STUDENT' && (
|
||||||
|
<Tooltip title="Wymiana grupami">
|
||||||
|
<Icon alt="transfer" src={TransferIcon} onClick={handleTransfer} />
|
||||||
|
</Tooltip>
|
||||||
|
)}
|
||||||
{/* <Icon alt="change_language" src={isPolish ? EnglishIcon : PolishIcon} onClick={onLangChange} /> */}
|
{/* <Icon alt="change_language" src={isPolish ? EnglishIcon : PolishIcon} onClick={onLangChange} /> */}
|
||||||
<Icon alt="logout" src={LogoutIcon} onClick={logout} />
|
<Tooltip title="Wyloguj">
|
||||||
|
<Icon alt="logout" src={LogoutIcon} onClick={logout} />
|
||||||
|
</Tooltip>
|
||||||
|
|
||||||
{/* <Profile anchorEl={anchorEl} handleClose={handleCloseProfile} /> */}
|
{/* <Profile anchorEl={anchorEl} handleClose={handleCloseProfile} /> */}
|
||||||
</IconWrapper>
|
</IconWrapper>
|
||||||
</Topbar>
|
</Topbar>
|
||||||
|
@@ -39,7 +39,6 @@ const TransferStyled = styled.div`
|
|||||||
background: white;
|
background: white;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
letter-spacing: 0.1ch;
|
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const BinIcon = styled(DeleteIcon)`
|
const BinIcon = styled(DeleteIcon)`
|
||||||
@@ -166,21 +165,24 @@ const Exchange = styled.div`
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
padding: 0.5rem;
|
padding: 0.5rem;
|
||||||
line-height: 0;
|
line-height:2;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const ExchangeTitle = styled.p`
|
const ExchangeTitle = styled.p`
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
|
|
||||||
|
margin:0;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const ExchangeParagraph = styled.p`
|
const ExchangeParagraph = styled.p`
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
color: #1a1a1a;
|
color: #1a1a1a;
|
||||||
|
margin:0;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export const Transfer = ({ handleClose, isTransferOpen }: TransferProps) => {
|
export const Transfer = ({ handleClose, isTransferOpen }: TransferProps) => {
|
||||||
const { basket, selectBasketCourses } = useContext(coursesContext)!;
|
const { basket, tour, selectBasketCourses } = useContext(coursesContext)!;
|
||||||
// const basketCourseGroups = useMemo(() => selectBasketCourseGroups(course.name), []);
|
// const basketCourseGroups = useMemo(() => selectBasketCourseGroups(course.name), []);
|
||||||
const basketCourses = selectBasketCourses();
|
const basketCourses = selectBasketCourses();
|
||||||
|
|
||||||
@@ -195,7 +197,6 @@ export const Transfer = ({ handleClose, isTransferOpen }: TransferProps) => {
|
|||||||
const [groups, setGroups] = useState<any>([]);
|
const [groups, setGroups] = useState<any>([]);
|
||||||
const [exchanges, setExchanges] = useState<any>(null);
|
const [exchanges, setExchanges] = useState<any>(null);
|
||||||
const [save, setSave] = useState(false);
|
const [save, setSave] = useState(false);
|
||||||
const [tour, setTour] = useState<any>(null);
|
|
||||||
// const allGroups
|
// const allGroups
|
||||||
const handleSelectedAssignmentsGroupChange = (event: React.ChangeEvent<{ value: unknown }>) => {
|
const handleSelectedAssignmentsGroupChange = (event: React.ChangeEvent<{ value: unknown }>) => {
|
||||||
setSelectedAssignmentsClasses(event.target.value as any);
|
setSelectedAssignmentsClasses(event.target.value as any);
|
||||||
@@ -243,7 +244,6 @@ export const Transfer = ({ handleClose, isTransferOpen }: TransferProps) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
getExchanges();
|
getExchanges();
|
||||||
getCurrentTour();
|
|
||||||
getAssignmentsGroups();
|
getAssignmentsGroups();
|
||||||
}, [isTransferOpen, save]);
|
}, [isTransferOpen, save]);
|
||||||
|
|
||||||
@@ -261,15 +261,6 @@ export const Transfer = ({ handleClose, isTransferOpen }: TransferProps) => {
|
|||||||
setSave(!save);
|
setSave(!save);
|
||||||
};
|
};
|
||||||
|
|
||||||
const getCurrentTour = async () => {
|
|
||||||
try {
|
|
||||||
const { data } = await axiosInstance.get(`${process.env.REACT_APP_API_URL}/api/v1/configurator/config/tour`);
|
|
||||||
setTour(data.currentTour);
|
|
||||||
} catch (e) {
|
|
||||||
console.log(e);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const deleteExchange = async (id: number) => {
|
const deleteExchange = async (id: number) => {
|
||||||
try {
|
try {
|
||||||
const response = await axiosInstance.delete(`${process.env.REACT_APP_API_URL}/api/v1/exchanges/exchange/${id}`);
|
const response = await axiosInstance.delete(`${process.env.REACT_APP_API_URL}/api/v1/exchanges/exchange/${id}`);
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
import React, { useState, useEffect, createContext, ReactNode } from 'react';
|
import React, { useState, useEffect, createContext, ReactNode } from 'react';
|
||||||
import { LoggedUser } from '../types';
|
import { LoggedUser } from '../types';
|
||||||
import { axiosInstance } from '../utils/axiosInstance';
|
import { axiosInstance, getNewTokens } from '../utils/axiosInstance';
|
||||||
|
|
||||||
|
|
||||||
export interface CASContext {
|
export interface CASContext {
|
||||||
user: LoggedUser | undefined;
|
user: LoggedUser | undefined;
|
||||||
@@ -42,6 +43,9 @@ export const CASProvider = ({ children }: CASProviderProps) => {
|
|||||||
localStorage.setItem('refreshToken', user.refreshToken);
|
localStorage.setItem('refreshToken', user.refreshToken);
|
||||||
setIsFetchingToken(false);
|
setIsFetchingToken(false);
|
||||||
}
|
}
|
||||||
|
else{
|
||||||
|
getNewTokens();
|
||||||
|
}
|
||||||
const token = localStorage.getItem('userToken');
|
const token = localStorage.getItem('userToken');
|
||||||
const refreshToken = localStorage.getItem('refreshToken');
|
const refreshToken = localStorage.getItem('refreshToken');
|
||||||
const role = localStorage.getItem('userPrivilige');
|
const role = localStorage.getItem('userPrivilige');
|
||||||
|
@@ -21,6 +21,9 @@ interface CourseContext {
|
|||||||
userID: string;
|
userID: string;
|
||||||
isDataLoading: boolean;
|
isDataLoading: boolean;
|
||||||
historyBasket: Array<Basket>;
|
historyBasket: Array<Basket>;
|
||||||
|
tour: string;
|
||||||
|
isSavingLoading: boolean;
|
||||||
|
getCurrentTour: () => void;
|
||||||
addCourseToBasket: (courses: Course) => void;
|
addCourseToBasket: (courses: Course) => void;
|
||||||
changeHoveredGroup: (group: Group | null) => void;
|
changeHoveredGroup: (group: Group | null) => void;
|
||||||
changeGroupInBasket: (group: any, courseId: number) => void;
|
changeGroupInBasket: (group: any, courseId: number) => void;
|
||||||
@@ -57,6 +60,8 @@ export const CoursesProvider = ({ children }: CoursesProviderProps) => {
|
|||||||
const [userID, setUserID] = useState('');
|
const [userID, setUserID] = useState('');
|
||||||
const [hoveredGroup, setHoveredGroup] = useState<Group | undefined | null>(null);
|
const [hoveredGroup, setHoveredGroup] = useState<Group | undefined | null>(null);
|
||||||
const [isDataLoading, setIsDataLoading] = useState(false);
|
const [isDataLoading, setIsDataLoading] = useState(false);
|
||||||
|
const [tour, setTour] = useState('');
|
||||||
|
const [isSavingLoading, setIsSavingLoading] = useState(false);
|
||||||
|
|
||||||
const selectBasketIds = () => {
|
const selectBasketIds = () => {
|
||||||
const classesIds = basket.map((course) => course?.classes?.id).filter((course) => course !== undefined);
|
const classesIds = basket.map((course) => course?.classes?.id).filter((course) => course !== undefined);
|
||||||
@@ -76,12 +81,12 @@ export const CoursesProvider = ({ children }: CoursesProviderProps) => {
|
|||||||
|
|
||||||
const selectSchedulerEvents = () => {
|
const selectSchedulerEvents = () => {
|
||||||
return basket.reduce((res, el) => {
|
return basket.reduce((res, el) => {
|
||||||
const { name } = el;
|
const { name, symbol } = el;
|
||||||
if (el.classes) {
|
if (el.classes) {
|
||||||
res.push({ ...el.classes, name });
|
res.push({ ...el.classes, name, symbol});
|
||||||
}
|
}
|
||||||
if (el.lecture) {
|
if (el.lecture) {
|
||||||
res.push({ ...el.lecture, name });
|
res.push({ ...el.lecture, name, symbol });
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}, [] as Array<SchedulerEvent>);
|
}, [] as Array<SchedulerEvent>);
|
||||||
@@ -122,6 +127,7 @@ export const CoursesProvider = ({ children }: CoursesProviderProps) => {
|
|||||||
const courseToBasket: Basket = {
|
const courseToBasket: Basket = {
|
||||||
name: course.name,
|
name: course.name,
|
||||||
id: course.id,
|
id: course.id,
|
||||||
|
symbol: course.symbol,
|
||||||
classes: course.classes !== undefined ? course.classes[0] : undefined,
|
classes: course.classes !== undefined ? course.classes[0] : undefined,
|
||||||
lecture: course.lectures !== undefined ? course.lectures[0] : undefined,
|
lecture: course.lectures !== undefined ? course.lectures[0] : undefined,
|
||||||
};
|
};
|
||||||
@@ -139,6 +145,7 @@ export const CoursesProvider = ({ children }: CoursesProviderProps) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const saveBasket = async (userID: string) => {
|
const saveBasket = async (userID: string) => {
|
||||||
|
setIsSavingLoading(true);
|
||||||
const basketIds = selectBasketIds();
|
const basketIds = selectBasketIds();
|
||||||
const action = (key: any) => (
|
const action = (key: any) => (
|
||||||
<>
|
<>
|
||||||
@@ -161,12 +168,13 @@ export const CoursesProvider = ({ children }: CoursesProviderProps) => {
|
|||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('error: ', e);
|
console.log('error: ', e);
|
||||||
enqueueSnackbar('Zapisywanie planu nie powiodło się', {
|
enqueueSnackbar('Zapisywanie niemożliwe w czasie bezturowym', {
|
||||||
variant: 'error',
|
variant: 'error',
|
||||||
action,
|
action,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
getStudentTimetablesHistory(userID);
|
getStudentTimetablesHistory(userID);
|
||||||
|
setIsSavingLoading(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
const changeGroupInBasket = (choosenGroup: any, courseId: number) => {
|
const changeGroupInBasket = (choosenGroup: any, courseId: number) => {
|
||||||
@@ -274,9 +282,19 @@ export const CoursesProvider = ({ children }: CoursesProviderProps) => {
|
|||||||
setHistoryBasket(basket);
|
setHistoryBasket(basket);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getCurrentTour = async () => {
|
||||||
|
try {
|
||||||
|
const { data } = await axiosInstance.get(`${process.env.REACT_APP_API_URL}/api/v1/configurator/config/tour`);
|
||||||
|
setTour(data.currentTour);
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setIsDataLoading(true);
|
setIsDataLoading(true);
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
getCurrentTour();
|
||||||
fetchCourses();
|
fetchCourses();
|
||||||
getNewestTimetable();
|
getNewestTimetable();
|
||||||
setIsDataLoading(false);
|
setIsDataLoading(false);
|
||||||
@@ -293,6 +311,9 @@ export const CoursesProvider = ({ children }: CoursesProviderProps) => {
|
|||||||
timetableHistory,
|
timetableHistory,
|
||||||
isDataLoading,
|
isDataLoading,
|
||||||
historyBasket,
|
historyBasket,
|
||||||
|
tour,
|
||||||
|
isSavingLoading,
|
||||||
|
getCurrentTour,
|
||||||
addCourseToBasket,
|
addCourseToBasket,
|
||||||
changeHoveredGroup,
|
changeHoveredGroup,
|
||||||
changeGroupInBasket,
|
changeGroupInBasket,
|
||||||
|
@@ -6,6 +6,7 @@ export enum GroupType {
|
|||||||
export interface Basket {
|
export interface Basket {
|
||||||
id: number;
|
id: number;
|
||||||
name: string;
|
name: string;
|
||||||
|
symbol?:string;
|
||||||
lecture?: Group;
|
lecture?: Group;
|
||||||
classes?: Group;
|
classes?: Group;
|
||||||
}
|
}
|
||||||
@@ -21,11 +22,13 @@ export interface Group {
|
|||||||
capacity?: number;
|
capacity?: number;
|
||||||
takenPlaces: number;
|
takenPlaces: number;
|
||||||
isAccepted:boolean;
|
isAccepted:boolean;
|
||||||
|
grNr: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Course {
|
export interface Course {
|
||||||
id: number;
|
id: number;
|
||||||
name: string;
|
name: string;
|
||||||
|
symbol:string;
|
||||||
lectures?: Array<Group>;
|
lectures?: Array<Group>;
|
||||||
classes?: Array<Group>;
|
classes?: Array<Group>;
|
||||||
}
|
}
|
||||||
@@ -55,6 +58,8 @@ export interface SchedulerEvent {
|
|||||||
takenPlaces: number;
|
takenPlaces: number;
|
||||||
name: string;
|
name: string;
|
||||||
isAccepted:boolean;
|
isAccepted:boolean;
|
||||||
|
grNr?: number;
|
||||||
|
symbol?:string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TimetableHistory {
|
export interface TimetableHistory {
|
||||||
|
@@ -3,12 +3,13 @@ import axios from 'axios';
|
|||||||
export const axiosInstance = axios.create();
|
export const axiosInstance = axios.create();
|
||||||
|
|
||||||
//getting new tokens
|
//getting new tokens
|
||||||
const getNewTokens = async () => {
|
export const getNewTokens = async () => {
|
||||||
try {
|
try {
|
||||||
const refreshToken = localStorage.getItem('refreshToken');
|
const refreshToken = localStorage.getItem('refreshToken');
|
||||||
const { data } = await axiosInstance.get(
|
const { data } = await axiosInstance.get(
|
||||||
`${process.env.REACT_APP_API_URL}/token/refresh?refreshToken=${refreshToken}`,
|
`${process.env.REACT_APP_API_URL}/token/refresh?refreshToken=${refreshToken}`,
|
||||||
);
|
);
|
||||||
|
localStorage.setItem('userPrivilige',data.authorityRole);
|
||||||
localStorage.setItem('userToken', data.token);
|
localStorage.setItem('userToken', data.token);
|
||||||
localStorage.setItem('refreshToken', data.refreshToken);
|
localStorage.setItem('refreshToken', data.refreshToken);
|
||||||
return data.token;
|
return data.token;
|
||||||
|
Reference in New Issue
Block a user