diff --git a/src/app/core/models/search-results.ts b/src/app/core/models/search-results.ts new file mode 100644 index 0000000000000000000000000000000000000000..a0c4694528860dbaf15205ea2c457e3dd68f5e56 --- /dev/null +++ b/src/app/core/models/search-results.ts @@ -0,0 +1,14 @@ +import { Subject } from '@app/core/models/course-details'; + +export interface SearchResult { + termCode: string; + courseId: string; + subject: Subject; +} + +export interface SearchResults { + found: number; + hits: SearchResult[]; + message: null; + success: boolean; +} diff --git a/src/app/degree-planner/course-search/course-search.component.ts b/src/app/degree-planner/course-search/course-search.component.ts index 6db84a0e8afe22ba238d26bb7dc7efa31c63f1cf..b221c9408faf7bd43eaa1bfbe89f228638866f0a 100644 --- a/src/app/degree-planner/course-search/course-search.component.ts +++ b/src/app/degree-planner/course-search/course-search.component.ts @@ -205,7 +205,7 @@ export class CourseSearchComponent implements OnInit, OnDestroy { ...course, subject: course.subject.description, subjectCode: course.subject.subjectCode, - }; + } as Course; }); }) .catch(console.log); diff --git a/src/app/degree-planner/services/api.service.ts b/src/app/degree-planner/services/api.service.ts index 2dbf41b11ab14e60c5865aca13ba09eb1a8e2ec9..f33cf522349d8283a6d70c9b8fae16c2515101e2 100644 --- a/src/app/degree-planner/services/api.service.ts +++ b/src/app/degree-planner/services/api.service.ts @@ -15,6 +15,7 @@ import { Term } from '@app/core/models/term'; import { CourseBase, SubjectMapping } from '@app/core/models/course'; import { DegreePlan } from '@app/core/models/degree-plan'; import { SavedForLaterCourseBase } from '@app/core/models/saved-for-later-course'; +import { SearchResults } from '@app/core/models/search-results'; const HTTP_OPTIONS = { headers: new HttpHeaders({ @@ -114,7 +115,7 @@ export class DegreePlannerApiService { subjectCode: string; searchText?: string; termCode?: string; - }): Observable<any> { + }) { const { subjectCode, termCode, searchText } = config; const payload: any = { @@ -152,7 +153,11 @@ export class DegreePlannerApiService { }); } - return this.http.post('/api/search/v1', payload, HTTP_OPTIONS); + return this.http.post<SearchResults>( + '/api/search/v1', + payload, + HTTP_OPTIONS, + ); } public addCourse(