diff --git a/nsysu_selector_helper/src/App.tsx b/nsysu_selector_helper/src/App.tsx index efb4f30..1ad76d3 100644 --- a/nsysu_selector_helper/src/App.tsx +++ b/nsysu_selector_helper/src/App.tsx @@ -86,7 +86,7 @@ const App: FC = () => { dataSource={courses} renderItem={course => ( - {course.name} - {course.teacher} ({course.credit} credits) + {course.id} {course.name} - {course.teacher} ({course.credit} credits) )} style={{ marginTop: '20px' }} diff --git a/nsysu_selector_helper/src/api/NSYSUCourseAPI.ts b/nsysu_selector_helper/src/api/NSYSUCourseAPI.ts index c7adaa8..22633ca 100644 --- a/nsysu_selector_helper/src/api/NSYSUCourseAPI.ts +++ b/nsysu_selector_helper/src/api/NSYSUCourseAPI.ts @@ -24,7 +24,11 @@ export class NSYSUCourseAPI { if (!response.ok) { throw new Error('Failed to fetch courses'); } - return response.json(); + + return response.json().then((courses: Course[]) => { + return Array.from(new Set(courses.map(course => course.id))) + .map(id => courses.find(course => course.id === id)!); + }); } static async getLatestCourses(): Promise {