import {inject, Injectable} from '@angular/core'; import {HttpClient} from '@angular/common/http'; import {Observable} from 'rxjs'; import {Platform} from '../interfaces/platform'; import {CrudService} from './crud.service'; @Injectable({ providedIn: 'root' }) export class PlatformService implements CrudService { private readonly http = inject(HttpClient); private readonly BASE_URL = 'http://localhost:3000/api/app/platforms'; getAll(): Observable { return this.http.get(this.BASE_URL, {withCredentials: true}); } add(item: Platform): Observable { console.log('Adding platform:', item); return this.http.post(this.BASE_URL, item, {withCredentials: true}); } update(id: string | number, item: Platform): Observable { console.log('Updating platform:', id, item); return this.http.put(`${this.BASE_URL}/${id}`, item, {withCredentials: true}); } delete(id: string | number): Observable { console.log('Deleting platform:', id); return this.http.delete(`${this.BASE_URL}/${id}`, {withCredentials: true}); } }