From a7e099b9db136ff0bbea889bd6706b729884a512 Mon Sep 17 00:00:00 2001 From: Cristiano Date: Thu, 11 Dec 2025 16:26:12 +0100 Subject: [PATCH] Real value for deliverer and suppliers count --- src/app/components/info-card/info-card.ts | 2 +- src/app/pages/welcome/welcome.html | 8 ++--- src/app/pages/welcome/welcome.ts | 40 +++++++++++++++++++++-- 3 files changed, 43 insertions(+), 7 deletions(-) diff --git a/src/app/components/info-card/info-card.ts b/src/app/components/info-card/info-card.ts index 7a2c8d7..db24377 100644 --- a/src/app/components/info-card/info-card.ts +++ b/src/app/components/info-card/info-card.ts @@ -13,7 +13,7 @@ import {NgStyle} from "@angular/common"; }) export class InfoCard { icon = input.required() - value = input.required() + value = input.required() description = input.required() color = input.required() } diff --git a/src/app/pages/welcome/welcome.html b/src/app/pages/welcome/welcome.html index 9155041..f416acc 100644 --- a/src/app/pages/welcome/welcome.html +++ b/src/app/pages/welcome/welcome.html @@ -1,8 +1,8 @@
- - - - + + + +
diff --git a/src/app/pages/welcome/welcome.ts b/src/app/pages/welcome/welcome.ts index 8d152d6..6632ec5 100644 --- a/src/app/pages/welcome/welcome.ts +++ b/src/app/pages/welcome/welcome.ts @@ -1,7 +1,10 @@ -import { Component } from '@angular/core'; +import {Component, inject, OnInit, signal} from '@angular/core'; import {InfoCard} from "../../components/info-card/info-card"; import {DeliveryValidator} from "../../components/delivery-validator/delivery-validator"; import {InfoTable} from "../../components/info-table/info-table"; +import {DeliverersService, SuppliersService} from "../../services/api"; +import {firstValueFrom} from "rxjs"; +import {NzNotificationService} from "ng-zorro-antd/notification"; @Component({ selector: 'app-welcome', @@ -14,6 +17,39 @@ import {InfoTable} from "../../components/info-table/info-table"; styleUrl: './welcome.css' }) -export class Welcome { +export class Welcome implements OnInit { + private deliverersService = inject(DeliverersService); + private suppliersService = inject(SuppliersService); + private notificationsService = inject(NzNotificationService); + deliversCount = signal(0); + suppliersCount = signal(0); + + async getDeliverers() { + try{ + const deliverers = await firstValueFrom(this.deliverersService.getAllDelivererEndpoint()); + this.deliversCount.set(deliverers.length); + }catch(e){ + this.notificationsService.error( + 'Error', + 'Error while getting deliverers.', + ) + } + } + + async getSuppliers() { + try{ + const suppliers = await firstValueFrom(this.suppliersService.getAllSuppliersEndpoint()); + this.suppliersCount.set(suppliers.length); + }catch(e){ + this.notificationsService.error( + 'Error', + 'Error while getting suppliers.', + ) + } + } + async ngOnInit() { + await this.getDeliverers(); + await this.getSuppliers(); + } }