changes to new package
This commit is contained in:
parent
d3f08623aa
commit
9d1cf2011c
@ -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 }) => ({
|
||||||
name,
|
id,
|
||||||
lectures: groups.filter(({ type }) => type === GroupType.LECTURE),
|
name,
|
||||||
classes: groups.filter(({ type }) => type === GroupType.CLASS),
|
lectures,
|
||||||
|
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));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user