Skip to content
Snippets Groups Projects
Commit 917d8127 authored by Isaac Evavold's avatar Isaac Evavold
Browse files

add search result types

parent 4d282500
No related branches found
No related tags found
No related merge requests found
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;
}
......@@ -205,7 +205,7 @@ export class CourseSearchComponent implements OnInit, OnDestroy {
...course,
subject: course.subject.description,
subjectCode: course.subject.subjectCode,
};
} as Course;
});
})
.catch(console.log);
......
......@@ -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(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment