import { inject, Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { lastValueFrom } from 'rxjs'; import { map } from 'rxjs/operators'; import { HttpPlainResponse, HttpResponse } from '@/core/models/response.interface'; import { OndemandVideo } from './ondemand.models'; @Injectable() export class OndemandService { private http = inject(HttpClient); private route = `ondemand`; getOndemandVideos() { return this.http.get>(this.route).pipe(map(({ data }) => data)); } getOndemandByTheme(theme: number) { return this.http .get>(`${this.route}/${theme}`) .pipe(map(({ data }) => data[0])); } saveOndemandTime(ondemand_id: number) { const request = this.http.post(`${this.route}/time_ondemand`, { ondemand_id, }); return lastValueFrom(request); } } export const injectOndemandService = () => inject(OndemandService);