changes to new package
This commit is contained in:
parent
d3f08623aa
commit
9d1cf2011c
@ -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));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user