Compare commits
2 Commits
develop
...
01848b3920
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
01848b3920 | ||
|
|
a7e099b9db |
@@ -13,7 +13,7 @@ import {NgStyle} from "@angular/common";
|
|||||||
})
|
})
|
||||||
export class InfoCard {
|
export class InfoCard {
|
||||||
icon = input.required<string>()
|
icon = input.required<string>()
|
||||||
value = input.required<string>()
|
value = input.required<number>()
|
||||||
description = input.required<string>()
|
description = input.required<string>()
|
||||||
color = input.required<string>()
|
color = input.required<string>()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
<div class="flex gap-17 ml-20">
|
<div class="flex gap-17 ml-20">
|
||||||
<app-info-card color="#f59e0b" icon="inbox" value="15" description="Produits sous le seuil minimal."></app-info-card>
|
<app-info-card color="#f59e0b" icon="inbox" [value]="productsUnderLimitCount()" description="Produits sous le seuil minimal."></app-info-card>
|
||||||
<app-info-card color="#3b82f6" icon="team" value="56" description="Partenaires actifs."></app-info-card>
|
<app-info-card color="#3b82f6" icon="team" [value]="deliversCount()+suppliersCount()" description="Partenaires actifs."></app-info-card>
|
||||||
<app-info-card color="#10b981" icon="truck" value="8" description="Livreurs partenaires."></app-info-card>
|
<app-info-card color="#10b981" icon="truck" [value]=deliversCount() description="Livreurs partenaires."></app-info-card>
|
||||||
<app-info-card color="#ef4444" icon="shop" value="48" description="Fournisseurs travaillant avec nous."></app-info-card>
|
<app-info-card color="#ef4444" icon="shop" [value]="suppliersCount()" description="Fournisseurs travaillant avec nous."></app-info-card>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mt-10 flex gap-30">
|
<div class="mt-10 flex gap-30">
|
||||||
|
|||||||
@@ -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 {InfoCard} from "../../components/info-card/info-card";
|
||||||
import {DeliveryValidator} from "../../components/delivery-validator/delivery-validator";
|
import {DeliveryValidator} from "../../components/delivery-validator/delivery-validator";
|
||||||
import {InfoTable} from "../../components/info-table/info-table";
|
import {InfoTable} from "../../components/info-table/info-table";
|
||||||
|
import {DeliverersService, ProductsService, SuppliersService} from "../../services/api";
|
||||||
|
import {firstValueFrom} from "rxjs";
|
||||||
|
import {NzNotificationService} from "ng-zorro-antd/notification";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-welcome',
|
selector: 'app-welcome',
|
||||||
@@ -14,6 +17,55 @@ import {InfoTable} from "../../components/info-table/info-table";
|
|||||||
styleUrl: './welcome.css'
|
styleUrl: './welcome.css'
|
||||||
})
|
})
|
||||||
|
|
||||||
export class Welcome {
|
export class Welcome implements OnInit {
|
||||||
|
private productsService = inject(ProductsService);
|
||||||
|
private deliverersService = inject(DeliverersService);
|
||||||
|
private suppliersService = inject(SuppliersService);
|
||||||
|
private notificationsService = inject(NzNotificationService);
|
||||||
|
|
||||||
|
deliversCount = signal<number>(0);
|
||||||
|
suppliersCount = signal<number>(0);
|
||||||
|
productsUnderLimitCount = signal<number>(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 getProductsUnderLimit(){
|
||||||
|
try{
|
||||||
|
const products = await firstValueFrom(this.productsService.getAllProductsUnderLimitEndpoint());
|
||||||
|
this.productsUnderLimitCount.set(products.length);
|
||||||
|
}catch(e){
|
||||||
|
this.notificationsService.error(
|
||||||
|
'Error',
|
||||||
|
'Error while getting products.',
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async ngOnInit() {
|
||||||
|
await this.getDeliverers();
|
||||||
|
await this.getSuppliers();
|
||||||
|
await this.getProductsUnderLimit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -142,6 +142,56 @@ export class ProductsService extends BaseService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @endpoint get /API/products/underLimit
|
||||||
|
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
|
||||||
|
* @param reportProgress flag to report request and response progress.
|
||||||
|
*/
|
||||||
|
public getAllProductsUnderLimitEndpoint(observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<Array<GetProductDto>>;
|
||||||
|
public getAllProductsUnderLimitEndpoint(observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<Array<GetProductDto>>>;
|
||||||
|
public getAllProductsUnderLimitEndpoint(observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<Array<GetProductDto>>>;
|
||||||
|
public getAllProductsUnderLimitEndpoint(observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {
|
||||||
|
|
||||||
|
let localVarHeaders = this.defaultHeaders;
|
||||||
|
|
||||||
|
const localVarHttpHeaderAcceptSelected: string | undefined = options?.httpHeaderAccept ?? this.configuration.selectHeaderAccept([
|
||||||
|
'application/json'
|
||||||
|
]);
|
||||||
|
if (localVarHttpHeaderAcceptSelected !== undefined) {
|
||||||
|
localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
|
||||||
|
}
|
||||||
|
|
||||||
|
const localVarHttpContext: HttpContext = options?.context ?? new HttpContext();
|
||||||
|
|
||||||
|
const localVarTransferCache: boolean = options?.transferCache ?? true;
|
||||||
|
|
||||||
|
|
||||||
|
let responseType_: 'text' | 'json' | 'blob' = 'json';
|
||||||
|
if (localVarHttpHeaderAcceptSelected) {
|
||||||
|
if (localVarHttpHeaderAcceptSelected.startsWith('text')) {
|
||||||
|
responseType_ = 'text';
|
||||||
|
} else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) {
|
||||||
|
responseType_ = 'json';
|
||||||
|
} else {
|
||||||
|
responseType_ = 'blob';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let localVarPath = `/API/products/underLimit`;
|
||||||
|
const { basePath, withCredentials } = this.configuration;
|
||||||
|
return this.httpClient.request<Array<GetProductDto>>('get', `${basePath}${localVarPath}`,
|
||||||
|
{
|
||||||
|
context: localVarHttpContext,
|
||||||
|
responseType: <any>responseType_,
|
||||||
|
...(withCredentials ? { withCredentials } : {}),
|
||||||
|
headers: localVarHeaders,
|
||||||
|
observe: observe,
|
||||||
|
...(localVarTransferCache !== undefined ? { transferCache: localVarTransferCache } : {}),
|
||||||
|
reportProgress: reportProgress
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @endpoint get /API/products/{id}
|
* @endpoint get /API/products/{id}
|
||||||
* @param id
|
* @param id
|
||||||
|
|||||||
Reference in New Issue
Block a user