aboutsummaryrefslogtreecommitdiff
path: root/ufund-ui/src/app/components/cupboard/cupboard.component.ts
diff options
context:
space:
mode:
Diffstat (limited to 'ufund-ui/src/app/components/cupboard/cupboard.component.ts')
-rw-r--r--ufund-ui/src/app/components/cupboard/cupboard.component.ts36
1 files changed, 22 insertions, 14 deletions
diff --git a/ufund-ui/src/app/components/cupboard/cupboard.component.ts b/ufund-ui/src/app/components/cupboard/cupboard.component.ts
index 53dad8a..409cf6c 100644
--- a/ufund-ui/src/app/components/cupboard/cupboard.component.ts
+++ b/ufund-ui/src/app/components/cupboard/cupboard.component.ts
@@ -1,7 +1,8 @@
import { Component, OnInit } from '@angular/core';
import { CupboardService } from '../../services/cupboard.service';
import { NeedListComponent } from '../need-list/need-list.component';
-
+import { HttpClient } from '@angular/common/http';
+import { FormsModule } from '@angular/forms';
import { Need, GoalType } from '../../models/Need';
@Component({
@@ -12,20 +13,27 @@ import { Need, GoalType } from '../../models/Need';
})
export class CupboardComponent implements
OnInit {
+ need: Need = {
+ id: 0,
+ name: '',
+ maxGoal: 0,
+ type: GoalType.MONETARY,
+ filterAttributes: [],
+ current: 0
+ };
- constructor(private cupboardService: CupboardService){}
- ngOnInit() {
-
-
+
+ constructor(private cupboardService: CupboardService, private http: HttpClient) { }
+ ngOnInit(): void {
+ console.log('CupboardComponent.ngOnInit');
}
- need!: Need;
- submit(name: string, id: number, maxGoal: number, type: string) {
- if (this.need) {
- this.need.name = name;
- this.need.id = id;
- this.need.maxGoal = maxGoal;
- console.log(type);
- this.cupboardService.createNeed(this.need);
- }
+
+ submit(form: any) {
+ console.log(form);
+ this.need.name = form.name;
+ this.need.id = form.id;
+ this.need.maxGoal = form.maxGoal;
+ this.need.type = GoalType[form.type as keyof typeof GoalType];
+ console.log(this.cupboardService.createNeed(this.need));
}
}