import { Injectable, inject } from '@angular/core'; import { Observable, of } from 'rxjs'; import { ApiService } from './api.service'; import { Enrollment, CourseProgress } from '../models/types'; @Injectable({ providedIn: 'root' }) export class EnrollmentService { private readonly api = inject(ApiService); enroll(courseId: string, userId: string): Observable { return this.api.post(`/api/courses/${courseId}/enroll`, { userId, courseId }); } getEnrollments(userId: string): Observable { return this.api.get(`/api/users/${userId}/enrollments`); } getCourseProgress(courseId: string, userId: string): Observable { return this.api.get(`/api/courses/${courseId}/progress`, { userId }); } markTopicProgress(topicId: string, userId: string, completed: boolean): Observable { return this.api.post(`/api/topics/${topicId}/progress`, { userId, topicId, completed }); } markResourceProgress(resourceId: string, userId: string, completed: boolean): Observable { return this.api.post(`/api/resources/${resourceId}/progress`, { userId, resourceId, completed }); } }