add possibility to finish a goal (#90)
All checks were successful
Backend Deploy / build (push) Successful in 16s
Backend Build and Test / build (push) Successful in 2m47s

closes #67

Reviewed-on: #90
This commit is contained in:
Huffle 2025-05-26 10:29:40 +02:00
parent 63982115a7
commit 45f40a7976
3 changed files with 10 additions and 1 deletions

View File

@ -61,7 +61,7 @@
<div class="buttons">
<button class="add-button">Add</button>
<!-- <button class="move-button">Move</button> -->
<button class="spend-button" [disabled]="!canFinishGoal(goal)">Finish goal</button>
<button class="spend-button" [disabled]="!canFinishGoal(goal)" (click)="completeGoal(goal.id)">Finish goal</button>
</div>
</div>
<div class="color" [style.--background]="hexToRgb(goal.colour)" [style.width.%]="getPercentage(goal)"></div>

View File

@ -67,4 +67,9 @@ export class AllowancePage implements ViewWillEnter {
updateAllowance(id: number) {
this.router.navigate(['edit', id], { relativeTo: this.route });
}
completeGoal(goalId: number) {
this.allowanceService.completeGoal(goalId, this.id);
this.getAllowance();
}
}

View File

@ -30,4 +30,8 @@ export class AllowanceService {
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();
}
}