aboutsummaryrefslogtreecommitdiff
path: root/ufund-ui/src/app/components/dashboard/dashboard.component.ts
diff options
context:
space:
mode:
authorGunther6070 <haydenhartman10@yahoo.com>2025-04-01 07:47:16 -0400
committerGunther6070 <haydenhartman10@yahoo.com>2025-04-01 07:47:16 -0400
commitd8330f1ac85b26d08ca4df5ce3875078d7b4f47f (patch)
tree2046e58c146097aac21c9e352771420c31df6589 /ufund-ui/src/app/components/dashboard/dashboard.component.ts
parentbc9d3417795d841b4cb3e9fb022f8d61448af946 (diff)
parent233fe120d2a9b30e0150401ebdfeb946dc9c2c07 (diff)
downloadJellySolutions-d8330f1ac85b26d08ca4df5ce3875078d7b4f47f.tar.gz
JellySolutions-d8330f1ac85b26d08ca4df5ce3875078d7b4f47f.tar.bz2
JellySolutions-d8330f1ac85b26d08ca4df5ce3875078d7b4f47f.zip
Merge branch 'main' of https://github.com/RIT-SWEN-261-02/team-project-2245-swen-261-02-2b
Diffstat (limited to 'ufund-ui/src/app/components/dashboard/dashboard.component.ts')
-rw-r--r--ufund-ui/src/app/components/dashboard/dashboard.component.ts36
1 files changed, 30 insertions, 6 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..c94b5c6 100644
--- a/ufund-ui/src/app/components/dashboard/dashboard.component.ts
+++ b/ufund-ui/src/app/components/dashboard/dashboard.component.ts
@@ -1,6 +1,10 @@
-import {Component} from '@angular/core';
-import {userType} from '../../models/User';
+import {Component, OnInit} from '@angular/core';
import {AuthService} from '../../services/auth.service';
+import {Router} from '@angular/router';
+import {Need} from '../../models/Need';
+import {CupboardService} from '../../services/cupboard.service';
+import {firstValueFrom} from 'rxjs';
+import {UsersService} from '../../services/users.service';
@Component({
selector: 'app-dashboard',
@@ -8,14 +12,34 @@ 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,
+ protected userService: UsersService
) {}
- isManager() {
- const type = this.authService.getCurrentUser()?.type;
- return type === ("MANAGER" as unknown as userType);
+ ngOnInit() {
+ let user = this.authService.getCurrentUser()
+ if(!localStorage.getItem("credential") && !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.userService.getBasket().subscribe(r => {
+ this.inBasket = r;
+ })
}
}