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(() => {
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`,
);
const courses = data.map(({ id, name, groups }) => ({
id: parseInt(id),
name,
lectures: groups.filter(({ type }) => type === GroupType.LECTURE),
classes: groups.filter(({ type }) => type === GroupType.CLASS),
console.log(data);
const courses = data.map(({ id, name, lectures, classes }) => ({
id,
name,
lectures,
classes,
})) as Array<Course>;
courses.sort((a: Course, b: Course) => (a.name > b.name ? 1 : -1));