aboutsummaryrefslogtreecommitdiff
path: root/ufund-ui/src/app/components/need-list
diff options
context:
space:
mode:
Diffstat (limited to 'ufund-ui/src/app/components/need-list')
-rw-r--r--ufund-ui/src/app/components/need-list/need-list.component.html2
-rw-r--r--ufund-ui/src/app/components/need-list/need-list.component.ts23
2 files changed, 25 insertions, 0 deletions
diff --git a/ufund-ui/src/app/components/need-list/need-list.component.html b/ufund-ui/src/app/components/need-list/need-list.component.html
index 07f6735..4a67dfa 100644
--- a/ufund-ui/src/app/components/need-list/need-list.component.html
+++ b/ufund-ui/src/app/components/need-list/need-list.component.html
@@ -14,6 +14,7 @@
{{need.name}}
</a>
<button (click)="delete(need.id)" *ngIf="isManager()">Delete</button>
+ <!-- <button (click)="add(need)" *ngIf="isHelper()">Add To Basket</button> -->
</div>
</div>
</div>
@@ -23,4 +24,5 @@
{{need.name}}
</a>
<button (click)="delete(need.id)" *ngIf="isManager()">Delete</button>
+ <!-- <button (click)="add(need)" *ngIf="isHelper()">Add To Basket</button> -->
</li>
diff --git a/ufund-ui/src/app/components/need-list/need-list.component.ts b/ufund-ui/src/app/components/need-list/need-list.component.ts
index fc2a594..e1c0de1 100644
--- a/ufund-ui/src/app/components/need-list/need-list.component.ts
+++ b/ufund-ui/src/app/components/need-list/need-list.component.ts
@@ -100,6 +100,29 @@ export class NeedListComponent {
return type === ("MANAGER" as unknown as userType);
}
+ isHelper() {
+ const type = this.usersService.getCurrentUser()?.type;
+ return type === ("HELPER" as unknown as userType);
+ }
+
+ add(need: number) {
+ const currentUser = this.usersService.getCurrentUser();
+ if (currentUser) {
+ this.usersService.updateUser(currentUser.username, currentUser).subscribe(() => {
+ const currentUser = this.usersService.getCurrentUser();
+ if (currentUser && currentUser.basket) {
+ currentUser.basket.push(need);
+ console.log("added to basket");
+ }
+ error: (err: any) => {
+ console.error(err);
+ }
+ });
+
+ }
+
+ }
+
back() {
this.searchResults = [];
}