mirror of
https://github.com/opelly27/WinStudentGoalTracker.git
synced 2026-05-20 08:47:42 +00:00
moved dummy services to return ApiResult type, and Promise API instead of rxjs observable
This commit is contained in:
@@ -19,6 +19,8 @@ export class Api {
|
||||
private readonly http = inject(HttpClient);
|
||||
private readonly base = environment.apiBaseUrl;
|
||||
|
||||
// ************************** Auth Endpoints **************************
|
||||
|
||||
// Phase 1 — verify credentials, receive session token + program list
|
||||
login(request: LoginRequest): Observable<ResponseResult<LoginResponse>> {
|
||||
return this.http.post<ResponseResult<LoginResponse>>(
|
||||
@@ -50,4 +52,7 @@ export class Api {
|
||||
request,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { ApiResult } from '../classes/api-result';
|
||||
|
||||
// *****************************************************************
|
||||
// TODO: This dummy service should be replaced by MobileHomeMeta,
|
||||
@@ -29,11 +30,13 @@ export class DummyMobileHomeMeta {
|
||||
// Replace with MobileHomeMeta service that calls
|
||||
// GET /api/mobile/home-meta (or similar).
|
||||
// *****************************************************************
|
||||
getMeta(): Observable<MobileHomeMeta> {
|
||||
return of({
|
||||
async getMeta(): Promise<ApiResult<MobileHomeMeta | null>> {
|
||||
var payload = {
|
||||
programName: 'WIN Program',
|
||||
userName: 'Polly Balsillie',
|
||||
});
|
||||
}
|
||||
|
||||
return ApiResult.ok(payload);
|
||||
}
|
||||
|
||||
// ************************ Event Handlers *************************
|
||||
|
||||
+2
-2
@@ -24,8 +24,8 @@ export class DummySaveProgressEvent {
|
||||
// TODO: DUMMY — Always returns success. Replace with
|
||||
// SaveProgressEvent calling POST /api/progress-events
|
||||
// *****************************************************************
|
||||
save(studentId: string, goalId: string, content: string): Observable<ApiResult> {
|
||||
return of(ApiResult.empty());
|
||||
async save(studentId: string, goalId: string, content: string): Promise<ApiResult> {
|
||||
return ApiResult.empty();
|
||||
}
|
||||
|
||||
// ************************ Event Handlers *************************
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { ApiResult } from '../classes/api-result';
|
||||
|
||||
// *****************************************************************
|
||||
// TODO: This dummy service should be replaced by StudentGoalService,
|
||||
@@ -84,8 +84,15 @@ export class DummyStudentGoalService {
|
||||
// Returns the student's identifier and their list of goals,
|
||||
// given a student ID.
|
||||
// *****************************************************************
|
||||
getGoalsForStudent(studentId: string): Observable<StudentGoalSummary | null> {
|
||||
return of(this.data[studentId] ?? null);
|
||||
async getGoalsForStudent(studentId: string): Promise<ApiResult<StudentGoalSummary | null>> {
|
||||
var goals = this.data[studentId] ?? null;
|
||||
if (goals === null)
|
||||
{
|
||||
return ApiResult.fail('Student not found');
|
||||
}
|
||||
|
||||
return ApiResult.ok(goals);
|
||||
|
||||
}
|
||||
|
||||
// ************************ Event Handlers *************************
|
||||
|
||||
Reference in New Issue
Block a user