Skip to content
This repository was archived by the owner on Jul 5, 2024. It is now read-only.

Commit b40cbde

Browse files
committed
attendance-management-angular-13 (JS-0323) Detected usage of the any type
closes #13 by adding explicit type feat(app): enhance authentication service and improve DTO imports Update AuthService to include LoginToken alongside LoginDTO for improved type safety during login requests Adjust return types within AuthService: Replace generic Observable responses with specific HttpResponse variants involving either LoginToken/StatusMessageResponse or just StatusMessageResponse. Modify AttendanceLineChartService's getAttendanceLineChart()/getSectionAttendanceLineChart() methods by specifying LineChartDTO in their return types while also importing it explicitly along with HttpResponse Remove redundant HttpClient import statement from TopHeaderComponent Enhance StudentService by returning more precise types: Convert countStudentsBySection() method's return value to an observable emitting HttpResponse wrapping around a CountDTO object Transform getAllStudents() method's result into an observable yielding StudentPaging objects rather than an unspecific any type Refactor TeacherService to fetch Teacher entities wrapped inside HttpResponse instances via the getTeacherByUserId() function Standardize SectionService by consistently utilizing observables encapsulating HTTP responses across all methods (createSection(), updateSection(), etc.) and importing required DTO classes like StatusMessageResponse upfront Ensure proper typing throughout remaining components such as AnnouncementsComponent, AdminDashboardComponent, TeacherDashboardComponent, and TeacherStudentsComponent
1 parent 2e6f47d commit b40cbde

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/app/services/attendance/attendance.service.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import {inject, Injectable} from '@angular/core';
22
import {environment} from "../../../environments/environment";
3-
import {HttpClient} from "@angular/common/http";
3+
import {HttpClient, HttpResponse} from "@angular/common/http";
44
import {DateRange, Status} from "../../DTO/DTOList";
55
import {Observable} from "rxjs";
66
import {CountDTO} from "../../DTO/CountDTO";
77
import {SortDirection} from "../../enums/SortDirection";
8+
import {AttendancePaging} from "../../DTO/AttendanceDTO";
89

910
@Injectable({
1011
providedIn: 'root'
@@ -14,8 +15,8 @@ export class AttendanceService {
1415
apiUrl: string = environment.apiUrl + "/api/v1/attendances";
1516
http: HttpClient = inject(HttpClient);
1617

17-
countAttendance(dateRange: DateRange, status: Status) {
18-
return this.http.post(this.apiUrl + `/status/${status}/date-range`, dateRange, {
18+
countAttendance(dateRange: DateRange, status: Status): Observable<HttpResponse<number>> {
19+
return this.http.post<number>(this.apiUrl + `/status/${status}/date-range`, dateRange, {
1920
observe: 'response',
2021
responseType: 'json'
2122
});
@@ -28,18 +29,18 @@ export class AttendanceService {
2829
});
2930
}
3031

31-
countAttendanceInSectionByDate(sectionId: number, date: Date, status: Status) {
32+
countAttendanceInSectionByDate(sectionId: number, date: Date, status: Status): Observable<HttpResponse<CountDTO>> {
3233
const formattedDate: string = date.toISOString().split('T')[0];
3334
return this.http.get<CountDTO>(this.apiUrl + `/status/${status}/section/${sectionId}/date?date=${formattedDate}`, {
3435
observe: 'response',
3536
responseType: 'json'
3637
});
3738
}
3839

39-
getAllSectionAndGradeLevelAttendanceByDate(sectionId: number, gradeLevelId: number, date: Date, page: number, size: number, sortBy = "date", orderBy: SortDirection = SortDirection.ASC) {
40+
getAllSectionAndGradeLevelAttendanceByDate(sectionId: number, gradeLevelId: number, date: Date, page: number, size: number, sortBy = "date", orderBy: SortDirection = SortDirection.ASC): Observable<HttpResponse<AttendancePaging>> {
4041
const formattedDate = date.toISOString().split('T')[0];
4142

42-
return this.http.get(this.apiUrl + `/statistics/section/${sectionId}/grade-level/${gradeLevelId}/date`, {
43+
return this.http.get<AttendancePaging>(this.apiUrl + `/statistics/section/${sectionId}/grade-level/${gradeLevelId}/date`, {
4344
params: {
4445
date: formattedDate,
4546
page: page,

0 commit comments

Comments
 (0)