Files
allowance_planner_2000/frontend/allowance-planner-v2/src/app/services/allowance.service.ts
Huffle 45f40a7976
All checks were successful
Backend Deploy / build (push) Successful in 16s
Backend Build and Test / build (push) Successful in 2m47s
add possibility to finish a goal (#90)
closes #67

Reviewed-on: #90
2025-05-26 10:29:40 +02:00

37 lines
1.3 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();
}
deleteAllowance(allowanceId: number, userId: number) {
this.http.delete(`${this.url}/user/${userId}/allowance/${allowanceId}`).subscribe();
}
completeGoal(goalId: number, userId: number) {
this.http.post(`${this.url}/user/${userId}/allowance/${goalId}/complete`, {}).subscribe();
}
}