This commit is contained in:
@@ -0,0 +1,48 @@
|
|||||||
|
import { HttpClient } from '@angular/common/http';
|
||||||
|
import { Injectable, inject } from '@angular/core';
|
||||||
|
import { Observable } from 'rxjs';
|
||||||
|
|
||||||
|
import { environment } from '../../environments/environment';
|
||||||
|
import { MagazzinoVoce } from './magazzino-api.service';
|
||||||
|
|
||||||
|
export interface GruppoMagazzino {
|
||||||
|
id: string;
|
||||||
|
orgId: string;
|
||||||
|
nome: string;
|
||||||
|
parentId: string | null;
|
||||||
|
creatoIl: string;
|
||||||
|
voci: MagazzinoVoce[];
|
||||||
|
// Sempre vuoto sui gruppi restituiti come figli: un solo livello di nesting.
|
||||||
|
figli: GruppoMagazzino[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CreaGruppoMagazzinoInput {
|
||||||
|
nome: string;
|
||||||
|
parentId?: string | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface AggiornaGruppoMagazzinoInput {
|
||||||
|
nome?: string;
|
||||||
|
parentId?: string | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Injectable({ providedIn: 'root' })
|
||||||
|
export class GruppiMagazzinoApiService {
|
||||||
|
private readonly http = inject(HttpClient);
|
||||||
|
|
||||||
|
getGruppi(): Observable<GruppoMagazzino[]> {
|
||||||
|
return this.http.get<GruppoMagazzino[]>(`${environment.magazzinoApiBaseUrl}/gruppi-magazzino`);
|
||||||
|
}
|
||||||
|
|
||||||
|
creaGruppo(input: CreaGruppoMagazzinoInput): Observable<GruppoMagazzino> {
|
||||||
|
return this.http.post<GruppoMagazzino>(`${environment.magazzinoApiBaseUrl}/gruppi-magazzino`, input);
|
||||||
|
}
|
||||||
|
|
||||||
|
aggiornaGruppo(id: string, input: AggiornaGruppoMagazzinoInput): Observable<GruppoMagazzino> {
|
||||||
|
return this.http.put<GruppoMagazzino>(`${environment.magazzinoApiBaseUrl}/gruppi-magazzino/${id}`, input);
|
||||||
|
}
|
||||||
|
|
||||||
|
eliminaGruppo(id: string): Observable<void> {
|
||||||
|
return this.http.delete<void>(`${environment.magazzinoApiBaseUrl}/gruppi-magazzino/${id}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user