Added automatic generation in dashboard when employees start application to generate product under limit during absence
This commit is contained in:
@@ -2,8 +2,9 @@ import {Component, inject, signal} from '@angular/core';
|
||||
import {InfoCard} from "../../components/info-card/info-card";
|
||||
import {DeliveryValidator} from "../../components/delivery-validator/delivery-validator";
|
||||
import {NzNotificationService} from "ng-zorro-antd/notification";
|
||||
import {DeliverersService, ProductsService, SuppliersService} from "../../services/api";
|
||||
import {DeliverersService, GetSupplierDto, ProductsService, SuppliersService} from "../../services/api";
|
||||
import {firstValueFrom} from "rxjs";
|
||||
import {StockAlert} from "../../services/stock.alert";
|
||||
|
||||
@Component({
|
||||
selector: 'app-welcome',
|
||||
@@ -20,32 +21,29 @@ export class Welcome {
|
||||
private deliverersService = inject(DeliverersService);
|
||||
private suppliersService = inject(SuppliersService);
|
||||
private notificationsService = inject(NzNotificationService);
|
||||
private stockAlertService = inject(StockAlert);
|
||||
|
||||
deliversCount = signal<number>(0);
|
||||
suppliersCount = signal<number>(0);
|
||||
productsUnderLimitCount = signal<number>(0);
|
||||
suppliers = signal<GetSupplierDto[]>([]);
|
||||
|
||||
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.',
|
||||
)
|
||||
this.notificationsService.error('Error', 'Error while getting deliverers.');
|
||||
}
|
||||
}
|
||||
|
||||
async getSuppliers() {
|
||||
try {
|
||||
const suppliers = await firstValueFrom(this.suppliersService.getAllSuppliersEndpoint());
|
||||
this.suppliers.set(suppliers);
|
||||
this.suppliersCount.set(suppliers.length);
|
||||
} catch (e) {
|
||||
this.notificationsService.error(
|
||||
'Error',
|
||||
'Error while getting suppliers.',
|
||||
)
|
||||
} catch {
|
||||
this.notificationsService.error('Error', 'Error while getting suppliers.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,6 +51,7 @@ export class Welcome {
|
||||
try {
|
||||
const products = await firstValueFrom(this.productsService.getAllProductsUnderLimitEndpoint());
|
||||
this.productsUnderLimitCount.set(products.length);
|
||||
await this.stockAlertService.generatePurchaseOrder(products, this.suppliers());
|
||||
} catch (e) {
|
||||
this.notificationsService.error(
|
||||
'Error',
|
||||
|
||||
Reference in New Issue
Block a user