added mocked fetch newest timetable

This commit is contained in:
maciekglowacki 2020-10-27 10:42:22 +01:00
parent 157dc2f35e
commit c16561cfd1

View File

@ -86,15 +86,33 @@ export const CoursesProvider = ({ children }: CoursesProviderProps) => {
} }
}; };
useEffect(() => { const getNewestTimetable = async () => {
const fetchData = async () => { //todo
try {
const { data: basket } = await axios.get(
`${process.env.REACT_APP_API_URL}/api/v1/assignments/getCurrentAssignments`,
);
// setBasket(basket);
} catch (e) {
console.log(e);
}
};
const fetchClasses = async () => {
try {
const { data: courses } = await axios.get<Array<Course>>( const { data: courses } = await axios.get<Array<Course>>(
`${process.env.REACT_APP_API_URL}/api/v1/courses/getCoursesWithGroups`, `${process.env.REACT_APP_API_URL}/api/v1/courses/getCoursesWithGroups`,
); );
courses.sort((a, b) => (a.name > b.name ? 1 : -1)); courses.sort((a, b) => (a.name > b.name ? 1 : -1));
setCourses(courses); setCourses(courses);
}; } catch (e) {
fetchData(); console.log(e);
}
};
useEffect(() => {
fetchClasses();
getNewestTimetable();
}, []); }, []);
return ( return (