2 Commits

Author SHA1 Message Date
Cristiano
01848b3920 Real value for products under limit 2025-12-11 17:49:32 +01:00
Cristiano
a7e099b9db Real value for deliverer and suppliers count 2025-12-11 16:26:12 +01:00
21 changed files with 152 additions and 173 deletions

View File

@@ -1,11 +1,11 @@
import {Component, effect, inject, input, OnInit, signal} from '@angular/core';
import {Component, inject, signal} from '@angular/core';
import {FormControl, FormGroup, ReactiveFormsModule, Validators} from "@angular/forms";
import {NzFormControlComponent, NzFormDirective, NzFormItemComponent, NzFormLabelComponent} from "ng-zorro-antd/form";
import {NzColDirective} from "ng-zorro-antd/grid";
import {NzFlexDirective} from "ng-zorro-antd/flex";
import {NzDatePickerComponent} from "ng-zorro-antd/date-picker";
import {NzOptionComponent, NzSelectComponent} from "ng-zorro-antd/select";
import {DeliverersService, GetDelivererDto, GetDeliveryNoteDto} from "../../services/api";
import {DeliverersService, GetDelivererDto} from "../../services/api";
import {NzNotificationService} from "ng-zorro-antd/notification";
import {firstValueFrom} from "rxjs";
@@ -21,14 +21,13 @@ import {firstValueFrom} from "rxjs";
ReactiveFormsModule,
NzDatePickerComponent,
NzSelectComponent,
NzOptionComponent,
NzOptionComponent
],
templateUrl: './deliverery-note-form.html',
styleUrl: './deliverery-note-form.css',
})
export class DelivereryNoteForm implements OnInit {
export class DelivereryNoteForm {
deliveryNoteForm: FormGroup = new FormGroup({
trackingNumber: new FormControl<string>("TRK-" + Date.now),
deliverer: new FormControl<string>(null,[Validators.required]),
expeditionDate: new FormControl(null,[Validators.required]),
estimatedDate: new FormControl(null),
@@ -55,20 +54,4 @@ export class DelivereryNoteForm implements OnInit {
filter(input: string, option: any) {
return option.nzLabel.toLowerCase().includes(input.toLowerCase());
}
deliveryNote= input<GetDeliveryNoteDto>();
constructor() {
effect(() => {
if (this.deliveryNote()) {
this.deliveryNoteForm.patchValue({
trackingNumber: this.deliveryNote().trackingNumber,
expeditionDate: this.deliveryNote().expeditionDate,
realDeliveryDate: this.deliveryNote().expeditionDate,
estimatedDate: this.deliveryNote().expeditionDate,
deliverer: this.deliveryNote().delivererId
});
}
});
}
}

View File

@@ -48,22 +48,24 @@
</td>
<td>
<div style="justify-content: center; display: flex">
<nz-icon nzType="check" nzTheme="outline" (click)="validate(deliveryNote.id)" class="cursor-pointer text-green-700"/>
<div>
<nz-icon nzType="check" nzTheme="outline" (click)="validate(deliveryNote.id)" class="cursor-pointer text-green-700"/>
</div>
<nz-divider nzType="vertical"></nz-divider>
<nz-icon nzType="edit" nzTheme="outline" class="cursor-pointer" (click)="openEditModal(deliveryNote)"></nz-icon>
<app-modal-nav nameIcon="edit" name="Modification du bon de livraison" class="cursor-pointer">
<app-deliverery-note-form></app-deliverery-note-form>
</app-modal-nav>
<nz-divider nzType="vertical"></nz-divider>
<nz-icon nzType="delete" nzTheme="outline" (click)="delete(deliveryNote.id)" class="cursor-pointer text-red-700"/>
<div>
<nz-icon nzType="delete" nzTheme="outline" (click)="delete(deliveryNote.id)" class="cursor-pointer text-red-700"/>
</div>
<nz-divider nzType="vertical"></nz-divider>
<nz-icon nzType="export" nzTheme="outline" (click)="export(deliveryNote.id)" class="cursor-pointer text-green-700"/>
<div>
<nz-icon nzType="export" nzTheme="outline" (click)="export(deliveryNote.id)" class="cursor-pointer text-green-700"/>
</div>
</div>
</td>
</tr>
}
</tbody>
</nz-table>
<div class="hidden">
<app-modal-nav #modalNav nameIcon="edit" [name]="'Modifier un bon de livraison'" (ok)="onModalOk(selectedDeliveryNote.id, deliveryNoteForm, modalNav)" (cancel)="onModalCancel(modalNav)">
<app-deliverery-note-form #deliveryNoteForm [deliveryNote]="selectedDeliveryNote"></app-deliverery-note-form>
</app-modal-nav>
</div>

View File

@@ -1,4 +1,4 @@
import {Component, inject, OnInit, signal, viewChild} from '@angular/core';
import {Component, inject, OnInit, signal} from '@angular/core';
import {DatePipe} from "@angular/common";
import {ModalButton} from "../modal-button/modal-button";
import {ModalNav} from "../modal-nav/modal-nav";
@@ -32,7 +32,6 @@ export class DelivereryNoteTable implements OnInit {
private fileService = inject(FileService);
deliveryNotes = signal<GetDeliveryNoteDto[]>([]);
deliveryNotesLoading = signal<boolean>(false);
modal = viewChild.required<ModalNav>('modalNav');
async ngOnInit() {
await this.fetchDeliveryNotes();
@@ -108,6 +107,7 @@ export class DelivereryNoteTable implements OnInit {
);
this.fileService.downloadBlob(pdf)
} catch (e) {
console.error(e);
this.notificationService.error(
'Erreur',
'Impossible de générer un PDF'
@@ -115,51 +115,4 @@ export class DelivereryNoteTable implements OnInit {
}
this.deliveryNotesLoading.set(false)
}
selectedDeliveryNote: GetDeliveryNoteDto | null = null;
openEditModal(deliveryNote: GetDeliveryNoteDto) {
this.selectedDeliveryNote = { ...deliveryNote };
this.modal().showModal();
}
async onModalOk(id: number, updateDelivereryNoteComponent: DelivereryNoteForm, modal: ModalNav) {
if (!this.selectedDeliveryNote) return;
await this.edit(id, updateDelivereryNoteComponent);
updateDelivereryNoteComponent.deliveryNoteForm.reset();
modal.isVisible = false;
await this.fetchDeliveryNotes();
}
onModalCancel(modal: ModalNav) {
modal.isVisible = false;
}
async edit(id: number, updateDelivereryNoteComponent: DelivereryNoteForm) {
if (updateDelivereryNoteComponent.deliveryNoteForm.invalid) {
this.notificationService.error(
'Erreur',
'Erreur d\'écriture dans le formulaire'
)
return;
}
try {
const deliveryNotes = updateDelivereryNoteComponent.deliveryNoteForm.getRawValue();
await firstValueFrom(this.deliveryNotesService.updateDeliveryNoteEndpoint(id, deliveryNotes))
this.notificationService.success(
'Success',
'Bon de livraison modifié'
)
} catch (e) {
console.error(e);
this.notificationService.error(
'Erreur',
'Erreur lors de la modification'
)
}
}
}

View File

@@ -13,7 +13,7 @@ import {NgStyle} from "@angular/common";
})
export class InfoCard {
icon = input.required<string>()
value = input.required<string>()
value = input.required<number>()
description = input.required<string>()
color = input.required<string>()
}

View File

@@ -1,9 +1,9 @@
<form nz-form nzLayout="horizontal" [formGroup]="searchForm">
<form nz-form nzLayout="horizontal" [formGroup]="searchForm" (ngSubmit)="submitForm()">
<nz-form-item nz-flex>
<nz-form-control nzSpan="12">
<div class="group">
<nz-icon nzType="search" nzTheme="outline" class="mr-2 text-xl" (click)="OnSearch()"></nz-icon>
<input class="input" placeholder="Rechercher" formControlName="searchValue" (input)="OnSearch()"/>
<nz-icon nzType="search" nzTheme="outline" class="mr-2 text-xl"></nz-icon>
<input class="input" placeholder="Rechercher" formControlName="searchValue"/>
</div>
</nz-form-control>
</nz-form-item>

View File

@@ -1,4 +1,4 @@
import { Component, output } from '@angular/core';
import { Component } from '@angular/core';
import {NzIconDirective} from "ng-zorro-antd/icon";
import {NzColDirective} from "ng-zorro-antd/grid";
import {NzFlexDirective} from "ng-zorro-antd/flex";
@@ -24,12 +24,14 @@ export class Search {
searchValue: new FormControl<string>(null)
})
searchEvent = output<string>();
submitForm() {
// Pour annuler si le formulaire est invalide
if (this.searchForm.invalid) return;
OnSearch(): void {
const raw = this.searchForm.controls['searchValue'].value ?? '';
const value = String(raw).trim();
this.searchEvent.emit(value);
// Pour obtenir la valeur du formulaire
console.log(this.searchForm.getRawValue())
// Pour vider le formulaire
this.searchForm.reset()
}
}

View File

@@ -1,5 +1,5 @@
<nz-table
[nzData]="filteredProducts()"
[nzData]="products()"
[nzFrontPagination]="false"
[nzLoading]="productsLoading()"
(nzCurrentPageDataChange)="onCurrentPageDataChange($event)"
@@ -27,7 +27,7 @@
</thead>
<tbody class="text-center">
@for (product of filteredProducts(); track product.id) {
@for (product of products(); track product.id) {
<tr>
<td nzWidth="40px">
<label

View File

@@ -1,4 +1,4 @@
import {Component, computed, inject, OnInit, output, signal, viewChild} from '@angular/core';
import {Component, inject, OnInit, output, signal, viewChild} from '@angular/core';
import {NzTableComponent, NzThMeasureDirective} from "ng-zorro-antd/table";
import {ModalNav} from "../modal-nav/modal-nav";
import {NzIconDirective} from "ng-zorro-antd/icon";
@@ -45,22 +45,6 @@ export class StockTable implements OnInit {
selectionChange = output<boolean>()
currentPageData: GetProductDto[] = [];
private searchQuery = signal<string>('');
filteredProducts = computed(() => {
const q = this.searchQuery().toLowerCase().trim();
if (!q) return this.products();
return this.products().filter(s => {
const name = (s.name ?? '').toLowerCase();
return name.includes(q);
});
});
applySearch(query: string) {
this.searchQuery.set(query);
}
get hasSelection(): boolean {
return this.setOfCheckedId.size > 0;
}

View File

@@ -1,4 +1,4 @@
<nz-table [nzData]="filteredSuppliers()"
<nz-table [nzData]="suppliers()"
[nzLoading]="suppliersLoading()"
[nzFrontPagination]="false">
<thead>
@@ -15,7 +15,7 @@
</tr>
</thead>
<tbody style="text-align: center">
@for (supplier of filteredSuppliers(); track supplier.id) {
@for (supplier of suppliers(); track supplier.id) {
<tr>
<td>{{ supplier.name }}</td>
<td>{{ supplier.phone }}</td>
@@ -26,7 +26,7 @@
<td>{{ supplier.deliveryDelay }} jours</td>
<td>
<app-modal-button type="link" [name]="'Voir les produits'" size="45%">
<nz-table [nzData]="filteredSuppliers()" [nzFrontPagination]="false">
<nz-table [nzData]="suppliers()" [nzFrontPagination]="false">
<thead>
<tr class="text-center">
<th>Produit</th>

View File

@@ -1,4 +1,4 @@
import {Component, computed, inject, OnInit, signal, viewChild} from '@angular/core';
import {Component, inject, OnInit, signal, viewChild} from '@angular/core';
import {ModalNav} from "../modal-nav/modal-nav";
import {NzDividerComponent} from "ng-zorro-antd/divider";
import {NzIconDirective} from "ng-zorro-antd/icon";
@@ -42,23 +42,6 @@ export class SupplierTable implements OnInit {
await this.fetchSuppliers();
}
private searchQuery = signal<string>('');
filteredSuppliers = computed(() => {
const q = this.searchQuery().toLowerCase().trim();
if (!q) return this.suppliers();
return this.suppliers().filter(s => {
const name = (s.name ?? '').toLowerCase();
return name.includes(q);
});
});
applySearch(query: string) {
this.searchQuery.set(query);
}
async fetchSuppliers() {
this.suppliersLoading.set(true);
try {

View File

@@ -1,4 +1,4 @@
<nz-table [nzData]="filteredUsers()"
<nz-table [nzData]="users()"
[nzLoading]="usersLoading()"
[nzFrontPagination]="false"
class="mr-7">
@@ -11,7 +11,7 @@
</tr>
</thead>
<tbody class="text-center">
@for (user of filteredUsers(); track user.id) {
@for (user of users(); track user.id) {
<tr>
<td>{{user.name}}</td>
<td>{{user.email}}</td>

View File

@@ -1,4 +1,4 @@
import {Component, computed, inject, OnInit, signal, viewChild} from '@angular/core';
import {Component, inject, OnInit, signal, viewChild} from '@angular/core';
import {ModalNav} from "../modal-nav/modal-nav";
import {NzIconDirective} from "ng-zorro-antd/icon";
import {NzTableComponent} from "ng-zorro-antd/table";
@@ -32,22 +32,6 @@ export class UserTable implements OnInit {
await this.fetchUsers();
}
private searchQuery = signal<string>('');
filteredUsers = computed(() => {
const q = this.searchQuery().toLowerCase().trim();
if (!q) return this.users();
return this.users().filter(s => {
const name = (s.name ?? '').toLowerCase();
return name.includes(q);
});
});
applySearch(query: string) {
this.searchQuery.set(query);
}
async fetchUsers() {
this.usersLoading.set(true)
@@ -121,7 +105,4 @@ export class UserTable implements OnInit {
onModalCancel(modal: ModalNav) {
modal.isVisible = false;
}
filterUser(input: string, option: any) {
return option.nzLabel.toLowerCase().includes(input.toLowerCase());
}
}

View File

@@ -10,8 +10,7 @@
}
<div class="ml-95 w-150">
<app-search (searchEvent)="onProductSearch($event)"></app-search>
<app-search class="w-full"></app-search>
</div>
</div>

View File

@@ -29,9 +29,6 @@ export class Stock {
private productsService = inject(ProductsService);
private notificationService = inject(NzNotificationService)
onProductSearch(query: string) {
this.productTable().applySearch(query);
}
// async onModalOk() {
// await this.addSupplier()
// this.createSupplier().supplierForm.reset();

View File

@@ -8,8 +8,9 @@
<app-supplier-form #supplierForm></app-supplier-form>
</app-modal-button>
<div class="ml-95 w-150">
<app-search (searchEvent)="onSupplierSearch($event)"></app-search>
<app-search></app-search>
</div>
</div>

View File

@@ -36,10 +36,6 @@ export class Supplier {
this.modal().isVisible = false;
}
onSupplierSearch(query: string) {
this.supplierTable().applySearch(query);
}
async addSupplier() {
if (this.createSupplier().supplierForm.invalid)
{

View File

@@ -9,8 +9,7 @@
</app-modal-button>
<div class="ml-95 w-150">
<app-search (searchEvent)="onUserSearch($event)"></app-search>
<app-search></app-search>
</div>
</div>

View File

@@ -32,9 +32,6 @@ export class User {
await this.usersTable().fetchUsers()
}
onUserSearch(query: string) {
this.usersTable().applySearch(query);
}
onModalCancel() {
this.modal().isVisible = false;
}

View File

@@ -1,8 +1,8 @@
<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="#3b82f6" icon="team" value="56" 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="#ef4444" icon="shop" value="48" description="Fournisseurs travaillant avec nous."></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]="deliversCount()+suppliersCount()" description="Partenaires actifs."></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]="suppliersCount()" description="Fournisseurs travaillant avec nous."></app-info-card>
</div>
<div class="mt-10 flex gap-30">

View File

@@ -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, ProductsService, SuppliersService} from "../../services/api";
import {firstValueFrom} from "rxjs";
import {NzNotificationService} from "ng-zorro-antd/notification";
@Component({
selector: 'app-welcome',
@@ -14,6 +17,55 @@ import {InfoTable} from "../../components/info-table/info-table";
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();
}
}

View File

@@ -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}
* @param id