diff --git a/src/app/components/delivery-validator/delivery-validator.html b/src/app/components/delivery-validator/delivery-validator.html index e91d686..fe7be05 100644 --- a/src/app/components/delivery-validator/delivery-validator.html +++ b/src/app/components/delivery-validator/delivery-validator.html @@ -3,18 +3,55 @@ (input)="search.set($any($event.target).value)"/>
- @for (deliveryItem of filteredLivraisons(); track deliveryItem.id) { + @for (deliveryItem of filteredDeliveries(); track deliveryItem.id) {
-

{{ deliveryItem.client }}

-

Date d'expédition: {{ deliveryItem.date }}

-

Produits : {{ deliveryItem.produits }}

+

{{ deliveryItem.delivererTransporter }}

+

Date d'expédition: {{ deliveryItem.expeditionDate }}

+

Quantité livrée : {{ deliveryItem.products.length }}

- + + +
+ + + @for (wareHouse of wareHouses(); track wareHouse.id) { + + } + +
+ + +
+ + + + Réference + Nom + Quantité + + + + @for (product of deliveryItem.products; track product.productId) { + + {{ product.productReference }} + {{ product.productName }} + {{ product.quantity }} + + } + + +
+
}
diff --git a/src/app/components/delivery-validator/delivery-validator.ts b/src/app/components/delivery-validator/delivery-validator.ts index 9b3d9a0..60a40ff 100644 --- a/src/app/components/delivery-validator/delivery-validator.ts +++ b/src/app/components/delivery-validator/delivery-validator.ts @@ -1,44 +1,120 @@ -import {Component, computed, signal} from '@angular/core'; -import {NzButtonComponent, NzButtonSize} from "ng-zorro-antd/button"; -import {NzIconDirective} from "ng-zorro-antd/icon"; +import {Component, computed, inject, OnInit, signal} from '@angular/core'; +import { + DeliverynotesService, + GetDeliveryNoteDto, GetWareHouseDto, + WarehouseproductsService, + WarehousesService +} from "../../services/api"; +import {firstValueFrom} from "rxjs"; +import {NzNotificationService} from "ng-zorro-antd/notification"; +import {NzTableComponent} from "ng-zorro-antd/table"; +import {format} from "date-fns"; +import {ModalNav} from "../modal-nav/modal-nav"; +import {NzOptionComponent, NzSelectComponent} from "ng-zorro-antd/select"; +import {FormsModule} from "@angular/forms"; @Component({ selector: 'app-delivery-validator', imports: [ - NzButtonComponent, - NzIconDirective + NzTableComponent, + ModalNav, + NzSelectComponent, + NzOptionComponent, + FormsModule ], templateUrl: './delivery-validator.html', styleUrl: './delivery-validator.css', }) -export class DeliveryValidator { - size: NzButtonSize = 'large'; - search = signal(''); +export class DeliveryValidator implements OnInit { + private deliveryNotesService = inject(DeliverynotesService); + private notificationService = inject(NzNotificationService); + private warehousesService = inject(WarehousesService); + private warehouseProductsService = inject(WarehouseproductsService); - livraisons = signal([ - {id: 1, client: 'Carrefour', date: '2025-02-03', produits: 12}, - {id: 2, client: 'Intermarché', date: '2025-02-04', produits: 8}, - {id: 3, client: 'Auchan', date: '2025-02-05', produits: 23}, - {id: 1, client: 'Carrefour', date: '2025-02-03', produits: 12}, - {id: 2, client: 'Intermarché', date: '2025-02-04', produits: 8}, - {id: 3, client: 'Auchan', date: '2025-02-05', produits: 23}, - {id: 1, client: 'Carrefour', date: '2025-02-03', produits: 12}, - {id: 2, client: 'Intermarché', date: '2025-02-04', produits: 8}, - {id: 3, client: 'Auchan', date: '2025-02-05', produits: 23}, - {id: 1, client: 'Carrefour', date: '2025-02-03', produits: 12}, - {id: 2, client: 'Intermarché', date: '2025-02-04', produits: 8}, - {id: 3, client: 'Auchan', date: '2025-02-05', produits: 23} - ]); + search = signal(''); + deliveryNotes = signal([]); + wareHouses = signal([]); - filteredLivraisons = computed(() => { + selectedWarehouseId: number | null = null; + + async ngOnInit() { + await this.fetchDeliveryNotes(); + try { + const wareHouses = await firstValueFrom(this.warehousesService.getAllWarehouseEndpoint()); + this.wareHouses.set(wareHouses); + } catch { + this.notificationService.error( + 'Erreur', + 'Erreur de communication avec l\'API' + ) + } + } + + async fetchDeliveryNotes() { + try { + const deliveries = await firstValueFrom(this.deliveryNotesService.getAllDeliveryNotesNotArrivedEndpoint()); + this.deliveryNotes.set(deliveries); + } catch { + this.notificationService.error( + 'Erreur', + 'Erreur de communication avec l\'API' + ) + } + } + + filteredDeliveries = computed(() => { const query = this.search().toLowerCase(); - return this.livraisons().filter(l => - l.client.toLowerCase().includes(query) || - l.date.includes(query) + return this.deliveryNotes().filter(l => + l.delivererTransporter.toLowerCase().includes(query) || + l.expeditionDate.includes(query) ); }); - validate(id: number) { - return + async check(id: number) { + try { + const PatchRealDate = { + realDeliveryDate: format(new Date(), 'yyyy-MM-dd') + }; + await firstValueFrom(this.deliveryNotesService.patchRealDeliveryDateEndpoint(id, PatchRealDate)); + } catch (e) { + this.notificationService.error( + 'Erreur', + 'Erreur de communication avec l\'API', + ) + } + } + + async validate(id: number, warehouseId: number, modal: ModalNav) { + try { + const deliveryNote = this.deliveryNotes().find(x => x.id === id); + + for (const product of deliveryNote.products) { + await firstValueFrom(this.warehouseProductsService.patchWareHouseProductQuantityEndpoint( + product.productId, + warehouseId, + { + quantity: product.quantity + } + )); + } + + this.notificationService.success( + 'Succès', + 'Les produits sont bien ajoutés au stock' + ) + + modal.isVisible = false; + await this.fetchDeliveryNotes(); + } catch { + this.notificationService.error( + 'Erreur', + 'Vous devez choisir un entrepôt', + ) + } + } + + async reject(modal: ModalNav) { + modal.isVisible = false; + await this.fetchDeliveryNotes(); } } diff --git a/src/app/components/info-card/info-card.ts b/src/app/components/info-card/info-card.ts index fb4b354..15b1c20 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/components/info-table/info-table.css b/src/app/components/info-table/info-table.css deleted file mode 100644 index 91012b7..0000000 --- a/src/app/components/info-table/info-table.css +++ /dev/null @@ -1,71 +0,0 @@ -.documents-section { - display: flex; - flex-direction: column; - align-items: flex-start; /* contenu aligné à gauche */ - gap: 16px; /* espace entre le titre et la liste */ - margin: 40px 6%; -} - -/* Titre */ -.documents-section h1 { - font-size: 24px; - font-weight: 700; - color: #111827; - margin: 0; /* on gère l’espace avec le gap */ - letter-spacing: 0.5px; - text-transform: capitalize; - border-left: 4px solid #3b82f6; - padding-left: 12px; -} - -/* Liste de documents scrollable */ -.content { - width: 1000px; - display: flex; - flex-wrap: wrap; - gap: 16px; - padding: 30px 15px; - border-radius: 20px; - box-shadow: 0 4px 8px rgba(0, 0, 0, 0.06), - 0 8px 20px rgba(0, 0, 0, 0.08), - 0 16px 40px rgba(0, 0, 0, 0.06); - max-height: 390px; - overflow-y: auto; -} - -/* Chaque carte */ -.content > div { - display: flex; - flex-direction: column; - align-items: center; - justify-content: center; - width: 120px; - height: 140px; - padding: 12px; - background: #ffffff; - border-radius: 14px; - cursor: pointer; - box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08); - transition: all 0.2s ease; - text-align: center; -} - -.content > div:hover { - transform: translateY(-3px); - box-shadow: 0 10px 22px rgba(0, 0, 0, 0.12); -} - -.content img { - width: 48px; - height: 48px; - margin-bottom: 10px; - object-fit: contain; -} - -.content p { - margin: 0; - font-size: 16px; - font-weight: 600; - color: #111827; - word-break: break-word; -} diff --git a/src/app/components/info-table/info-table.html b/src/app/components/info-table/info-table.html deleted file mode 100644 index 85a991d..0000000 --- a/src/app/components/info-table/info-table.html +++ /dev/null @@ -1,11 +0,0 @@ -
-

Documents récents

-
- @for (doc of purchaseOrder(); track doc.id) { -
- pdf -

{{ doc.name }}

-
- } -
-
\ No newline at end of file diff --git a/src/app/components/info-table/info-table.ts b/src/app/components/info-table/info-table.ts deleted file mode 100644 index a02fc7f..0000000 --- a/src/app/components/info-table/info-table.ts +++ /dev/null @@ -1,44 +0,0 @@ -import {Component} from '@angular/core'; - -interface PurchaseOrder { - id: number; - name: string; -} - -@Component({ - selector: 'app-info-table', - templateUrl: './info-table.html', - styleUrls: ['./info-table.css'], -}) -export class InfoTable { - docs: PurchaseOrder[] = [ - {id: 1, name: 'Bon de commande'}, - {id: 2, name: 'Bon de commande'}, - {id: 3, name: 'Bon de commande'}, - {id: 1, name: 'Bon de commande'}, - {id: 2, name: 'Bon de commande'}, - {id: 3, name: 'Bon de commande'}, - {id: 1, name: 'Bon de commande'}, - {id: 2, name: 'Bon de commande'}, - {id: 3, name: 'Bon de commande'}, - {id: 1, name: 'Bon de commande'}, - {id: 2, name: 'Bon de commande'}, - {id: 3, name: 'Bon de commande'}, - {id: 1, name: 'Bon de commande'}, - {id: 2, name: 'Bon de commande'}, - {id: 3, name: 'Bon de commande'}, - {id: 1, name: 'Bon de commande'}, - {id: 2, name: 'Bon de commande'}, - {id: 3, name: 'Bon de commande'}, - {id: 1, name: 'Bon de commande'}, - {id: 2, name: 'Bon de commande'}, - {id: 3, name: 'Bon de commande'}, - {id: 1, name: 'Bon de commande'}, - {id: 2, name: 'Bon de commande'}, - {id: 3, name: 'Bon de commande'}, - ]; - - purchaseOrder(): PurchaseOrder[] { - return this.docs; - } -} diff --git a/src/app/pages/welcome/welcome.html b/src/app/pages/welcome/welcome.html index 9e9695c..ce1390c 100644 --- a/src/app/pages/welcome/welcome.html +++ b/src/app/pages/welcome/welcome.html @@ -1,13 +1,14 @@
- - - - + + +
-
\ No newline at end of file diff --git a/src/app/pages/welcome/welcome.ts b/src/app/pages/welcome/welcome.ts index d73a531..8faebbb 100644 --- a/src/app/pages/welcome/welcome.ts +++ b/src/app/pages/welcome/welcome.ts @@ -1,19 +1,69 @@ -import {Component} from '@angular/core'; +import {Component, inject, 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 {NzNotificationService} from "ng-zorro-antd/notification"; +import {DeliverersService, ProductsService, SuppliersService} from "../../services/api"; +import {firstValueFrom} from "rxjs"; @Component({ selector: 'app-welcome', imports: [ InfoCard, DeliveryValidator, - InfoTable, ], templateUrl: './welcome.html', styleUrl: './welcome.css' }) export class Welcome { + private productsService = inject(ProductsService); + private deliverersService = inject(DeliverersService); + private suppliersService = inject(SuppliersService); + private notificationsService = inject(NzNotificationService); + deliversCount = signal(0); + suppliersCount = signal(0); + productsUnderLimitCount = 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 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(); + } } diff --git a/src/app/services/api/.openapi-generator/FILES b/src/app/services/api/.openapi-generator/FILES index be3ab3e..93654d7 100644 --- a/src/app/services/api/.openapi-generator/FILES +++ b/src/app/services/api/.openapi-generator/FILES @@ -14,6 +14,7 @@ api/settings.service.ts api/suppliers.service.ts api/users.service.ts api/warehouseproducts.service.ts +api/warehouses.service.ts configuration.ts encoder.ts git_push.sh @@ -44,6 +45,7 @@ model/get-supplier-dto.ts model/get-token-dto.ts model/get-total-quantity-dto.ts model/get-user-dto.ts +model/get-ware-house-dto.ts model/get-ware-house-product-dto.ts model/models.ts model/patch-delivery-note-real-delivery-date-dto.ts diff --git a/src/app/services/api/README.md b/src/app/services/api/README.md index 4d71313..29f22fe 100644 --- a/src/app/services/api/README.md +++ b/src/app/services/api/README.md @@ -59,9 +59,9 @@ In your Angular project: ```typescript -import {ApplicationConfig} from '@angular/core'; -import {provideHttpClient} from '@angular/common/http'; -import {provideApi} from ''; +import { ApplicationConfig } from '@angular/core'; +import { provideHttpClient } from '@angular/common/http'; +import { provideApi } from ''; export const appConfig: ApplicationConfig = { providers: [ diff --git a/src/app/services/api/api/api.ts b/src/app/services/api/api/api.ts index 58e0a7c..4a692c4 100644 --- a/src/app/services/api/api/api.ts +++ b/src/app/services/api/api/api.ts @@ -28,4 +28,7 @@ import {UsersService} from './users.service'; export * from './warehouseproducts.service'; import {WarehouseproductsService} from './warehouseproducts.service'; -export const APIS = [DeliverersService, DeliverynotesService, PricesService, ProductsService, PurchaseordersService, QuotationsService, SettingsService, SuppliersService, UsersService, WarehouseproductsService]; +export * from './warehouses.service'; +import {WarehousesService} from './warehouses.service'; + +export const APIS = [DeliverersService, DeliverynotesService, PricesService, ProductsService, PurchaseordersService, QuotationsService, SettingsService, SuppliersService, UsersService, WarehouseproductsService, WarehousesService]; diff --git a/src/app/services/api/api/deliverynotes.service.ts b/src/app/services/api/api/deliverynotes.service.ts index dcea385..12ff36e 100644 --- a/src/app/services/api/api/deliverynotes.service.ts +++ b/src/app/services/api/api/deliverynotes.service.ts @@ -261,6 +261,72 @@ export class DeliverynotesService extends BaseService { ); } + /** + * @endpoint get /API/deliveryNotes/validation + * @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 getAllDeliveryNotesNotArrivedEndpoint(observe?: 'body', reportProgress?: boolean, options?: { + httpHeaderAccept?: 'application/json', + context?: HttpContext, + transferCache?: boolean + }): Observable>; + public getAllDeliveryNotesNotArrivedEndpoint(observe?: 'response', reportProgress?: boolean, options?: { + httpHeaderAccept?: 'application/json', + context?: HttpContext, + transferCache?: boolean + }): Observable>>; + public getAllDeliveryNotesNotArrivedEndpoint(observe?: 'events', reportProgress?: boolean, options?: { + httpHeaderAccept?: 'application/json', + context?: HttpContext, + transferCache?: boolean + }): Observable>>; + public getAllDeliveryNotesNotArrivedEndpoint(observe: any = 'body', reportProgress: boolean = false, options?: { + httpHeaderAccept?: 'application/json', + context?: HttpContext, + transferCache?: boolean + }): Observable { + + 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/deliveryNotes/validation`; + const {basePath, withCredentials} = this.configuration; + return this.httpClient.request>('get', `${basePath}${localVarPath}`, + { + context: localVarHttpContext, + responseType: responseType_, + ...(withCredentials ? {withCredentials} : {}), + headers: localVarHeaders, + observe: observe, + ...(localVarTransferCache !== undefined ? {transferCache: localVarTransferCache} : {}), + reportProgress: reportProgress + } + ); + } + /** * @endpoint get /API/deliveryNotes/{deliveryNoteId} * @param deliveryNoteId diff --git a/src/app/services/api/model/models.ts b/src/app/services/api/model/models.ts index 5b2b4e5..074577e 100644 --- a/src/app/services/api/model/models.ts +++ b/src/app/services/api/model/models.ts @@ -24,6 +24,7 @@ export * from './get-supplier-dto'; export * from './get-token-dto'; export * from './get-total-quantity-dto'; export * from './get-user-dto'; +export * from './get-ware-house-dto'; export * from './get-ware-house-product-dto'; export * from './patch-delivery-note-real-delivery-date-dto'; export * from './patch-price-selling-price-dto';