mirror of
https://github.com/opelly27/WinStudentGoalTracker.git
synced 2026-05-20 01:47:41 +00:00
latest
This commit is contained in:
@@ -4,7 +4,6 @@ import { Subject } from 'rxjs';
|
||||
import { debounceTime } from 'rxjs/operators';
|
||||
import { ProgressItem } from '../progress-item/progress-item';
|
||||
import { ProgressEventDto } from '../../../shared/classes/progress-event.dto';
|
||||
import { DummyStudentService } from '../../../shared/services/dummy-student.service';
|
||||
import { StudentService } from '../../../shared/services/student.service';
|
||||
|
||||
@Component({
|
||||
@@ -30,7 +29,6 @@ export class ProgressList implements OnDestroy {
|
||||
|
||||
// ************************** Declarations *************************
|
||||
|
||||
private readonly dummyService = inject(DummyStudentService);
|
||||
private readonly studentService = inject(StudentService);
|
||||
private readonly route = inject(ActivatedRoute);
|
||||
private readonly router = inject(Router);
|
||||
@@ -97,12 +95,11 @@ export class ProgressList implements OnDestroy {
|
||||
// ********************** Support Procedures ***********************
|
||||
|
||||
// *****************************************************************
|
||||
// Loads progress events for the given goal from the dummy service,
|
||||
// sorted newest-first by createdAt.
|
||||
// TODO: Replace DummyStudentService with StudentService
|
||||
// Loads progress events for the given goal from the API, sorted
|
||||
// newest-first by createdAt.
|
||||
// *****************************************************************
|
||||
private loadEvents() {
|
||||
this.dummyService.getProgressEventsForGoal(this.goalId).then(result => {
|
||||
this.studentService.getProgressEventsForGoal(this.goalId).then(result => {
|
||||
if (!result.success) {
|
||||
this.errorMessage.set(result.message);
|
||||
} else {
|
||||
|
||||
@@ -9,6 +9,7 @@ import { CreateStudentDto } from '../classes/create-student.dto';
|
||||
import { CreateGoalDto } from '../classes/create-goal.dto';
|
||||
import { StudentCardDto } from '../classes/student-card.dto';
|
||||
import { StudentGoalSummary, StudentGoalItem } from '../classes/student-goal';
|
||||
import { ProgressEventDto } from '../classes/progress-event.dto';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
@@ -103,6 +104,22 @@ export class StudentService {
|
||||
}
|
||||
}
|
||||
|
||||
// *****************************************************************
|
||||
// Returns progress events for a given student goal.
|
||||
// *****************************************************************
|
||||
async getProgressEventsForGoal(goalId: string): Promise<ApiResult<ProgressEventDto[]>> {
|
||||
try {
|
||||
const result = await firstValueFrom(
|
||||
this.http.get<ResponseResult<ProgressEventDto[]>>(`${this.base}/api/Student/goals/${goalId}/progress-events`)
|
||||
);
|
||||
return result.success
|
||||
? ApiResult.ok(result.data ?? [])
|
||||
: ApiResult.fail(result.message);
|
||||
} catch (error) {
|
||||
return ApiResult.fail(describeHttpError(error as HttpErrorResponse));
|
||||
}
|
||||
}
|
||||
|
||||
// ************************ Event Handlers *************************
|
||||
|
||||
// ********************** Support Procedures ***********************
|
||||
|
||||
Reference in New Issue
Block a user