Skip to content

Commit

Permalink
Fix: Make the return of course unique
Browse files Browse the repository at this point in the history
  • Loading branch information
whats2000 committed Jul 2, 2024
1 parent 17abef6 commit c50e56d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion nsysu_selector_helper/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const App: FC = () => {
dataSource={courses}
renderItem={course => (
<List.Item>
<Typography.Text>{course.name}</Typography.Text> - {course.teacher} ({course.credit} credits)
<Typography.Text>{course.id} {course.name}</Typography.Text> - {course.teacher} ({course.credit} credits)
</List.Item>
)}
style={{ marginTop: '20px' }}
Expand Down
6 changes: 5 additions & 1 deletion nsysu_selector_helper/src/api/NSYSUCourseAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Course[]> {
Expand Down

0 comments on commit c50e56d

Please sign in to comment.