refactor: reorganize component files and update import paths; add PsItem and PsProduct interfaces
This commit is contained in:
32
client/src/app/services/platform.service.ts
Normal file
32
client/src/app/services/platform.service.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
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<Platform> {
|
||||
private readonly http = inject(HttpClient);
|
||||
private readonly BASE_URL = 'http://localhost:3000/api/app/platforms';
|
||||
|
||||
getAll(): Observable<Platform[]> {
|
||||
return this.http.get<Platform[]>(this.BASE_URL, {withCredentials: true});
|
||||
}
|
||||
|
||||
add(item: Platform): Observable<Platform> {
|
||||
console.log('Adding platform:', item);
|
||||
return this.http.post<Platform>(this.BASE_URL, item, {withCredentials: true});
|
||||
}
|
||||
|
||||
update(id: string | number, item: Platform): Observable<Platform> {
|
||||
console.log('Updating platform:', id, item);
|
||||
return this.http.put<Platform>(`${this.BASE_URL}/${id}`, item, {withCredentials: true});
|
||||
}
|
||||
|
||||
delete(id: string | number): Observable<void> {
|
||||
console.log('Deleting platform:', id);
|
||||
return this.http.delete<void>(`${this.BASE_URL}/${id}`, {withCredentials: true});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user