From 02858a9af74b5f564b882adf38391dd3a1f5126c Mon Sep 17 00:00:00 2001 From: benal01 Date: Tue, 18 Mar 2025 00:01:16 -0400 Subject: add need to basket --- .../app/components/need-list/need-list.component.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'ufund-ui/src/app/components/need-list/need-list.component.ts') 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 b21979f..953904c 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 @@ -96,6 +96,25 @@ export class NeedListComponent { return type === ("MANAGER" as unknown as userType); } + isHelper() { + const type = this.usersService.getCurrentUser()?.type; + console.log(type); + return type === ("HELPER" as unknown as userType); + } + + add(need: Need) { + const currentUser = this.usersService.getCurrentUser(); + if (currentUser) { + this.usersService.updateUser(currentUser.username).subscribe(() => { + const currentUser = this.usersService.getCurrentUser(); + if (currentUser && currentUser.basket) { + currentUser.basket.push(need); + } + }); + } + + } + back() { this.searchResults = []; } -- cgit v1.2.3 From 67ef92fbde4ab5cbe10bb9ad8556087b6d60e8ca Mon Sep 17 00:00:00 2001 From: benal01 Date: Tue, 18 Mar 2025 00:24:21 -0400 Subject: logging error handling --- ufund-ui/src/app/components/need-list/need-list.component.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'ufund-ui/src/app/components/need-list/need-list.component.ts') 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 953904c..0afa79e 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 @@ -98,7 +98,6 @@ export class NeedListComponent { isHelper() { const type = this.usersService.getCurrentUser()?.type; - console.log(type); return type === ("HELPER" as unknown as userType); } @@ -109,8 +108,13 @@ export class NeedListComponent { const currentUser = this.usersService.getCurrentUser(); if (currentUser && currentUser.basket) { currentUser.basket.push(need); + console.log("added to basket"); + } + error: (err: any) => { + console.error(err); } }); + } } -- cgit v1.2.3 From 3564917a539bc5bba7e149b8c157e0bd633be23e Mon Sep 17 00:00:00 2001 From: sowgro Date: Tue, 18 Mar 2025 00:24:42 -0400 Subject: Fix problem in userService --- ufund-ui/src/app/components/need-list/need-list.component.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'ufund-ui/src/app/components/need-list/need-list.component.ts') 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 953904c..34e849d 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 @@ -105,14 +105,14 @@ export class NeedListComponent { add(need: Need) { const currentUser = this.usersService.getCurrentUser(); if (currentUser) { - this.usersService.updateUser(currentUser.username).subscribe(() => { + this.usersService.updateUser(currentUser.username, currentUser).subscribe(() => { const currentUser = this.usersService.getCurrentUser(); if (currentUser && currentUser.basket) { currentUser.basket.push(need); } }); } - + } back() { -- cgit v1.2.3 From a5b811ab467a2225aa316be0e62f661fad2080d2 Mon Sep 17 00:00:00 2001 From: benal01 Date: Tue, 18 Mar 2025 00:41:05 -0400 Subject: hide search form on open --- ufund-ui/src/app/components/need-list/need-list.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ufund-ui/src/app/components/need-list/need-list.component.ts') 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 fb09632..0e808dc 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 @@ -24,7 +24,7 @@ export class NeedListComponent { ngOnInit(): void { this.refresh() - // this.close(); + this.close(); } private showElement(element: any) { -- cgit v1.2.3 From b9d7dc1cf8962978652e5814e6a5c936d4ff9b61 Mon Sep 17 00:00:00 2001 From: sowgro Date: Tue, 18 Mar 2025 01:13:04 -0400 Subject: push changes so far --- ufund-ui/src/app/components/need-list/need-list.component.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'ufund-ui/src/app/components/need-list/need-list.component.ts') 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 0e808dc..5bb3887 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 @@ -101,7 +101,7 @@ export class NeedListComponent { return type === ("HELPER" as unknown as userType); } - add(need: Need) { + add(need: number) { const currentUser = this.usersService.getCurrentUser(); if (currentUser) { this.usersService.updateUser(currentUser.username, currentUser).subscribe(() => { @@ -114,7 +114,7 @@ export class NeedListComponent { console.error(err); } }); - + } } -- cgit v1.2.3