From ea13cf6ab3b71ff5e83fca876ec71fec1f7b00ae Mon Sep 17 00:00:00 2001 From: sowgro Date: Wed, 26 Mar 2025 15:38:46 -0400 Subject: Make frontend work with the new backend checkout system --- .../app/components/dashboard/dashboard.component.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'ufund-ui/src/app/components/dashboard/dashboard.component.ts') diff --git a/ufund-ui/src/app/components/dashboard/dashboard.component.ts b/ufund-ui/src/app/components/dashboard/dashboard.component.ts index b9faefa..a0ad566 100644 --- a/ufund-ui/src/app/components/dashboard/dashboard.component.ts +++ b/ufund-ui/src/app/components/dashboard/dashboard.component.ts @@ -1,21 +1,21 @@ -import { Component } from '@angular/core'; -import { UsersService } from '../../services/users.service'; -import { userType } from '../../models/User'; +import {Component} from '@angular/core'; +import {userType} from '../../models/User'; +import {AuthService} from '../../services/auth.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 { constructor( - protected usersService: UsersService, + protected authService: AuthService, ) {} isManager() { - const type = this.usersService.getCurrentUser()?.type; + const type = this.authService.getCurrentUser()?.type; return type === ("MANAGER" as unknown as userType); - } + } } -- cgit v1.2.3 From e1eb3f16e10042c2539b56d6c2d2e33f07abf7d9 Mon Sep 17 00:00:00 2001 From: sowgro Date: Fri, 28 Mar 2025 21:37:28 -0400 Subject: Implement new dashboard and mini-need-list --- .../components/dashboard/dashboard.component.ts | 31 ++++++++++++++++++---- 1 file changed, 26 insertions(+), 5 deletions(-) (limited to 'ufund-ui/src/app/components/dashboard/dashboard.component.ts') 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) + }) } } -- cgit v1.2.3 From 9f31fea81818dae21f67b23a6004a3ca369f8e0d Mon Sep 17 00:00:00 2001 From: Gunther6070 Date: Mon, 31 Mar 2025 15:09:23 -0400 Subject: Added check to prevent redirect to login page --- ufund-ui/src/app/components/dashboard/dashboard.component.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'ufund-ui/src/app/components/dashboard/dashboard.component.ts') diff --git a/ufund-ui/src/app/components/dashboard/dashboard.component.ts b/ufund-ui/src/app/components/dashboard/dashboard.component.ts index 165c7ba..49d93bf 100644 --- a/ufund-ui/src/app/components/dashboard/dashboard.component.ts +++ b/ufund-ui/src/app/components/dashboard/dashboard.component.ts @@ -27,7 +27,7 @@ export class DashboardComponent implements OnInit{ ngOnInit() { let user = this.authService.getCurrentUser() - if(!user) { + if(!localStorage.getItem("credential") && !user) { this.router.navigate(['/login']) return } @@ -35,7 +35,7 @@ export class DashboardComponent implements OnInit{ 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) + this.inBasket = r.filter(n => n.id in user!.basket) }) } -- cgit v1.2.3 From b07405c2a1817271c84e25bfe62b6b3ff36136f9 Mon Sep 17 00:00:00 2001 From: Gunther6070 Date: Mon, 31 Mar 2025 15:10:52 -0400 Subject: Unused imports --- ufund-ui/src/app/components/dashboard/dashboard.component.ts | 2 -- 1 file changed, 2 deletions(-) (limited to 'ufund-ui/src/app/components/dashboard/dashboard.component.ts') diff --git a/ufund-ui/src/app/components/dashboard/dashboard.component.ts b/ufund-ui/src/app/components/dashboard/dashboard.component.ts index 49d93bf..645893f 100644 --- a/ufund-ui/src/app/components/dashboard/dashboard.component.ts +++ b/ufund-ui/src/app/components/dashboard/dashboard.component.ts @@ -1,10 +1,8 @@ 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({ -- cgit v1.2.3 From 0e9c0803e35a23ef2e873dc7ebf224a49a92f207 Mon Sep 17 00:00:00 2001 From: sowgro Date: Tue, 1 Apr 2025 02:16:04 -0400 Subject: Get everything working enough to go in main --- ufund-ui/src/app/components/dashboard/dashboard.component.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'ufund-ui/src/app/components/dashboard/dashboard.component.ts') diff --git a/ufund-ui/src/app/components/dashboard/dashboard.component.ts b/ufund-ui/src/app/components/dashboard/dashboard.component.ts index 645893f..c94b5c6 100644 --- a/ufund-ui/src/app/components/dashboard/dashboard.component.ts +++ b/ufund-ui/src/app/components/dashboard/dashboard.component.ts @@ -4,6 +4,7 @@ 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', @@ -20,7 +21,8 @@ export class DashboardComponent implements OnInit{ constructor( protected authService: AuthService, protected router: Router, - protected cupboardService: CupboardService + protected cupboardService: CupboardService, + protected userService: UsersService ) {} ngOnInit() { @@ -33,7 +35,10 @@ export class DashboardComponent implements OnInit{ 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) + }) + + this.userService.getBasket().subscribe(r => { + this.inBasket = r; }) } -- cgit v1.2.3