11import * as React from "react" ;
22import { FC , useEffect , useState , useMemo } from "react" ;
33import { useNavigate , useParams , useSearchParams } from "react-router-dom" ;
4- import { AccountDataDto , CourseViewModel , HomeworkViewModel , StatisticsCourseMatesModel } from "@/api" ;
4+ import { AccountDataDto , CourseViewModel , GroupViewModel , HomeworkViewModel , StatisticsCourseMatesModel } from "@/api" ;
55import StudentStats from "./StudentStats" ;
66import NewCourseStudents from "./NewCourseStudents" ;
77import ApiSingleton from "../../api/ApiSingleton" ;
@@ -46,6 +46,7 @@ interface ICourseState {
4646 isFound : boolean ;
4747 course : CourseViewModel ;
4848 courseHomeworks : HomeworkViewModel [ ] ;
49+ groups : GroupViewModel [ ] ;
4950 mentors : AccountDataDto [ ] ;
5051 acceptedStudents : AccountDataDto [ ] ;
5152 newStudents : AccountDataDto [ ] ;
@@ -67,6 +68,7 @@ const Course: React.FC = () => {
6768 course : { } ,
6869 courseHomeworks : [ ] ,
6970 mentors : [ ] ,
71+ groups : [ ] ,
7072 acceptedStudents : [ ] ,
7173 newStudents : [ ] ,
7274 studentSolutions : [ ] ,
@@ -85,10 +87,16 @@ const Course: React.FC = () => {
8587 newStudents,
8688 acceptedStudents,
8789 courseHomeworks,
90+ groups
8891 } = courseState
8992
90- const groups = course . groups || [ ]
91- const loadGroups = async ( ) => setCurrentState ( ) ;
93+ const loadGroups = async ( ) => {
94+ const groups = await ApiSingleton . courseGroupsApi . courseGroupsGetAllCourseGroups ( course . id ! )
95+ setCourseState ( prevState => ( {
96+ ...prevState ,
97+ groups : groups
98+ } ) )
99+ } ;
92100
93101 const userId = ApiSingleton . authService . getUserId ( )
94102
@@ -142,6 +150,7 @@ const Course: React.FC = () => {
142150 courseHomeworks : course . homeworks ! ,
143151 createHomework : false ,
144152 mentors : course . mentors ! ,
153+ groups : course . groups || [ ] ,
145154 acceptedStudents : course . acceptedStudents ! ,
146155 newStudents : course . newStudents ! ,
147156 } ) )
0 commit comments