aboutsummaryrefslogtreecommitdiff
path: root/ufund-ui/src/app/components/dashboard/dashboard.component.ts
diff options
context:
space:
mode:
authorGunther6070 <haydenhartman10@yahoo.com>2025-04-03 13:00:38 -0400
committerGunther6070 <haydenhartman10@yahoo.com>2025-04-03 13:00:38 -0400
commit2423f4ee67e7e9079e12ecde51326472308cf22f (patch)
tree6dc7b364a4a59560b1628f2e548856e3c3b147d6 /ufund-ui/src/app/components/dashboard/dashboard.component.ts
parent84cb4b31da27c0db49b933a56a1de563121ceb60 (diff)
downloadJellySolutions-2423f4ee67e7e9079e12ecde51326472308cf22f.tar.gz
JellySolutions-2423f4ee67e7e9079e12ecde51326472308cf22f.tar.bz2
JellySolutions-2423f4ee67e7e9079e12ecde51326472308cf22f.zip
Added fulfilled needs list dashboard
Diffstat (limited to 'ufund-ui/src/app/components/dashboard/dashboard.component.ts')
-rw-r--r--ufund-ui/src/app/components/dashboard/dashboard.component.ts12
1 files changed, 5 insertions, 7 deletions
diff --git a/ufund-ui/src/app/components/dashboard/dashboard.component.ts b/ufund-ui/src/app/components/dashboard/dashboard.component.ts
index 8c397ff..9bf7627 100644
--- a/ufund-ui/src/app/components/dashboard/dashboard.component.ts
+++ b/ufund-ui/src/app/components/dashboard/dashboard.component.ts
@@ -16,7 +16,8 @@ export class DashboardComponent implements OnInit{
protected count = new BehaviorSubject<number | undefined>(undefined)
protected totalDonations = new BehaviorSubject<number | undefined>(undefined)
- protected fulfilledNeeds = new BehaviorSubject<number | undefined>(undefined)
+ protected totalNeeds = new BehaviorSubject<number | undefined>(undefined)
+ protected fulfilledNeeds = new BehaviorSubject<Need[] | undefined>(undefined)
protected mostFulfilledNeeds = new BehaviorSubject<Need[] | undefined>(undefined)
constructor(
@@ -35,22 +36,19 @@ export class DashboardComponent implements OnInit{
this.userService.getCount().subscribe(count => this.count.next(count))
this.cupboardService.getNeeds().subscribe(needs => {
- let fulfilledNeeds = 0
let totalValue = 0
for (let need of needs) {
- let needPercent = need.current / need.maxGoal
- if (needPercent >= 1) {
- fulfilledNeeds++
- this.fulfilledNeeds.next(fulfilledNeeds)
- }
if (need.type === GoalType.MONETARY) {
totalValue += need.current
this.totalDonations.next(totalValue)
}
}
+ this.fulfilledNeeds.next(needs.filter(a => ((a.current / a.maxGoal)) >= 1))
needs.sort((a, b) => b.current/b.maxGoal - a.current/a.maxGoal)
+
needs = needs.filter(a => a.current != 0)
+ this.totalNeeds.next(needs.length)
this.mostFulfilledNeeds.next(needs.slice(0, 5))
})