switched to yarn:
This commit is contained in:
@ -18,27 +18,26 @@ export const CASProvider = ({ children }: CASProviderProps) => {
|
||||
const [user, setUser] = useState<User | undefined>(undefined);
|
||||
const [token, setToken] = useState<string | null>(null);
|
||||
useEffect(() => {
|
||||
const login = async () => {
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
const ticket = urlParams.get('ticket');
|
||||
if (!ticket) {
|
||||
redirectToCASLoginService();
|
||||
}
|
||||
try {
|
||||
if (!sessionStorage.getItem('userToken')) {
|
||||
const { data: token } = await axiosInstance.get(`${process.env.REACT_APP_API_URL}/token?ticket=${ticket}`);
|
||||
sessionStorage.setItem('userToken', token);
|
||||
}
|
||||
const token = sessionStorage.getItem('userToken');
|
||||
setToken(token);
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
};
|
||||
login();
|
||||
}, []);
|
||||
|
||||
const login = async () => {
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
const ticket = urlParams.get('ticket');
|
||||
if (!ticket) {
|
||||
redirectToCASLoginService();
|
||||
}
|
||||
try {
|
||||
if (!sessionStorage.getItem('userToken')) {
|
||||
const { data: token } = await axiosInstance.get(`${process.env.REACT_APP_API_URL}/token?ticket=${ticket}`);
|
||||
sessionStorage.setItem('userToken', token);
|
||||
}
|
||||
const token = sessionStorage.getItem('userToken');
|
||||
setToken(token);
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
};
|
||||
|
||||
function logout() {
|
||||
redirectToCASLogoutService();
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import React, { useState, createContext, useEffect, ReactNode, useContext } from 'react';
|
||||
import React, { useState, createContext, useEffect, ReactNode } from 'react';
|
||||
import { Course, Group, Basket, GroupType, SchedulerEvent } from '../types';
|
||||
import { useSnackbar } from 'notistack';
|
||||
import { createClassTime } from '../utils';
|
||||
@ -120,7 +120,6 @@ export const CoursesProvider = ({ children }: CoursesProviderProps) => {
|
||||
);
|
||||
const basket = data === '' ? [] : data;
|
||||
setBasket(basket);
|
||||
console.log('newest timetable: ', basket);
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
@ -132,7 +131,6 @@ export const CoursesProvider = ({ children }: CoursesProviderProps) => {
|
||||
`${process.env.REACT_APP_API_URL}/api/v1/courses/getCoursesWithGroups`,
|
||||
);
|
||||
const sortedCourses = courses.sort((a, b) => (a.name > b.name ? 1 : -1));
|
||||
console.log('courses: ', courses);
|
||||
setCourses(sortedCourses);
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
|
Reference in New Issue
Block a user