Compare commits
14 Commits
49d9c6acdd
...
master
Author | SHA1 | Date | |
---|---|---|---|
59b085dd34 | |||
3eaaa2ef10 | |||
4091525f61 | |||
67a8281aa1 | |||
4ac917649a | |||
c83f839705 | |||
f319e022fe | |||
62d73fcbe3 | |||
0ecdc6db20 | |||
a229f0cd6d | |||
a72fb6b12c | |||
8ff51a6598 | |||
954e0a751f | |||
52d4a384d9 |
@ -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 ? (
|
||||||
|
@ -120,9 +120,10 @@ export const Dropdown = ({ open, input, handleCloseDropdown, selectedOption }: D
|
|||||||
<>
|
<>
|
||||||
{selectedOption === 'studenci' ? (
|
{selectedOption === 'studenci' ? (
|
||||||
<div>
|
<div>
|
||||||
{filteredStudents.map(({ surname, name, 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>{name} {surname}</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} />
|
||||||
))}
|
))}
|
||||||
|
@ -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>
|
||||||
|
@ -10,6 +10,7 @@ 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 Tooltip from '@material-ui/core/Tooltip';
|
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,7 +215,7 @@ export default function ({ handleTransfer }: TopbarProps) {
|
|||||||
</ClickAwayListener>
|
</ClickAwayListener>
|
||||||
</FlexboxColumn>
|
</FlexboxColumn>
|
||||||
<IconWrapper>
|
<IconWrapper>
|
||||||
<SelectedStudent>{selectedStudent?.surname}</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' && (
|
{userPrivilige === 'STUDENT' && (
|
||||||
<Tooltip title="Wymiana grupami">
|
<Tooltip title="Wymiana grupami">
|
||||||
|
@ -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,17 +165,20 @@ 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) => {
|
||||||
|
@ -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');
|
||||||
|
@ -22,6 +22,7 @@ interface CourseContext {
|
|||||||
isDataLoading: boolean;
|
isDataLoading: boolean;
|
||||||
historyBasket: Array<Basket>;
|
historyBasket: Array<Basket>;
|
||||||
tour: string;
|
tour: string;
|
||||||
|
isSavingLoading: boolean;
|
||||||
getCurrentTour: () => void;
|
getCurrentTour: () => void;
|
||||||
addCourseToBasket: (courses: Course) => void;
|
addCourseToBasket: (courses: Course) => void;
|
||||||
changeHoveredGroup: (group: Group | null) => void;
|
changeHoveredGroup: (group: Group | null) => void;
|
||||||
@ -60,6 +61,7 @@ export const CoursesProvider = ({ children }: CoursesProviderProps) => {
|
|||||||
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 [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);
|
||||||
@ -143,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) => (
|
||||||
<>
|
<>
|
||||||
@ -171,6 +174,7 @@ export const CoursesProvider = ({ children }: CoursesProviderProps) => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
getStudentTimetablesHistory(userID);
|
getStudentTimetablesHistory(userID);
|
||||||
|
setIsSavingLoading(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
const changeGroupInBasket = (choosenGroup: any, courseId: number) => {
|
const changeGroupInBasket = (choosenGroup: any, courseId: number) => {
|
||||||
@ -308,6 +312,7 @@ export const CoursesProvider = ({ children }: CoursesProviderProps) => {
|
|||||||
isDataLoading,
|
isDataLoading,
|
||||||
historyBasket,
|
historyBasket,
|
||||||
tour,
|
tour,
|
||||||
|
isSavingLoading,
|
||||||
getCurrentTour,
|
getCurrentTour,
|
||||||
addCourseToBasket,
|
addCourseToBasket,
|
||||||
changeHoveredGroup,
|
changeHoveredGroup,
|
||||||
|
@ -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