From c16561cfd11eb6f421455e2cabffb7571e3a5e32 Mon Sep 17 00:00:00 2001 From: maciekglowacki Date: Tue, 27 Oct 2020 10:42:22 +0100 Subject: [PATCH] added mocked fetch newest timetable --- src/contexts/CoursesProvider.tsx | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/src/contexts/CoursesProvider.tsx b/src/contexts/CoursesProvider.tsx index c78b870..035971a 100644 --- a/src/contexts/CoursesProvider.tsx +++ b/src/contexts/CoursesProvider.tsx @@ -86,15 +86,33 @@ export const CoursesProvider = ({ children }: CoursesProviderProps) => { } }; - useEffect(() => { - const fetchData = async () => { + const getNewestTimetable = 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>( `${process.env.REACT_APP_API_URL}/api/v1/courses/getCoursesWithGroups`, ); courses.sort((a, b) => (a.name > b.name ? 1 : -1)); setCourses(courses); - }; - fetchData(); + } catch (e) { + console.log(e); + } + }; + + useEffect(() => { + fetchClasses(); + getNewestTimetable(); }, []); return (