diff options
| author | benal01 <bja4245@rit.edu> | 2025-04-01 09:34:36 -0400 | 
|---|---|---|
| committer | benal01 <bja4245@rit.edu> | 2025-04-01 09:34:36 -0400 | 
| commit | 7ed26c5ee7171a502f6f8527fc55de2bb77eab3b (patch) | |
| tree | 2046e58c146097aac21c9e352771420c31df6589 /ufund-ui/src/app/components/dashboard | |
| parent | ef46ddd082bb91d0262363536d46fe3eb4da47be (diff) | |
| parent | d8330f1ac85b26d08ca4df5ce3875078d7b4f47f (diff) | |
| download | JellySolutions-7ed26c5ee7171a502f6f8527fc55de2bb77eab3b.tar.gz JellySolutions-7ed26c5ee7171a502f6f8527fc55de2bb77eab3b.tar.bz2 JellySolutions-7ed26c5ee7171a502f6f8527fc55de2bb77eab3b.zip  | |
Merge branch 'main' of https://github.com/RIT-SWEN-261-02/team-project-2245-swen-261-02-2b-jellysolutions
Diffstat (limited to 'ufund-ui/src/app/components/dashboard')
3 files changed, 48 insertions, 16 deletions
diff --git a/ufund-ui/src/app/components/dashboard/dashboard.component.css b/ufund-ui/src/app/components/dashboard/dashboard.component.css index e69de29..78a69ba 100644 --- a/ufund-ui/src/app/components/dashboard/dashboard.component.css +++ b/ufund-ui/src/app/components/dashboard/dashboard.component.css @@ -0,0 +1,7 @@ +:host { +    display: flex; +    flex-direction: column; +    width: 1000px; +    align-self: center; +    gap: 20px +} diff --git a/ufund-ui/src/app/components/dashboard/dashboard.component.html b/ufund-ui/src/app/components/dashboard/dashboard.component.html index a1151b7..6a95ecd 100644 --- a/ufund-ui/src/app/components/dashboard/dashboard.component.html +++ b/ufund-ui/src/app/components/dashboard/dashboard.component.html @@ -1,4 +1,5 @@ -<h1>Dashboard</h1> -<app-cupboard></app-cupboard> -<app-funding-basket *ngIf="!isManager()"></app-funding-basket>
\ No newline at end of file +<h1>Your Dashboard</h1> +<app-mini-need-list [needList]="topNeeds" jtitle="Top needs" url="/cupboard"/> +<app-mini-need-list [needList]="almostThere" jtitle="Almost there" url="/cupboard"/> +<app-mini-need-list [needList]="inBasket" jtitle="In your basket" url="/basket"/> diff --git a/ufund-ui/src/app/components/dashboard/dashboard.component.ts b/ufund-ui/src/app/components/dashboard/dashboard.component.ts index b9faefa..c94b5c6 100644 --- a/ufund-ui/src/app/components/dashboard/dashboard.component.ts +++ b/ufund-ui/src/app/components/dashboard/dashboard.component.ts @@ -1,21 +1,45 @@ -import { Component } from '@angular/core'; -import { UsersService } from '../../services/users.service'; -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', -  standalone: false, -  templateUrl: './dashboard.component.html', -  styleUrl: './dashboard.component.css' +    selector: 'app-dashboard', +    standalone: false, +    templateUrl: './dashboard.component.html', +    styleUrl: './dashboard.component.css'  }) -export class DashboardComponent { +export class DashboardComponent implements OnInit{ + +    topNeeds?: Need[] +    almostThere?: Need[] +    inBasket?: Need[] +      constructor( -      protected usersService: UsersService, +        protected authService: AuthService, +        protected router: Router, +        protected cupboardService: CupboardService, +        protected userService: UsersService      ) {} -    isManager() { -        const type = this.usersService.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; +        }) +    }  }  | 
