changes to new package

This commit is contained in:
wrzesinski-hubert 2020-10-26 19:40:03 +01:00
parent d3f08623aa
commit 9d1cf2011c

View File

@ -73,14 +73,15 @@ export const CoursesProvider = ({ children }: CoursesProviderProps) => {
useEffect(() => { useEffect(() => {
const fetchData = async () => { const fetchData = async () => {
const { data } = await axios.get<Array<{ id: string; name: string; groups: Array<Group> }>>( const { data } = await axios.get<Array<{ id: number; name: string; lectures: Array<Group>, classes:Array<Group> }>>(
`${process.env.REACT_APP_API_URL}/api/v1/courses/getCoursesWithGroups`, `${process.env.REACT_APP_API_URL}/api/v1/courses/getCoursesWithGroups`,
); );
const courses = data.map(({ id, name, groups }) => ({ console.log(data);
id: parseInt(id), const courses = data.map(({ id, name, lectures, classes }) => ({
id,
name, name,
lectures: groups.filter(({ type }) => type === GroupType.LECTURE), lectures,
classes: groups.filter(({ type }) => type === GroupType.CLASS), classes,
})) as Array<Course>; })) as Array<Course>;
courses.sort((a: Course, b: Course) => (a.name > b.name ? 1 : -1)); courses.sort((a: Course, b: Course) => (a.name > b.name ? 1 : -1));