aboutsummaryrefslogtreecommitdiff
path: root/ufund-ui/src/app/components/dashboard/dashboard.component.ts
diff options
context:
space:
mode:
authorsowgro <tpoke.ferrari@gmail.com>2025-04-07 21:00:53 -0400
committersowgro <tpoke.ferrari@gmail.com>2025-04-07 21:00:53 -0400
commit426b21de0a3f7ee8706b83af4acddb731798be2c (patch)
treeb51bda63a4bbbef158353600a878e8192f7f7952 /ufund-ui/src/app/components/dashboard/dashboard.component.ts
parent71e01e85a33b0109847867878b2af733b4751e46 (diff)
parent7617db08a43d873a65abd47b02e23ad8cb4cb5cd (diff)
downloadJellySolutions-426b21de0a3f7ee8706b83af4acddb731798be2c.tar.gz
JellySolutions-426b21de0a3f7ee8706b83af4acddb731798be2c.tar.bz2
JellySolutions-426b21de0a3f7ee8706b83af4acddb731798be2c.zip
Merge branch 'main' into call-to-action
Diffstat (limited to 'ufund-ui/src/app/components/dashboard/dashboard.component.ts')
-rw-r--r--ufund-ui/src/app/components/dashboard/dashboard.component.ts10
1 files changed, 8 insertions, 2 deletions
diff --git a/ufund-ui/src/app/components/dashboard/dashboard.component.ts b/ufund-ui/src/app/components/dashboard/dashboard.component.ts
index 2ab4db2..b73be44 100644
--- a/ufund-ui/src/app/components/dashboard/dashboard.component.ts
+++ b/ufund-ui/src/app/components/dashboard/dashboard.component.ts
@@ -16,10 +16,11 @@ import {userType} from '../../models/User';
export class DashboardComponent implements OnInit{
protected count = new BehaviorSubject<number | undefined>(undefined)
- protected totalDonations = new BehaviorSubject<number | undefined>(undefined)
+ protected totalDonations = new BehaviorSubject<String | undefined>(undefined)
protected totalNeeds = new BehaviorSubject<number | undefined>(undefined)
protected fulfilledNeeds = new BehaviorSubject<Need[] | undefined>(undefined)
protected mostFulfilledNeeds = new BehaviorSubject<Need[] | undefined>(undefined)
+ protected physicalTotal: string[] = []
constructor(
protected authService: AuthService,
@@ -30,15 +31,20 @@ export class DashboardComponent implements OnInit{
ngOnInit() {
this.userService.getCount().subscribe(count => this.count.next(count))
+ this.physicalTotal = []
this.cupboardService.getNeeds().subscribe(needs => {
let totalValue = 0
for (let need of needs) {
if (need.type === GoalType.MONETARY) {
totalValue += need.current
- this.totalDonations.next(totalValue)
+ this.totalDonations.next(totalValue.toLocaleString())
+ } else {
+ this.physicalTotal.push(need.name + ": " + need.current)
}
}
+
+ this.physicalTotal.sort((a, b) => a < b ? -1 : 1);
this.fulfilledNeeds.next(needs.filter(a => ((a.current / a.maxGoal)) >= 1))
needs.sort((a, b) => b.current/b.maxGoal - a.current/a.maxGoal)