aboutsummaryrefslogtreecommitdiff
path: root/ufund-ui/src/app/components/dashboard/dashboard.component.ts
diff options
context:
space:
mode:
authorsowgro <tpoke.ferrari@gmail.com>2025-03-28 21:37:28 -0400
committersowgro <tpoke.ferrari@gmail.com>2025-03-28 21:37:28 -0400
commite1eb3f16e10042c2539b56d6c2d2e33f07abf7d9 (patch)
tree921b54a870974a30612b8b079bdfd55570326f42 /ufund-ui/src/app/components/dashboard/dashboard.component.ts
parentfb4e2bc3eb66ca861eb8393ade21811e4510669a (diff)
downloadJellySolutions-e1eb3f16e10042c2539b56d6c2d2e33f07abf7d9.tar.gz
JellySolutions-e1eb3f16e10042c2539b56d6c2d2e33f07abf7d9.tar.bz2
JellySolutions-e1eb3f16e10042c2539b56d6c2d2e33f07abf7d9.zip
Implement new dashboard and mini-need-list
Diffstat (limited to '')
-rw-r--r--ufund-ui/src/app/components/dashboard/dashboard.component.ts31
1 files changed, 26 insertions, 5 deletions
diff --git a/ufund-ui/src/app/components/dashboard/dashboard.component.ts b/ufund-ui/src/app/components/dashboard/dashboard.component.ts
index a0ad566..165c7ba 100644
--- a/ufund-ui/src/app/components/dashboard/dashboard.component.ts
+++ b/ufund-ui/src/app/components/dashboard/dashboard.component.ts
@@ -1,6 +1,11 @@
-import {Component} from '@angular/core';
+import {Component, OnInit} from '@angular/core';
import {userType} from '../../models/User';
import {AuthService} from '../../services/auth.service';
+import {Router} from '@angular/router';
+import {Need} from '../../models/Need';
+import {CupboardService} from '../../services/cupboard.service';
+import {UsersService} from '../../services/users.service';
+import {firstValueFrom} from 'rxjs';
@Component({
selector: 'app-dashboard',
@@ -8,14 +13,30 @@ import {AuthService} from '../../services/auth.service';
templateUrl: './dashboard.component.html',
styleUrl: './dashboard.component.css'
})
-export class DashboardComponent {
+export class DashboardComponent implements OnInit{
+
+ topNeeds?: Need[]
+ almostThere?: Need[]
+ inBasket?: Need[]
+
constructor(
protected authService: AuthService,
+ protected router: Router,
+ protected cupboardService: CupboardService
) {}
- isManager() {
- const type = this.authService.getCurrentUser()?.type;
- return type === ("MANAGER" as unknown as userType);
+ ngOnInit() {
+ let user = this.authService.getCurrentUser()
+ if(!user) {
+ this.router.navigate(['/login'])
+ return
+ }
+
+ firstValueFrom(this.cupboardService.getNeeds()).then(r => {
+ this.topNeeds = r.sort((a, b) => b.current - a.current)
+ this.almostThere = r.sort((a, b) => a.current/a.maxGoal - b.current/b.maxGoal)
+ this.inBasket = r.filter(n => n.id in user?.basket)
+ })
}
}