From b55bdedc20dc08d40b51968d24de80448d09ee59 Mon Sep 17 00:00:00 2001 From: Enzo Date: Thu, 27 Nov 2025 18:52:30 +0100 Subject: [PATCH 1/4] uptading Supplier Page --- package-lock.json | 29 +-- .../supplier-form/supplier-form.html | 11 +- .../components/supplier-form/supplier-form.ts | 15 +- .../supplier-table/supplier-table.html | 92 ++++---- .../supplier-table/supplier-table.ts | 199 ++++++++---------- src/app/services/api/.openapi-generator/FILES | 1 + src/app/services/api/api.base.service.ts | 2 +- .../services/api/model/get-supplier-dto.ts | 2 + 8 files changed, 148 insertions(+), 203 deletions(-) diff --git a/package-lock.json b/package-lock.json index 488f3a4..0c9a89a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -500,7 +500,6 @@ "resolved": "https://registry.npmjs.org/@angular/common/-/common-20.3.11.tgz", "integrity": "sha512-zQ8xlyUBS+UDAUKk7z/hhWdTtQU2oc/Dwo7jXpyrYlz9y2X1A6sAZpUigdYpbrBkIaNs3MplJevgMiCm3kmN8g==", "license": "MIT", - "peer": true, "dependencies": { "tslib": "^2.3.0" }, @@ -517,7 +516,6 @@ "resolved": "https://registry.npmjs.org/@angular/compiler/-/compiler-20.3.11.tgz", "integrity": "sha512-3O0iMPttD8a4QQQrjVfIjboiZZ17ErkZuqK8BXJBTn2rplpkq1m3kVhgsmzN2OANRR05GF9Ed1dTf8ycTrO1yg==", "license": "MIT", - "peer": true, "dependencies": { "tslib": "^2.3.0" }, @@ -531,7 +529,6 @@ "integrity": "sha512-u6T8kxj7LzK3btEln6Vd8y7p+O1eNXrLiGwqPuRF/QoyjBrRkTYufZ1I4TvzUxdd0ot6mPDRfdmiD15q//Y+oQ==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@babel/core": "7.28.3", "@jridgewell/sourcemap-codec": "^1.4.14", @@ -564,7 +561,6 @@ "resolved": "https://registry.npmjs.org/@angular/core/-/core-20.3.11.tgz", "integrity": "sha512-tOXlxG0SI9Yy1b/ntGyBahfffDpFg7vAbAt+9riOb5ZZ8GYyyOzg78Lqa/lrdBVEG0PXdDjEa0MV93qCyqwYlg==", "license": "MIT", - "peer": true, "dependencies": { "tslib": "^2.3.0" }, @@ -590,7 +586,6 @@ "resolved": "https://registry.npmjs.org/@angular/forms/-/forms-20.3.11.tgz", "integrity": "sha512-jXDvW6a9HUzmLmvgPE+hVoZzc6QJBtQ1kYNn/FZDhbtmjRThJtaMW9YfS0Vz/a9KT9cxBf+8O8Q+yspvgsh3fg==", "license": "MIT", - "peer": true, "dependencies": { "tslib": "^2.3.0" }, @@ -609,7 +604,6 @@ "resolved": "https://registry.npmjs.org/@angular/platform-browser/-/platform-browser-20.3.11.tgz", "integrity": "sha512-hh+8O8m4QzYYlQr9WGew472P37GF1u64NF3HfHmUKJ0xSqqTOHfpni3utev8upJAFJXBKOUZETgeHu2JRcGavg==", "license": "MIT", - "peer": true, "dependencies": { "tslib": "^2.3.0" }, @@ -632,7 +626,6 @@ "resolved": "https://registry.npmjs.org/@angular/router/-/router-20.3.11.tgz", "integrity": "sha512-kuv7Yso7GY3tfRtQN0kW4v2Or4NUEBdjxTz5C8YuAhGDpiKXxDNkXzFliYTVWpJkr3EkTuR9mt9IAc+wxof3Pw==", "license": "MIT", - "peer": true, "dependencies": { "tslib": "^2.3.0" }, @@ -714,7 +707,6 @@ "integrity": "sha512-yDBHV9kQNcr2/sUr9jghVyz9C3Y5G2zUM2H2lo+9mKv4sFgbA8s8Z9t8D1jiTkGoO/NoIfKMyKWr4s6CN23ZwQ==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@ampproject/remapping": "^2.2.0", "@babel/code-frame": "^7.27.1", @@ -1656,7 +1648,6 @@ "integrity": "sha512-nqhDw2ZcAUrKNPwhjinJny903bRhI0rQhiDz1LksjeRxqa36i3l75+4iXbOy0rlDpLJGxqtgoPavQjmmyS5UJw==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@inquirer/checkbox": "^4.2.1", "@inquirer/confirm": "^5.1.14", @@ -2516,7 +2507,6 @@ "resolved": "https://registry.npmjs.org/@nestjs/common/-/common-11.1.9.tgz", "integrity": "sha512-zDntUTReRbAThIfSp3dQZ9kKqI+LjgLp5YZN5c1bgNRDuoeLySAoZg46Bg1a+uV8TMgIRziHocglKGNzr6l+bQ==", "license": "MIT", - "peer": true, "dependencies": { "file-type": "21.1.0", "iterare": "1.2.1", @@ -4280,7 +4270,6 @@ "resolved": "https://registry.npmjs.org/axios/-/axios-1.13.2.tgz", "integrity": "sha512-VPk9ebNqPcy5lRGuSlKx752IlDatOjT9paPlm8A7yOuW2Fbvp4X3JznJtT4f0GzGLLiWE9W8onz51SqLYwzGaA==", "license": "MIT", - "peer": true, "dependencies": { "follow-redirects": "^1.15.6", "form-data": "^4.0.4", @@ -4448,7 +4437,6 @@ } ], "license": "MIT", - "peer": true, "dependencies": { "baseline-browser-mapping": "^2.8.25", "caniuse-lite": "^1.0.30001754", @@ -5647,7 +5635,6 @@ "integrity": "sha512-DT9ck5YIRU+8GYzzU5kT3eHGA5iL+1Zd0EutOmTE9Dtk+Tvuzd23VBU+ec7HPNSTxXYO55gPV/hq4pSBJDjFpA==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "accepts": "^2.0.0", "body-parser": "^2.2.0", @@ -6903,7 +6890,6 @@ "integrity": "sha512-j1n1IuTX1VQjIy3tT7cyGbX7nvQOsFLoIqobZv4ttI5axP923gA44zUj6miiA6R5Aoms4sEGVIIcucXUbRI14g==", "devOptional": true, "license": "Apache-2.0", - "peer": true, "dependencies": { "copy-anything": "^2.0.1", "parse-node-version": "^1.0.1", @@ -7191,7 +7177,6 @@ "integrity": "sha512-SL0JY3DaxylDuo/MecFeiC+7pedM0zia33zl0vcjgwcq1q1FWWF1To9EIauPbl8GbMCU0R2e0uJ8bZunhYKD2g==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "cli-truncate": "^4.0.0", "colorette": "^2.0.20", @@ -8847,8 +8832,7 @@ "version": "0.2.2", "resolved": "https://registry.npmjs.org/reflect-metadata/-/reflect-metadata-0.2.2.tgz", "integrity": "sha512-urBwgfrvVP/eAyXx4hluJivBKzuEbSQs9rKWCrCkbSxNv8mxPcUZKeuoF3Uy4mJl3Lwprp6yy5/39VWigZ4K6Q==", - "license": "Apache-2.0", - "peer": true + "license": "Apache-2.0" }, "node_modules/require-directory": { "version": "2.1.1", @@ -8996,7 +8980,6 @@ "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.8.2.tgz", "integrity": "sha512-dhKf903U/PQZY6boNNtAGdWbG85WAbjT/1xYoZIC7FAY0yWapOBQVsVrDl58W86//e1VpMNBtRV4MaXfdMySFA==", "license": "Apache-2.0", - "peer": true, "dependencies": { "tslib": "^2.1.0" } @@ -9033,7 +9016,6 @@ "integrity": "sha512-9GUyuksjw70uNpb1MTYWsH9MQHOHY6kwfnkafC24+7aOMZn9+rVMBxRbLvw756mrBFbIsFg6Xw9IkR2Fnn3k+Q==", "devOptional": true, "license": "MIT", - "peer": true, "dependencies": { "chokidar": "^4.0.0", "immutable": "^5.0.2", @@ -9782,8 +9764,7 @@ "version": "2.8.1", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", - "license": "0BSD", - "peer": true + "license": "0BSD" }, "node_modules/tuf-js": { "version": "3.1.0", @@ -9833,7 +9814,6 @@ "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", "dev": true, "license": "Apache-2.0", - "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -9994,7 +9974,6 @@ "resolved": "https://registry.npmjs.org/vite/-/vite-7.1.11.tgz", "integrity": "sha512-uzcxnSDVjAopEUjljkWh8EIrg6tlzrjFUfMcR1EVsRDGwf/ccef0qQPRyOrROwhrTDaApueq+ja+KLPlzR/zdg==", "license": "MIT", - "peer": true, "dependencies": { "esbuild": "^0.25.0", "fdir": "^6.5.0", @@ -10382,7 +10361,6 @@ "integrity": "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ==", "dev": true, "license": "MIT", - "peer": true, "funding": { "url": "https://github.com/sponsors/colinhacks" } @@ -10401,8 +10379,7 @@ "version": "0.15.1", "resolved": "https://registry.npmjs.org/zone.js/-/zone.js-0.15.1.tgz", "integrity": "sha512-XE96n56IQpJM7NAoXswY3XRLcWFW83xe0BiAOeMD7K5k5xecOeul3Qcpx6GqEeeHNkW5DWL5zOyTbEfB4eti8w==", - "license": "MIT", - "peer": true + "license": "MIT" } } } diff --git a/src/app/components/supplier-form/supplier-form.html b/src/app/components/supplier-form/supplier-form.html index 1b7e80d..8702c8d 100644 --- a/src/app/components/supplier-form/supplier-form.html +++ b/src/app/components/supplier-form/supplier-form.html @@ -1,4 +1,4 @@ -
+ @@ -54,13 +54,4 @@ - - - Produits - - - - - -
diff --git a/src/app/components/supplier-form/supplier-form.ts b/src/app/components/supplier-form/supplier-form.ts index 87895f2..b51f003 100644 --- a/src/app/components/supplier-form/supplier-form.ts +++ b/src/app/components/supplier-form/supplier-form.ts @@ -1,9 +1,10 @@ -import { Component } from '@angular/core'; +import {Component, input} from '@angular/core'; import {NzColDirective} from "ng-zorro-antd/grid"; import {NzFlexDirective} from "ng-zorro-antd/flex"; import {NzFormControlComponent, NzFormDirective, NzFormItemComponent, NzFormLabelComponent} from "ng-zorro-antd/form"; import {NzInputDirective} from "ng-zorro-antd/input"; import {FormControl, FormGroup, ReactiveFormsModule, Validators} from "@angular/forms"; +import {GetSupplierDto} from "../../services/api"; @Component({ selector: 'app-supplier-form', @@ -28,18 +29,8 @@ export class SupplierForm { address: new FormControl(null, [Validators.required]), city: new FormControl(null, [Validators.required]), deliveryDelay: new FormControl(null, [Validators.required]), - product: new FormControl(null, [Validators.required]), }) + supplier= input.required() - submitForm() { - // Pour annuler si le formulaire est invalide - if (this.supplierForm.invalid) return; - - // Pour obtenir la valeur du formulaire - console.log(this.supplierForm.getRawValue()) - - // Pour vider le formulaire - this.supplierForm.reset() - } } diff --git a/src/app/components/supplier-table/supplier-table.html b/src/app/components/supplier-table/supplier-table.html index b26448e..7a9cb69 100644 --- a/src/app/components/supplier-table/supplier-table.html +++ b/src/app/components/supplier-table/supplier-table.html @@ -1,61 +1,63 @@ - + - + Nom - email - Téléphone - Adresse - Ville - Délai Moyen - Produits - Action + Prénom + Email + Anniversaire + Emprunt + Action - - @for (data of basicTable.data; track data) { + + @for (supplier of suppliers(); track supplier.id) { - {{data.name}} - {{data.email}} - {{data.phone}} - {{data.address}}, {{data.zipCode}} - {{data.city}} - {{data.deliveryDelay}} + {{ supplier.name }} + {{ supplier.phone }} + {{ supplier.email }} + {{ supplier.address}} + {{ supplier.zipCode}} + {{ supplier.city}} + {{ supplier.deliveryDelay}} - -
- - - - Nom - Référence - Prix - - - - @for (product of data.products; track product) { - - {{product.name}} - {{product.reference}} - xx.x€ - - } - - -
+ + + + + Produits + Nom + Référence + Prix + + + + @for (product of supplier.products; track product.id) { + + {{ product.name }} + {{ product.references }} + Price ??? + + } + + -
- - - +
+ -
- -
+
} + + diff --git a/src/app/components/supplier-table/supplier-table.ts b/src/app/components/supplier-table/supplier-table.ts index e6f9d25..03bd41c 100644 --- a/src/app/components/supplier-table/supplier-table.ts +++ b/src/app/components/supplier-table/supplier-table.ts @@ -1,13 +1,14 @@ -import { Component } from '@angular/core'; +import {Component, inject, 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"; import {NzTableComponent} from "ng-zorro-antd/table"; import {ModalButton} from "../modal-button/modal-button"; -import {DatePipe} from "@angular/common"; import {SupplierForm} from "../supplier-form/supplier-form"; -import {SupplierInfo} from "../../interfaces/supplier.interface"; -import {DelivererForm} from "../deliverer-form/deliverer-form"; +import {GetSupplierDto, SuppliersService} from "../../services/api"; +import {NzNotificationService} from "ng-zorro-antd/notification"; +import {firstValueFrom} from "rxjs"; +import {format} from "date-fns"; @Component({ selector: 'app-supplier-table', @@ -24,111 +25,91 @@ import {DelivererForm} from "../deliverer-form/deliverer-form"; }) export class SupplierTable { - listOfSupplier: SupplierInfo[] = [ - { - name: "PyroNova", - email: "contact@pyronova.com", - phone: "+33 1 45 23 67 89", - address: "12 Rue des Artisans", - zipCode: "69003", - city: "Lyon", - deliveryDelay: 4, - products: [] - }, - { - name: "FX Industries", - email: "sales@fxindus.com", - phone: "+33 2 41 22 90 10", - address: "118 Avenue Lumière", - zipCode: "49000", - city: "Angers", - deliveryDelay: 6, - products: [] - }, - { - name: "EuroFire", - email: "info@eurofire.eu", - phone: "+33 1 80 22 11 77", - address: "2 Avenue de l’Europe", - zipCode: "75012", - city: "Paris", - deliveryDelay: 3, - products: [] - }, - { - name: "FlashEffect", - email: "contact@flasheffect.fr", - phone: "+33 4 72 81 91 22", - address: "44 Rue Centrale", - zipCode: "69007", - city: "Lyon", - deliveryDelay: 5, - products: [] - }, - { - name: "StageLight FX", - email: "support@stagelightfx.com", - phone: "+33 5 55 74 99 31", - address: "99 Boulevard du Progrès", - zipCode: "31000", - city: "Toulouse", - deliveryDelay: 7, - products: [] - }, - { - name: "NovaSpark", - email: "hello@novaspark.fr", - phone: "+33 3 29 55 11 88", - address: "7 Rue de la Source", - zipCode: "54000", - city: "Nancy", - deliveryDelay: 4, - products: [] - }, - { - name: "FXWare", - email: "contact@fxware.eu", - phone: "+33 4 75 55 66 44", - address: "123 Route du Nord", - zipCode: "38000", - city: "Grenoble", - deliveryDelay: 6, - products: [] - }, - { - name: "PyroSet", - email: "info@pyroset.com", - phone: "+33 1 61 73 55 00", - address: "5 Chemin des Prés", - zipCode: "95000", - city: "Cergy", - deliveryDelay: 2, - products: [] - }, - { - name: "SkyFX", - email: "support@skyfx.fr", - phone: "+33 6 55 88 22 11", - address: "1 Rue du Ciel", - zipCode: "33000", - city: "Bordeaux", - deliveryDelay: 5, - products: [] - }, - { - name: "SparkLab", - email: "sales@sparklab.eu", - phone: "+33 2 33 55 77 12", - address: "33 Rue du Port", - zipCode: "14000", - city: "Caen", - deliveryDelay: 4, - products: [] - } - ]; + private suppliersService = inject(SuppliersService); + private notificationService = inject(NzNotificationService) + suppliers = signal([]); + suppliersLoading = signal(false); + updateSupplier = viewChild.required('supplierForm'); + modal = viewChild.required('modalNav'); - delete() { - return + async ngOnInit() { + await this.fetchSuppliers(); } -} + async fetchSuppliers() { + this.suppliersLoading.set(true) + + try { + const suppliers = await firstValueFrom(this.suppliersService.getAllSuppliersEndpoint()) + this.suppliers.set(suppliers); + } catch (e) { + this.notificationService.error( + 'Erreur', + 'Erreur de communication avec l\'API' + ) + } + this.suppliersLoading.set(false) + } + + async delete(supplier:number) { + try { + await firstValueFrom(this.suppliersService.deleteSupplierEndpoint(supplier)) + this.notificationService.success( + 'Success', + 'Suppression effectuée' + ) + } catch (e) { + this.notificationService.error( + 'Erreur', + 'Impossible de supprimer la ligne' + ) + } + await this.fetchSuppliers(); + } + + async edit(id: number, updateSupplierComponent: SupplierForm) { + if (updateSupplierComponent.supplierForm.invalid) { + this.notificationService.error( + 'Erreur', + 'Erreur d\'écriture dans le formulaire' + ) + return; + } + + try { + + const suppliers = updateSupplierComponent.supplierForm.getRawValue(); + + await firstValueFrom(this.suppliersService.updateSupplierEndpoint(id, suppliers)) + + this.notificationService.success( + 'Success', + 'Fournisseur modifié' + ) + } catch (e) { + this.notificationService.error( + 'Erreur', + 'Erreur lors de la modification' + ) + } + } + + selectedSupplier: GetSupplierDto | null = null; + openEditModal(supplier: GetSupplierDto) { + this.selectedSupplier = { ...supplier }; + this.modal().showModal(); + } + + async onModalOk(supplierId: number, updateSupplierComponent: SupplierForm, modal: ModalNav) { + if (!this.selectedSupplier) return; + + await this.edit(supplierId, updateSupplierComponent); + updateSupplierComponent.supplierForm.reset(); + modal.isVisible = false; + await this.fetchSuppliers(); + } + + onModalCancel(modal: ModalNav) { + modal.isVisible = false; + } +} \ No newline at end of file diff --git a/src/app/services/api/.openapi-generator/FILES b/src/app/services/api/.openapi-generator/FILES index 72ed5fa..3d6d1ae 100644 --- a/src/app/services/api/.openapi-generator/FILES +++ b/src/app/services/api/.openapi-generator/FILES @@ -1,4 +1,5 @@ .gitignore +.openapi-generator-ignore README.md api.base.service.ts api.module.ts diff --git a/src/app/services/api/api.base.service.ts b/src/app/services/api/api.base.service.ts index 34531a6..1e0f210 100644 --- a/src/app/services/api/api.base.service.ts +++ b/src/app/services/api/api.base.service.ts @@ -12,7 +12,7 @@ import { CustomHttpParameterCodec } from './encoder'; import { Configuration } from './configuration'; export class BaseService { - protected basePath = 'https://localhost:44379'; + protected basePath = 'http://localhost:5298'; public defaultHeaders = new HttpHeaders(); public configuration: Configuration; public encoder: HttpParameterCodec; diff --git a/src/app/services/api/model/get-supplier-dto.ts b/src/app/services/api/model/get-supplier-dto.ts index 35345b0..378eb06 100644 --- a/src/app/services/api/model/get-supplier-dto.ts +++ b/src/app/services/api/model/get-supplier-dto.ts @@ -7,6 +7,7 @@ * https://openapi-generator.tech * Do not edit the class manually. */ +import { GetProductDto } from './get-product-dto'; export interface GetSupplierDto { @@ -18,5 +19,6 @@ export interface GetSupplierDto { zipCode?: string | null; city?: string | null; deliveryDelay?: number; + products?: Array | null; } From 376f2174565ab9318e21a0bd274e5b70fdc2c805 Mon Sep 17 00:00:00 2001 From: sanchezvem Date: Thu, 27 Nov 2025 19:25:08 +0100 Subject: [PATCH 2/4] updated supplier page --- package-lock.json | 29 ++++++++++-- .../components/modal-button/modal-button.ts | 13 ++++-- src/app/components/modal-nav/modal-nav.html | 4 +- src/app/components/modal-nav/modal-nav.ts | 13 +++--- .../components/supplier-form/supplier-form.ts | 19 ++++++-- .../supplier-table/supplier-table.ts | 6 +-- src/app/pages/supplier/supplier.html | 13 ++++-- src/app/pages/supplier/supplier.ts | 44 ++++++++++++++++++- src/app/services/api/.openapi-generator/FILES | 1 - src/app/services/api/api.base.service.ts | 2 +- 10 files changed, 117 insertions(+), 27 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0c9a89a..488f3a4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -500,6 +500,7 @@ "resolved": "https://registry.npmjs.org/@angular/common/-/common-20.3.11.tgz", "integrity": "sha512-zQ8xlyUBS+UDAUKk7z/hhWdTtQU2oc/Dwo7jXpyrYlz9y2X1A6sAZpUigdYpbrBkIaNs3MplJevgMiCm3kmN8g==", "license": "MIT", + "peer": true, "dependencies": { "tslib": "^2.3.0" }, @@ -516,6 +517,7 @@ "resolved": "https://registry.npmjs.org/@angular/compiler/-/compiler-20.3.11.tgz", "integrity": "sha512-3O0iMPttD8a4QQQrjVfIjboiZZ17ErkZuqK8BXJBTn2rplpkq1m3kVhgsmzN2OANRR05GF9Ed1dTf8ycTrO1yg==", "license": "MIT", + "peer": true, "dependencies": { "tslib": "^2.3.0" }, @@ -529,6 +531,7 @@ "integrity": "sha512-u6T8kxj7LzK3btEln6Vd8y7p+O1eNXrLiGwqPuRF/QoyjBrRkTYufZ1I4TvzUxdd0ot6mPDRfdmiD15q//Y+oQ==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@babel/core": "7.28.3", "@jridgewell/sourcemap-codec": "^1.4.14", @@ -561,6 +564,7 @@ "resolved": "https://registry.npmjs.org/@angular/core/-/core-20.3.11.tgz", "integrity": "sha512-tOXlxG0SI9Yy1b/ntGyBahfffDpFg7vAbAt+9riOb5ZZ8GYyyOzg78Lqa/lrdBVEG0PXdDjEa0MV93qCyqwYlg==", "license": "MIT", + "peer": true, "dependencies": { "tslib": "^2.3.0" }, @@ -586,6 +590,7 @@ "resolved": "https://registry.npmjs.org/@angular/forms/-/forms-20.3.11.tgz", "integrity": "sha512-jXDvW6a9HUzmLmvgPE+hVoZzc6QJBtQ1kYNn/FZDhbtmjRThJtaMW9YfS0Vz/a9KT9cxBf+8O8Q+yspvgsh3fg==", "license": "MIT", + "peer": true, "dependencies": { "tslib": "^2.3.0" }, @@ -604,6 +609,7 @@ "resolved": "https://registry.npmjs.org/@angular/platform-browser/-/platform-browser-20.3.11.tgz", "integrity": "sha512-hh+8O8m4QzYYlQr9WGew472P37GF1u64NF3HfHmUKJ0xSqqTOHfpni3utev8upJAFJXBKOUZETgeHu2JRcGavg==", "license": "MIT", + "peer": true, "dependencies": { "tslib": "^2.3.0" }, @@ -626,6 +632,7 @@ "resolved": "https://registry.npmjs.org/@angular/router/-/router-20.3.11.tgz", "integrity": "sha512-kuv7Yso7GY3tfRtQN0kW4v2Or4NUEBdjxTz5C8YuAhGDpiKXxDNkXzFliYTVWpJkr3EkTuR9mt9IAc+wxof3Pw==", "license": "MIT", + "peer": true, "dependencies": { "tslib": "^2.3.0" }, @@ -707,6 +714,7 @@ "integrity": "sha512-yDBHV9kQNcr2/sUr9jghVyz9C3Y5G2zUM2H2lo+9mKv4sFgbA8s8Z9t8D1jiTkGoO/NoIfKMyKWr4s6CN23ZwQ==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@ampproject/remapping": "^2.2.0", "@babel/code-frame": "^7.27.1", @@ -1648,6 +1656,7 @@ "integrity": "sha512-nqhDw2ZcAUrKNPwhjinJny903bRhI0rQhiDz1LksjeRxqa36i3l75+4iXbOy0rlDpLJGxqtgoPavQjmmyS5UJw==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@inquirer/checkbox": "^4.2.1", "@inquirer/confirm": "^5.1.14", @@ -2507,6 +2516,7 @@ "resolved": "https://registry.npmjs.org/@nestjs/common/-/common-11.1.9.tgz", "integrity": "sha512-zDntUTReRbAThIfSp3dQZ9kKqI+LjgLp5YZN5c1bgNRDuoeLySAoZg46Bg1a+uV8TMgIRziHocglKGNzr6l+bQ==", "license": "MIT", + "peer": true, "dependencies": { "file-type": "21.1.0", "iterare": "1.2.1", @@ -4270,6 +4280,7 @@ "resolved": "https://registry.npmjs.org/axios/-/axios-1.13.2.tgz", "integrity": "sha512-VPk9ebNqPcy5lRGuSlKx752IlDatOjT9paPlm8A7yOuW2Fbvp4X3JznJtT4f0GzGLLiWE9W8onz51SqLYwzGaA==", "license": "MIT", + "peer": true, "dependencies": { "follow-redirects": "^1.15.6", "form-data": "^4.0.4", @@ -4437,6 +4448,7 @@ } ], "license": "MIT", + "peer": true, "dependencies": { "baseline-browser-mapping": "^2.8.25", "caniuse-lite": "^1.0.30001754", @@ -5635,6 +5647,7 @@ "integrity": "sha512-DT9ck5YIRU+8GYzzU5kT3eHGA5iL+1Zd0EutOmTE9Dtk+Tvuzd23VBU+ec7HPNSTxXYO55gPV/hq4pSBJDjFpA==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "accepts": "^2.0.0", "body-parser": "^2.2.0", @@ -6890,6 +6903,7 @@ "integrity": "sha512-j1n1IuTX1VQjIy3tT7cyGbX7nvQOsFLoIqobZv4ttI5axP923gA44zUj6miiA6R5Aoms4sEGVIIcucXUbRI14g==", "devOptional": true, "license": "Apache-2.0", + "peer": true, "dependencies": { "copy-anything": "^2.0.1", "parse-node-version": "^1.0.1", @@ -7177,6 +7191,7 @@ "integrity": "sha512-SL0JY3DaxylDuo/MecFeiC+7pedM0zia33zl0vcjgwcq1q1FWWF1To9EIauPbl8GbMCU0R2e0uJ8bZunhYKD2g==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "cli-truncate": "^4.0.0", "colorette": "^2.0.20", @@ -8832,7 +8847,8 @@ "version": "0.2.2", "resolved": "https://registry.npmjs.org/reflect-metadata/-/reflect-metadata-0.2.2.tgz", "integrity": "sha512-urBwgfrvVP/eAyXx4hluJivBKzuEbSQs9rKWCrCkbSxNv8mxPcUZKeuoF3Uy4mJl3Lwprp6yy5/39VWigZ4K6Q==", - "license": "Apache-2.0" + "license": "Apache-2.0", + "peer": true }, "node_modules/require-directory": { "version": "2.1.1", @@ -8980,6 +8996,7 @@ "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.8.2.tgz", "integrity": "sha512-dhKf903U/PQZY6boNNtAGdWbG85WAbjT/1xYoZIC7FAY0yWapOBQVsVrDl58W86//e1VpMNBtRV4MaXfdMySFA==", "license": "Apache-2.0", + "peer": true, "dependencies": { "tslib": "^2.1.0" } @@ -9016,6 +9033,7 @@ "integrity": "sha512-9GUyuksjw70uNpb1MTYWsH9MQHOHY6kwfnkafC24+7aOMZn9+rVMBxRbLvw756mrBFbIsFg6Xw9IkR2Fnn3k+Q==", "devOptional": true, "license": "MIT", + "peer": true, "dependencies": { "chokidar": "^4.0.0", "immutable": "^5.0.2", @@ -9764,7 +9782,8 @@ "version": "2.8.1", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", - "license": "0BSD" + "license": "0BSD", + "peer": true }, "node_modules/tuf-js": { "version": "3.1.0", @@ -9814,6 +9833,7 @@ "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", "dev": true, "license": "Apache-2.0", + "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -9974,6 +9994,7 @@ "resolved": "https://registry.npmjs.org/vite/-/vite-7.1.11.tgz", "integrity": "sha512-uzcxnSDVjAopEUjljkWh8EIrg6tlzrjFUfMcR1EVsRDGwf/ccef0qQPRyOrROwhrTDaApueq+ja+KLPlzR/zdg==", "license": "MIT", + "peer": true, "dependencies": { "esbuild": "^0.25.0", "fdir": "^6.5.0", @@ -10361,6 +10382,7 @@ "integrity": "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ==", "dev": true, "license": "MIT", + "peer": true, "funding": { "url": "https://github.com/sponsors/colinhacks" } @@ -10379,7 +10401,8 @@ "version": "0.15.1", "resolved": "https://registry.npmjs.org/zone.js/-/zone.js-0.15.1.tgz", "integrity": "sha512-XE96n56IQpJM7NAoXswY3XRLcWFW83xe0BiAOeMD7K5k5xecOeul3Qcpx6GqEeeHNkW5DWL5zOyTbEfB4eti8w==", - "license": "MIT" + "license": "MIT", + "peer": true } } } diff --git a/src/app/components/modal-button/modal-button.ts b/src/app/components/modal-button/modal-button.ts index b1ed57a..49d0fee 100644 --- a/src/app/components/modal-button/modal-button.ts +++ b/src/app/components/modal-button/modal-button.ts @@ -1,21 +1,24 @@ -import {Component, input, Input} from '@angular/core'; +import {Component, input, Input, output} from '@angular/core'; import {NzModalComponent} from "ng-zorro-antd/modal"; import {NzButtonComponent} from "ng-zorro-antd/button"; @Component({ - selector: 'app-modal-button', + selector: 'app-modal-button', imports: [ NzModalComponent, NzButtonComponent, ], - templateUrl: './modal-button.html', - styleUrl: './modal-button.css', + templateUrl: './modal-button.html', + styleUrl: './modal-button.css', }) export class ModalButton { name = input.required() type = input<"primary" | "default" | "dashed" | "link" | "text">() + ok = output(); + cancel = output(); + isVisible = false; isOkLoading = false; @@ -26,12 +29,14 @@ export class ModalButton { handleOk(): void { this.isOkLoading = true; setTimeout(() => { + this.ok.emit(); this.isVisible = false; this.isOkLoading = false; }, 1000); } handleCancel(): void { + this.cancel.emit(); this.isVisible = false; } } \ No newline at end of file diff --git a/src/app/components/modal-nav/modal-nav.html b/src/app/components/modal-nav/modal-nav.html index 102ad5c..1401a39 100644 --- a/src/app/components/modal-nav/modal-nav.html +++ b/src/app/components/modal-nav/modal-nav.html @@ -1,5 +1,5 @@
- +
@@ -8,7 +8,7 @@ () + name = input.required() + ok = output(); + cancel = output(); isVisible = false; isOkLoading = false; @@ -23,12 +24,14 @@ export class ModalNav { handleOk(): void { this.isOkLoading = true; setTimeout(() => { - this.isVisible = false; + this.ok.emit(); this.isOkLoading = false; }, 1000); } handleCancel(): void { this.isVisible = false; + this.cancel.emit(); + } } diff --git a/src/app/components/supplier-form/supplier-form.ts b/src/app/components/supplier-form/supplier-form.ts index b51f003..2341018 100644 --- a/src/app/components/supplier-form/supplier-form.ts +++ b/src/app/components/supplier-form/supplier-form.ts @@ -1,4 +1,4 @@ -import {Component, input} from '@angular/core'; +import {Component, effect, input} from '@angular/core'; import {NzColDirective} from "ng-zorro-antd/grid"; import {NzFlexDirective} from "ng-zorro-antd/flex"; import {NzFormControlComponent, NzFormDirective, NzFormItemComponent, NzFormLabelComponent} from "ng-zorro-antd/form"; @@ -31,6 +31,19 @@ export class SupplierForm { deliveryDelay: new FormControl(null, [Validators.required]), }) - supplier= input.required() - + supplier= input.required(); + constructor() { + effect(() => { + if (this.supplier()) { + this.supplierForm.patchValue({ + name: this.supplier().name, + email: this.supplier().email, + phone: this.supplier().phone, + address: this.supplier().address, + city: this.supplier().city, + deliveryDelay: this.supplier().deliveryDelay, + }); + } + }); + } } diff --git a/src/app/components/supplier-table/supplier-table.ts b/src/app/components/supplier-table/supplier-table.ts index 03bd41c..894b519 100644 --- a/src/app/components/supplier-table/supplier-table.ts +++ b/src/app/components/supplier-table/supplier-table.ts @@ -1,4 +1,4 @@ -import {Component, inject, 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"; @@ -8,7 +8,6 @@ import {SupplierForm} from "../supplier-form/supplier-form"; import {GetSupplierDto, SuppliersService} from "../../services/api"; import {NzNotificationService} from "ng-zorro-antd/notification"; import {firstValueFrom} from "rxjs"; -import {format} from "date-fns"; @Component({ selector: 'app-supplier-table', @@ -24,7 +23,7 @@ import {format} from "date-fns"; styleUrl: './supplier-table.css', }) -export class SupplierTable { +export class SupplierTable implements OnInit { private suppliersService = inject(SuppliersService); private notificationService = inject(NzNotificationService) suppliers = signal([]); @@ -87,6 +86,7 @@ export class SupplierTable { 'Fournisseur modifié' ) } catch (e) { + console.error(e); this.notificationService.error( 'Erreur', 'Erreur lors de la modification' diff --git a/src/app/pages/supplier/supplier.html b/src/app/pages/supplier/supplier.html index 08f4baa..7ba9c6c 100644 --- a/src/app/pages/supplier/supplier.html +++ b/src/app/pages/supplier/supplier.html @@ -1,13 +1,18 @@
- - + + +
- +
- +
diff --git a/src/app/pages/supplier/supplier.ts b/src/app/pages/supplier/supplier.ts index 7f5c1ee..6de0c4b 100644 --- a/src/app/pages/supplier/supplier.ts +++ b/src/app/pages/supplier/supplier.ts @@ -1,8 +1,11 @@ -import { Component } from '@angular/core'; +import {Component, inject, viewChild} from '@angular/core'; import {Search} from "../../components/search/search"; import {ModalButton} from "../../components/modal-button/modal-button"; import {SupplierTable} from "../../components/supplier-table/supplier-table"; import {SupplierForm} from "../../components/supplier-form/supplier-form"; +import {SuppliersService} from "../../services/api"; +import {NzNotificationService} from "ng-zorro-antd/notification"; +import {firstValueFrom} from "rxjs"; @Component({ selector: 'app-supplier', @@ -16,5 +19,44 @@ import {SupplierForm} from "../../components/supplier-form/supplier-form"; styleUrl: './supplier.css', }) export class Supplier { + modal = viewChild.required('modalButton'); + createSupplier = viewChild.required('supplierForm'); + suppliersTable = viewChild.required('suppliersTable'); + private usersService = inject(SuppliersService); + private notificationService = inject(NzNotificationService) + async onModalOk() { + await this.addSupplier() + this.createSupplier().supplierForm.reset(); + this.modal().isVisible = false; + await this.suppliersTable().fetchSuppliers() + } + + onModalCancel() { + this.modal().isVisible = false; + } + + async addSupplier() { + if (this.createSupplier().supplierForm.invalid) + { + this.notificationService.error( + 'Erreur', + 'Erreur d\'écriture dans le formulaire' + ) + } + try { + const suppliers = this.createSupplier().supplierForm.getRawValue(); + await firstValueFrom(this.usersService.createSupplierEndpoint(suppliers)) + + this.notificationService.success( + 'Success', + 'Fournisseur enregistré' + ) + } catch (e) { + this.notificationService.error( + 'Erreur', + 'Erreur d\'enregistrement' + ) + } + } } diff --git a/src/app/services/api/.openapi-generator/FILES b/src/app/services/api/.openapi-generator/FILES index 3d6d1ae..72ed5fa 100644 --- a/src/app/services/api/.openapi-generator/FILES +++ b/src/app/services/api/.openapi-generator/FILES @@ -1,5 +1,4 @@ .gitignore -.openapi-generator-ignore README.md api.base.service.ts api.module.ts diff --git a/src/app/services/api/api.base.service.ts b/src/app/services/api/api.base.service.ts index 1e0f210..34531a6 100644 --- a/src/app/services/api/api.base.service.ts +++ b/src/app/services/api/api.base.service.ts @@ -12,7 +12,7 @@ import { CustomHttpParameterCodec } from './encoder'; import { Configuration } from './configuration'; export class BaseService { - protected basePath = 'http://localhost:5298'; + protected basePath = 'https://localhost:44379'; public defaultHeaders = new HttpHeaders(); public configuration: Configuration; public encoder: HttpParameterCodec; From b54ba70c11cfc5a54c54ac940933acc148005160 Mon Sep 17 00:00:00 2001 From: sanchezvem Date: Fri, 28 Nov 2025 09:00:41 +0100 Subject: [PATCH 3/4] fixed errors in supplier page --- src/app/components/supplier-form/supplier-form.html | 11 ++++++++++- src/app/components/supplier-form/supplier-form.ts | 5 ++++- src/app/components/supplier-table/supplier-table.html | 9 ++++++--- src/app/components/supplier-table/supplier-table.ts | 1 - src/app/pages/supplier/supplier.html | 2 +- src/app/pages/supplier/supplier.ts | 4 ++-- src/app/services/api/.openapi-generator/FILES | 1 + src/app/services/api/api.base.service.ts | 2 +- 8 files changed, 25 insertions(+), 10 deletions(-) diff --git a/src/app/components/supplier-form/supplier-form.html b/src/app/components/supplier-form/supplier-form.html index 8702c8d..ed44a1a 100644 --- a/src/app/components/supplier-form/supplier-form.html +++ b/src/app/components/supplier-form/supplier-form.html @@ -36,6 +36,15 @@ + + + Code Postal + + + + + + Ville @@ -50,7 +59,7 @@ Délai Moyen - + diff --git a/src/app/components/supplier-form/supplier-form.ts b/src/app/components/supplier-form/supplier-form.ts index 2341018..c3cc539 100644 --- a/src/app/components/supplier-form/supplier-form.ts +++ b/src/app/components/supplier-form/supplier-form.ts @@ -27,11 +27,13 @@ export class SupplierForm { email: new FormControl(null, [Validators.required]), phone: new FormControl(null, [Validators.required]), address: new FormControl(null, [Validators.required]), + zipCode: new FormControl(null, [Validators.required]), city: new FormControl(null, [Validators.required]), deliveryDelay: new FormControl(null, [Validators.required]), }) - supplier= input.required(); + + supplier= input(); constructor() { effect(() => { if (this.supplier()) { @@ -40,6 +42,7 @@ export class SupplierForm { email: this.supplier().email, phone: this.supplier().phone, address: this.supplier().address, + zipCode: this.supplier().zipCode, city: this.supplier().city, deliveryDelay: this.supplier().deliveryDelay, }); diff --git a/src/app/components/supplier-table/supplier-table.html b/src/app/components/supplier-table/supplier-table.html index 7a9cb69..33d127f 100644 --- a/src/app/components/supplier-table/supplier-table.html +++ b/src/app/components/supplier-table/supplier-table.html @@ -4,10 +4,13 @@ Nom - Prénom + Téléphone Email - Anniversaire - Emprunt + Adresse + Code Postal + Ville + Délai moyen + Produits Action diff --git a/src/app/components/supplier-table/supplier-table.ts b/src/app/components/supplier-table/supplier-table.ts index 894b519..87ea541 100644 --- a/src/app/components/supplier-table/supplier-table.ts +++ b/src/app/components/supplier-table/supplier-table.ts @@ -78,7 +78,6 @@ export class SupplierTable implements OnInit { try { const suppliers = updateSupplierComponent.supplierForm.getRawValue(); - await firstValueFrom(this.suppliersService.updateSupplierEndpoint(id, suppliers)) this.notificationService.success( diff --git a/src/app/pages/supplier/supplier.html b/src/app/pages/supplier/supplier.html index 7ba9c6c..5593490 100644 --- a/src/app/pages/supplier/supplier.html +++ b/src/app/pages/supplier/supplier.html @@ -5,7 +5,7 @@ (ok)="onModalOk()" (cancel)="onModalCancel()"> - +
diff --git a/src/app/pages/supplier/supplier.ts b/src/app/pages/supplier/supplier.ts index 6de0c4b..0a5051f 100644 --- a/src/app/pages/supplier/supplier.ts +++ b/src/app/pages/supplier/supplier.ts @@ -21,7 +21,7 @@ import {firstValueFrom} from "rxjs"; export class Supplier { modal = viewChild.required('modalButton'); createSupplier = viewChild.required('supplierForm'); - suppliersTable = viewChild.required('suppliersTable'); + supplierTable = viewChild.required('supplierTable'); private usersService = inject(SuppliersService); private notificationService = inject(NzNotificationService) @@ -29,7 +29,7 @@ export class Supplier { await this.addSupplier() this.createSupplier().supplierForm.reset(); this.modal().isVisible = false; - await this.suppliersTable().fetchSuppliers() + await this.supplierTable().fetchSuppliers() } onModalCancel() { diff --git a/src/app/services/api/.openapi-generator/FILES b/src/app/services/api/.openapi-generator/FILES index 72ed5fa..3d6d1ae 100644 --- a/src/app/services/api/.openapi-generator/FILES +++ b/src/app/services/api/.openapi-generator/FILES @@ -1,4 +1,5 @@ .gitignore +.openapi-generator-ignore README.md api.base.service.ts api.module.ts diff --git a/src/app/services/api/api.base.service.ts b/src/app/services/api/api.base.service.ts index 34531a6..1e0f210 100644 --- a/src/app/services/api/api.base.service.ts +++ b/src/app/services/api/api.base.service.ts @@ -12,7 +12,7 @@ import { CustomHttpParameterCodec } from './encoder'; import { Configuration } from './configuration'; export class BaseService { - protected basePath = 'https://localhost:44379'; + protected basePath = 'http://localhost:5298'; public defaultHeaders = new HttpHeaders(); public configuration: Configuration; public encoder: HttpParameterCodec; From aae87da374ec282dd0204800e008ed6b7d47cec8 Mon Sep 17 00:00:00 2001 From: sanchezvem Date: Fri, 28 Nov 2025 09:05:30 +0100 Subject: [PATCH 4/4] fixed errors in supplier page --- src/app/components/supplier-table/supplier-table.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/components/supplier-table/supplier-table.html b/src/app/components/supplier-table/supplier-table.html index 33d127f..b1a665d 100644 --- a/src/app/components/supplier-table/supplier-table.html +++ b/src/app/components/supplier-table/supplier-table.html @@ -23,7 +23,7 @@ {{ supplier.address}} {{ supplier.zipCode}} {{ supplier.city}} - {{ supplier.deliveryDelay}} + {{ supplier.deliveryDelay}} jours