Huffle 2678280400
Some checks failed
Backend Build and Test / build (push) Has been cancelled
add funcionality to edit allowance
2025-05-26 09:48:00 +02:00

29 lines
1.0 KiB
TypeScript

import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { Allowance } from '../models/allowance';
@Injectable({
providedIn: 'root'
})
export class AllowanceService {
private url = 'http://localhost:8080/api';
constructor(private http: HttpClient) {}
getAllowanceList(userId: number): Observable<Array<Allowance>> {
return this.http.get<Allowance[]>(`${this.url}/user/${userId}/allowance`);
}
getAllowanceById(allowanceId: number, userId: number): Observable<Allowance> {
return this.http.get<Allowance>(`${this.url}/user/${userId}/allowance/${allowanceId}`);
}
createAllowance(allowance: Partial<Allowance>, userId: number) {
this.http.post(`${this.url}/user/${userId}/allowance`, allowance).subscribe();
}
updateAllowance(allowance: Partial<Allowance>, allowanceId: number, userId: number) {
this.http.put(`${this.url}/user/${userId}/allowance/${allowanceId}`, allowance).subscribe();
}
}