Compare commits
40 Commits
8b7d48779e
...
develop
| Author | SHA1 | Date | |
|---|---|---|---|
| 47b8765906 | |||
| 09763ea730 | |||
| e29de8e167 | |||
| 80b4726004 | |||
| cf53e4c8ef | |||
| 670dd561cc | |||
| 9b898432c0 | |||
| d0e98482b9 | |||
| 04b08e76c4 | |||
| d8d36d5c1e | |||
| fdb728cd25 | |||
| 7f56bb4cf8 | |||
| 24f82742f7 | |||
| caff8aa312 | |||
| 82aef7da0a | |||
| 4de58d6f6e | |||
| d37ff4ace4 | |||
| 7041c5335b | |||
| c20a0c5daf | |||
| e66c95a65e | |||
| d8112facb4 | |||
| 027c36dc52 | |||
| 0aec0be1d4 | |||
| a7ef707388 | |||
| 56d3d1bea7 | |||
| 14d3d25217 | |||
| 961551e926 | |||
| 4dd1d7e81d | |||
| f233c46853 | |||
| 6e9daf3e60 | |||
| 2d8104aeae | |||
| c10a0a7c2f | |||
| 7e69cbd952 | |||
| dbeb5b43ee | |||
| 561b8e5fc3 | |||
| 8afa2e6f06 | |||
| d2ca8b1bf2 | |||
| b03196ce0f | |||
| cb4686765b | |||
| 5e039281de |
Generated
+136
-9
@@ -17,8 +17,11 @@
|
|||||||
"@openapitools/openapi-generator-cli": "^2.25.2",
|
"@openapitools/openapi-generator-cli": "^2.25.2",
|
||||||
"@tailwindcss/postcss": "^4.1.17",
|
"@tailwindcss/postcss": "^4.1.17",
|
||||||
"@tailwindcss/vite": "^4.1.17",
|
"@tailwindcss/vite": "^4.1.17",
|
||||||
|
"browser-image-compression": "^2.0.2",
|
||||||
|
"jwt-decode": "^4.0.0",
|
||||||
"ng-zorro-antd": "^20.4.0",
|
"ng-zorro-antd": "^20.4.0",
|
||||||
"postcss": "^8.5.6",
|
"postcss": "^8.5.6",
|
||||||
|
"rimraf": "^6.1.3",
|
||||||
"rxjs": "~7.8.0",
|
"rxjs": "~7.8.0",
|
||||||
"tailwindcss": "^4.1.17",
|
"tailwindcss": "^4.1.17",
|
||||||
"tslib": "^2.3.0",
|
"tslib": "^2.3.0",
|
||||||
@@ -28,6 +31,7 @@
|
|||||||
"@angular/build": "^20.3.9",
|
"@angular/build": "^20.3.9",
|
||||||
"@angular/cli": "^20.3.9",
|
"@angular/cli": "^20.3.9",
|
||||||
"@angular/compiler-cli": "^20.3.0",
|
"@angular/compiler-cli": "^20.3.0",
|
||||||
|
"baseline-browser-mapping": "^2.10.32",
|
||||||
"less": "^4.2.0",
|
"less": "^4.2.0",
|
||||||
"typescript": "~5.9.2"
|
"typescript": "~5.9.2"
|
||||||
}
|
}
|
||||||
@@ -4315,13 +4319,16 @@
|
|||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/baseline-browser-mapping": {
|
"node_modules/baseline-browser-mapping": {
|
||||||
"version": "2.8.27",
|
"version": "2.10.32",
|
||||||
"resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.8.27.tgz",
|
"resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.10.32.tgz",
|
||||||
"integrity": "sha512-2CXFpkjVnY2FT+B6GrSYxzYf65BJWEqz5tIRHCvNsZZ2F3CmsCB37h8SpYgKG7y9C4YAeTipIPWG7EmFmhAeXA==",
|
"integrity": "sha512-wbPvpyjJPC0zdfdKXxqEL3Ea+bOMD/87X4lftiJkkaBiuG6ALQy1SLmEd7BSmVCuwCQsBrCamgBoLyfFDD1EPg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"bin": {
|
"bin": {
|
||||||
"baseline-browser-mapping": "dist/cli.js"
|
"baseline-browser-mapping": "dist/cli.cjs"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=6.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/basic-ftp": {
|
"node_modules/basic-ftp": {
|
||||||
@@ -4428,6 +4435,15 @@
|
|||||||
"node": ">=8"
|
"node": ">=8"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/browser-image-compression": {
|
||||||
|
"version": "2.0.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/browser-image-compression/-/browser-image-compression-2.0.2.tgz",
|
||||||
|
"integrity": "sha512-pBLlQyUf6yB8SmmngrcOw3EoS4RpQ1BcylI3T9Yqn7+4nrQTXJD4sJDe5ODnJdrvNMaio5OicFo75rDyJD2Ucw==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"uzip": "0.20201231.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/browserslist": {
|
"node_modules/browserslist": {
|
||||||
"version": "4.28.0",
|
"version": "4.28.0",
|
||||||
"resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.28.0.tgz",
|
"resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.28.0.tgz",
|
||||||
@@ -6897,6 +6913,15 @@
|
|||||||
],
|
],
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
|
"node_modules/jwt-decode": {
|
||||||
|
"version": "4.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/jwt-decode/-/jwt-decode-4.0.0.tgz",
|
||||||
|
"integrity": "sha512-+KJGIyHgkGuIq3IEBNftfhW/LfWhXUIY6OmyVWjliu5KH1y0fw7VQ8YndE2O4qZdMSd9SqbnC8GOcZEy0Om7sA==",
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/less": {
|
"node_modules/less": {
|
||||||
"version": "4.4.2",
|
"version": "4.4.2",
|
||||||
"resolved": "https://registry.npmjs.org/less/-/less-4.4.2.tgz",
|
"resolved": "https://registry.npmjs.org/less/-/less-4.4.2.tgz",
|
||||||
@@ -7580,10 +7605,10 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/minipass": {
|
"node_modules/minipass": {
|
||||||
"version": "7.1.2",
|
"version": "7.1.3",
|
||||||
"resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.3.tgz",
|
||||||
"integrity": "sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==",
|
"integrity": "sha512-tEBHqDnIoM/1rXME1zgka9g6Q2lcoCkxHLuc7ODJ5BxbP5d4c2Z5cGgtXAku59200Cx7diuHTOYfSBD8n6mm8A==",
|
||||||
"license": "ISC",
|
"license": "BlueOak-1.0.0",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=16 || 14 >=14.17"
|
"node": ">=16 || 14 >=14.17"
|
||||||
}
|
}
|
||||||
@@ -8389,7 +8414,6 @@
|
|||||||
"version": "1.0.1",
|
"version": "1.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.1.tgz",
|
||||||
"integrity": "sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw==",
|
"integrity": "sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw==",
|
||||||
"dev": true,
|
|
||||||
"license": "BlueOak-1.0.0"
|
"license": "BlueOak-1.0.0"
|
||||||
},
|
},
|
||||||
"node_modules/pacote": {
|
"node_modules/pacote": {
|
||||||
@@ -8924,6 +8948,103 @@
|
|||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
|
"node_modules/rimraf": {
|
||||||
|
"version": "6.1.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-6.1.3.tgz",
|
||||||
|
"integrity": "sha512-LKg+Cr2ZF61fkcaK1UdkH2yEBBKnYjTyWzTJT6KNPcSPaiT7HSdhtMXQuN5wkTX0Xu72KQ1l8S42rlmexS2hSA==",
|
||||||
|
"license": "BlueOak-1.0.0",
|
||||||
|
"dependencies": {
|
||||||
|
"glob": "^13.0.3",
|
||||||
|
"package-json-from-dist": "^1.0.1"
|
||||||
|
},
|
||||||
|
"bin": {
|
||||||
|
"rimraf": "dist/esm/bin.mjs"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "20 || >=22"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/isaacs"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/rimraf/node_modules/balanced-match": {
|
||||||
|
"version": "4.0.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.4.tgz",
|
||||||
|
"integrity": "sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==",
|
||||||
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": "18 || 20 || >=22"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/rimraf/node_modules/brace-expansion": {
|
||||||
|
"version": "5.0.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.6.tgz",
|
||||||
|
"integrity": "sha512-kLpxurY4Z4r9sgMsyG0Z9uzsBlgiU/EFKhj/h91/8yHu0edo7XuixOIH3VcJ8kkxs6/jPzoI6U9Vj3WqbMQ94g==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"balanced-match": "^4.0.2"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "18 || 20 || >=22"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/rimraf/node_modules/glob": {
|
||||||
|
"version": "13.0.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/glob/-/glob-13.0.6.tgz",
|
||||||
|
"integrity": "sha512-Wjlyrolmm8uDpm/ogGyXZXb1Z+Ca2B8NbJwqBVg0axK9GbBeoS7yGV6vjXnYdGm6X53iehEuxxbyiKp8QmN4Vw==",
|
||||||
|
"license": "BlueOak-1.0.0",
|
||||||
|
"dependencies": {
|
||||||
|
"minimatch": "^10.2.2",
|
||||||
|
"minipass": "^7.1.3",
|
||||||
|
"path-scurry": "^2.0.2"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "18 || 20 || >=22"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/isaacs"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/rimraf/node_modules/lru-cache": {
|
||||||
|
"version": "11.5.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.5.1.tgz",
|
||||||
|
"integrity": "sha512-RPimw/7aMdv2oqRrxKwvZXcPfwBrn/JZ2xYcY9Hus/6LaS3VOAKVWKWgNLCFSiOm1ESXinjsDlidVU7JlnCN2A==",
|
||||||
|
"license": "BlueOak-1.0.0",
|
||||||
|
"engines": {
|
||||||
|
"node": "20 || >=22"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/rimraf/node_modules/minimatch": {
|
||||||
|
"version": "10.2.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.5.tgz",
|
||||||
|
"integrity": "sha512-MULkVLfKGYDFYejP07QOurDLLQpcjk7Fw+7jXS2R2czRQzR56yHRveU5NDJEOviH+hETZKSkIk5c+T23GjFUMg==",
|
||||||
|
"license": "BlueOak-1.0.0",
|
||||||
|
"dependencies": {
|
||||||
|
"brace-expansion": "^5.0.5"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "18 || 20 || >=22"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/isaacs"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/rimraf/node_modules/path-scurry": {
|
||||||
|
"version": "2.0.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-2.0.2.tgz",
|
||||||
|
"integrity": "sha512-3O/iVVsJAPsOnpwWIeD+d6z/7PmqApyQePUtCndjatj/9I5LylHvt5qluFaBT3I5h3r1ejfR056c+FCv+NnNXg==",
|
||||||
|
"license": "BlueOak-1.0.0",
|
||||||
|
"dependencies": {
|
||||||
|
"lru-cache": "^11.0.0",
|
||||||
|
"minipass": "^7.1.2"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "18 || 20 || >=22"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/isaacs"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/rollup": {
|
"node_modules/rollup": {
|
||||||
"version": "4.52.3",
|
"version": "4.52.3",
|
||||||
"resolved": "https://registry.npmjs.org/rollup/-/rollup-4.52.3.tgz",
|
"resolved": "https://registry.npmjs.org/rollup/-/rollup-4.52.3.tgz",
|
||||||
@@ -9958,6 +10079,12 @@
|
|||||||
"integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==",
|
"integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
|
"node_modules/uzip": {
|
||||||
|
"version": "0.20201231.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/uzip/-/uzip-0.20201231.0.tgz",
|
||||||
|
"integrity": "sha512-OZeJfZP+R0z9D6TmBgLq2LHzSSptGMGDGigGiEe0pr8UBe/7fdflgHlHBNDASTXB5jnFuxHpNaJywSg8YFeGng==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/validate-npm-package-license": {
|
"node_modules/validate-npm-package-license": {
|
||||||
"version": "3.0.4",
|
"version": "3.0.4",
|
||||||
"resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz",
|
||||||
|
|||||||
+5
-2
@@ -6,8 +6,7 @@
|
|||||||
"start": "ng serve",
|
"start": "ng serve",
|
||||||
"build": "ng build",
|
"build": "ng build",
|
||||||
"watch": "ng build --watch --configuration development",
|
"watch": "ng build --watch --configuration development",
|
||||||
"openapi": "rm -rf src/app/services/api && openapi-generator-cli generate -i http://localhost:5298/swagger/v1/swagger.json -g typescript-angular -o src/app/services/api -c openapi-generator.yaml",
|
"openapi": "rimraf src/app/services/api && openapi-generator-cli generate -i http://localhost:5298/swagger/v1/swagger.json -g typescript-angular -o src/app/services/api -c openapi-generator.yaml"
|
||||||
"openapiWin": "set JAVA_TOOL_OPTIONS=-Dcom.sun.net.ssl.checkRevocation=false -Djavax.net.ssl.trustStoreType=WINDOWS-ROOT && openapi-generator-cli generate -i https://localhost:44379/swagger/v1/swagger.json -g typescript-angular -o src/app/services/api -c openapi-generator.yaml\n"
|
|
||||||
},
|
},
|
||||||
"prettier": {
|
"prettier": {
|
||||||
"printWidth": 100,
|
"printWidth": 100,
|
||||||
@@ -32,8 +31,11 @@
|
|||||||
"@openapitools/openapi-generator-cli": "^2.25.2",
|
"@openapitools/openapi-generator-cli": "^2.25.2",
|
||||||
"@tailwindcss/postcss": "^4.1.17",
|
"@tailwindcss/postcss": "^4.1.17",
|
||||||
"@tailwindcss/vite": "^4.1.17",
|
"@tailwindcss/vite": "^4.1.17",
|
||||||
|
"browser-image-compression": "^2.0.2",
|
||||||
|
"jwt-decode": "^4.0.0",
|
||||||
"ng-zorro-antd": "^20.4.0",
|
"ng-zorro-antd": "^20.4.0",
|
||||||
"postcss": "^8.5.6",
|
"postcss": "^8.5.6",
|
||||||
|
"rimraf": "^6.1.3",
|
||||||
"rxjs": "~7.8.0",
|
"rxjs": "~7.8.0",
|
||||||
"tailwindcss": "^4.1.17",
|
"tailwindcss": "^4.1.17",
|
||||||
"tslib": "^2.3.0",
|
"tslib": "^2.3.0",
|
||||||
@@ -43,6 +45,7 @@
|
|||||||
"@angular/build": "^20.3.9",
|
"@angular/build": "^20.3.9",
|
||||||
"@angular/cli": "^20.3.9",
|
"@angular/cli": "^20.3.9",
|
||||||
"@angular/compiler-cli": "^20.3.0",
|
"@angular/compiler-cli": "^20.3.0",
|
||||||
|
"baseline-browser-mapping": "^2.10.32",
|
||||||
"less": "^4.2.0",
|
"less": "^4.2.0",
|
||||||
"typescript": "~5.9.2"
|
"typescript": "~5.9.2"
|
||||||
}
|
}
|
||||||
|
|||||||
+14
-12
@@ -1,19 +1,21 @@
|
|||||||
import { ApplicationConfig, provideBrowserGlobalErrorListeners, provideZoneChangeDetection } from '@angular/core';
|
import {ApplicationConfig, provideBrowserGlobalErrorListeners, provideZoneChangeDetection} from '@angular/core';
|
||||||
import { provideRouter } from '@angular/router';
|
import {provideRouter} from '@angular/router';
|
||||||
|
|
||||||
import { routes } from './app.routes';
|
import {routes} from './app.routes';
|
||||||
import { fr_FR, provideNzI18n } from 'ng-zorro-antd/i18n';
|
import {fr_FR, provideNzI18n} from 'ng-zorro-antd/i18n';
|
||||||
import { registerLocaleData } from '@angular/common';
|
import {registerLocaleData} from '@angular/common';
|
||||||
import fr from '@angular/common/locales/fr';
|
import fr from '@angular/common/locales/fr';
|
||||||
import { provideAnimationsAsync } from '@angular/platform-browser/animations/async';
|
import {provideAnimationsAsync} from '@angular/platform-browser/animations/async';
|
||||||
import { provideHttpClient } from '@angular/common/http';
|
import {provideHttpClient, withInterceptors} from '@angular/common/http';
|
||||||
|
import {authInterceptor} from "./interceptors/auth-interceptor";
|
||||||
|
|
||||||
registerLocaleData(fr);
|
registerLocaleData(fr);
|
||||||
|
|
||||||
export const appConfig: ApplicationConfig = {
|
export const appConfig: ApplicationConfig = {
|
||||||
providers: [
|
providers: [
|
||||||
provideBrowserGlobalErrorListeners(),
|
provideBrowserGlobalErrorListeners(),
|
||||||
provideZoneChangeDetection({ eventCoalescing: true }),
|
provideZoneChangeDetection({eventCoalescing: true}),
|
||||||
provideRouter(routes), provideNzI18n(fr_FR), provideAnimationsAsync(), provideHttpClient()
|
provideRouter(routes), provideNzI18n(fr_FR), provideAnimationsAsync(), provideHttpClient(),
|
||||||
]
|
provideHttpClient(withInterceptors([authInterceptor]))
|
||||||
|
]
|
||||||
};
|
};
|
||||||
|
|||||||
-113
@@ -1,113 +0,0 @@
|
|||||||
:host {
|
|
||||||
display: flex;
|
|
||||||
}
|
|
||||||
|
|
||||||
.app-layout {
|
|
||||||
height: 100vh;
|
|
||||||
}
|
|
||||||
|
|
||||||
nz-header {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
background: #001529;
|
|
||||||
padding: 0 24px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.header-container {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: space-between;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* --- LOGO + TITRE --- */
|
|
||||||
.logo {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.logo a {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.logo img {
|
|
||||||
height: 40px;
|
|
||||||
width: auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
.logo h1 {
|
|
||||||
margin: 0 0 0 10px;
|
|
||||||
color: #fff;
|
|
||||||
font-weight: 600;
|
|
||||||
font-size: 20px;
|
|
||||||
font-family: Avenir, Helvetica Neue, Arial, Helvetica, sans-serif;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* --- MENU PRINCIPAL --- */
|
|
||||||
.top-nav {
|
|
||||||
flex: 1;
|
|
||||||
margin: 0 40px;
|
|
||||||
line-height: 64px;
|
|
||||||
background: #001529;
|
|
||||||
border: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Couleur grise par défaut + effet blanc et zoom au survol */
|
|
||||||
.top-nav li {
|
|
||||||
transition: transform 0.2s ease, color 0.2s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.top-nav li a {
|
|
||||||
color: #bfbfbf !important; /* gris clair par défaut */
|
|
||||||
transition: transform 0.2s ease, color 0.2s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Au survol → zoom + blanc pur */
|
|
||||||
.top-nav li:hover {
|
|
||||||
transform: scale(1.08);
|
|
||||||
background: transparent !important;
|
|
||||||
color: #fff !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.top-nav li:hover a {
|
|
||||||
color: #ffffff !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Supprime toute coloration bleue ou fond par défaut NG-ZORRO */
|
|
||||||
.top-nav li.ant-menu-item-active,
|
|
||||||
.top-nav li.ant-menu-item-selected {
|
|
||||||
background: transparent !important;
|
|
||||||
color: #fff !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* --- ICONES DROITES --- */
|
|
||||||
.right-icons {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 20px;
|
|
||||||
color: #fff;
|
|
||||||
font-size: 18px;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
.right-icons app-modal-nav {
|
|
||||||
transition: transform 0.2s ease, color 0.2s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.right-icons app-modal-nav:hover {
|
|
||||||
color: #40a9ff;
|
|
||||||
transform: scale(1.2);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* --- CONTENU --- */
|
|
||||||
nz-content {
|
|
||||||
padding: 24px 50px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.inner-content {
|
|
||||||
padding: 24px;
|
|
||||||
background: #fff;
|
|
||||||
height: 100%;
|
|
||||||
}
|
|
||||||
|
|||||||
+1
-90
@@ -1,90 +1 @@
|
|||||||
<nz-layout class="app-layout">
|
<router-outlet></router-outlet>
|
||||||
<nz-header>
|
|
||||||
<div class="header-container">
|
|
||||||
<!-- LOGO -->
|
|
||||||
<div class="logo">
|
|
||||||
<a routerLink="/welcome">
|
|
||||||
<img
|
|
||||||
src="https://www.pyro-fetes.com/wp-content/themes/pcptheme/img/logo-pyro-fetes-OR-top.png"
|
|
||||||
alt="logo"
|
|
||||||
style="width: 100px; height: auto"
|
|
||||||
/>
|
|
||||||
<h1 class="text-amber-300">PYRO FÊTES</h1>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- MENU PRINCIPAL -->
|
|
||||||
<ul nz-menu class="top-nav" nzTheme="dark" nzMode="horizontal">
|
|
||||||
<li nz-menu-item routerLinkActive="ant-menu-item-selected">
|
|
||||||
<a routerLink="/stock">
|
|
||||||
<nz-icon nzType="stock"></nz-icon>
|
|
||||||
<span>Stock</span>
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<li nz-submenu nzTitle="Partenaires" nzIcon="team">
|
|
||||||
<ul>
|
|
||||||
<li nz-menu-item routerLinkActive="ant-menu-item-selected">
|
|
||||||
<a routerLink="/supplier">
|
|
||||||
<nz-icon nzType="shop"></nz-icon>
|
|
||||||
<span>Fournisseurs</span>
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<li nz-menu-item routerLinkActive="ant-menu-item-selected">
|
|
||||||
<a routerLink="/deliverer">
|
|
||||||
<nz-icon nzType="car"></nz-icon>
|
|
||||||
<span>Livreurs</span>
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</li>
|
|
||||||
<li nz-submenu nzTitle="Recettes" nzIcon="euro-circle">
|
|
||||||
<ul>
|
|
||||||
<li nz-menu-item routerLinkActive="ant-menu-item-selected">
|
|
||||||
<a routerLink="/quotation">
|
|
||||||
<nz-icon nzType="file"></nz-icon>
|
|
||||||
<span>Devis</span>
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<li nz-menu-item routerLinkActive="ant-menu-item-selected">
|
|
||||||
<a routerLink="/purchase-order">
|
|
||||||
<nz-icon nzType="file"></nz-icon>
|
|
||||||
<span>Bon de commande</span>
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<li nz-menu-item routerLinkActive="ant-menu-item-selected">
|
|
||||||
<a routerLink="/delivery-note">
|
|
||||||
<nz-icon nzType="file"></nz-icon>
|
|
||||||
<span>Bon de livraison</span>
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</li>
|
|
||||||
<li nz-menu-item routerLinkActive="ant-menu-item-selected">
|
|
||||||
<a routerLink="/user">
|
|
||||||
<nz-icon nzType="user"></nz-icon>
|
|
||||||
<span>Utilisateur</span>
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<!-- ICONES À DROITE -->
|
|
||||||
<div class="right-icons">
|
|
||||||
<app-modal-nav nameIcon="bell" name="Notification">
|
|
||||||
<app-notif-list></app-notif-list>
|
|
||||||
</app-modal-nav>
|
|
||||||
<app-modal-nav nameIcon="user" name="Profil">
|
|
||||||
<app-profil></app-profil>
|
|
||||||
</app-modal-nav>
|
|
||||||
<app-modal-nav nameIcon="setting" name="Paramètres">
|
|
||||||
<app-setting-form></app-setting-form>
|
|
||||||
</app-modal-nav>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</nz-header>
|
|
||||||
|
|
||||||
<nz-content>
|
|
||||||
<div class="inner-content overflow-auto">
|
|
||||||
<router-outlet></router-outlet>
|
|
||||||
</div>
|
|
||||||
</nz-content>
|
|
||||||
</nz-layout>
|
|
||||||
+59
-30
@@ -1,41 +1,70 @@
|
|||||||
import { Routes } from '@angular/router';
|
import {Routes} from '@angular/router';
|
||||||
|
import {authGuard} from "./guards/auth.guard";
|
||||||
|
|
||||||
export const routes: Routes = [
|
export const routes: Routes = [
|
||||||
{
|
{
|
||||||
path: '',
|
path: '',
|
||||||
pathMatch: 'full',
|
pathMatch: 'full',
|
||||||
redirectTo: '/welcome'
|
redirectTo: '/login'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'welcome',
|
path: 'login',
|
||||||
loadComponent: () => import('./pages/welcome/welcome').then(x => x.Welcome)
|
loadComponent: () => import('./pages/login/login').then(x => x.Login)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'stock',
|
path: '',
|
||||||
loadComponent: () => import('./pages/stock/stock').then(x => x.Stock)
|
loadComponent: () =>
|
||||||
},
|
import('./components/layout/layout').then(m => m.Layout),
|
||||||
{
|
children: [
|
||||||
path: 'supplier',
|
{
|
||||||
loadComponent: () => import('./pages/supplier/supplier').then(x => x.Supplier)
|
path: '',
|
||||||
},
|
pathMatch: 'full',
|
||||||
{
|
redirectTo: '/dashboard'
|
||||||
path: 'deliverer',
|
},
|
||||||
loadComponent: () => import('./pages/deliverer/deliverer').then(x => x.Deliverer)
|
{
|
||||||
},
|
path: 'dashboard',
|
||||||
{
|
loadComponent: () => import('./pages/dashboard/dashboard').then(m => m.Dashboard),
|
||||||
path: 'quotation',
|
canActivate: [authGuard]
|
||||||
loadComponent: () => import('./pages/quotation/quotation').then(x => x.Quotation)
|
},
|
||||||
},
|
{
|
||||||
{
|
path: 'stock',
|
||||||
path: 'purchase-order',
|
loadComponent: () => import('./pages/stock/stock').then(m => m.Stock),
|
||||||
loadComponent: () => import('./pages/purchase-order/purchase-order').then(x => x.PurchaseOrder)
|
canActivate: [authGuard]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'delivery-note',
|
path: 'supplier',
|
||||||
loadComponent: () => import('./pages/delivery-note/delivery-note').then(x => x.DeliveryNote)
|
loadComponent: () => import('./pages/supplier/supplier').then(m => m.Supplier),
|
||||||
},
|
canActivate: [authGuard]
|
||||||
{
|
},
|
||||||
path: 'user',
|
{
|
||||||
loadComponent: () => import('./pages/user/user').then(x => x.User)
|
path: 'deliverer',
|
||||||
|
loadComponent: () => import('./pages/deliverer/deliverer').then(m => m.Deliverer),
|
||||||
|
canActivate: [authGuard]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'quotation',
|
||||||
|
loadComponent: () => import('./pages/quotation/quotation').then(m => m.Quotation),
|
||||||
|
canActivate: [authGuard]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'purchase-order',
|
||||||
|
loadComponent: () => import('./pages/purchase-order/purchase-order').then(m => m.PurchaseOrder),
|
||||||
|
canActivate: [authGuard]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'delivery-note',
|
||||||
|
loadComponent: () => import('./pages/delivery-note/delivery-note').then(m => m.DeliveryNote),
|
||||||
|
canActivate: [authGuard]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'user',
|
||||||
|
loadComponent: () => import('./pages/user/user').then(m => m.User),
|
||||||
|
canActivate: [authGuard],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '**',
|
||||||
|
redirectTo: 'dashboard'
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|||||||
+10
-14
@@ -1,17 +1,13 @@
|
|||||||
import { Component } from '@angular/core';
|
import {Component} from '@angular/core';
|
||||||
import {RouterLink, RouterLinkActive, RouterOutlet} from '@angular/router';
|
import {RouterOutlet} from '@angular/router';
|
||||||
import { NzLayoutModule } from 'ng-zorro-antd/layout';
|
import {NzLayoutModule} from 'ng-zorro-antd/layout';
|
||||||
import { NzMenuModule } from 'ng-zorro-antd/menu';
|
import {NzMenuModule} from 'ng-zorro-antd/menu';
|
||||||
import {NzIconDirective} from "ng-zorro-antd/icon";
|
|
||||||
import {ModalNav} from "./components/modal-nav/modal-nav";
|
|
||||||
import {Profil} from "./components/profil/profil";
|
|
||||||
import {NotifList} from "./components/notif-list/notif-list";
|
|
||||||
import {SettingForm} from "./components/setting-form/setting-form";
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-root',
|
selector: 'app-root',
|
||||||
imports: [RouterOutlet, NzLayoutModule, NzMenuModule, NzIconDirective, RouterLinkActive, RouterLink, ModalNav, Profil, NotifList, SettingForm],
|
imports: [RouterOutlet, NzLayoutModule, NzMenuModule],
|
||||||
templateUrl: './app.html',
|
templateUrl: './app.html',
|
||||||
styleUrl: './app.css'
|
styleUrl: './app.css'
|
||||||
})
|
})
|
||||||
export class App {}
|
export class App {
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
<form [formGroup]="addProductForm">
|
||||||
|
<nz-form-item nz-flex>
|
||||||
|
<nz-form-label nzSpan="12" nzRequired>
|
||||||
|
Fournisseur
|
||||||
|
</nz-form-label>
|
||||||
|
|
||||||
|
<nz-form-control nzSpan="12" nzErrorTip="Ce champ est requis">
|
||||||
|
<nz-select formControlName="supplierId" nzPlaceHolder="Choisir un fournisseur" nzShowSearch>
|
||||||
|
@for (supplier of suppliers(); track supplier.id) {
|
||||||
|
<nz-option [nzLabel]="supplier.name" [nzValue]="supplier.id"></nz-option>
|
||||||
|
}
|
||||||
|
</nz-select>
|
||||||
|
</nz-form-control>
|
||||||
|
</nz-form-item>
|
||||||
|
|
||||||
|
<div class="overflow-x-auto mt-6">
|
||||||
|
<nz-table [nzBordered]="true" class="mx-auto text-center">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th class="text-center">Produit</th>
|
||||||
|
<th class="text-center">Prix</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody formArrayName="lines">
|
||||||
|
@for (line of lines.controls; let i = $index; track i) {
|
||||||
|
<tr [formGroupName]="i" class="text-center">
|
||||||
|
<td class="text-center">{{ line.value.name }}</td>
|
||||||
|
<td class="text-center">
|
||||||
|
<nz-input-number
|
||||||
|
formControlName="price"
|
||||||
|
[nzMin]="0"
|
||||||
|
[nzStep]="1">
|
||||||
|
</nz-input-number>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
</tbody>
|
||||||
|
</nz-table>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
import {Component, input} from '@angular/core';
|
||||||
|
import {FormArray, FormControl, FormGroup, ReactiveFormsModule, Validators} from "@angular/forms";
|
||||||
|
import {GetProductDto, GetSupplierDto} from "../../services/api";
|
||||||
|
import {NzColDirective, NzRowDirective} from "ng-zorro-antd/grid";
|
||||||
|
import {NzFormControlComponent, NzFormLabelComponent} from "ng-zorro-antd/form";
|
||||||
|
import {NzFlexDirective} from "ng-zorro-antd/flex";
|
||||||
|
import {NzTableComponent} from "ng-zorro-antd/table";
|
||||||
|
import {NzInputNumberComponent} from "ng-zorro-antd/input-number";
|
||||||
|
import {NzOptionComponent, NzSelectComponent} from "ng-zorro-antd/select";
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-add-product-supplier-form',
|
||||||
|
imports: [
|
||||||
|
NzRowDirective,
|
||||||
|
NzFormControlComponent,
|
||||||
|
NzFormLabelComponent,
|
||||||
|
ReactiveFormsModule,
|
||||||
|
NzFlexDirective,
|
||||||
|
NzColDirective,
|
||||||
|
NzTableComponent,
|
||||||
|
NzInputNumberComponent,
|
||||||
|
NzOptionComponent,
|
||||||
|
NzSelectComponent
|
||||||
|
],
|
||||||
|
templateUrl: './add-product-supplier-form.html',
|
||||||
|
styleUrl: './add-product-supplier-form.css',
|
||||||
|
})
|
||||||
|
export class AddProductSupplierForm {
|
||||||
|
addProductForm: FormGroup = new FormGroup({
|
||||||
|
supplierId: new FormControl<number>(null, Validators.required),
|
||||||
|
lines: new FormArray([], Validators.required),
|
||||||
|
});
|
||||||
|
|
||||||
|
suppliers = input.required<GetSupplierDto[]>();
|
||||||
|
products = input.required<GetProductDto[]>();
|
||||||
|
|
||||||
|
get lines(): FormArray {
|
||||||
|
return this.addProductForm.get('lines') as FormArray;
|
||||||
|
}
|
||||||
|
|
||||||
|
addProductToForm() {
|
||||||
|
this.lines.clear();
|
||||||
|
|
||||||
|
this.products().forEach(x => {
|
||||||
|
this.lines.push(
|
||||||
|
new FormGroup({
|
||||||
|
productId: new FormControl(x.id),
|
||||||
|
name: new FormControl(x.name),
|
||||||
|
price: new FormControl(0, [Validators.required, Validators.min(0)])
|
||||||
|
})
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,6 +9,23 @@
|
|||||||
</nz-form-control>
|
</nz-form-control>
|
||||||
</nz-form-item>
|
</nz-form-item>
|
||||||
|
|
||||||
|
<nz-form-item nz-flex>
|
||||||
|
<nz-form-label nzSpan="12" nzRequired>
|
||||||
|
Fournisseur
|
||||||
|
</nz-form-label>
|
||||||
|
|
||||||
|
<nz-form-control nzSpan="12" nzErrorTip="Ce champ est requis">
|
||||||
|
<nz-select formControlName="supplierId"
|
||||||
|
(ngModelChange)="refresh()"
|
||||||
|
[nzPlaceHolder]="getBestSupplier().name ?? 'Choisir un fournisseur'"
|
||||||
|
nzShowSearch>
|
||||||
|
@for (supplier of suppliers(); track supplier.id) {
|
||||||
|
<nz-option [nzLabel]="supplier.name" [nzValue]="supplier.id"></nz-option>
|
||||||
|
}
|
||||||
|
</nz-select>
|
||||||
|
</nz-form-control>
|
||||||
|
</nz-form-item>
|
||||||
|
|
||||||
<div class="overflow-x-auto">
|
<div class="overflow-x-auto">
|
||||||
<nz-table [nzBordered]="true" class="mx-auto text-center">
|
<nz-table [nzBordered]="true" class="mx-auto text-center">
|
||||||
<thead>
|
<thead>
|
||||||
@@ -18,7 +35,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody formArrayName="lines">
|
<tbody formArrayName="lines">
|
||||||
@for (line of lines.controls.slice(); let i = $index; track i) {
|
@for (line of lines.controls; let i = $index; track i) {
|
||||||
<tr [formGroupName]="i" class="text-center">
|
<tr [formGroupName]="i" class="text-center">
|
||||||
<td class="text-center">{{ line.value.name }}</td>
|
<td class="text-center">{{ line.value.name }}</td>
|
||||||
<td class="text-center">
|
<td class="text-center">
|
||||||
|
|||||||
@@ -1,12 +1,14 @@
|
|||||||
import { Component } from '@angular/core';
|
import {Component, input, OnInit, signal} from '@angular/core';
|
||||||
import {FormBuilder, FormGroup, FormArray, Validators, ReactiveFormsModule, FormControl} from '@angular/forms';
|
import {FormBuilder, FormGroup, FormArray, Validators, ReactiveFormsModule, FormControl} from '@angular/forms';
|
||||||
import { GetProductDto } from '../../services/api';
|
import {GetProductDto, GetSupplierDto} from '../../services/api';
|
||||||
import {NzTableComponent} from "ng-zorro-antd/table";
|
import {NzTableComponent} from "ng-zorro-antd/table";
|
||||||
import {NzInputNumberComponent} from "ng-zorro-antd/input-number";
|
import {NzInputNumberComponent} from "ng-zorro-antd/input-number";
|
||||||
import {NzColDirective} from "ng-zorro-antd/grid";
|
import {NzColDirective} from "ng-zorro-antd/grid";
|
||||||
import {NzFlexDirective} from "ng-zorro-antd/flex";
|
import {NzFlexDirective} from "ng-zorro-antd/flex";
|
||||||
import {NzFormControlComponent, NzFormItemComponent, NzFormLabelComponent} from "ng-zorro-antd/form";
|
import {NzFormControlComponent, NzFormItemComponent, NzFormLabelComponent} from "ng-zorro-antd/form";
|
||||||
import {NzInputDirective} from "ng-zorro-antd/input";
|
import {NzInputDirective} from "ng-zorro-antd/input";
|
||||||
|
import {NzOptionComponent, NzSelectComponent} from "ng-zorro-antd/select";
|
||||||
|
import {min} from "rxjs";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-create-purchaseorder-form',
|
selector: 'app-create-purchaseorder-form',
|
||||||
@@ -22,31 +24,70 @@ import {NzInputDirective} from "ng-zorro-antd/input";
|
|||||||
NzFormItemComponent,
|
NzFormItemComponent,
|
||||||
NzFormLabelComponent,
|
NzFormLabelComponent,
|
||||||
NzInputDirective,
|
NzInputDirective,
|
||||||
|
NzOptionComponent,
|
||||||
|
NzSelectComponent,
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
export class CreatePurchaseorderForm {
|
export class CreatePurchaseorderForm {
|
||||||
createPurchaseOrderForm: FormGroup
|
suppliers = input.required<GetSupplierDto[]>();
|
||||||
|
products = input.required<GetProductDto[]>();
|
||||||
|
|
||||||
constructor(private fb: FormBuilder) {
|
getBestSupplier() {
|
||||||
this.createPurchaseOrderForm = this.fb.group({
|
let bestSupplier: GetSupplierDto = this.suppliers()[0];
|
||||||
purchaseConditions: new FormControl<string | null>(null, Validators.required),
|
let maxProducts = 0;
|
||||||
lines: this.fb.array([])
|
|
||||||
});
|
const selectedProducts = this.products().map(x => x.id);
|
||||||
|
|
||||||
|
this.suppliers().forEach(x => {
|
||||||
|
const supplierProductsCount = x.prices.filter(p => selectedProducts.includes(p.productId)).length ?? 0;
|
||||||
|
|
||||||
|
if (supplierProductsCount > maxProducts) {
|
||||||
|
maxProducts = supplierProductsCount;
|
||||||
|
bestSupplier = x;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return bestSupplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getProductsOfSupplier() {
|
||||||
|
const supplier = this.suppliers().find(x => x.id === this.createPurchaseOrderForm.value.supplierId);
|
||||||
|
if (!supplier) return [];
|
||||||
|
|
||||||
|
const supplierProductIds = supplier.prices.map(x => x.productId);
|
||||||
|
|
||||||
|
return this.products().filter(product => supplierProductIds.includes(product.id));
|
||||||
|
}
|
||||||
|
|
||||||
|
createPurchaseOrderForm: FormGroup = new FormGroup({
|
||||||
|
purchaseConditions: new FormControl<string | null>(null, Validators.required),
|
||||||
|
lines: new FormArray([], Validators.required),
|
||||||
|
supplierId: new FormControl<number>(null, Validators.required),
|
||||||
|
})
|
||||||
|
|
||||||
get lines(): FormArray {
|
get lines(): FormArray {
|
||||||
return this.createPurchaseOrderForm.get('lines') as FormArray;
|
return this.createPurchaseOrderForm.get('lines') as FormArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ajouter des produits sélectionnés dans le formulaire
|
addProductToForm() {
|
||||||
syncSelectedProducts(selectedProducts: GetProductDto[]) {
|
const supplierId = this.createPurchaseOrderForm.value.supplierId ?? this.getBestSupplier().id;
|
||||||
|
this.createPurchaseOrderForm.patchValue({
|
||||||
|
supplierId
|
||||||
|
});
|
||||||
|
|
||||||
|
this.refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
refresh() {
|
||||||
this.lines.clear();
|
this.lines.clear();
|
||||||
selectedProducts.forEach(p => {
|
|
||||||
this.lines.push(this.fb.group({
|
this.getProductsOfSupplier().forEach(x => {
|
||||||
productId: [p.id],
|
this.lines.push(
|
||||||
name: [p.name],
|
new FormGroup({
|
||||||
quantity: [1, [Validators.required, Validators.min(1)]]
|
productId: new FormControl(x.id),
|
||||||
}));
|
name: new FormControl(x.name),
|
||||||
|
quantity: new FormControl(1, [Validators.required, Validators.min(1)])
|
||||||
|
})
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,20 @@
|
|||||||
<form [formGroup]="createQuotationForm">
|
<form [formGroup]="createQuotationForm">
|
||||||
|
<nz-form-item nz-flex>
|
||||||
|
<nz-form-label nzSpan="12" nzRequired>
|
||||||
|
Client
|
||||||
|
</nz-form-label>
|
||||||
|
|
||||||
|
<nz-form-control nzSpan="12" nzErrorTip="Ce champ est requis">
|
||||||
|
<nz-select formControlName="customerId" nzPlaceHolder="Choisir un client"
|
||||||
|
nzShowSearch>
|
||||||
|
@for (customer of customers(); track customer.id) {
|
||||||
|
<nz-option [nzLabel]="customer.note" [nzValue]="customer.id"></nz-option>
|
||||||
|
}
|
||||||
|
</nz-select>
|
||||||
|
</nz-form-control>
|
||||||
|
</nz-form-item>
|
||||||
|
|
||||||
|
|
||||||
<nz-form-item nz-flex>
|
<nz-form-item nz-flex>
|
||||||
<nz-form-label nzSpan="12" nzRequired>
|
<nz-form-label nzSpan="12" nzRequired>
|
||||||
Message
|
Message
|
||||||
@@ -15,7 +31,7 @@
|
|||||||
</nz-form-label>
|
</nz-form-label>
|
||||||
|
|
||||||
<nz-form-control nzSpan="12" nzErrorTip="Ce champ est requis">
|
<nz-form-control nzSpan="12" nzErrorTip="Ce champ est requis">
|
||||||
<input nz-input placeholder="Conditions générales de vente" formControlName="purchaseConditions">
|
<input nz-input placeholder="Conditions générales de vente" formControlName="conditionsSale">
|
||||||
</nz-form-control>
|
</nz-form-control>
|
||||||
</nz-form-item>
|
</nz-form-item>
|
||||||
|
|
||||||
@@ -28,7 +44,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody formArrayName="lines">
|
<tbody formArrayName="lines">
|
||||||
@for (line of lines.controls.slice(); let i = $index; track i) {
|
@for (line of lines.controls; let i = $index; track i) {
|
||||||
<tr [formGroupName]="i" class="text-center">
|
<tr [formGroupName]="i" class="text-center">
|
||||||
<td class="text-center">{{ line.value.name }}</td>
|
<td class="text-center">{{ line.value.name }}</td>
|
||||||
<td class="text-center">
|
<td class="text-center">
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Component } from '@angular/core';
|
import {Component, inject, input, OnInit, signal} from '@angular/core';
|
||||||
import {
|
import {
|
||||||
FormArray,
|
FormArray,
|
||||||
FormBuilder,
|
FormBuilder,
|
||||||
@@ -14,10 +14,13 @@ import {NzFormControlComponent, NzFormItemComponent, NzFormLabelComponent} from
|
|||||||
import {NzInputDirective} from "ng-zorro-antd/input";
|
import {NzInputDirective} from "ng-zorro-antd/input";
|
||||||
import {NzInputNumberComponent} from "ng-zorro-antd/input-number";
|
import {NzInputNumberComponent} from "ng-zorro-antd/input-number";
|
||||||
import {NzTableComponent} from "ng-zorro-antd/table";
|
import {NzTableComponent} from "ng-zorro-antd/table";
|
||||||
import {GetProductDto} from "../../services/api";
|
import {CustomersService, GetCustomerDto, GetProductDto, GetSupplierDto} from "../../services/api";
|
||||||
|
import {NzOptionComponent, NzSelectComponent} from "ng-zorro-antd/select";
|
||||||
|
import {firstValueFrom} from "rxjs";
|
||||||
|
import {NzNotificationService} from "ng-zorro-antd/notification";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-create-quotation-form',
|
selector: 'app-create-quotation-form',
|
||||||
imports: [
|
imports: [
|
||||||
FormsModule,
|
FormsModule,
|
||||||
NzColDirective,
|
NzColDirective,
|
||||||
@@ -28,35 +31,75 @@ import {GetProductDto} from "../../services/api";
|
|||||||
NzInputDirective,
|
NzInputDirective,
|
||||||
NzInputNumberComponent,
|
NzInputNumberComponent,
|
||||||
NzTableComponent,
|
NzTableComponent,
|
||||||
ReactiveFormsModule
|
ReactiveFormsModule,
|
||||||
|
NzOptionComponent,
|
||||||
|
NzSelectComponent
|
||||||
],
|
],
|
||||||
templateUrl: './create-quotation-form.html',
|
templateUrl: './create-quotation-form.html',
|
||||||
styleUrl: './create-quotation-form.css',
|
styleUrl: './create-quotation-form.css',
|
||||||
})
|
})
|
||||||
export class CreateQuotationForm {
|
export class CreateQuotationForm implements OnInit {
|
||||||
createQuotationForm: FormGroup
|
private customersService = inject(CustomersService);
|
||||||
|
private notificationService = inject(NzNotificationService);
|
||||||
|
|
||||||
constructor(private fb: FormBuilder) {
|
suppliers = input.required<GetSupplierDto[]>();
|
||||||
this.createQuotationForm = this.fb.group({
|
products = input.required<GetProductDto[]>();
|
||||||
message: new FormControl<string>(null, Validators.required),
|
|
||||||
purchaseConditions: new FormControl<string>(null, Validators.required),
|
customers = signal<GetCustomerDto[]>([]);
|
||||||
lines: this.fb.array([])
|
|
||||||
});
|
async ngOnInit() {
|
||||||
|
try {
|
||||||
|
const customers = await firstValueFrom(this.customersService.getAllCustomersEndpoint())
|
||||||
|
this.customers.set(customers);
|
||||||
|
} catch {
|
||||||
|
this.notificationService.error('Erreur', 'Erreur de communication avec l\'API')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
createQuotationForm: FormGroup = new FormGroup({
|
||||||
|
message: new FormControl<string>(null, Validators.required),
|
||||||
|
conditionsSale: new FormControl<string>(null, Validators.required),
|
||||||
|
supplierId: new FormControl<number>(null, Validators.required),
|
||||||
|
customerId: new FormControl<number>(null, Validators.required),
|
||||||
|
lines: new FormArray([], Validators.required),
|
||||||
|
})
|
||||||
|
|
||||||
get lines(): FormArray {
|
get lines(): FormArray {
|
||||||
return this.createQuotationForm.get('lines') as FormArray;
|
return this.createQuotationForm.get('lines') as FormArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ajouter des produits sélectionnés dans le formulaire
|
getDefaultSupplier() {
|
||||||
syncSelectedProducts(selectedProducts: GetProductDto[]) {
|
let defaultSupplier: GetSupplierDto = this.suppliers()[0];
|
||||||
|
let maxProducts = 0;
|
||||||
|
|
||||||
|
const selectedProducts = this.products().map(x => x.id);
|
||||||
|
|
||||||
|
this.suppliers().forEach(x => {
|
||||||
|
const supplierProductsCount = x.prices.filter(p => selectedProducts.includes(p.productId)).length ?? 0;
|
||||||
|
|
||||||
|
if (supplierProductsCount > maxProducts) {
|
||||||
|
maxProducts = supplierProductsCount;
|
||||||
|
defaultSupplier = x;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
return defaultSupplier;
|
||||||
|
}
|
||||||
|
|
||||||
|
addProductToForm() {
|
||||||
this.lines.clear();
|
this.lines.clear();
|
||||||
selectedProducts.forEach(p => {
|
this.products().forEach(x => {
|
||||||
this.lines.push(this.fb.group({
|
this.lines.push(
|
||||||
productId: [p.id],
|
new FormGroup({
|
||||||
name: [p.name],
|
productId: new FormControl(x.id),
|
||||||
quantity: [1, [Validators.required, Validators.min(1)]]
|
name: new FormControl(x.name),
|
||||||
}));
|
quantity: new FormControl(1, [Validators.required, Validators.min(1)])
|
||||||
|
})
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
this.createQuotationForm.patchValue({
|
||||||
|
supplierId: this.getDefaultSupplier().id,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
<form [formGroup]="choiceDelivererForm">
|
||||||
|
<nz-form-item nz-flex>
|
||||||
|
<nz-form-label nzSpan="12" nzRequired>
|
||||||
|
Transporteur
|
||||||
|
</nz-form-label>
|
||||||
|
|
||||||
|
<nz-form-control nzSpan="12" nzErrorTip="Ce champ est requis">
|
||||||
|
<nz-select formControlName="delivererId" nzPlaceHolder="Choisir un transporteur" nzShowSearch>
|
||||||
|
@for (deliverer of deliverers(); track deliverer.id) {
|
||||||
|
<nz-option [nzLabel]="deliverer.transporter" [nzValue]="deliverer.id"></nz-option>
|
||||||
|
}
|
||||||
|
</nz-select>
|
||||||
|
</nz-form-control>
|
||||||
|
</nz-form-item>
|
||||||
|
</form>
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
import {Component, inject, OnInit, signal} from '@angular/core';
|
||||||
|
import {FormControl, FormGroup, FormsModule, ReactiveFormsModule, Validators} from "@angular/forms";
|
||||||
|
import {NzColDirective, NzRowDirective} from "ng-zorro-antd/grid";
|
||||||
|
import {NzFlexDirective} from "ng-zorro-antd/flex";
|
||||||
|
import {NzFormControlComponent, NzFormLabelComponent} from "ng-zorro-antd/form";
|
||||||
|
import {NzOptionComponent, NzSelectComponent} from "ng-zorro-antd/select";
|
||||||
|
import {DeliverersService, GetDelivererDto} from "../../services/api";
|
||||||
|
import {firstValueFrom} from "rxjs";
|
||||||
|
import {NzNotificationService} from "ng-zorro-antd/notification";
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-deliverer-choice',
|
||||||
|
imports: [
|
||||||
|
FormsModule,
|
||||||
|
NzColDirective,
|
||||||
|
NzFlexDirective,
|
||||||
|
NzFormControlComponent,
|
||||||
|
NzFormLabelComponent,
|
||||||
|
NzOptionComponent,
|
||||||
|
NzRowDirective,
|
||||||
|
NzSelectComponent,
|
||||||
|
ReactiveFormsModule
|
||||||
|
],
|
||||||
|
templateUrl: './deliverer-choice.html',
|
||||||
|
styleUrl: './deliverer-choice.css',
|
||||||
|
})
|
||||||
|
export class DelivererChoice implements OnInit {
|
||||||
|
private deliverersService = inject(DeliverersService);
|
||||||
|
private notificationService = inject(NzNotificationService);
|
||||||
|
|
||||||
|
choiceDelivererForm: FormGroup = new FormGroup({
|
||||||
|
delivererId: new FormControl<number>(null, Validators.required),
|
||||||
|
});
|
||||||
|
|
||||||
|
deliverers = signal<GetDelivererDto[]>([]);
|
||||||
|
|
||||||
|
async ngOnInit() {
|
||||||
|
try {
|
||||||
|
const deliverers = await firstValueFrom(this.deliverersService.getAllDelivererEndpoint());
|
||||||
|
this.deliverers.set(deliverers);
|
||||||
|
} catch {
|
||||||
|
this.notificationService.error('Erreur', 'Erreur lors de l\'affichage des livreurs');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,7 +7,7 @@ import {FormControl, FormGroup, ReactiveFormsModule, Validators} from "@angular/
|
|||||||
import {GetDelivererDto} from "../../services/api";
|
import {GetDelivererDto} from "../../services/api";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-deliverer-form',
|
selector: 'app-deliverer-form',
|
||||||
imports: [
|
imports: [
|
||||||
NzColDirective,
|
NzColDirective,
|
||||||
NzFlexDirective,
|
NzFlexDirective,
|
||||||
@@ -18,15 +18,16 @@ import {GetDelivererDto} from "../../services/api";
|
|||||||
NzInputDirective,
|
NzInputDirective,
|
||||||
ReactiveFormsModule
|
ReactiveFormsModule
|
||||||
],
|
],
|
||||||
templateUrl: './deliverer-form.html',
|
templateUrl: './deliverer-form.html',
|
||||||
styleUrl: './deliverer-form.css',
|
styleUrl: './deliverer-form.css',
|
||||||
})
|
})
|
||||||
export class DelivererForm {
|
export class DelivererForm {
|
||||||
delivererForm: FormGroup = new FormGroup({
|
delivererForm: FormGroup = new FormGroup({
|
||||||
transporter: new FormControl<string>(null, [Validators.required])
|
transporter: new FormControl<string>(null, [Validators.required])
|
||||||
})
|
})
|
||||||
|
|
||||||
deliverer= input<GetDelivererDto>();
|
deliverer = input<GetDelivererDto>();
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
effect(() => {
|
effect(() => {
|
||||||
if (this.deliverer()) {
|
if (this.deliverer()) {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ nz-table {
|
|||||||
background: #fff;
|
background: #fff;
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
box-shadow: 0 2px 6px rgba(0,0,0,0.1);
|
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
|
||||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,18 +66,21 @@ nz-table tbody td p {
|
|||||||
nz-table thead {
|
nz-table thead {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
nz-table tbody tr {
|
nz-table tbody tr {
|
||||||
display: block;
|
display: block;
|
||||||
margin-bottom: 16px;
|
margin-bottom: 16px;
|
||||||
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
|
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
padding: 12px;
|
padding: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
nz-table tbody td {
|
nz-table tbody td {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
padding: 6px 12px;
|
padding: 6px 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
nz-table tbody td::before {
|
nz-table tbody td::before {
|
||||||
content: attr(data-label);
|
content: attr(data-label);
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<nz-table [nzData]="deliverers()"
|
<nz-table [nzData]="deliverers()"
|
||||||
[nzFrontPagination]="false"
|
[nzFrontPagination]="false"
|
||||||
[nzLoading]="deliverersLoading()">
|
[nzLoading]="deliverersLoading()">
|
||||||
<thead>
|
<thead>
|
||||||
<tr class="text-center">
|
<tr class="text-center">
|
||||||
<th>Transporteur</th>
|
<th>Transporteur</th>
|
||||||
@@ -11,12 +11,12 @@
|
|||||||
<tbody class="text-center">
|
<tbody class="text-center">
|
||||||
@for (deliverer of deliverers(); track deliverer.id) {
|
@for (deliverer of deliverers(); track deliverer.id) {
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{deliverer.transporter}}</td>
|
<td>{{ deliverer.transporter }}</td>
|
||||||
<td>
|
<td>
|
||||||
<app-modal-button type="link" name="Voir tout les bons de livraison" size="50%">
|
<app-modal-button type="link" name="Voir tout les bons de livraison" size="50%">
|
||||||
<div style="max-height: 400px; overflow-y: auto;">
|
<div style="max-height: 400px; overflow-y: auto;">
|
||||||
<nz-table [nzData]="deliverers()"
|
<nz-table [nzData]="deliverers()"
|
||||||
[nzFrontPagination]="false">
|
[nzFrontPagination]="false">
|
||||||
<thead>
|
<thead>
|
||||||
<tr class="text-center">
|
<tr class="text-center">
|
||||||
<th>Numéro de livraison</th>
|
<th>Numéro de livraison</th>
|
||||||
@@ -28,10 +28,10 @@
|
|||||||
<tbody class="text-center">
|
<tbody class="text-center">
|
||||||
@for (deliveryInfo of deliverer.deliveryNotes; track deliveryInfo.id) {
|
@for (deliveryInfo of deliverer.deliveryNotes; track deliveryInfo.id) {
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{deliveryInfo.trackingNumber}}</td>
|
<td>{{ deliveryInfo.trackingNumber }}</td>
|
||||||
<td>{{deliveryInfo.expeditionDate | date: 'dd/MM/yyyy'}}</td>
|
<td>{{ deliveryInfo.expeditionDate | date: 'dd/MM/yyyy' }}</td>
|
||||||
<td>{{deliveryInfo.estimateDeliveryDate | date: 'dd/MM/yyyy'}}</td>
|
<td>{{ deliveryInfo.estimateDeliveryDate | date: 'dd/MM/yyyy' }}</td>
|
||||||
<td>{{deliveryInfo.realDeliveryDate | date: 'dd/MM/yyyy'}}</td>
|
<td>{{ deliveryInfo.realDeliveryDate | date: 'dd/MM/yyyy' }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
}
|
}
|
||||||
</tbody>
|
</tbody>
|
||||||
@@ -41,9 +41,13 @@
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div style="justify-content: center; display: flex">
|
<div style="justify-content: center; display: flex">
|
||||||
<nz-icon nzType="edit" nzTheme="outline" class="cursor-pointer" (click)="openEditModal(deliverer)"></nz-icon>
|
<nz-icon nzType="edit" nzTheme="outline" class="cursor-pointer"
|
||||||
<nz-divider nzType="vertical"></nz-divider>
|
(click)="openEditModal(deliverer)"></nz-icon>
|
||||||
<nz-icon nzType="delete" nzTheme="outline" (click)="delete(deliverer.id)" class="text-red-600 cursor-pointer"></nz-icon>
|
@if (admin()){
|
||||||
|
<nz-divider nzType="vertical"></nz-divider>
|
||||||
|
<nz-icon nzType="delete" nzTheme="outline" (click)="delete(deliverer.id)"
|
||||||
|
class="text-red-600 cursor-pointer"></nz-icon>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -52,7 +56,8 @@
|
|||||||
</nz-table>
|
</nz-table>
|
||||||
|
|
||||||
<div class="hidden">
|
<div class="hidden">
|
||||||
<app-modal-nav #modalNav nameIcon="edit" [name]="'Modifier'" (ok)="onModalOk(selectedDeliverer.id, delivererForm, modalNav)" (cancel)="onModalCancel(modalNav)">
|
<app-modal-nav #modalNav nameIcon="edit" [name]="'Modifier'"
|
||||||
|
(ok)="onModalOk(selectedDeliverer.id, delivererForm, modalNav)" (cancel)="onModalCancel(modalNav)">
|
||||||
<app-deliverer-form #delivererForm [deliverer]="selectedDeliverer"></app-deliverer-form>
|
<app-deliverer-form #delivererForm [deliverer]="selectedDeliverer"></app-deliverer-form>
|
||||||
</app-modal-nav>
|
</app-modal-nav>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -9,10 +9,10 @@ import {DelivererForm} from "../deliverer-form/deliverer-form";
|
|||||||
import {DeliverersService, GetDelivererDto, GetSupplierDto} from "../../services/api";
|
import {DeliverersService, GetDelivererDto, GetSupplierDto} from "../../services/api";
|
||||||
import {NzNotificationService} from "ng-zorro-antd/notification";
|
import {NzNotificationService} from "ng-zorro-antd/notification";
|
||||||
import {firstValueFrom} from "rxjs";
|
import {firstValueFrom} from "rxjs";
|
||||||
import {SupplierForm} from "../supplier-form/supplier-form";
|
import {AuthService} from "../../services/auth.service";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-deliverer-table',
|
selector: 'app-deliverer-table',
|
||||||
imports: [
|
imports: [
|
||||||
ModalNav,
|
ModalNav,
|
||||||
NzDividerComponent,
|
NzDividerComponent,
|
||||||
@@ -22,20 +22,24 @@ import {SupplierForm} from "../supplier-form/supplier-form";
|
|||||||
DatePipe,
|
DatePipe,
|
||||||
DelivererForm,
|
DelivererForm,
|
||||||
],
|
],
|
||||||
templateUrl: './deliverer-table.html',
|
templateUrl: './deliverer-table.html',
|
||||||
styleUrl: './deliverer-table.css',
|
styleUrl: './deliverer-table.css',
|
||||||
})
|
})
|
||||||
|
|
||||||
export class DelivererTable implements OnInit {
|
export class DelivererTable implements OnInit {
|
||||||
private deliverersService = inject(DeliverersService);
|
private deliverersService = inject(DeliverersService);
|
||||||
private notificationService = inject(NzNotificationService)
|
private notificationService = inject(NzNotificationService)
|
||||||
|
private authService = inject(AuthService);
|
||||||
|
|
||||||
deliverers = signal<GetDelivererDto[]>([]);
|
deliverers = signal<GetDelivererDto[]>([]);
|
||||||
deliverersLoading = signal<boolean>(false);
|
deliverersLoading = signal<boolean>(false);
|
||||||
updateDeliverer = viewChild.required<DelivererForm>('delivererForm');
|
admin = signal<boolean>(false);
|
||||||
|
|
||||||
modal = viewChild.required<ModalNav>('modalNav');
|
modal = viewChild.required<ModalNav>('modalNav');
|
||||||
|
|
||||||
async ngOnInit() {
|
async ngOnInit() {
|
||||||
await this.fetchDeliverers();
|
await this.fetchDeliverers();
|
||||||
|
this.admin.set(this.authService.isAdmin());
|
||||||
}
|
}
|
||||||
|
|
||||||
async fetchDeliverers() {
|
async fetchDeliverers() {
|
||||||
@@ -44,23 +48,17 @@ export class DelivererTable implements OnInit {
|
|||||||
try {
|
try {
|
||||||
const deliverers = await firstValueFrom(this.deliverersService.getAllDelivererEndpoint())
|
const deliverers = await firstValueFrom(this.deliverersService.getAllDelivererEndpoint())
|
||||||
this.deliverers.set(deliverers);
|
this.deliverers.set(deliverers);
|
||||||
} catch (e) {
|
} catch {
|
||||||
this.notificationService.error(
|
this.notificationService.error('Erreur', 'Erreur lors du chargement des transporteurs');
|
||||||
'Erreur',
|
|
||||||
'Erreur de communication avec l\'API'
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
this.deliverersLoading.set(false)
|
this.deliverersLoading.set(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
async delete(deliverer:number) {
|
async delete(deliverer: number) {
|
||||||
try {
|
try {
|
||||||
await firstValueFrom(this.deliverersService.deleteDelivererEndpoint(deliverer))
|
await firstValueFrom(this.deliverersService.deleteDelivererEndpoint(deliverer))
|
||||||
this.notificationService.success(
|
this.notificationService.success('Success', 'Suppression effectuée');
|
||||||
'Success',
|
} catch {
|
||||||
'Suppression effectuée'
|
|
||||||
)
|
|
||||||
} catch (e) {
|
|
||||||
this.notificationService.error(
|
this.notificationService.error(
|
||||||
'Erreur',
|
'Erreur',
|
||||||
'Impossible de supprimer la ligne'
|
'Impossible de supprimer la ligne'
|
||||||
@@ -71,10 +69,7 @@ export class DelivererTable implements OnInit {
|
|||||||
|
|
||||||
async edit(id: number, updateDelivererComponent: DelivererForm) {
|
async edit(id: number, updateDelivererComponent: DelivererForm) {
|
||||||
if (updateDelivererComponent.delivererForm.invalid) {
|
if (updateDelivererComponent.delivererForm.invalid) {
|
||||||
this.notificationService.error(
|
this.notificationService.error('Erreur', 'Formulaire invalide');
|
||||||
'Erreur',
|
|
||||||
'Erreur d\'écriture dans le formulaire'
|
|
||||||
)
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,14 +78,15 @@ export class DelivererTable implements OnInit {
|
|||||||
await firstValueFrom(this.deliverersService.updateDelivererEndpoint(id, deliverers))
|
await firstValueFrom(this.deliverersService.updateDelivererEndpoint(id, deliverers))
|
||||||
|
|
||||||
this.notificationService.success('Success', 'Transporteur modifié')
|
this.notificationService.success('Success', 'Transporteur modifié')
|
||||||
} catch (e) {
|
} catch {
|
||||||
this.notificationService.error('Erreur', 'Erreur lors de la modification')
|
this.notificationService.error('Erreur', 'Erreur lors de la modification')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
selectedDeliverer: GetDelivererDto | null = null;
|
selectedDeliverer: GetDelivererDto | null = null;
|
||||||
|
|
||||||
openEditModal(supplier: GetSupplierDto) {
|
openEditModal(supplier: GetSupplierDto) {
|
||||||
this.selectedDeliverer = { ...supplier };
|
this.selectedDeliverer = {...supplier};
|
||||||
this.modal().showModal();
|
this.modal().showModal();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,7 +95,7 @@ export class DelivererTable implements OnInit {
|
|||||||
|
|
||||||
await this.edit(supplierId, updateDelivererComponent);
|
await this.edit(supplierId, updateDelivererComponent);
|
||||||
updateDelivererComponent.delivererForm.reset();
|
updateDelivererComponent.delivererForm.reset();
|
||||||
modal.isVisible = false;
|
this.onModalCancel(modal);
|
||||||
await this.fetchDeliverers();
|
await this.fetchDeliverers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
</nz-form-label>
|
</nz-form-label>
|
||||||
|
|
||||||
<nz-form-control nzSpan="9" nzErrorTip="Ce champ est requis">
|
<nz-form-control nzSpan="9" nzErrorTip="Ce champ est requis">
|
||||||
<nz-select formControlName="delivererId" [nzPlaceHolder]="'Choisir un transporteur'" nzShowSearch [nzFilterOption]="filter">
|
<nz-select formControlName="delivererId" nzPlaceHolder="Choisir un transporteur" nzShowSearch>
|
||||||
@for (deliverer of deliverers(); track deliverer.id) {
|
@for (deliverer of deliverers(); track deliverer.id) {
|
||||||
<nz-option [nzValue]="deliverer.id" [nzLabel]="deliverer.transporter"></nz-option>
|
<nz-option [nzValue]="deliverer.id" [nzLabel]="deliverer.transporter"></nz-option>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import {NzNotificationService} from "ng-zorro-antd/notification";
|
|||||||
import {firstValueFrom} from "rxjs";
|
import {firstValueFrom} from "rxjs";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-deliverery-note-form',
|
selector: 'app-deliverery-note-form',
|
||||||
imports: [
|
imports: [
|
||||||
NzFormItemComponent,
|
NzFormItemComponent,
|
||||||
NzFormLabelComponent,
|
NzFormLabelComponent,
|
||||||
@@ -23,27 +23,30 @@ import {firstValueFrom} from "rxjs";
|
|||||||
NzSelectComponent,
|
NzSelectComponent,
|
||||||
NzOptionComponent,
|
NzOptionComponent,
|
||||||
],
|
],
|
||||||
templateUrl: './deliverery-note-form.html',
|
templateUrl: './deliverery-note-form.html',
|
||||||
styleUrl: './deliverery-note-form.css',
|
styleUrl: './deliverery-note-form.css',
|
||||||
})
|
})
|
||||||
export class DelivereryNoteForm implements OnInit {
|
export class DelivereryNoteForm implements OnInit {
|
||||||
deliveryNoteForm: FormGroup = new FormGroup({
|
deliveryNoteForm: FormGroup = new FormGroup({
|
||||||
trackingNumber: new FormControl<string>(null),
|
trackingNumber: new FormControl<string>(null),
|
||||||
delivererId: new FormControl<number>(null,[Validators.required]),
|
delivererId: new FormControl<number>(null, [Validators.required]),
|
||||||
expeditionDate: new FormControl(null,[Validators.required]),
|
expeditionDate: new FormControl(null, [Validators.required]),
|
||||||
estimatedDate: new FormControl(null),
|
estimatedDate: new FormControl(null, [Validators.required]),
|
||||||
realDeliveryDate: new FormControl(null)
|
realDeliveryDate: new FormControl(null)
|
||||||
})
|
})
|
||||||
|
|
||||||
private deliverersService = inject(DeliverersService);
|
private deliverersService = inject(DeliverersService);
|
||||||
private notificationService = inject(NzNotificationService);
|
private notificationService = inject(NzNotificationService);
|
||||||
|
|
||||||
deliverers = signal<GetDelivererDto[]>([]);
|
deliverers = signal<GetDelivererDto[]>([]);
|
||||||
|
|
||||||
|
deliveryNote = input<GetDeliveryNoteDto>();
|
||||||
|
|
||||||
async fetchDeliverers() {
|
async fetchDeliverers() {
|
||||||
try {
|
try {
|
||||||
const deliverers = await firstValueFrom(this.deliverersService.getAllDelivererEndpoint());
|
const deliverers = await firstValueFrom(this.deliverersService.getAllDelivererEndpoint());
|
||||||
this.deliverers.set(deliverers);
|
this.deliverers.set(deliverers);
|
||||||
} catch (e) {
|
} catch {
|
||||||
this.notificationService.error('Erreur', 'Impossible de récupérer les transporteurs');
|
this.notificationService.error('Erreur', 'Impossible de récupérer les transporteurs');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -52,19 +55,14 @@ export class DelivereryNoteForm implements OnInit {
|
|||||||
await this.fetchDeliverers();
|
await this.fetchDeliverers();
|
||||||
}
|
}
|
||||||
|
|
||||||
filter(input: string, option: any) {
|
|
||||||
return option.nzLabel.toLowerCase().includes(input.toLowerCase());
|
|
||||||
}
|
|
||||||
|
|
||||||
deliveryNote= input<GetDeliveryNoteDto>();
|
|
||||||
constructor() {
|
constructor() {
|
||||||
effect(() => {
|
effect(() => {
|
||||||
if (this.deliveryNote()) {
|
if (this.deliveryNote()) {
|
||||||
this.deliveryNoteForm.patchValue({
|
this.deliveryNoteForm.patchValue({
|
||||||
trackingNumber: this.deliveryNote().trackingNumber,
|
trackingNumber: this.deliveryNote().trackingNumber,
|
||||||
expeditionDate: this.deliveryNote().expeditionDate,
|
expeditionDate: this.deliveryNote().expeditionDate,
|
||||||
realDeliveryDate: this.deliveryNote().expeditionDate,
|
realDeliveryDate: this.deliveryNote().realDeliveryDate,
|
||||||
estimatedDate: this.deliveryNote().expeditionDate,
|
estimatedDate: this.deliveryNote().estimateDeliveryDate,
|
||||||
delivererId: this.deliveryNote().delivererId
|
delivererId: this.deliveryNote().delivererId
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ nz-table {
|
|||||||
background: #fff;
|
background: #fff;
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
box-shadow: 0 2px 6px rgba(0,0,0,0.1);
|
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
|
||||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,18 +66,21 @@ nz-table tbody td p {
|
|||||||
nz-table thead {
|
nz-table thead {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
nz-table tbody tr {
|
nz-table tbody tr {
|
||||||
display: block;
|
display: block;
|
||||||
margin-bottom: 16px;
|
margin-bottom: 16px;
|
||||||
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
|
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
padding: 12px;
|
padding: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
nz-table tbody td {
|
nz-table tbody td {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
padding: 6px 12px;
|
padding: 6px 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
nz-table tbody td::before {
|
nz-table tbody td::before {
|
||||||
content: attr(data-label);
|
content: attr(data-label);
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
|
|||||||
@@ -1,60 +1,50 @@
|
|||||||
<nz-table [nzData]="deliveryNotes()"
|
<nz-table [nzData]="deliveryNotes()"
|
||||||
class="mr-7"
|
class="mr-7"
|
||||||
[nzFrontPagination]="false"
|
[nzFrontPagination]="false"
|
||||||
[nzLoading]="deliveryNotesLoading()">
|
[nzLoading]="deliveryNotesLoading()">
|
||||||
<thead>
|
<thead>
|
||||||
<tr class="text-center">
|
<tr class="text-center">
|
||||||
<th>Numéro de livraison</th>
|
<th>Numéro de livraison</th>
|
||||||
<th>Transporteur</th>
|
<th>Transporteur</th>
|
||||||
<th>Date d'expédition</th>
|
<th>Date d'expédition</th>
|
||||||
<th>Date de livraison estimée</th>
|
<th>Date de livraison estimée</th>
|
||||||
<th>Date de livraison réelle</th>
|
<th>Date de livraison réelle</th>
|
||||||
<th>Produits</th>
|
<th>Statut</th>
|
||||||
<th>Action</th>
|
<th>Action</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead >
|
</thead>
|
||||||
<tbody class="text-center">
|
<tbody class="text-center">
|
||||||
@for (deliveryNote of deliveryNotes(); track deliveryNote.id) {
|
@for (deliveryNote of deliveryNotes(); track deliveryNote.id) {
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{deliveryNote.trackingNumber}}</td>
|
<td>{{ deliveryNote.trackingNumber }}</td>
|
||||||
<td>{{deliveryNote.delivererTransporter}}</td>
|
<td>{{ deliveryNote.delivererTransporter }}</td>
|
||||||
<td>{{deliveryNote.expeditionDate | date: 'dd/MM/yyyy'}}</td>
|
<td>{{ deliveryNote.expeditionDate | date: 'dd/MM/yyyy' }}</td>
|
||||||
<td>{{deliveryNote.estimateDeliveryDate | date: 'dd/MM/yyyy'}}</td>
|
<td>{{ deliveryNote.estimateDeliveryDate | date: 'dd/MM/yyyy' }}</td>
|
||||||
<td>{{deliveryNote.realDeliveryDate | date: 'dd/MM/yyyy'}}</td>
|
<td>{{ deliveryNote.realDeliveryDate | date: 'dd/MM/yyyy' }}</td>
|
||||||
<td>
|
<td>
|
||||||
<app-modal-button type="link" name="Voir les produits" size="40%">
|
@if (deliveryNote.estimateDeliveryDate >= date && deliveryNote.realDeliveryDate == null) {
|
||||||
<div style="max-height: 400px; overflow-y: auto;">
|
<p class="text-blue-900 font-semibold">En cours</p>
|
||||||
<nz-table [nzData]="deliveryNotes()"
|
} @else if (deliveryNote.realDeliveryDate == null) {
|
||||||
[nzFrontPagination]="false">
|
<p class="text-red-600 font-semibold">En retard</p>
|
||||||
<thead>
|
} @else {
|
||||||
<tr class="text-center">
|
<p class="text-green-800 font-semibold">Terminée</p>
|
||||||
<th>Réference</th>
|
}
|
||||||
<th>Nom</th>
|
|
||||||
<th>Quantité</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody class="text-center">
|
|
||||||
@for (product of deliveryNote.products; track product.productId) {
|
|
||||||
<tr>
|
|
||||||
<td>{{product.productReference}}</td>
|
|
||||||
<td>{{product.productName}}</td>
|
|
||||||
<td>{{product.quantity}}</td>
|
|
||||||
</tr>
|
|
||||||
}
|
|
||||||
</tbody>
|
|
||||||
</nz-table>
|
|
||||||
</div>
|
|
||||||
</app-modal-button>
|
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div style="justify-content: center; display: flex">
|
<div style="justify-content: center; display: flex">
|
||||||
<nz-icon nzType="check" nzTheme="outline" (click)="validate(deliveryNote.id)" class="cursor-pointer text-green-700"/>
|
<nz-icon nzType="check" nzTheme="outline" (click)="validate(deliveryNote.id)"
|
||||||
|
class="cursor-pointer text-green-700"/>
|
||||||
<nz-divider nzType="vertical"></nz-divider>
|
<nz-divider nzType="vertical"></nz-divider>
|
||||||
<nz-icon nzType="edit" nzTheme="outline" class="cursor-pointer" (click)="openEditModal(deliveryNote)"></nz-icon>
|
<nz-icon nzType="edit" nzTheme="outline" class="cursor-pointer"
|
||||||
|
(click)="openEditModal(deliveryNote)"></nz-icon>
|
||||||
<nz-divider nzType="vertical"></nz-divider>
|
<nz-divider nzType="vertical"></nz-divider>
|
||||||
<nz-icon nzType="delete" nzTheme="outline" (click)="delete(deliveryNote.id)" class="cursor-pointer text-red-700"/>
|
@if (admin()){
|
||||||
<nz-divider nzType="vertical"></nz-divider>
|
<nz-icon nzType="delete" nzTheme="outline" (click)="delete(deliveryNote.id)"
|
||||||
<nz-icon nzType="export" nzTheme="outline" (click)="export(deliveryNote.id)" class="cursor-pointer text-green-700"/>
|
class="cursor-pointer text-red-700"/>
|
||||||
|
<nz-divider nzType="vertical"></nz-divider>
|
||||||
|
}
|
||||||
|
<nz-icon nzType="export" nzTheme="outline" (click)="export(deliveryNote.id)"
|
||||||
|
class="cursor-pointer text-green-700"/>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -63,7 +53,9 @@
|
|||||||
</nz-table>
|
</nz-table>
|
||||||
|
|
||||||
<div class="hidden">
|
<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-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-deliverery-note-form #deliveryNoteForm [deliveryNote]="selectedDeliveryNote"></app-deliverery-note-form>
|
||||||
</app-modal-nav>
|
</app-modal-nav>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,21 +1,20 @@
|
|||||||
import {Component, inject, OnInit, signal, viewChild} from '@angular/core';
|
import {Component, inject, OnInit, signal, viewChild} from '@angular/core';
|
||||||
import {DatePipe} from "@angular/common";
|
import {DatePipe} from "@angular/common";
|
||||||
import {ModalButton} from "../modal-button/modal-button";
|
|
||||||
import {ModalNav} from "../modal-nav/modal-nav";
|
import {ModalNav} from "../modal-nav/modal-nav";
|
||||||
import {NzDividerComponent} from "ng-zorro-antd/divider";
|
import {NzDividerComponent} from "ng-zorro-antd/divider";
|
||||||
import {NzIconDirective} from "ng-zorro-antd/icon";
|
import {NzIconDirective} from "ng-zorro-antd/icon";
|
||||||
import {NzTableComponent} from "ng-zorro-antd/table";
|
import {NzTableComponent} from "ng-zorro-antd/table";
|
||||||
import {DelivereryNoteForm} from "../deliverery-note-form/deliverery-note-form";
|
import {DelivereryNoteForm} from "../deliverery-note-form/deliverery-note-form";
|
||||||
import {DeliverynotesService, GetDeliveryNoteDto} from "../../services/api";
|
import {DeliverynotesService, GetDeliveryNoteDto, UpdateDeliveryNoteDto} from "../../services/api";
|
||||||
import {NzNotificationService} from "ng-zorro-antd/notification";
|
import {NzNotificationService} from "ng-zorro-antd/notification";
|
||||||
import {firstValueFrom} from "rxjs";
|
import {firstValueFrom} from "rxjs";
|
||||||
import {format} from "date-fns";
|
import {format} from "date-fns";
|
||||||
import {FileService} from "../../services/file.service";
|
import {FileService} from "../../services/file.service";
|
||||||
|
import {AuthService} from "../../services/auth.service";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-deliverery-note-table',
|
selector: 'app-deliverery-note-table',
|
||||||
imports: [
|
imports: [
|
||||||
ModalButton,
|
|
||||||
ModalNav,
|
ModalNav,
|
||||||
NzDividerComponent,
|
NzDividerComponent,
|
||||||
NzIconDirective,
|
NzIconDirective,
|
||||||
@@ -23,54 +22,52 @@ import {FileService} from "../../services/file.service";
|
|||||||
DelivereryNoteForm,
|
DelivereryNoteForm,
|
||||||
DatePipe,
|
DatePipe,
|
||||||
],
|
],
|
||||||
templateUrl: './deliverery-note-table.html',
|
templateUrl: './deliverery-note-table.html',
|
||||||
styleUrl: './deliverery-note-table.css',
|
styleUrl: './deliverery-note-table.css',
|
||||||
})
|
})
|
||||||
export class DelivereryNoteTable implements OnInit {
|
export class DelivereryNoteTable implements OnInit {
|
||||||
private deliveryNotesService = inject(DeliverynotesService);
|
private deliveryNotesService = inject(DeliverynotesService);
|
||||||
private notificationService = inject(NzNotificationService);
|
private notificationService = inject(NzNotificationService);
|
||||||
private fileService = inject(FileService);
|
private fileService = inject(FileService);
|
||||||
|
private authService = inject(AuthService);
|
||||||
|
|
||||||
deliveryNotes = signal<GetDeliveryNoteDto[]>([]);
|
deliveryNotes = signal<GetDeliveryNoteDto[]>([]);
|
||||||
deliveryNotesLoading = signal<boolean>(false);
|
deliveryNotesLoading = signal<boolean>(false);
|
||||||
|
admin = signal<boolean>(false);
|
||||||
|
|
||||||
modal = viewChild.required<ModalNav>('modalNav');
|
modal = viewChild.required<ModalNav>('modalNav');
|
||||||
|
|
||||||
|
date = new Date().toISOString().split('T')[0]; // yyyy-mm-dd
|
||||||
|
|
||||||
async ngOnInit() {
|
async ngOnInit() {
|
||||||
await this.fetchDeliveryNotes();
|
await this.fetchDeliveryNotes();
|
||||||
|
this.admin.set(this.authService.isAdmin());
|
||||||
}
|
}
|
||||||
|
|
||||||
async fetchDeliveryNotes() {
|
async fetchDeliveryNotes() {
|
||||||
this.deliveryNotesLoading.set(true)
|
this.deliveryNotesLoading.set(true)
|
||||||
try {
|
try {
|
||||||
const deliveryNotes = await firstValueFrom(this.deliveryNotesService.getAllDeliveryNoteEndpoint())
|
const deliveryNotes = await firstValueFrom(this.deliveryNotesService.getAllDeliveryNoteEndpoint());
|
||||||
this.deliveryNotes.set(deliveryNotes);
|
this.deliveryNotes.set(deliveryNotes);
|
||||||
} catch (e) {
|
} catch {
|
||||||
this.notificationService.error(
|
this.notificationService.error('Erreur', 'Erreur lors du chargement des bons de livraison');
|
||||||
'Erreur',
|
|
||||||
'Erreur de communication avec l\'API'
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
this.deliveryNotesLoading.set(false)
|
this.deliveryNotesLoading.set(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
async delete(deliveryNote:number) {
|
async delete(deliveryNote: number) {
|
||||||
this.deliveryNotesLoading.set(true)
|
this.deliveryNotesLoading.set(true)
|
||||||
try {
|
try {
|
||||||
await firstValueFrom(this.deliveryNotesService.deleteDeliveryNoteEndpoint(deliveryNote));
|
await firstValueFrom(this.deliveryNotesService.deleteDeliveryNoteEndpoint(deliveryNote));
|
||||||
this.notificationService.success(
|
this.notificationService.success('Success', 'Suppression effectuée');
|
||||||
'Success',
|
} catch {
|
||||||
'Suppression effectuée'
|
this.notificationService.error('Erreur', 'Impossible de supprimer la ligne');
|
||||||
)
|
|
||||||
} catch (e) {
|
|
||||||
this.notificationService.error(
|
|
||||||
'Erreur',
|
|
||||||
'Impossible de supprimer la ligne'
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
this.deliveryNotesLoading.set(false)
|
this.deliveryNotesLoading.set(false)
|
||||||
await this.fetchDeliveryNotes();
|
await this.fetchDeliveryNotes();
|
||||||
}
|
}
|
||||||
|
|
||||||
async validate(deliveryNote:number) {
|
async validate(deliveryNote: number) {
|
||||||
this.deliveryNotesLoading.set(true)
|
this.deliveryNotesLoading.set(true)
|
||||||
try {
|
try {
|
||||||
const PatchRealDate = {
|
const PatchRealDate = {
|
||||||
@@ -79,22 +76,12 @@ export class DelivereryNoteTable implements OnInit {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
await firstValueFrom(this.deliveryNotesService.patchRealDeliveryDateEndpoint(deliveryNote, PatchRealDate))
|
await firstValueFrom(this.deliveryNotesService.patchRealDeliveryDateEndpoint(deliveryNote, PatchRealDate))
|
||||||
|
this.notificationService.success('Success', 'Date actualisée');
|
||||||
this.notificationService.success(
|
} catch {
|
||||||
'Success',
|
this.notificationService.error('Erreur', 'La date à déjà été actualisée');
|
||||||
'Date actualisée'
|
|
||||||
)
|
|
||||||
} catch (e) {
|
|
||||||
this.notificationService.error(
|
|
||||||
'Erreur',
|
|
||||||
'La date à déjà été actualisée'
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch {
|
||||||
this.notificationService.error(
|
this.notificationService.error('Erreur', 'Erreur d\'actualisation de la date');
|
||||||
'Erreur',
|
|
||||||
'Erreur d\'actualisation de la date'
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
this.deliveryNotesLoading.set(false)
|
this.deliveryNotesLoading.set(false)
|
||||||
await this.fetchDeliveryNotes()
|
await this.fetchDeliveryNotes()
|
||||||
@@ -103,15 +90,10 @@ export class DelivereryNoteTable implements OnInit {
|
|||||||
async export(deliveryNoteId: number) {
|
async export(deliveryNoteId: number) {
|
||||||
this.deliveryNotesLoading.set(true)
|
this.deliveryNotesLoading.set(true)
|
||||||
try {
|
try {
|
||||||
const pdf = await firstValueFrom(
|
const pdf = await firstValueFrom(this.deliveryNotesService.getDeliveryNotePdfEndpoint(deliveryNoteId, "response"));
|
||||||
this.deliveryNotesService.getDeliveryNotePdfEndpoint(deliveryNoteId, "response")
|
|
||||||
);
|
|
||||||
this.fileService.downloadBlob(pdf)
|
this.fileService.downloadBlob(pdf)
|
||||||
} catch (e) {
|
} catch {
|
||||||
this.notificationService.error(
|
this.notificationService.error('Erreur', 'Impossible de générer un PDF');
|
||||||
'Erreur',
|
|
||||||
'Impossible de générer un PDF'
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
this.deliveryNotesLoading.set(false)
|
this.deliveryNotesLoading.set(false)
|
||||||
}
|
}
|
||||||
@@ -125,41 +107,28 @@ export class DelivereryNoteTable implements OnInit {
|
|||||||
try {
|
try {
|
||||||
const raw = updateDelivereryNoteComponent.deliveryNoteForm.getRawValue();
|
const raw = updateDelivereryNoteComponent.deliveryNoteForm.getRawValue();
|
||||||
|
|
||||||
// convertit proprement les dates (string OU Date)
|
const toIso = (val: any) =>
|
||||||
const toIso = (val: any) => {
|
val ? new Date(val).toISOString().substring(0, 10) : null;
|
||||||
if (!val) return null;
|
|
||||||
|
|
||||||
// si c’est déjà un string ISO "yyyy-MM-dd", on renvoie tel quel
|
const deliveryNoteDto: UpdateDeliveryNoteDto = {
|
||||||
if (typeof val === 'string' && /^\d{4}-\d{2}-\d{2}/.test(val)) {
|
|
||||||
return val.substring(0, 10);
|
|
||||||
}
|
|
||||||
|
|
||||||
// sinon on reconstruit une Date
|
|
||||||
const d = new Date(val);
|
|
||||||
if (isNaN(d.getTime())) return null;
|
|
||||||
|
|
||||||
return d.toISOString().substring(0, 10); // yyyy-MM-dd
|
|
||||||
};
|
|
||||||
|
|
||||||
const deliveryNoteDto = {
|
|
||||||
trackingNumber: raw.trackingNumber,
|
trackingNumber: raw.trackingNumber,
|
||||||
delivererId: raw.delivererId,
|
delivererId: raw.delivererId,
|
||||||
expeditionDate: toIso(raw.expeditionDate),
|
expeditionDate: toIso(raw.expeditionDate),
|
||||||
estimatedDate: toIso(raw.estimatedDate),
|
estimateDeliveryDate: toIso(raw.estimatedDate),
|
||||||
realDeliveryDate: toIso(raw.realDeliveryDate)
|
realDeliveryDate: toIso(raw.realDeliveryDate)
|
||||||
};
|
};
|
||||||
|
|
||||||
await firstValueFrom(this.deliveryNotesService.updateDeliveryNoteEndpoint(id, deliveryNoteDto));
|
await firstValueFrom(this.deliveryNotesService.updateDeliveryNoteEndpoint(id, deliveryNoteDto));
|
||||||
this.notificationService.success('Success', 'Bon de livraison modifié');
|
this.notificationService.success('Success', 'Bon de livraison modifié');
|
||||||
} catch (e) {
|
} catch {
|
||||||
console.error(e);
|
|
||||||
this.notificationService.error('Erreur', 'Erreur lors de la modification');
|
this.notificationService.error('Erreur', 'Erreur lors de la modification');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
selectedDeliveryNote: GetDeliveryNoteDto | null = null;
|
selectedDeliveryNote: GetDeliveryNoteDto | null = null;
|
||||||
|
|
||||||
openEditModal(deliveryNote: GetDeliveryNoteDto) {
|
openEditModal(deliveryNote: GetDeliveryNoteDto) {
|
||||||
this.selectedDeliveryNote = { ...deliveryNote };
|
this.selectedDeliveryNote = {...deliveryNote};
|
||||||
this.modal().showModal();
|
this.modal().showModal();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,7 +137,7 @@ export class DelivereryNoteTable implements OnInit {
|
|||||||
|
|
||||||
await this.edit(id, updateDelivereryNoteComponent);
|
await this.edit(id, updateDelivereryNoteComponent);
|
||||||
updateDelivereryNoteComponent.deliveryNoteForm.reset();
|
updateDelivereryNoteComponent.deliveryNoteForm.reset();
|
||||||
modal.isVisible = false;
|
this.onModalCancel(modal);
|
||||||
await this.fetchDeliveryNotes();
|
await this.fetchDeliveryNotes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,11 +11,9 @@
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: flex-start;
|
align-items: flex-start;
|
||||||
|
|
||||||
/* Box shadow pour effet superposition */
|
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.06),
|
||||||
box-shadow:
|
0 8px 20px rgba(0, 0, 0, 0.08),
|
||||||
0 4px 8px rgba(0, 0, 0, 0.06),
|
0 16px 40px rgba(0, 0, 0, 0.06);
|
||||||
0 8px 20px rgba(0, 0, 0, 0.08),
|
|
||||||
0 16px 40px rgba(0, 0, 0, 0.06);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -32,19 +30,17 @@
|
|||||||
|
|
||||||
.search-input:focus {
|
.search-input:focus {
|
||||||
border-color: #3b82f6;
|
border-color: #3b82f6;
|
||||||
box-shadow: 0 0 8px rgba(59,130,246,0.2);
|
box-shadow: 0 0 8px rgba(59, 130, 246, 0.2);
|
||||||
outline: none;
|
outline: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Liste scrollable */
|
|
||||||
.livraisons-list {
|
.livraisons-list {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
max-height: 350px; /* hauteur max de la liste */
|
max-height: 500px;
|
||||||
overflow-y: auto; /* scroll vertical activé */
|
overflow-y: auto;
|
||||||
padding-right: 10px; /* pour le scrollbar */
|
padding-right: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Scrollbar personnalisée (optionnel) */
|
|
||||||
.livraisons-list::-webkit-scrollbar {
|
.livraisons-list::-webkit-scrollbar {
|
||||||
width: 8px;
|
width: 8px;
|
||||||
}
|
}
|
||||||
@@ -58,12 +54,11 @@
|
|||||||
background: #f3f4f6;
|
background: #f3f4f6;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Carte de livraison */
|
|
||||||
.livraison-card {
|
.livraison-card {
|
||||||
background: #ffffff;
|
background: #ffffff;
|
||||||
padding: 20px 22px;
|
padding: 20px 22px;
|
||||||
border-radius: 14px;
|
border-radius: 14px;
|
||||||
box-shadow: 0 6px 16px rgba(0,0,0,0.05);
|
box-shadow: 0 6px 16px rgba(0, 0, 0, 0.05);
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@@ -74,10 +69,9 @@
|
|||||||
|
|
||||||
.livraison-card:hover {
|
.livraison-card:hover {
|
||||||
transform: translateY(-3px);
|
transform: translateY(-3px);
|
||||||
box-shadow: 0 10px 22px rgba(0,0,0,0.08);
|
box-shadow: 0 10px 22px rgba(0, 0, 0, 0.08);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Infos livraison */
|
|
||||||
.livraison-info h3 {
|
.livraison-info h3 {
|
||||||
font-size: 17px;
|
font-size: 17px;
|
||||||
margin: 0 0 4px;
|
margin: 0 0 4px;
|
||||||
@@ -89,26 +83,3 @@
|
|||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
color: #6b7280;
|
color: #6b7280;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Bouton valider */
|
|
||||||
.validate-btn {
|
|
||||||
padding: 10px 20px;
|
|
||||||
border-radius: 12px;
|
|
||||||
border: none;
|
|
||||||
cursor: pointer;
|
|
||||||
font-weight: 600;
|
|
||||||
background: #3b82f6;
|
|
||||||
color: white;
|
|
||||||
transition: all 0.3s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.validate-btn:hover {
|
|
||||||
background: #2563eb;
|
|
||||||
}
|
|
||||||
|
|
||||||
.validate-btn.validated {
|
|
||||||
background: #9ca3af;
|
|
||||||
cursor: default;
|
|
||||||
color: #ffffff;
|
|
||||||
opacity: 0.9;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,19 +1,57 @@
|
|||||||
<div class="livraisons-container">
|
<div class="livraisons-container">
|
||||||
<input type="text" placeholder="Rechercher une livraison" class="search-input" (input)="search.set($any($event.target).value)"/>
|
<input type="text" placeholder="Rechercher une livraison" class="search-input"
|
||||||
|
(input)="search.set($any($event.target).value)"/>
|
||||||
|
|
||||||
<div class="livraisons-list">
|
<div class="livraisons-list">
|
||||||
@for (deliveryItem of filteredLivraisons(); track deliveryItem.id) {
|
@for (deliveryItem of filteredDeliveries(); track deliveryItem.id) {
|
||||||
<div class="livraison-card">
|
<div class="livraison-card">
|
||||||
<div class="livraison-info">
|
<div class="livraison-info">
|
||||||
<h3>{{ deliveryItem.client }}</h3>
|
<h3>{{ deliveryItem.delivererTransporter }}</h3>
|
||||||
<p class="mr-5">Date d'expédition: {{ deliveryItem.date }}</p>
|
<p class="mr-5">Date d'expédition: {{ deliveryItem.expeditionDate }}</p>
|
||||||
<p>Produits : {{ deliveryItem.produits }}</p>
|
<p>Quantité livrée : {{ deliveryItem.products.length }}</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button nz-button nzType="primary" [nzSize]="size" nzShape="round" (click)="validate(deliveryItem.id)">
|
<app-modal-nav #modal name="Valider la livraison" nameIcon="check"
|
||||||
<nz-icon nzType="check" />
|
(click)="check(deliveryItem.id)"
|
||||||
Valider
|
(ok)="validate(deliveryItem.id, selectedWarehouseId!, modal)"
|
||||||
</button>
|
(cancel)="reject(modal)">
|
||||||
|
|
||||||
|
<div class="mb-4 flex justify-center">
|
||||||
|
<nz-select
|
||||||
|
[(ngModel)]="selectedWarehouseId"
|
||||||
|
nzPlaceHolder="Sélectionner un entrepôt"
|
||||||
|
required
|
||||||
|
class="w-64">
|
||||||
|
|
||||||
|
@for (wareHouse of wareHouses(); track wareHouse.id) {
|
||||||
|
<nz-option [nzValue]="wareHouse.id" [nzLabel]="wareHouse.name"/>
|
||||||
|
}
|
||||||
|
</nz-select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div style="max-height: 400px; overflow-y: auto;">
|
||||||
|
<nz-table [nzData]="filteredDeliveries()"
|
||||||
|
[nzFrontPagination]="false">
|
||||||
|
<thead>
|
||||||
|
<tr class="text-center">
|
||||||
|
<th>Réference</th>
|
||||||
|
<th>Nom</th>
|
||||||
|
<th>Quantité</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody class="text-center">
|
||||||
|
@for (product of deliveryItem.products; track product.productId) {
|
||||||
|
<tr>
|
||||||
|
<td>{{ product.productReference }}</td>
|
||||||
|
<td>{{ product.productName }}</td>
|
||||||
|
<td>{{ product.quantity }}</td>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
</tbody>
|
||||||
|
</nz-table>
|
||||||
|
</div>
|
||||||
|
</app-modal-nav>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,44 +1,105 @@
|
|||||||
import {Component, computed, signal} from '@angular/core';
|
import {Component, computed, inject, OnInit, signal} from '@angular/core';
|
||||||
import {NzButtonComponent, NzButtonSize} from "ng-zorro-antd/button";
|
import {
|
||||||
import {NzIconDirective} from "ng-zorro-antd/icon";
|
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({
|
@Component({
|
||||||
selector: 'app-delivery-validator',
|
selector: 'app-delivery-validator',
|
||||||
imports: [
|
imports: [
|
||||||
NzButtonComponent,
|
NzTableComponent,
|
||||||
NzIconDirective
|
ModalNav,
|
||||||
|
NzSelectComponent,
|
||||||
|
NzOptionComponent,
|
||||||
|
FormsModule
|
||||||
],
|
],
|
||||||
templateUrl: './delivery-validator.html',
|
templateUrl: './delivery-validator.html',
|
||||||
styleUrl: './delivery-validator.css',
|
styleUrl: './delivery-validator.css',
|
||||||
})
|
})
|
||||||
export class DeliveryValidator {
|
export class DeliveryValidator implements OnInit {
|
||||||
size: NzButtonSize = 'large';
|
private deliveryNotesService = inject(DeliverynotesService);
|
||||||
search = signal('');
|
private notificationService = inject(NzNotificationService);
|
||||||
|
private warehousesService = inject(WarehousesService);
|
||||||
|
private warehouseProductsService = inject(WarehouseproductsService);
|
||||||
|
|
||||||
livraisons = signal([
|
search = signal<string>('');
|
||||||
{ id: 1, client: 'Carrefour', date: '2025-02-03', produits: 12 },
|
deliveryNotes = signal<GetDeliveryNoteDto[]>([]);
|
||||||
{ id: 2, client: 'Intermarché', date: '2025-02-04', produits: 8 },
|
wareHouses = signal<GetWareHouseDto[]>([]);
|
||||||
{ 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 }
|
|
||||||
]);
|
|
||||||
|
|
||||||
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 lors du chargement des quantitées')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fetchDeliveryNotes() {
|
||||||
|
try {
|
||||||
|
const deliveries = await firstValueFrom(this.deliveryNotesService.getAllDeliveryNotesNotArrivedEndpoint());
|
||||||
|
this.deliveryNotes.set(deliveries);
|
||||||
|
} catch {
|
||||||
|
this.notificationService.error('Erreur', 'Erreur lors du chargement des bon de livraison')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
filteredDeliveries = computed(() => {
|
||||||
const query = this.search().toLowerCase();
|
const query = this.search().toLowerCase();
|
||||||
return this.livraisons().filter(l =>
|
return this.deliveryNotes().filter(l =>
|
||||||
l.client.toLowerCase().includes(query) ||
|
l.delivererTransporter.toLowerCase().includes(query) ||
|
||||||
l.date.includes(query)
|
l.expeditionDate.includes(query)
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
validate(id: number) {
|
async check(id: number) {
|
||||||
return
|
try {
|
||||||
|
const PatchRealDate = {
|
||||||
|
realDeliveryDate: format(new Date(), 'yyyy-MM-dd')
|
||||||
|
};
|
||||||
|
await firstValueFrom(this.deliveryNotesService.patchRealDeliveryDateEndpoint(id, PatchRealDate));
|
||||||
|
} catch {
|
||||||
|
this.notificationService.error('Erreur', 'Impossible d\'actualiser la date')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<div class="card-content">
|
<div class="card-content">
|
||||||
<div class="card-top">
|
<div class="card-top">
|
||||||
<nz-icon [ngStyle]="{ 'color': color() }" [nzType]="icon()" nzTheme="outline"></nz-icon>
|
<nz-icon [ngStyle]="{ 'color': color() }" [nzType]="icon()" nzTheme="outline"></nz-icon>
|
||||||
<p class="card-number">{{value()}}</p>
|
<p class="card-number">{{ value() }}</p>
|
||||||
</div>
|
</div>
|
||||||
<p class="card-text">{{description()}}</p>
|
<p class="card-text">{{ description() }}</p>
|
||||||
</div>
|
</div>
|
||||||
@@ -3,17 +3,17 @@ import {NzIconDirective} from "ng-zorro-antd/icon";
|
|||||||
import {NgStyle} from "@angular/common";
|
import {NgStyle} from "@angular/common";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-info-card',
|
selector: 'app-info-card',
|
||||||
imports: [
|
imports: [
|
||||||
NzIconDirective,
|
NzIconDirective,
|
||||||
NgStyle
|
NgStyle
|
||||||
],
|
],
|
||||||
templateUrl: './info-card.html',
|
templateUrl: './info-card.html',
|
||||||
styleUrl: './info-card.css',
|
styleUrl: './info-card.css',
|
||||||
})
|
})
|
||||||
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,72 +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;
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
<div class="documents-section">
|
|
||||||
<h1>Documents récents</h1>
|
|
||||||
<div class="content">
|
|
||||||
@for (doc of purchaseOrder(); track doc.id) {
|
|
||||||
<div>
|
|
||||||
<img src="https://cdn-icons-png.flaticon.com/512/337/337946.png" alt="pdf">
|
|
||||||
<p>{{ doc.name }}</p>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,122 @@
|
|||||||
|
:host {
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
|
||||||
|
.app-layout {
|
||||||
|
height: 100vh;
|
||||||
|
}
|
||||||
|
|
||||||
|
nz-header {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
background: #001529;
|
||||||
|
padding: 0 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header-container {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --- LOGO + TITRE --- */
|
||||||
|
.logo {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.logo a {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.logo img {
|
||||||
|
height: 40px;
|
||||||
|
width: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.logo h1 {
|
||||||
|
margin: 0 0 0 10px;
|
||||||
|
color: #fff;
|
||||||
|
font-weight: 600;
|
||||||
|
font-size: 20px;
|
||||||
|
font-family: Avenir, Helvetica Neue, Arial, Helvetica, sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --- MENU PRINCIPAL --- */
|
||||||
|
.top-nav {
|
||||||
|
flex: 1;
|
||||||
|
margin: 0 40px;
|
||||||
|
line-height: 64px;
|
||||||
|
background: #001529;
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Couleur grise par défaut + effet blanc et zoom au survol */
|
||||||
|
.top-nav li {
|
||||||
|
transition: transform 0.2s ease, color 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.top-nav li a {
|
||||||
|
color: #bfbfbf !important; /* gris clair par défaut */
|
||||||
|
transition: transform 0.2s ease, color 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Au survol → zoom + blanc pur */
|
||||||
|
.top-nav li:hover {
|
||||||
|
transform: scale(1.08);
|
||||||
|
background: transparent !important;
|
||||||
|
color: #fff !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.top-nav li:hover a {
|
||||||
|
color: #ffffff !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Supprime toute coloration bleue ou fond par défaut NG-ZORRO */
|
||||||
|
.top-nav li.ant-menu-item-active,
|
||||||
|
.top-nav li.ant-menu-item-selected {
|
||||||
|
background: transparent !important;
|
||||||
|
color: #fff !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --- ICONES DROITES --- */
|
||||||
|
.right-icons {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 20px;
|
||||||
|
color: #fff;
|
||||||
|
font-size: 18px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.right-icons app-modal-nav {
|
||||||
|
transition: transform 0.2s ease, color 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.disconnect {
|
||||||
|
transition: transform 0.2s ease, color 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.disconnect:hover {
|
||||||
|
color: #40a9ff;
|
||||||
|
transform: scale(1.2);
|
||||||
|
}
|
||||||
|
|
||||||
|
.right-icons app-modal-nav:hover {
|
||||||
|
color: #40a9ff;
|
||||||
|
transform: scale(1.2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --- CONTENU --- */
|
||||||
|
nz-content {
|
||||||
|
padding: 24px 50px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.inner-content {
|
||||||
|
padding: 24px;
|
||||||
|
background: #fff;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
@@ -0,0 +1,90 @@
|
|||||||
|
<nz-layout class="app-layout">
|
||||||
|
<nz-header>
|
||||||
|
<div class="header-container">
|
||||||
|
<!-- LOGO -->
|
||||||
|
<div class="logo">
|
||||||
|
<a routerLink="/dashboard">
|
||||||
|
<img
|
||||||
|
src="https://www.pyro-fetes.com/wp-content/themes/pcptheme/img/logo-pyro-fetes-OR-top.png"
|
||||||
|
alt="logo"
|
||||||
|
style="width: 100px; height: auto"
|
||||||
|
/>
|
||||||
|
<h1 class="text-amber-300">PYRO FÊTES</h1>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- MENU PRINCIPAL -->
|
||||||
|
<ul nz-menu class="top-nav" nzTheme="dark" nzMode="horizontal">
|
||||||
|
<li nz-menu-item routerLinkActive="ant-menu-item-selected">
|
||||||
|
<a routerLink="/stock">
|
||||||
|
<nz-icon nzType="stock"></nz-icon>
|
||||||
|
<span>Stock</span>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li nz-submenu nzTitle="Partenaires" nzIcon="team">
|
||||||
|
<ul>
|
||||||
|
<li nz-menu-item routerLinkActive="ant-menu-item-selected">
|
||||||
|
<a routerLink="/supplier">
|
||||||
|
<nz-icon nzType="shop"></nz-icon>
|
||||||
|
<span>Fournisseurs</span>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li nz-menu-item routerLinkActive="ant-menu-item-selected">
|
||||||
|
<a routerLink="/deliverer">
|
||||||
|
<nz-icon nzType="car"></nz-icon>
|
||||||
|
<span>Livreurs</span>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
<li nz-submenu nzTitle="Recettes" nzIcon="euro-circle">
|
||||||
|
<ul>
|
||||||
|
<li nz-menu-item routerLinkActive="ant-menu-item-selected">
|
||||||
|
<a routerLink="/quotation">
|
||||||
|
<nz-icon nzType="file"></nz-icon>
|
||||||
|
<span>Devis</span>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li nz-menu-item routerLinkActive="ant-menu-item-selected">
|
||||||
|
<a routerLink="/purchase-order">
|
||||||
|
<nz-icon nzType="file"></nz-icon>
|
||||||
|
<span>Bon de commande</span>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li nz-menu-item routerLinkActive="ant-menu-item-selected">
|
||||||
|
<a routerLink="/delivery-note">
|
||||||
|
<nz-icon nzType="file"></nz-icon>
|
||||||
|
<span>Bon de livraison</span>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
@if (admin()) {
|
||||||
|
<li nz-menu-item routerLinkActive="ant-menu-item-selected">
|
||||||
|
<a routerLink="/user">
|
||||||
|
<nz-icon nzType="user"></nz-icon>
|
||||||
|
<span>Utilisateur</span>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
}
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<!-- ICONES À DROITE -->
|
||||||
|
<div class="right-icons">
|
||||||
|
<nz-icon nzType="logout" nzTheme="outline" class="disconnect" (click)="disconnect()"/>
|
||||||
|
<app-modal-nav nameIcon="user" name="Profil">
|
||||||
|
<app-profil></app-profil>
|
||||||
|
</app-modal-nav>
|
||||||
|
<app-modal-nav nameIcon="setting" name="Paramètres">
|
||||||
|
<app-setting-form></app-setting-form>
|
||||||
|
</app-modal-nav>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</nz-header>
|
||||||
|
|
||||||
|
<nz-content>
|
||||||
|
<div class="inner-content overflow-auto">
|
||||||
|
<router-outlet></router-outlet>
|
||||||
|
</div>
|
||||||
|
</nz-content>
|
||||||
|
</nz-layout>
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
import {Component, inject, OnInit, signal} from '@angular/core';
|
||||||
|
import {ModalNav} from "../modal-nav/modal-nav";
|
||||||
|
import {NzContentComponent, NzHeaderComponent, NzLayoutComponent} from "ng-zorro-antd/layout";
|
||||||
|
import {NzIconDirective} from "ng-zorro-antd/icon";
|
||||||
|
import {NzMenuDirective, NzMenuItemComponent, NzSubMenuComponent} from "ng-zorro-antd/menu";
|
||||||
|
import {Profil} from "../profil/profil";
|
||||||
|
import {Router, RouterLink, RouterLinkActive, RouterOutlet} from "@angular/router";
|
||||||
|
import {SettingForm} from "../setting-form/setting-form";
|
||||||
|
import {AuthService} from "../../services/auth.service";
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-layout',
|
||||||
|
imports: [
|
||||||
|
ModalNav,
|
||||||
|
NzContentComponent,
|
||||||
|
NzHeaderComponent,
|
||||||
|
NzIconDirective,
|
||||||
|
NzLayoutComponent,
|
||||||
|
NzMenuDirective,
|
||||||
|
NzMenuItemComponent,
|
||||||
|
NzSubMenuComponent,
|
||||||
|
Profil,
|
||||||
|
RouterLink,
|
||||||
|
RouterLinkActive,
|
||||||
|
RouterOutlet,
|
||||||
|
SettingForm
|
||||||
|
],
|
||||||
|
templateUrl: './layout.html',
|
||||||
|
styleUrl: './layout.css',
|
||||||
|
})
|
||||||
|
export class Layout implements OnInit {
|
||||||
|
private authService = inject(AuthService);
|
||||||
|
private router = inject(Router);
|
||||||
|
|
||||||
|
admin = signal<boolean>(false);
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.admin.set(this.authService.isAdmin());
|
||||||
|
}
|
||||||
|
|
||||||
|
async disconnect() {
|
||||||
|
this.authService.logout();
|
||||||
|
await this.router.navigate(['/login']);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
<button nz-button [nzType]="type()" (click)="showModal()">{{name()}}</button>
|
<button nz-button [nzType]="type()" (click)="showModal()">{{ name() }}</button>
|
||||||
|
|
||||||
<ng-template #modalContent>
|
<ng-template #modalContent>
|
||||||
<ng-content></ng-content>
|
<ng-content></ng-content>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import {Component, input, Input, output} from '@angular/core';
|
import {Component, input, output} from '@angular/core';
|
||||||
import {NzModalComponent} from "ng-zorro-antd/modal";
|
import {NzModalComponent} from "ng-zorro-antd/modal";
|
||||||
import {NzButtonComponent} from "ng-zorro-antd/button";
|
import {NzButtonComponent} from "ng-zorro-antd/button";
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import {Component, Input, input, output} from '@angular/core';
|
import {Component, input, output} from '@angular/core';
|
||||||
import { NzButtonModule } from 'ng-zorro-antd/button';
|
import {NzButtonModule} from 'ng-zorro-antd/button';
|
||||||
import { NzModalModule } from 'ng-zorro-antd/modal';
|
import {NzModalModule} from 'ng-zorro-antd/modal';
|
||||||
import {NzIconDirective} from "ng-zorro-antd/icon";
|
import {NzIconDirective} from "ng-zorro-antd/icon";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
|||||||
@@ -1,34 +0,0 @@
|
|||||||
<div class="ml-90">
|
|
||||||
<p class="cursor-pointer text-red-700" (click)="delete()">
|
|
||||||
<nz-icon nzType="delete" nzTheme="outline"/> Tout supprimer
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<nz-list nzItemLayout="vertical" class="max-w-xl mx-auto max-h-[400px] overflow-y-auto border border-gray-200 rounded-lg">
|
|
||||||
@for (item of notifList; track item) {
|
|
||||||
<nz-list-item class="flex items-start p-4 border-b border-gray-200">
|
|
||||||
|
|
||||||
<nz-list-item-meta class="flex-1">
|
|
||||||
<nz-list-item-meta-avatar>
|
|
||||||
<img src="https://cdn-icons-png.flaticon.com/512/1/1176.png" alt="info" class="w-10 h-10 rounded-full mt-10 mr-2 w-10">
|
|
||||||
</nz-list-item-meta-avatar>
|
|
||||||
|
|
||||||
<nz-list-item-meta-title>
|
|
||||||
<p class="font-semibold mb-1">{{item.title}}</p>
|
|
||||||
<p class="text-gray-500 mb-1">{{item.author}}</p>
|
|
||||||
</nz-list-item-meta-title>
|
|
||||||
|
|
||||||
<nz-list-item-meta-description>
|
|
||||||
<p>{{item.content}}</p>
|
|
||||||
</nz-list-item-meta-description>
|
|
||||||
</nz-list-item-meta>
|
|
||||||
|
|
||||||
<nz-list-item-extra>
|
|
||||||
<img src="https://www.pyro-fetes.com/wp-content/themes/pcptheme/img/logo-pyro-fetes-OR-top.png"
|
|
||||||
alt="logo"
|
|
||||||
class="w-35 object-contain mt-4">
|
|
||||||
</nz-list-item-extra>
|
|
||||||
|
|
||||||
</nz-list-item>
|
|
||||||
}
|
|
||||||
</nz-list>
|
|
||||||
@@ -1,92 +0,0 @@
|
|||||||
import { Component } from '@angular/core';
|
|
||||||
import {NotifInfo} from "../../interfaces/notif.interface";
|
|
||||||
import {
|
|
||||||
NzListComponent,
|
|
||||||
NzListItemComponent,
|
|
||||||
NzListItemExtraComponent, NzListItemMetaAvatarComponent,
|
|
||||||
NzListItemMetaComponent, NzListItemMetaDescriptionComponent, NzListItemMetaTitleComponent
|
|
||||||
} from "ng-zorro-antd/list";
|
|
||||||
import {NzIconDirective} from "ng-zorro-antd/icon";
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'app-notif-list',
|
|
||||||
imports: [
|
|
||||||
NzListComponent,
|
|
||||||
NzListItemComponent,
|
|
||||||
NzListItemMetaComponent,
|
|
||||||
NzListItemExtraComponent,
|
|
||||||
NzListItemMetaDescriptionComponent,
|
|
||||||
NzListItemMetaAvatarComponent,
|
|
||||||
NzListItemMetaTitleComponent,
|
|
||||||
NzIconDirective
|
|
||||||
],
|
|
||||||
templateUrl: './notif-list.html',
|
|
||||||
styleUrl: './notif-list.css',
|
|
||||||
})
|
|
||||||
export class NotifList {
|
|
||||||
notifList: NotifInfo[] = [
|
|
||||||
{
|
|
||||||
author: 'Admin',
|
|
||||||
title: 'Information system',
|
|
||||||
content: 'L\'utilisateur à bien été crée.'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
author: 'Admin',
|
|
||||||
title: 'Information system',
|
|
||||||
content: 'L\'utilisateur à bien été crée.'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
author: 'Admin',
|
|
||||||
title: 'Information system',
|
|
||||||
content: 'L\'utilisateur à bien été crée.'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
author: 'Admin',
|
|
||||||
title: 'Information system',
|
|
||||||
content: 'L\'utilisateur à bien été crée.'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
author: 'Admin',
|
|
||||||
title: 'Information system',
|
|
||||||
content: 'L\'utilisateur à bien été crée.'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
author: 'Admin',
|
|
||||||
title: 'Information system',
|
|
||||||
content: 'L\'utilisateur à bien été crée.'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
author: 'Admin',
|
|
||||||
title: 'Information system',
|
|
||||||
content: 'L\'utilisateur à bien été crée.'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
author: 'Admin',
|
|
||||||
title: 'Information system',
|
|
||||||
content: 'L\'utilisateur à bien été crée.'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
author: 'Admin',
|
|
||||||
title: 'Information system',
|
|
||||||
content: 'L\'utilisateur à bien été crée.'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
author: 'Admin',
|
|
||||||
title: 'Information system',
|
|
||||||
content: 'L\'utilisateur à bien été crée.'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
author: 'Admin',
|
|
||||||
title: 'Information system',
|
|
||||||
content: 'L\'utilisateur à bien été crée.'
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
delete() {
|
|
||||||
this.notifList = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
addContent(author: string, title: string, content: string) {
|
|
||||||
this.notifList.push({ author, title, content });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -4,10 +4,10 @@ import {NzColDirective} from "ng-zorro-antd/grid";
|
|||||||
import {NzFlexDirective} from "ng-zorro-antd/flex";
|
import {NzFlexDirective} from "ng-zorro-antd/flex";
|
||||||
import {NzFormControlComponent, NzFormDirective, NzFormItemComponent, NzFormLabelComponent} from "ng-zorro-antd/form";
|
import {NzFormControlComponent, NzFormDirective, NzFormItemComponent, NzFormLabelComponent} from "ng-zorro-antd/form";
|
||||||
import {NzInputDirective} from "ng-zorro-antd/input";
|
import {NzInputDirective} from "ng-zorro-antd/input";
|
||||||
import {GetPriceDto, GetSupplierDto} from "../../services/api";
|
import {GetPriceDto} from "../../services/api";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-price-form',
|
selector: 'app-price-form',
|
||||||
imports: [
|
imports: [
|
||||||
FormsModule,
|
FormsModule,
|
||||||
NzColDirective,
|
NzColDirective,
|
||||||
@@ -19,15 +19,16 @@ import {GetPriceDto, GetSupplierDto} from "../../services/api";
|
|||||||
NzInputDirective,
|
NzInputDirective,
|
||||||
ReactiveFormsModule
|
ReactiveFormsModule
|
||||||
],
|
],
|
||||||
templateUrl: './price-form.html',
|
templateUrl: './price-form.html',
|
||||||
styleUrl: './price-form.css',
|
styleUrl: './price-form.css',
|
||||||
})
|
})
|
||||||
export class PriceForm {
|
export class PriceForm {
|
||||||
priceForm: FormGroup = new FormGroup({
|
priceForm: FormGroup = new FormGroup({
|
||||||
price: new FormControl<string>(null, [Validators.required]),
|
price: new FormControl<string>(null, [Validators.required]),
|
||||||
})
|
})
|
||||||
|
|
||||||
price= input<GetPriceDto>();
|
price = input<GetPriceDto>();
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
effect(() => {
|
effect(() => {
|
||||||
if (this.price()) {
|
if (this.price()) {
|
||||||
|
|||||||
@@ -1,21 +0,0 @@
|
|||||||
<form nz-form nzLayout="horizontal" [formGroup]="productForm">
|
|
||||||
<nz-form-item nz-flex>
|
|
||||||
<nz-form-label nzSpan="9" nzRequired>
|
|
||||||
Prix
|
|
||||||
</nz-form-label>
|
|
||||||
|
|
||||||
<nz-form-control nzSpan="8" nzErrorTip="Ce champ est requis">
|
|
||||||
<input nz-input placeholder="Prix" formControlName="price">
|
|
||||||
</nz-form-control>
|
|
||||||
</nz-form-item>
|
|
||||||
|
|
||||||
<nz-form-item nz-flex>
|
|
||||||
<nz-form-label nzSpan="9" nzRequired>
|
|
||||||
Quantité
|
|
||||||
</nz-form-label>
|
|
||||||
|
|
||||||
<nz-form-control nzSpan="8" nzErrorTip="Ce champ est requis">
|
|
||||||
<input nz-input placeholder="Quantité" formControlName="quantity">
|
|
||||||
</nz-form-control>
|
|
||||||
</nz-form-item>
|
|
||||||
</form>
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
import { Component } from '@angular/core';
|
|
||||||
import {FormControl, FormGroup, FormsModule, ReactiveFormsModule, Validators} from "@angular/forms";
|
|
||||||
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";
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'app-product-form',
|
|
||||||
imports: [
|
|
||||||
FormsModule,
|
|
||||||
NzColDirective,
|
|
||||||
NzFlexDirective,
|
|
||||||
NzFormControlComponent,
|
|
||||||
NzFormDirective,
|
|
||||||
NzFormItemComponent,
|
|
||||||
NzFormLabelComponent,
|
|
||||||
NzInputDirective,
|
|
||||||
ReactiveFormsModule
|
|
||||||
],
|
|
||||||
templateUrl: './product-form.html',
|
|
||||||
styleUrl: './product-form.css',
|
|
||||||
})
|
|
||||||
export class ProductForm {
|
|
||||||
productForm: FormGroup = new FormGroup({
|
|
||||||
price: new FormControl<string>(null, [Validators.required]),
|
|
||||||
quantity: new FormControl<string>(null, [Validators.required])
|
|
||||||
})
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
import { Component } from '@angular/core';
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'app-product-table',
|
|
||||||
imports: [],
|
|
||||||
templateUrl: './product-table.html',
|
|
||||||
styleUrl: './product-table.css',
|
|
||||||
})
|
|
||||||
export class ProductTable {}
|
|
||||||
@@ -26,8 +26,7 @@
|
|||||||
<nz-form-control nzSpan="12" nzErrorTip="Ce champ est requis">
|
<nz-form-control nzSpan="12" nzErrorTip="Ce champ est requis">
|
||||||
<nz-select formControlName="fonction" [nzPlaceHolder]="'Choisir une fonction'">
|
<nz-select formControlName="fonction" [nzPlaceHolder]="'Choisir une fonction'">
|
||||||
<nz-option nzLabel="Admin" nzValue="Admin"></nz-option>
|
<nz-option nzLabel="Admin" nzValue="Admin"></nz-option>
|
||||||
<nz-option nzLabel="Visiteur" nzValue="Visiteur"></nz-option>
|
<nz-option nzLabel="Employé" nzValue="Employe"></nz-option>
|
||||||
<nz-option nzLabel="Partenaire" nzValue="Partenaire"></nz-option>
|
|
||||||
</nz-select>
|
</nz-select>
|
||||||
</nz-form-control>
|
</nz-form-control>
|
||||||
</nz-form-item>
|
</nz-form-item>
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import {NzOptionComponent, NzSelectComponent} from "ng-zorro-antd/select";
|
|||||||
import {GetUserDto} from "../../services/api";
|
import {GetUserDto} from "../../services/api";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-profil-form',
|
selector: 'app-profil-form',
|
||||||
imports: [
|
imports: [
|
||||||
FormsModule,
|
FormsModule,
|
||||||
NzColDirective,
|
NzColDirective,
|
||||||
@@ -22,8 +22,8 @@ import {GetUserDto} from "../../services/api";
|
|||||||
NzSelectComponent,
|
NzSelectComponent,
|
||||||
NzOptionComponent
|
NzOptionComponent
|
||||||
],
|
],
|
||||||
templateUrl: './profil-form.html',
|
templateUrl: './profil-form.html',
|
||||||
styleUrl: './profil-form.css',
|
styleUrl: './profil-form.css',
|
||||||
})
|
})
|
||||||
export class ProfilForm {
|
export class ProfilForm {
|
||||||
profilForm: FormGroup = new FormGroup({
|
profilForm: FormGroup = new FormGroup({
|
||||||
@@ -34,6 +34,7 @@ export class ProfilForm {
|
|||||||
})
|
})
|
||||||
|
|
||||||
user = input<GetUserDto>();
|
user = input<GetUserDto>();
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
effect(() => {
|
effect(() => {
|
||||||
if (this.user()) {
|
if (this.user()) {
|
||||||
|
|||||||
@@ -1,15 +1,9 @@
|
|||||||
<div class="ml-110 cursor-pointer">
|
|
||||||
<app-modal-nav nameIcon="edit" name="Modification du profil">
|
|
||||||
<app-profil-form [user]=""></app-profil-form>
|
|
||||||
</app-modal-nav>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="mx-auto flex items-center justify-center w-30 h-30 rounded-full bg-blue-900 text-white text-6xl fontProfil">
|
<div class="mx-auto flex items-center justify-center w-30 h-30 rounded-full bg-blue-900 text-white text-6xl fontProfil">
|
||||||
{{ getInitial(data.name) }}
|
{{ getInitial(user().name) }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mt-6">
|
<div class="mt-6">
|
||||||
<p class="text-3xl festive2 mx-auto flex items-center justify-center">{{data.name}}</p>
|
<p class="text-3xl festive2 mx-auto flex items-center justify-center">{{ user().name }}</p>
|
||||||
<p class="text-xl festive2 mt-0 flex items-center justify-center">{{data.email}}</p>
|
<p class="text-xl festive2 mt-0 flex items-center justify-center">{{ user().email }}</p>
|
||||||
<p class="text-xl festive2 mt-0 flex items-center justify-center">{{data.fonction}}</p>
|
<p class="text-xl festive2 mt-0 flex items-center justify-center">{{ user().fonction }}</p>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,24 +1,28 @@
|
|||||||
import { Component } from '@angular/core';
|
import {Component, inject, OnInit, signal} from '@angular/core';
|
||||||
import {UserInfo} from "../../interfaces/user.interface";
|
import {NzNotificationService} from "ng-zorro-antd/notification";
|
||||||
import {ProfilForm} from "../profil-form/profil-form";
|
import {GetUserDto, UserService} from "../../services/api";
|
||||||
import {ModalNav} from "../modal-nav/modal-nav";
|
import {firstValueFrom} from "rxjs";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-profil',
|
selector: 'app-profil',
|
||||||
imports: [
|
imports: [],
|
||||||
ProfilForm,
|
templateUrl: './profil.html',
|
||||||
ModalNav
|
styleUrl: './profil.css',
|
||||||
],
|
|
||||||
templateUrl: './profil.html',
|
|
||||||
styleUrl: './profil.css',
|
|
||||||
})
|
})
|
||||||
export class Profil {
|
export class Profil implements OnInit {
|
||||||
data: UserInfo =
|
private notificationService = inject(NzNotificationService);
|
||||||
{
|
private userService = inject(UserService);
|
||||||
name: 'Mathys Sanchez Vendé',
|
|
||||||
email: 'mathys.sanchez@vende.fr',
|
user = signal<GetUserDto>({});
|
||||||
fonction: 'admin',
|
|
||||||
};
|
async ngOnInit() {
|
||||||
|
try {
|
||||||
|
const user = await firstValueFrom(this.userService.getUserEndpoint());
|
||||||
|
this.user.set(user);
|
||||||
|
} catch {
|
||||||
|
this.notificationService.error('Erreur', 'Impossible de charger l\'utilisateur');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
getInitial(name: string): string {
|
getInitial(name: string): string {
|
||||||
if (!name || name.trim() === '') return '?';
|
if (!name || name.trim() === '') return '?';
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import {NzInputDirective} from "ng-zorro-antd/input";
|
|||||||
import {GetPurchaseOrderDto} from "../../services/api";
|
import {GetPurchaseOrderDto} from "../../services/api";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-purchase-order-form',
|
selector: 'app-purchase-order-form',
|
||||||
imports: [
|
imports: [
|
||||||
FormsModule,
|
FormsModule,
|
||||||
NzColDirective,
|
NzColDirective,
|
||||||
@@ -19,15 +19,16 @@ import {GetPurchaseOrderDto} from "../../services/api";
|
|||||||
NzInputDirective,
|
NzInputDirective,
|
||||||
ReactiveFormsModule
|
ReactiveFormsModule
|
||||||
],
|
],
|
||||||
templateUrl: './purchase-order-form.html',
|
templateUrl: './purchase-order-form.html',
|
||||||
styleUrl: './purchase-order-form.css',
|
styleUrl: './purchase-order-form.css',
|
||||||
})
|
})
|
||||||
export class PurchaseOrderForm {
|
export class PurchaseOrderForm {
|
||||||
purchaseOrderForm: FormGroup = new FormGroup({
|
purchaseOrderForm: FormGroup = new FormGroup({
|
||||||
purchaseConditions: new FormControl<string>(null,[Validators.required])
|
purchaseConditions: new FormControl<string>(null, [Validators.required])
|
||||||
})
|
})
|
||||||
|
|
||||||
purchaseOrder= input<GetPurchaseOrderDto>();
|
purchaseOrder = input<GetPurchaseOrderDto>();
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
effect(() => {
|
effect(() => {
|
||||||
if (this.purchaseOrder()) {
|
if (this.purchaseOrder()) {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ nz-table {
|
|||||||
background: #fff;
|
background: #fff;
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
box-shadow: 0 2px 6px rgba(0,0,0,0.1);
|
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
|
||||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,18 +66,21 @@ nz-table tbody td p {
|
|||||||
nz-table thead {
|
nz-table thead {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
nz-table tbody tr {
|
nz-table tbody tr {
|
||||||
display: block;
|
display: block;
|
||||||
margin-bottom: 16px;
|
margin-bottom: 16px;
|
||||||
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
|
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
padding: 12px;
|
padding: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
nz-table tbody td {
|
nz-table tbody td {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
padding: 6px 12px;
|
padding: 6px 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
nz-table tbody td::before {
|
nz-table tbody td::before {
|
||||||
content: attr(data-label);
|
content: attr(data-label);
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
|
|||||||
@@ -15,8 +15,8 @@
|
|||||||
@for (purchaseOrder of purchaseOrders(); track purchaseOrder.id) {
|
@for (purchaseOrder of purchaseOrders(); track purchaseOrder.id) {
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ purchaseOrder.id }}</td>
|
<td>{{ purchaseOrder.id }}</td>
|
||||||
<td>{{purchaseOrder.purchaseConditions}}</td>
|
<td>{{ purchaseOrder.purchaseConditions }}</td>
|
||||||
<td>Fournisseur ???</td>
|
<td>{{ purchaseOrder.supplierName }}</td>
|
||||||
<td>
|
<td>
|
||||||
<app-modal-button type="link" name="Voir les produits" size="45%">
|
<app-modal-button type="link" name="Voir les produits" size="45%">
|
||||||
<div style="max-height: 400px; overflow-y: auto;">
|
<div style="max-height: 400px; overflow-y: auto;">
|
||||||
@@ -34,15 +34,18 @@
|
|||||||
<tbody class="text-center">
|
<tbody class="text-center">
|
||||||
@for (product of purchaseOrder.products; track product.productId) {
|
@for (product of purchaseOrder.products; track product.productId) {
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{product.productName}}</td>
|
<td>{{ product.productName }}</td>
|
||||||
<td>{{product.productReferences}}</td>
|
<td>{{ product.productReference }}</td>
|
||||||
<td>Prix €€€€</td>
|
<td>{{ product.productPrice }} €</td>
|
||||||
<td>{{product.quantity}}</td>
|
<td>{{ product.quantity }}</td>
|
||||||
<td>
|
<td>
|
||||||
<div style="justify-content: center; display: flex">
|
<div style="justify-content: center; display: flex">
|
||||||
<nz-icon nzType="edit" nzTheme="outline" class="cursor-pointer" (click)="openEditQuantityModal(product)"></nz-icon>
|
<nz-icon nzType="edit" nzTheme="outline" class="cursor-pointer"
|
||||||
|
(click)="openEditQuantityModal(product)"></nz-icon>
|
||||||
<nz-divider nzType="vertical"></nz-divider>
|
<nz-divider nzType="vertical"></nz-divider>
|
||||||
<nz-icon nzType="delete" nzTheme="outline" class="cursor-pointer text-red-700" (click)="deleteProduct(product.productId, purchaseOrder.id)"/>
|
<nz-icon nzType="delete" nzTheme="outline"
|
||||||
|
class="cursor-pointer text-red-700"
|
||||||
|
(click)="deleteProduct(product.productId, purchaseOrder.id)"/>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -54,15 +57,19 @@
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div style="justify-content: center; display: flex">
|
<div style="justify-content: center; display: flex">
|
||||||
<nz-icon nzType="plus-circle" nzTheme="outline" class="cursor-pointer text-green-700"/>
|
<nz-icon nzType="edit" nzTheme="outline" class="cursor-pointer"
|
||||||
|
(click)="openEditModal(purchaseOrder)"></nz-icon>
|
||||||
<nz-divider nzType="vertical"></nz-divider>
|
<nz-divider nzType="vertical"></nz-divider>
|
||||||
<nz-icon nzType="edit" nzTheme="outline" class="cursor-pointer" (click)="openEditModal(purchaseOrder)"></nz-icon>
|
@if (admin()) {
|
||||||
|
<nz-icon nzType="delete" nzTheme="outline" (click)="delete(purchaseOrder.id)"
|
||||||
|
class="cursor-pointer text-red-700"/>
|
||||||
|
<nz-divider nzType="vertical"></nz-divider>
|
||||||
|
}
|
||||||
|
<nz-icon nzType="export" nzTheme="outline" (click)="export(purchaseOrder.id)"
|
||||||
|
class="cursor-pointer text-green-700"/>
|
||||||
<nz-divider nzType="vertical"></nz-divider>
|
<nz-divider nzType="vertical"></nz-divider>
|
||||||
<nz-icon nzType="delete" nzTheme="outline" (click)="delete(purchaseOrder.id)" class="cursor-pointer text-red-700"/>
|
<nz-icon nzType="interaction" nzTheme="outline" (click)="openDelivererModal(purchaseOrder)"
|
||||||
<nz-divider nzType="vertical"></nz-divider>
|
class="cursor-pointer text-blue-700"/>
|
||||||
<nz-icon nzType="export" nzTheme="outline" (click)="export(purchaseOrder.id)" class="cursor-pointer text-green-700"/>
|
|
||||||
<nz-divider nzType="vertical"></nz-divider>
|
|
||||||
<nz-icon nzType="interaction" nzTheme="outline" (click)="transfer()" class="cursor-pointer text-blue-700"/>
|
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -71,13 +78,25 @@
|
|||||||
</nz-table>
|
</nz-table>
|
||||||
|
|
||||||
<div class="hidden">
|
<div class="hidden">
|
||||||
<app-modal-nav #modalNav nameIcon="edit" [name]="'Modification des conditions de vente'" (ok)="onModalOk(selectedPurchaseOrder.id, purchaseOrderForm, modalNav)" (cancel)="onModalCancel(modalNav)">
|
<app-modal-nav #modalNav nameIcon="edit" name="Modification des conditions de vente"
|
||||||
|
(ok)="onModalOk(selectedPurchaseOrder.id, purchaseOrderForm, modalNav)"
|
||||||
|
(cancel)="onModalCancel(modalNav)">
|
||||||
<app-purchase-order-form #purchaseOrderForm [purchaseOrder]="selectedPurchaseOrder"></app-purchase-order-form>
|
<app-purchase-order-form #purchaseOrderForm [purchaseOrder]="selectedPurchaseOrder"></app-purchase-order-form>
|
||||||
</app-modal-nav>
|
</app-modal-nav>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="hidden">
|
<div class="hidden">
|
||||||
<app-modal-nav #modalQuantity nameIcon="edit" [name]="'Modification de la quantité'" (ok)="onModalQuantityOk(selectedQuantity.productId, selectedQuantity.purchaseOrderId, quantityForm, modalQuantity)" (cancel)="onModalCancel(modalQuantity)">
|
<app-modal-nav #modalQuantity nameIcon="edit" name="Modification de la quantité"
|
||||||
|
(ok)="onModalQuantityOk(selectedQuantity.productId, selectedQuantity.purchaseOrderId, quantityForm, modalQuantity)"
|
||||||
|
(cancel)="onModalCancel(modalQuantity)">
|
||||||
<app-quantity-form #quantityForm [quantity]="selectedQuantity"></app-quantity-form>
|
<app-quantity-form #quantityForm [quantity]="selectedQuantity"></app-quantity-form>
|
||||||
</app-modal-nav>
|
</app-modal-nav>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="hidden">
|
||||||
|
<app-modal-nav #modalDeliverer nameIcon="edit" name="Choix du transporteur"
|
||||||
|
(ok)="transfer(selectedPurchaseOrder, delivererChoice)"
|
||||||
|
(cancel)="onModalCancel(modalDeliverer)">
|
||||||
|
<app-deliverer-choice #delivererChoice></app-deliverer-choice>
|
||||||
|
</app-modal-nav>
|
||||||
|
</div>
|
||||||
@@ -6,18 +6,21 @@ import {NzTableComponent} from "ng-zorro-antd/table";
|
|||||||
import {PurchaseOrderForm} from "../purchase-order-form/purchase-order-form";
|
import {PurchaseOrderForm} from "../purchase-order-form/purchase-order-form";
|
||||||
import {ModalButton} from "../modal-button/modal-button";
|
import {ModalButton} from "../modal-button/modal-button";
|
||||||
import {
|
import {
|
||||||
|
CreateDeliveryNoteDto,
|
||||||
|
DeliverynotesService,
|
||||||
GetPurchaseOrderDto,
|
GetPurchaseOrderDto,
|
||||||
GetPurchaseProductDto,
|
GetPurchaseProductDto,
|
||||||
PurchaseordersService,
|
PurchaseordersService,
|
||||||
PurchaseproductsService
|
|
||||||
} from "../../services/api";
|
} from "../../services/api";
|
||||||
import {NzNotificationService} from "ng-zorro-antd/notification";
|
import {NzNotificationService} from "ng-zorro-antd/notification";
|
||||||
import {firstValueFrom} from "rxjs";
|
import {firstValueFrom} from "rxjs";
|
||||||
import {FileService} from "../../services/file.service";
|
import {FileService} from "../../services/file.service";
|
||||||
import {QuantityForm} from "../quantity-form/quantity-form";
|
import {QuantityForm} from "../quantity-form/quantity-form";
|
||||||
|
import {DelivererChoice} from "../deliverer-choice/deliverer-choice";
|
||||||
|
import {AuthService} from "../../services/auth.service";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-purchase-order-table',
|
selector: 'app-purchase-order-table',
|
||||||
imports: [
|
imports: [
|
||||||
ModalNav,
|
ModalNav,
|
||||||
NzDividerComponent,
|
NzDividerComponent,
|
||||||
@@ -26,22 +29,29 @@ import {QuantityForm} from "../quantity-form/quantity-form";
|
|||||||
PurchaseOrderForm,
|
PurchaseOrderForm,
|
||||||
ModalButton,
|
ModalButton,
|
||||||
QuantityForm,
|
QuantityForm,
|
||||||
|
DelivererChoice,
|
||||||
],
|
],
|
||||||
templateUrl: './purchase-order-table.html',
|
templateUrl: './purchase-order-table.html',
|
||||||
styleUrl: './purchase-order-table.css',
|
styleUrl: './purchase-order-table.css',
|
||||||
})
|
})
|
||||||
export class PurchaseOrderTable implements OnInit {
|
export class PurchaseOrderTable implements OnInit {
|
||||||
private purchaseOrdersService = inject(PurchaseordersService);
|
private purchaseOrdersService = inject(PurchaseordersService);
|
||||||
private notificationService = inject(NzNotificationService);
|
private notificationService = inject(NzNotificationService);
|
||||||
private fileService = inject(FileService);
|
private fileService = inject(FileService);
|
||||||
private purchaseProductService = inject(PurchaseproductsService)
|
private deliveryNoteService = inject(DeliverynotesService);
|
||||||
|
private authService = inject(AuthService);
|
||||||
|
|
||||||
purchaseOrders = signal<GetPurchaseOrderDto[]>([]);
|
purchaseOrders = signal<GetPurchaseOrderDto[]>([]);
|
||||||
purchaseOrdersLoading = signal<boolean>(false);
|
purchaseOrdersLoading = signal<boolean>(false);
|
||||||
|
admin = signal<boolean>(false);
|
||||||
|
|
||||||
modal = viewChild.required<ModalNav>('modalNav');
|
modal = viewChild.required<ModalNav>('modalNav');
|
||||||
modalQuantity = viewChild.required<ModalNav>('modalQuantity');
|
modalQuantity = viewChild.required<ModalNav>('modalQuantity');
|
||||||
|
modalDeliverer = viewChild.required<ModalNav>('modalDeliverer');
|
||||||
|
|
||||||
async ngOnInit() {
|
async ngOnInit() {
|
||||||
await this.fetchPurchaseOrder();
|
await this.fetchPurchaseOrder();
|
||||||
|
this.admin.set(this.authService.isAdmin());
|
||||||
}
|
}
|
||||||
|
|
||||||
async fetchPurchaseOrder() {
|
async fetchPurchaseOrder() {
|
||||||
@@ -50,59 +60,77 @@ export class PurchaseOrderTable implements OnInit {
|
|||||||
try {
|
try {
|
||||||
const purchaseOrders = await firstValueFrom(this.purchaseOrdersService.getAllPurchaseOrderEndpoint())
|
const purchaseOrders = await firstValueFrom(this.purchaseOrdersService.getAllPurchaseOrderEndpoint())
|
||||||
this.purchaseOrders.set(purchaseOrders);
|
this.purchaseOrders.set(purchaseOrders);
|
||||||
} catch (e) {
|
} catch {
|
||||||
this.notificationService.error(
|
this.notificationService.error('Erreur', 'Erreur lors du chargement des bons de commande')
|
||||||
'Erreur',
|
|
||||||
'Erreur de communication avec l\'API'
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
this.purchaseOrdersLoading.set(false)
|
this.purchaseOrdersLoading.set(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
async delete(purchaseOrderId:number) {
|
async delete(purchaseOrderId: number) {
|
||||||
this.purchaseOrdersLoading.set(true)
|
this.purchaseOrdersLoading.set(true)
|
||||||
try {
|
try {
|
||||||
await firstValueFrom(this.purchaseOrdersService.deletePurchaseOrderEndpoint(purchaseOrderId))
|
await firstValueFrom(this.purchaseOrdersService.deletePurchaseOrderEndpoint(purchaseOrderId))
|
||||||
this.notificationService.success(
|
this.notificationService.success('Success', 'Suppression effectuée')
|
||||||
'Success',
|
} catch {
|
||||||
'Suppression effectuée'
|
this.notificationService.error('Erreur', 'Impossible de supprimer la ligne')
|
||||||
)
|
|
||||||
} catch (e) {
|
|
||||||
this.notificationService.error(
|
|
||||||
'Erreur',
|
|
||||||
'Impossible de supprimer la ligne'
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
this.purchaseOrdersLoading.set(false)
|
this.purchaseOrdersLoading.set(false)
|
||||||
await this.fetchPurchaseOrder();
|
await this.fetchPurchaseOrder();
|
||||||
}
|
}
|
||||||
|
|
||||||
async export(purchaseOrderId: number){
|
async export(purchaseOrderId: number) {
|
||||||
this.purchaseOrdersLoading.set(true)
|
this.purchaseOrdersLoading.set(true)
|
||||||
try {
|
try {
|
||||||
const pdf = await firstValueFrom(
|
const pdf = await firstValueFrom(
|
||||||
this.purchaseOrdersService.getPurchaseOrderPdfEndpoint(purchaseOrderId, "response")
|
this.purchaseOrdersService.getPurchaseOrderPdfEndpoint(purchaseOrderId, "response")
|
||||||
);
|
);
|
||||||
this.fileService.downloadBlob(pdf)
|
this.fileService.downloadBlob(pdf)
|
||||||
} catch (e) {
|
} catch {
|
||||||
this.notificationService.error(
|
this.notificationService.error('Erreur', 'Impossible de générer un PDF');
|
||||||
'Erreur',
|
|
||||||
'Impossible de générer un PDF'
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
this.purchaseOrdersLoading.set(false)
|
this.purchaseOrdersLoading.set(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
transfer() {
|
async transfer(purchaseOrder: GetPurchaseOrderDto, delivererForm: DelivererChoice) {
|
||||||
return
|
this.purchaseOrdersLoading.set(true);
|
||||||
|
try {
|
||||||
|
const deliverer = delivererForm.choiceDelivererForm.getRawValue();
|
||||||
|
|
||||||
|
const date = new Date().toISOString().split('T')[0]; // yyyy-mm-dd
|
||||||
|
|
||||||
|
let trackingValue = 'TRK-';
|
||||||
|
const idStr = purchaseOrder.id?.toString() ?? '';
|
||||||
|
if (idStr.length < 2) trackingValue += '00' + idStr + '-' + date;
|
||||||
|
else if (idStr.length < 3) trackingValue += '0' + idStr + '-' + date;
|
||||||
|
else trackingValue += idStr.substring(0, 3) + date.replace(/-/g, '');
|
||||||
|
|
||||||
|
const productQuantities: Record<number, number> = {};
|
||||||
|
purchaseOrder.products?.forEach(p => {
|
||||||
|
if (p.productId != null && p.quantity != null) {
|
||||||
|
productQuantities[p.productId] = p.quantity;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const deliveryNoteDto: CreateDeliveryNoteDto = {
|
||||||
|
trackingNumber: trackingValue,
|
||||||
|
delivererId: deliverer.delivererId,
|
||||||
|
productQuantities: productQuantities,
|
||||||
|
supplierId: purchaseOrder.supplierId
|
||||||
|
};
|
||||||
|
|
||||||
|
await firstValueFrom(this.deliveryNoteService.createDeliveryNoteEndpoint(deliveryNoteDto));
|
||||||
|
this.notificationService.success('Succès', 'Bon de livraison créé avec succès');
|
||||||
|
} catch {
|
||||||
|
this.notificationService.error('Erreur', 'Erreur lors du transfert');
|
||||||
|
}
|
||||||
|
this.onModalCancel(this.modalDeliverer());
|
||||||
|
this.purchaseOrdersLoading.set(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async edit(id: number, updatePurchaseOrderComponent: PurchaseOrderForm) {
|
async edit(id: number, updatePurchaseOrderComponent: PurchaseOrderForm) {
|
||||||
if (updatePurchaseOrderComponent.purchaseOrderForm.invalid) {
|
if (updatePurchaseOrderComponent.purchaseOrderForm.invalid) {
|
||||||
this.notificationService.error(
|
this.notificationService.error('Erreur', 'Formulaire invalide')
|
||||||
'Erreur',
|
|
||||||
'Erreur d\'écriture dans le formulaire'
|
|
||||||
)
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,7 +139,7 @@ export class PurchaseOrderTable implements OnInit {
|
|||||||
await firstValueFrom(this.purchaseOrdersService.patchPurchaseOrderPurchaseConditionsEndpoint(id, purchaseOrders))
|
await firstValueFrom(this.purchaseOrdersService.patchPurchaseOrderPurchaseConditionsEndpoint(id, purchaseOrders))
|
||||||
|
|
||||||
this.notificationService.success('Success', 'Bon de commande modifié')
|
this.notificationService.success('Success', 'Bon de commande modifié')
|
||||||
} catch (e) {
|
} catch {
|
||||||
this.notificationService.error('Erreur', 'Erreur lors de la modification')
|
this.notificationService.error('Erreur', 'Erreur lors de la modification')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -119,16 +147,10 @@ export class PurchaseOrderTable implements OnInit {
|
|||||||
async deleteProduct(productId: number, purchaseOrderId: number) {
|
async deleteProduct(productId: number, purchaseOrderId: number) {
|
||||||
this.purchaseOrdersLoading.set(true)
|
this.purchaseOrdersLoading.set(true)
|
||||||
try {
|
try {
|
||||||
await firstValueFrom(this.purchaseProductService.deletePurchaseProductEndpoint(productId, purchaseOrderId))
|
await firstValueFrom(this.purchaseOrdersService.deleteProductFromPurchaseOrderEndpoint(productId, purchaseOrderId))
|
||||||
this.notificationService.success(
|
this.notificationService.success('Success', 'Suppression effectuée')
|
||||||
'Success',
|
} catch {
|
||||||
'Suppression effectuée'
|
this.notificationService.error('Erreur', 'Impossible de supprimer la ligne')
|
||||||
)
|
|
||||||
} catch (e) {
|
|
||||||
this.notificationService.error(
|
|
||||||
'Erreur',
|
|
||||||
'Impossible de supprimer la ligne'
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
this.purchaseOrdersLoading.set(false)
|
this.purchaseOrdersLoading.set(false)
|
||||||
await this.fetchPurchaseOrder();
|
await this.fetchPurchaseOrder();
|
||||||
@@ -136,35 +158,38 @@ export class PurchaseOrderTable implements OnInit {
|
|||||||
|
|
||||||
async editQuantity(productId: number, purchaseOrderId: number, updateQuantityComponent: QuantityForm) {
|
async editQuantity(productId: number, purchaseOrderId: number, updateQuantityComponent: QuantityForm) {
|
||||||
if (updateQuantityComponent.quantityForm.invalid) {
|
if (updateQuantityComponent.quantityForm.invalid) {
|
||||||
this.notificationService.error(
|
this.notificationService.error('Erreur', 'Erreur d\'écriture dans le formulaire')
|
||||||
'Erreur',
|
|
||||||
'Erreur d\'écriture dans le formulaire'
|
|
||||||
)
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const quantity = updateQuantityComponent.quantityForm.getRawValue();
|
const quantity = updateQuantityComponent.quantityForm.getRawValue();
|
||||||
await firstValueFrom(this.purchaseProductService.patchPurchaseProductQuantityEndpoint(productId, purchaseOrderId, quantity))
|
await firstValueFrom(this.purchaseOrdersService.patchPurchaseProductQuantityEndpoint(productId, purchaseOrderId, quantity))
|
||||||
|
|
||||||
this.notificationService.success('Success', 'Quantité modifiée')
|
this.notificationService.success('Success', 'Quantité modifiée');
|
||||||
} catch (e) {
|
} catch {
|
||||||
this.notificationService.error('Erreur', 'Erreur lors de la modification')
|
this.notificationService.error('Erreur', 'Erreur lors de la modification');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
selectedPurchaseOrder: GetPurchaseOrderDto | null = null;
|
selectedPurchaseOrder: GetPurchaseOrderDto | null = null;
|
||||||
|
|
||||||
openEditModal(purchaseOrder: GetPurchaseOrderDto) {
|
openEditModal(purchaseOrder: GetPurchaseOrderDto) {
|
||||||
this.selectedPurchaseOrder = { ...purchaseOrder };
|
this.selectedPurchaseOrder = {...purchaseOrder};
|
||||||
this.modal().showModal();
|
this.modal().showModal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
openDelivererModal(purchaseOrder: GetPurchaseOrderDto) {
|
||||||
|
this.selectedPurchaseOrder = {...purchaseOrder};
|
||||||
|
this.modalDeliverer().showModal();
|
||||||
|
}
|
||||||
|
|
||||||
async onModalOk(id: number, updatePurchaseOrderComponent: PurchaseOrderForm, modal: ModalNav) {
|
async onModalOk(id: number, updatePurchaseOrderComponent: PurchaseOrderForm, modal: ModalNav) {
|
||||||
if (!this.selectedPurchaseOrder) return;
|
if (!this.selectedPurchaseOrder) return;
|
||||||
|
|
||||||
await this.edit(id, updatePurchaseOrderComponent);
|
await this.edit(id, updatePurchaseOrderComponent);
|
||||||
updatePurchaseOrderComponent.purchaseOrderForm.reset();
|
updatePurchaseOrderComponent.purchaseOrderForm.reset();
|
||||||
modal.isVisible = false;
|
this.onModalCancel(modal);
|
||||||
await this.fetchPurchaseOrder();
|
await this.fetchPurchaseOrder();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -173,8 +198,9 @@ export class PurchaseOrderTable implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
selectedQuantity: GetPurchaseProductDto | null = null;
|
selectedQuantity: GetPurchaseProductDto | null = null;
|
||||||
|
|
||||||
openEditQuantityModal(quantity: GetPurchaseProductDto) {
|
openEditQuantityModal(quantity: GetPurchaseProductDto) {
|
||||||
this.selectedQuantity = { ...quantity };
|
this.selectedQuantity = {...quantity};
|
||||||
this.modalQuantity().showModal();
|
this.modalQuantity().showModal();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,7 +209,7 @@ export class PurchaseOrderTable implements OnInit {
|
|||||||
|
|
||||||
await this.editQuantity(productId, purchaseOrderId, updateQuantityComponent);
|
await this.editQuantity(productId, purchaseOrderId, updateQuantityComponent);
|
||||||
updateQuantityComponent.quantityForm.reset();
|
updateQuantityComponent.quantityForm.reset();
|
||||||
modal.isVisible = false;
|
this.onModalCancel(modal);
|
||||||
await this.fetchPurchaseOrder();
|
await this.fetchPurchaseOrder();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,10 +4,10 @@ import {NzColDirective} from "ng-zorro-antd/grid";
|
|||||||
import {NzFlexDirective} from "ng-zorro-antd/flex";
|
import {NzFlexDirective} from "ng-zorro-antd/flex";
|
||||||
import {NzFormControlComponent, NzFormDirective, NzFormItemComponent, NzFormLabelComponent} from "ng-zorro-antd/form";
|
import {NzFormControlComponent, NzFormDirective, NzFormItemComponent, NzFormLabelComponent} from "ng-zorro-antd/form";
|
||||||
import {NzInputDirective} from "ng-zorro-antd/input";
|
import {NzInputDirective} from "ng-zorro-antd/input";
|
||||||
import {GetDelivererDto, GetPurchaseProductDto} from "../../services/api";
|
import {GetPurchaseProductDto} from "../../services/api";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-quantity-form',
|
selector: 'app-quantity-form',
|
||||||
imports: [
|
imports: [
|
||||||
FormsModule,
|
FormsModule,
|
||||||
NzColDirective,
|
NzColDirective,
|
||||||
@@ -19,15 +19,16 @@ import {GetDelivererDto, GetPurchaseProductDto} from "../../services/api";
|
|||||||
NzInputDirective,
|
NzInputDirective,
|
||||||
ReactiveFormsModule
|
ReactiveFormsModule
|
||||||
],
|
],
|
||||||
templateUrl: './quantity-form.html',
|
templateUrl: './quantity-form.html',
|
||||||
styleUrl: './quantity-form.css',
|
styleUrl: './quantity-form.css',
|
||||||
})
|
})
|
||||||
export class QuantityForm {
|
export class QuantityForm {
|
||||||
quantityForm: FormGroup = new FormGroup({
|
quantityForm: FormGroup = new FormGroup({
|
||||||
quantity: new FormControl<number>(null, [Validators.required])
|
quantity: new FormControl<number>(null, [Validators.required])
|
||||||
})
|
})
|
||||||
|
|
||||||
quantity= input<GetPurchaseProductDto>();
|
quantity = input<GetPurchaseProductDto>();
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
effect(() => {
|
effect(() => {
|
||||||
if (this.quantity()) {
|
if (this.quantity()) {
|
||||||
|
|||||||
@@ -27,7 +27,8 @@ export class QuotationForm {
|
|||||||
conditionsSale: new FormControl<string>(null, [Validators.required]),
|
conditionsSale: new FormControl<string>(null, [Validators.required]),
|
||||||
})
|
})
|
||||||
|
|
||||||
quotation= input<GetQuotationDto>();
|
quotation = input<GetQuotationDto>();
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
effect(() => {
|
effect(() => {
|
||||||
if (this.quotation()) {
|
if (this.quotation()) {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ nz-table {
|
|||||||
background: #fff;
|
background: #fff;
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
box-shadow: 0 2px 6px rgba(0,0,0,0.1);
|
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
|
||||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,18 +66,21 @@ nz-table tbody td p {
|
|||||||
nz-table thead {
|
nz-table thead {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
nz-table tbody tr {
|
nz-table tbody tr {
|
||||||
display: block;
|
display: block;
|
||||||
margin-bottom: 16px;
|
margin-bottom: 16px;
|
||||||
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
|
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
padding: 12px;
|
padding: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
nz-table tbody td {
|
nz-table tbody td {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
padding: 6px 12px;
|
padding: 6px 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
nz-table tbody td::before {
|
nz-table tbody td::before {
|
||||||
content: attr(data-label);
|
content: attr(data-label);
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
|
|||||||
@@ -11,13 +11,13 @@
|
|||||||
<th>Produit</th>
|
<th>Produit</th>
|
||||||
<th>Action</th>
|
<th>Action</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead >
|
</thead>
|
||||||
<tbody class="text-center">
|
<tbody class="text-center">
|
||||||
@for (quotation of quotations(); track quotation.id) {
|
@for (quotation of quotations(); track quotation.id) {
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{quotation.id}}</td>
|
<td>{{ quotation.id }}</td>
|
||||||
<td>{{quotation.message}}</td>
|
<td>{{ quotation.message }}</td>
|
||||||
<td>{{quotation.conditionsSale}}</td>
|
<td>{{ quotation.conditionsSale }}</td>
|
||||||
<td>
|
<td>
|
||||||
<app-modal-button type="link" name="Voir les produits" size="45%">
|
<app-modal-button type="link" name="Voir les produits" size="45%">
|
||||||
<div style="max-height: 400px; overflow-y: auto;">
|
<div style="max-height: 400px; overflow-y: auto;">
|
||||||
@@ -34,15 +34,18 @@
|
|||||||
<tbody class="text-center">
|
<tbody class="text-center">
|
||||||
@for (product of quotation.products; track product.productId) {
|
@for (product of quotation.products; track product.productId) {
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ product.productReferences }}</td>
|
<td>{{ product.productReference }}</td>
|
||||||
<td>{{ product.productName }}</td>
|
<td>{{ product.productName }}</td>
|
||||||
<td>Price ???</td>
|
<td>{{ product.productPrice }} €</td>
|
||||||
<td>{{ product.quantity }}</td>
|
<td>{{ product.quantity }}</td>
|
||||||
<td>
|
<td>
|
||||||
<div style="justify-content: center; display: flex">
|
<div style="justify-content: center; display: flex">
|
||||||
<nz-icon nzType="edit" nzTheme="outline" class="cursor-pointer" (click)="openEditQuantityModal(product)"></nz-icon>
|
<nz-icon nzType="edit" nzTheme="outline" class="cursor-pointer"
|
||||||
|
(click)="openEditQuantityModal(product)"></nz-icon>
|
||||||
<nz-divider nzType="vertical"></nz-divider>
|
<nz-divider nzType="vertical"></nz-divider>
|
||||||
<nz-icon nzType="delete" nzTheme="outline" class="cursor-pointer text-red-700" (click)="deleteProduct(product.productId, quotation.id)"/>
|
<nz-icon nzType="delete" nzTheme="outline"
|
||||||
|
class="cursor-pointer text-red-700"
|
||||||
|
(click)="deleteProduct(product.productId, quotation.id)"/>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -54,13 +57,16 @@
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<div style="justify-content: center; display: flex">
|
<div style="justify-content: center; display: flex">
|
||||||
<nz-icon nzType="plus-circle" nzTheme="outline" class="cursor-pointer text-green-700" />
|
<nz-icon nzType="edit" nzTheme="outline" class="cursor-pointer"
|
||||||
|
(click)="openEditModal(quotation)"></nz-icon>
|
||||||
<nz-divider nzType="vertical"></nz-divider>
|
<nz-divider nzType="vertical"></nz-divider>
|
||||||
<nz-icon nzType="edit" nzTheme="outline" class="cursor-pointer" (click)="openEditModal(quotation)"></nz-icon>
|
@if (admin()) {
|
||||||
<nz-divider nzType="vertical"></nz-divider>
|
<nz-icon nzType="delete" nzTheme="outline" class="cursor-pointer text-red-700"
|
||||||
<nz-icon nzType="delete" nzTheme="outline" class="cursor-pointer text-red-700" (click)="delete(quotation.id)"/>
|
(click)="delete(quotation.id)"/>
|
||||||
<nz-divider nzType="vertical"></nz-divider>
|
<nz-divider nzType="vertical"></nz-divider>
|
||||||
<nz-icon nzType="export" (click)="export(quotation.id)" nzTheme="outline" class="cursor-pointer text-green-700"/>
|
}
|
||||||
|
<nz-icon nzType="export" (click)="export(quotation.id)" nzTheme="outline"
|
||||||
|
class="cursor-pointer text-green-700"/>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -69,13 +75,16 @@
|
|||||||
</nz-table>
|
</nz-table>
|
||||||
|
|
||||||
<div class="hidden">
|
<div class="hidden">
|
||||||
<app-modal-nav #modalNav nameIcon="edit" [name]="'Modification du devis'" (ok)="onModalOk(selectedQuotation.id, quotationForm, modalNav)" (cancel)="onModalCancel(modalNav)">
|
<app-modal-nav #modalNav nameIcon="edit" [name]="'Modification du devis'"
|
||||||
|
(ok)="onModalOk(selectedQuotation.id, quotationForm, modalNav)" (cancel)="onModalCancel(modalNav)">
|
||||||
<app-quotation-form #quotationForm [quotation]="selectedQuotation"></app-quotation-form>
|
<app-quotation-form #quotationForm [quotation]="selectedQuotation"></app-quotation-form>
|
||||||
</app-modal-nav>
|
</app-modal-nav>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="hidden">
|
<div class="hidden">
|
||||||
<app-modal-nav #modalQuantity nameIcon="edit" [name]="'Modification de la quantité'" (ok)="onModalQuantityOk(selectedQuantity.productId, selectedQuantity.quotationId, quantityForm, modalQuantity)" (cancel)="onModalCancel(modalQuantity)">
|
<app-modal-nav #modalQuantity nameIcon="edit" [name]="'Modification de la quantité'"
|
||||||
|
(ok)="onModalQuantityOk(selectedQuantity.productId, selectedQuantity.quotationId, quantityForm, modalQuantity)"
|
||||||
|
(cancel)="onModalCancel(modalQuantity)">
|
||||||
<app-quantity-form #quantityForm [quantity]="selectedQuantity"></app-quantity-form>
|
<app-quantity-form #quantityForm [quantity]="selectedQuantity"></app-quantity-form>
|
||||||
</app-modal-nav>
|
</app-modal-nav>
|
||||||
</div>
|
</div>
|
||||||
@@ -8,13 +8,13 @@ import {QuotationForm} from "../quotation-form/quotation-form";
|
|||||||
import {
|
import {
|
||||||
GetQuotationDto,
|
GetQuotationDto,
|
||||||
GetQuotationProductDto,
|
GetQuotationProductDto,
|
||||||
QuotationproductsService,
|
|
||||||
QuotationsService
|
QuotationsService
|
||||||
} from "../../services/api";
|
} from "../../services/api";
|
||||||
import {NzNotificationService} from "ng-zorro-antd/notification";
|
import {NzNotificationService} from "ng-zorro-antd/notification";
|
||||||
import {firstValueFrom} from "rxjs";
|
import {firstValueFrom} from "rxjs";
|
||||||
import {FileService} from "../../services/file.service";
|
import {FileService} from "../../services/file.service";
|
||||||
import {QuantityForm} from "../quantity-form/quantity-form";
|
import {QuantityForm} from "../quantity-form/quantity-form";
|
||||||
|
import {AuthService} from "../../services/auth.service";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-quotation-table',
|
selector: 'app-quotation-table',
|
||||||
@@ -34,15 +34,19 @@ import {QuantityForm} from "../quantity-form/quantity-form";
|
|||||||
export class QuotationTable implements OnInit {
|
export class QuotationTable implements OnInit {
|
||||||
private quotationsService = inject(QuotationsService);
|
private quotationsService = inject(QuotationsService);
|
||||||
private notificationService = inject(NzNotificationService);
|
private notificationService = inject(NzNotificationService);
|
||||||
private quotationProductsService = inject(QuotationproductsService)
|
|
||||||
private fileService = inject(FileService);
|
private fileService = inject(FileService);
|
||||||
|
private authService = inject(AuthService);
|
||||||
|
|
||||||
quotations = signal<GetQuotationDto[]>([]);
|
quotations = signal<GetQuotationDto[]>([]);
|
||||||
quotationsLoading = signal<boolean>(false);
|
quotationsLoading = signal<boolean>(false);
|
||||||
|
admin = signal<boolean>(false);
|
||||||
|
|
||||||
modal = viewChild.required<ModalNav>('modalNav');
|
modal = viewChild.required<ModalNav>('modalNav');
|
||||||
modalQuantity = viewChild.required<ModalNav>('modalQuantity');
|
modalQuantity = viewChild.required<ModalNav>('modalQuantity');
|
||||||
|
|
||||||
async ngOnInit() {
|
async ngOnInit() {
|
||||||
await this.fetchQuotations();
|
await this.fetchQuotations();
|
||||||
|
this.admin.set(this.authService.isAdmin());
|
||||||
}
|
}
|
||||||
|
|
||||||
async fetchQuotations() {
|
async fetchQuotations() {
|
||||||
@@ -51,46 +55,33 @@ export class QuotationTable implements OnInit {
|
|||||||
try {
|
try {
|
||||||
const quotations = await firstValueFrom(this.quotationsService.getAllQuotationEndpoint())
|
const quotations = await firstValueFrom(this.quotationsService.getAllQuotationEndpoint())
|
||||||
this.quotations.set(quotations);
|
this.quotations.set(quotations);
|
||||||
} catch (e) {
|
} catch {
|
||||||
this.notificationService.error(
|
this.notificationService.error('Erreur', 'Erreur lors du chargement des devis')
|
||||||
'Erreur',
|
|
||||||
'Erreur de communication avec l\'API'
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
this.quotationsLoading.set(false)
|
this.quotationsLoading.set(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
async delete(quotation:number) {
|
async delete(quotation: number) {
|
||||||
this.quotationsLoading.set(true)
|
this.quotationsLoading.set(true)
|
||||||
try {
|
try {
|
||||||
await firstValueFrom(this.quotationsService.deleteQuotationEndpoint(quotation))
|
await firstValueFrom(this.quotationsService.deleteQuotationEndpoint(quotation))
|
||||||
this.notificationService.success(
|
this.notificationService.success('Success', 'Suppression effectuée')
|
||||||
'Success',
|
} catch {
|
||||||
'Suppression effectuée'
|
this.notificationService.error('Erreur', 'Impossible de supprimer la ligne')
|
||||||
)
|
|
||||||
} catch (e) {
|
|
||||||
this.notificationService.error(
|
|
||||||
'Erreur',
|
|
||||||
'Impossible de supprimer la ligne'
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
this.quotationsLoading.set(false)
|
this.quotationsLoading.set(false)
|
||||||
await this.fetchQuotations();
|
await this.fetchQuotations();
|
||||||
}
|
}
|
||||||
|
|
||||||
async export(quotationId: number){
|
async export(quotationId: number) {
|
||||||
this.quotationsLoading.set(true)
|
this.quotationsLoading.set(true)
|
||||||
try {
|
try {
|
||||||
const pdf = await firstValueFrom(
|
const pdf = await firstValueFrom(
|
||||||
this.quotationsService.getQuotationPdfEndpoint(quotationId, "response")
|
this.quotationsService.getQuotationPdfEndpoint(quotationId, "response")
|
||||||
);
|
);
|
||||||
this.fileService.downloadBlob(pdf)
|
this.fileService.downloadBlob(pdf)
|
||||||
} catch (e) {
|
} catch {
|
||||||
console.error(e);
|
this.notificationService.error('Erreur', 'Impossible de générer un PDF');
|
||||||
this.notificationService.error(
|
|
||||||
'Erreur',
|
|
||||||
'Impossible de générer un PDF'
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
this.quotationsLoading.set(false)
|
this.quotationsLoading.set(false)
|
||||||
}
|
}
|
||||||
@@ -105,8 +96,7 @@ export class QuotationTable implements OnInit {
|
|||||||
const quotations = updateQuotationComponent.quotationForm.getRawValue();
|
const quotations = updateQuotationComponent.quotationForm.getRawValue();
|
||||||
await firstValueFrom(this.quotationsService.updateQuotationEndpoint(id, quotations));
|
await firstValueFrom(this.quotationsService.updateQuotationEndpoint(id, quotations));
|
||||||
this.notificationService.success('Success', 'Devis modifié')
|
this.notificationService.success('Success', 'Devis modifié')
|
||||||
} catch (e) {
|
} catch {
|
||||||
console.error(e)
|
|
||||||
this.notificationService.error('Erreur', 'Erreur lors de la modification')
|
this.notificationService.error('Erreur', 'Erreur lors de la modification')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -114,16 +104,10 @@ export class QuotationTable implements OnInit {
|
|||||||
async deleteProduct(productId: number, quotationId: number) {
|
async deleteProduct(productId: number, quotationId: number) {
|
||||||
this.quotationsLoading.set(true)
|
this.quotationsLoading.set(true)
|
||||||
try {
|
try {
|
||||||
await firstValueFrom(this.quotationProductsService.deleteQuotationProductEndpoint(productId, quotationId))
|
await firstValueFrom(this.quotationsService.deleteProductFromQuotationEndpoint(productId, quotationId))
|
||||||
this.notificationService.success(
|
this.notificationService.success('Success', 'Suppression effectuée')
|
||||||
'Success',
|
} catch {
|
||||||
'Suppression effectuée'
|
this.notificationService.error('Erreur', 'Impossible de supprimer la ligne')
|
||||||
)
|
|
||||||
} catch (e) {
|
|
||||||
this.notificationService.error(
|
|
||||||
'Erreur',
|
|
||||||
'Impossible de supprimer la ligne'
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
this.quotationsLoading.set(false)
|
this.quotationsLoading.set(false)
|
||||||
await this.fetchQuotations();
|
await this.fetchQuotations();
|
||||||
@@ -131,26 +115,24 @@ export class QuotationTable implements OnInit {
|
|||||||
|
|
||||||
async editQuantity(productId: number, quotationId: number, updateQuantityComponent: QuantityForm) {
|
async editQuantity(productId: number, quotationId: number, updateQuantityComponent: QuantityForm) {
|
||||||
if (updateQuantityComponent.quantityForm.invalid) {
|
if (updateQuantityComponent.quantityForm.invalid) {
|
||||||
this.notificationService.error(
|
this.notificationService.error('Erreur', 'Formulaire invalide')
|
||||||
'Erreur',
|
|
||||||
'Erreur d\'écriture dans le formulaire'
|
|
||||||
)
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const quantity = updateQuantityComponent.quantityForm.getRawValue();
|
const quantity = updateQuantityComponent.quantityForm.getRawValue();
|
||||||
await firstValueFrom(this.quotationProductsService.patchQuotationProductQuantityEndpoint(productId, quotationId, quantity))
|
await firstValueFrom(this.quotationsService.patchQuotationProductQuantityEndpoint(productId, quotationId, quantity))
|
||||||
|
|
||||||
this.notificationService.success('Success', 'Quantité modifiée')
|
this.notificationService.success('Success', 'Quantité modifiée')
|
||||||
} catch (e) {
|
} catch {
|
||||||
this.notificationService.error('Erreur', 'Erreur lors de la modification')
|
this.notificationService.error('Erreur', 'Erreur lors de la modification')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
selectedQuotation: GetQuotationDto | null = null;
|
selectedQuotation: GetQuotationDto | null = null;
|
||||||
|
|
||||||
openEditModal(quotation: GetQuotationDto) {
|
openEditModal(quotation: GetQuotationDto) {
|
||||||
this.selectedQuotation = { ...quotation };
|
this.selectedQuotation = {...quotation};
|
||||||
this.modal().showModal();
|
this.modal().showModal();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,7 +141,7 @@ export class QuotationTable implements OnInit {
|
|||||||
|
|
||||||
await this.edit(id, updateQuotationComponent);
|
await this.edit(id, updateQuotationComponent);
|
||||||
updateQuotationComponent.quotationForm.reset();
|
updateQuotationComponent.quotationForm.reset();
|
||||||
modal.isVisible = false;
|
this.onModalCancel(modal);
|
||||||
await this.fetchQuotations();
|
await this.fetchQuotations();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,8 +150,9 @@ export class QuotationTable implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
selectedQuantity: GetQuotationProductDto | null = null;
|
selectedQuantity: GetQuotationProductDto | null = null;
|
||||||
|
|
||||||
openEditQuantityModal(quantity: GetQuotationProductDto) {
|
openEditQuantityModal(quantity: GetQuotationProductDto) {
|
||||||
this.selectedQuantity = { ...quantity };
|
this.selectedQuantity = {...quantity};
|
||||||
this.modalQuantity().showModal();
|
this.modalQuantity().showModal();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -178,7 +161,7 @@ export class QuotationTable implements OnInit {
|
|||||||
|
|
||||||
await this.editQuantity(productId, quotationId, updateQuantityComponent);
|
await this.editQuantity(productId, quotationId, updateQuantityComponent);
|
||||||
updateQuantityComponent.quantityForm.reset();
|
updateQuantityComponent.quantityForm.reset();
|
||||||
modal.isVisible = false;
|
this.onModalCancel(modal);
|
||||||
await this.fetchQuotations();
|
await this.fetchQuotations();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,36 +0,0 @@
|
|||||||
/* From Uiverse.io by LightAndy1 */
|
|
||||||
.group {
|
|
||||||
box-shadow: 0 1px 2px 1px #001529;
|
|
||||||
border-radius: 15px;
|
|
||||||
padding: 0.1rem 0.5rem 0.1rem 1rem;
|
|
||||||
display: flex;
|
|
||||||
line-height: 28px;
|
|
||||||
align-items: center;
|
|
||||||
position: relative;
|
|
||||||
max-width: 400px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.input {
|
|
||||||
width: 100%;
|
|
||||||
height: 32px;
|
|
||||||
line-height: 28px;
|
|
||||||
padding: 0 1rem;
|
|
||||||
border: 2px solid transparent;
|
|
||||||
border-radius: 8px;
|
|
||||||
outline: none;
|
|
||||||
background-color: #f3f3f4;
|
|
||||||
color: #0d0c22;
|
|
||||||
transition: 0.3s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.input::placeholder {
|
|
||||||
color: #9e9ea7;
|
|
||||||
}
|
|
||||||
|
|
||||||
.input:focus,
|
|
||||||
input:hover {
|
|
||||||
outline: none;
|
|
||||||
border-color: #40A9FF;
|
|
||||||
background-color: #fff;
|
|
||||||
box-shadow: 0 0 0 4px rgba(199, 199, 197, 0.1);
|
|
||||||
}
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
<form nz-form nzLayout="horizontal" [formGroup]="searchForm">
|
|
||||||
<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()"/>
|
|
||||||
</div>
|
|
||||||
</nz-form-control>
|
|
||||||
</nz-form-item>
|
|
||||||
</form>
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
import { Component, output } from '@angular/core';
|
|
||||||
import {NzIconDirective} from "ng-zorro-antd/icon";
|
|
||||||
import {NzColDirective} from "ng-zorro-antd/grid";
|
|
||||||
import {NzFlexDirective} from "ng-zorro-antd/flex";
|
|
||||||
import {NzFormControlComponent, NzFormDirective, NzFormItemComponent} from "ng-zorro-antd/form";
|
|
||||||
import {FormControl, FormGroup, ReactiveFormsModule} from "@angular/forms";
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'app-search',
|
|
||||||
imports: [
|
|
||||||
NzIconDirective,
|
|
||||||
NzColDirective,
|
|
||||||
NzFlexDirective,
|
|
||||||
NzFormControlComponent,
|
|
||||||
NzFormDirective,
|
|
||||||
NzFormItemComponent,
|
|
||||||
ReactiveFormsModule
|
|
||||||
],
|
|
||||||
templateUrl: './search.html',
|
|
||||||
styleUrl: './search.css',
|
|
||||||
})
|
|
||||||
export class Search {
|
|
||||||
searchForm: FormGroup = new FormGroup({
|
|
||||||
searchValue: new FormControl<string>(null)
|
|
||||||
})
|
|
||||||
|
|
||||||
searchEvent = output<string>();
|
|
||||||
|
|
||||||
OnSearch(): void {
|
|
||||||
const raw = this.searchForm.controls['searchValue'].value ?? '';
|
|
||||||
const value = String(raw).trim();
|
|
||||||
this.searchEvent.emit(value);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,35 +1,60 @@
|
|||||||
<form nz-form nzLayout="horizontal" [formGroup]="settingForm" (ngSubmit)="submitForm()">
|
<form nz-form nzLayout="horizontal" [formGroup]="settingForm">
|
||||||
|
|
||||||
<!-- Logo -->
|
<!-- Logo -->
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="row-left">
|
<div class="row-left">
|
||||||
<img [src]="setting.logo" alt="logo">
|
@if (settings().logo) {
|
||||||
|
<img [src]="settings().logo" alt=""/>
|
||||||
|
} @else {
|
||||||
|
<img [src]="setting.logo" alt="logo">
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row-right">
|
@if (admin()){
|
||||||
<nz-form-item>
|
<div class="row-right">
|
||||||
<nz-form-label nzSpan="9">Logo</nz-form-label>
|
<nz-form-item>
|
||||||
<nz-form-control nzSpan="25">
|
<nz-form-label nzSpan="9">Logo</nz-form-label>
|
||||||
<input nz-input type="file" formControlName="logo" />
|
<nz-form-control nzErrorTip="Ce champ est requis">
|
||||||
</nz-form-control>
|
<input #fileInputLogo nz-input type="file" placeholder="Déposer"
|
||||||
</nz-form-item>
|
(change)="onFileChange('logo', fileInputLogo.files)">
|
||||||
</div>
|
</nz-form-control>
|
||||||
|
</nz-form-item>
|
||||||
|
</div>
|
||||||
|
} @else {
|
||||||
|
<div class="row-right">
|
||||||
|
<nz-form-item>
|
||||||
|
<p class="text-red-600">Vous ne pouvez pas modifier le logo</p>
|
||||||
|
</nz-form-item>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Signature -->
|
<!-- Signature -->
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="row-left">
|
<div class="row-left">
|
||||||
<img [src]="setting.signature" alt="logo">
|
@if (settings().electronicSignature) {
|
||||||
|
<img [src]="settings().electronicSignature" alt=""/>
|
||||||
|
} @else {
|
||||||
|
<img [src]="setting.electronicSignature" alt="logo">
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row-right">
|
@if (admin()) {
|
||||||
<nz-form-item>
|
<div class="row-right">
|
||||||
<nz-form-label nzSpan="9">Signature</nz-form-label>
|
<nz-form-item>
|
||||||
<nz-form-control nzSpan="25">
|
<nz-form-label nzSpan="9">Signature</nz-form-label>
|
||||||
<input nz-input type="file" formControlName="signature" />
|
<nz-form-control nzErrorTip="Ce champ est requis">
|
||||||
</nz-form-control>
|
<input #fileInputSignature nz-input type="file" placeholder="Déposer"
|
||||||
</nz-form-item>
|
(change)="onFileChange('electronicSignature', fileInputSignature.files)">
|
||||||
</div>
|
</nz-form-control>
|
||||||
|
</nz-form-item>
|
||||||
|
</div>
|
||||||
|
} @else {
|
||||||
|
<div class="row-right">
|
||||||
|
<nz-form-item>
|
||||||
|
<p class="text-red-600">Vous ne pouvez pas modifier la signature</p>
|
||||||
|
</nz-form-item>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
@@ -1,12 +1,17 @@
|
|||||||
import { Component } from '@angular/core';
|
import {Component, inject, OnInit, signal} from '@angular/core';
|
||||||
import {FormControl, FormGroup, FormsModule, ReactiveFormsModule} from "@angular/forms";
|
import {FormControl, FormGroup, FormsModule, ReactiveFormsModule} from "@angular/forms";
|
||||||
import {NzColDirective} from "ng-zorro-antd/grid";
|
import {NzColDirective} from "ng-zorro-antd/grid";
|
||||||
import {NzFormControlComponent, NzFormDirective, NzFormItemComponent, NzFormLabelComponent} from "ng-zorro-antd/form";
|
import {NzFormControlComponent, NzFormDirective, NzFormItemComponent, NzFormLabelComponent} from "ng-zorro-antd/form";
|
||||||
import {NzInputDirective} from "ng-zorro-antd/input";
|
import {NzInputDirective} from "ng-zorro-antd/input";
|
||||||
import {SettingInfo} from "../../interfaces/setting.interface";
|
import {SettingInfo} from "../../interfaces/setting.interface";
|
||||||
|
import {firstValueFrom} from "rxjs";
|
||||||
|
import {GetSettingDto, SettingsService} from "../../services/api";
|
||||||
|
import {NzNotificationService} from "ng-zorro-antd/notification";
|
||||||
|
import imageCompression from "browser-image-compression";
|
||||||
|
import {AuthService} from "../../services/auth.service";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-setting-form',
|
selector: 'app-setting-form',
|
||||||
imports: [
|
imports: [
|
||||||
FormsModule,
|
FormsModule,
|
||||||
NzColDirective,
|
NzColDirective,
|
||||||
@@ -15,30 +20,68 @@ import {SettingInfo} from "../../interfaces/setting.interface";
|
|||||||
NzFormItemComponent,
|
NzFormItemComponent,
|
||||||
NzFormLabelComponent,
|
NzFormLabelComponent,
|
||||||
NzInputDirective,
|
NzInputDirective,
|
||||||
ReactiveFormsModule
|
ReactiveFormsModule,
|
||||||
],
|
],
|
||||||
templateUrl: './setting-form.html',
|
templateUrl: './setting-form.html',
|
||||||
styleUrl: './setting-form.css',
|
styleUrl: './setting-form.css',
|
||||||
})
|
})
|
||||||
export class SettingForm {
|
export class SettingForm implements OnInit {
|
||||||
settingForm: FormGroup = new FormGroup({
|
private settingsService = inject(SettingsService);
|
||||||
logo: new FormControl<string>(null),
|
private notificationService = inject(NzNotificationService);
|
||||||
signature: new FormControl<string>(null)
|
private authService = inject(AuthService);
|
||||||
})
|
|
||||||
|
|
||||||
submitForm() {
|
settings = signal<GetSettingDto>({});
|
||||||
// Pour annuler si le formulaire est invalide
|
admin = signal<boolean>(false);
|
||||||
if (this.settingForm.invalid) return;
|
|
||||||
|
|
||||||
// Pour obtenir la valeur du formulaire
|
|
||||||
console.log(this.settingForm.getRawValue())
|
|
||||||
|
|
||||||
// Pour vider le formulaire
|
|
||||||
this.settingForm.reset()
|
|
||||||
}
|
|
||||||
|
|
||||||
setting: SettingInfo = {
|
setting: SettingInfo = {
|
||||||
logo: 'https://www.pyro-fetes.com/wp-content/themes/pcptheme/img/logo-pyro-fetes-OR-top.png',
|
logo: 'https://www.pyro-fetes.com/wp-content/themes/pcptheme/img/logo-pyro-fetes-OR-top.png',
|
||||||
signature: 'https://www.pyro-fetes.com/wp-content/themes/pcptheme/img/logo-pyro-fetes-OR-top.png'
|
electronicSignature: 'https://www.pyro-fetes.com/wp-content/themes/pcptheme/img/logo-pyro-fetes-OR-top.png'
|
||||||
|
}
|
||||||
|
|
||||||
|
settingForm: FormGroup = new FormGroup({
|
||||||
|
logo: new FormControl<string>(null),
|
||||||
|
electronicSignature: new FormControl<string>(null)
|
||||||
|
})
|
||||||
|
|
||||||
|
async ngOnInit() {
|
||||||
|
await this.fetchSettings();
|
||||||
|
this.admin.set(this.authService.isAdmin());
|
||||||
|
}
|
||||||
|
|
||||||
|
async fetchSettings() {
|
||||||
|
try {
|
||||||
|
const settingsPicture = await firstValueFrom(this.settingsService.getSettingEndpoint());
|
||||||
|
this.settings.set(settingsPicture);
|
||||||
|
} catch {
|
||||||
|
this.notificationService.error('Erreur', 'Aucun paramètre défini')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async onFileChange(control: string, files?: FileList | null) {
|
||||||
|
if (!files?.length) return;
|
||||||
|
|
||||||
|
const file = files[0];
|
||||||
|
|
||||||
|
const options = {
|
||||||
|
maxSizeMB: 1,
|
||||||
|
maxWidthOrHeight: 1080,
|
||||||
|
useWebWorker: true,
|
||||||
|
fileType: 'image/jpeg'
|
||||||
|
}
|
||||||
|
|
||||||
|
const compressed = await imageCompression(file, options);
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (control === 'logo') {
|
||||||
|
await firstValueFrom(this.settingsService.patchSettingLogoEndpoint(compressed));
|
||||||
|
} else {
|
||||||
|
await firstValueFrom(this.settingsService.patchSettingElectronicSignatureEndpoint(compressed));
|
||||||
|
}
|
||||||
|
await this.fetchSettings();
|
||||||
|
} catch {
|
||||||
|
this.notificationService.error('Erreur', 'Impossible de changer les paramètres actuellement');
|
||||||
|
}
|
||||||
|
|
||||||
|
this.settingForm.reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
</nz-form-label>
|
</nz-form-label>
|
||||||
|
|
||||||
<nz-form-control nzSpan="4" nzErrorTip="Requis">
|
<nz-form-control nzSpan="4" nzErrorTip="Requis">
|
||||||
<input nz-input type="number" placeholder="12345" formControlName="minimalQuantity">
|
<input nz-input type="number" placeholder="0" formControlName="minimalQuantity">
|
||||||
</nz-form-control>
|
</nz-form-control>
|
||||||
</nz-form-item>
|
</nz-form-item>
|
||||||
</form>
|
</form>
|
||||||
@@ -7,7 +7,7 @@ import {NzFlexDirective} from "ng-zorro-antd/flex";
|
|||||||
import {GetProductDto} from "../../services/api";
|
import {GetProductDto} from "../../services/api";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-stock-form',
|
selector: 'app-stock-form',
|
||||||
imports: [
|
imports: [
|
||||||
NzFormItemComponent,
|
NzFormItemComponent,
|
||||||
NzFormLabelComponent,
|
NzFormLabelComponent,
|
||||||
@@ -18,8 +18,8 @@ import {GetProductDto} from "../../services/api";
|
|||||||
ReactiveFormsModule,
|
ReactiveFormsModule,
|
||||||
NzFlexDirective
|
NzFlexDirective
|
||||||
],
|
],
|
||||||
templateUrl: './stock-form.html',
|
templateUrl: './stock-form.html',
|
||||||
styleUrl: './stock-form.css',
|
styleUrl: './stock-form.css',
|
||||||
})
|
})
|
||||||
export class StockForm {
|
export class StockForm {
|
||||||
stockForm = new FormGroup({
|
stockForm = new FormGroup({
|
||||||
@@ -27,7 +27,8 @@ export class StockForm {
|
|||||||
minimalQuantity: new FormControl<number>(null, [Validators.required])
|
minimalQuantity: new FormControl<number>(null, [Validators.required])
|
||||||
})
|
})
|
||||||
|
|
||||||
product= input<GetProductDto>();
|
product = input<GetProductDto>();
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
effect(() => {
|
effect(() => {
|
||||||
if (this.product()) {
|
if (this.product()) {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ nz-table {
|
|||||||
background: #fff;
|
background: #fff;
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
box-shadow: 0 2px 6px rgba(0,0,0,0.1);
|
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
|
||||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,18 +66,21 @@ nz-table tbody td p {
|
|||||||
nz-table thead {
|
nz-table thead {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
nz-table tbody tr {
|
nz-table tbody tr {
|
||||||
display: block;
|
display: block;
|
||||||
margin-bottom: 16px;
|
margin-bottom: 16px;
|
||||||
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
|
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
padding: 12px;
|
padding: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
nz-table tbody td {
|
nz-table tbody td {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
padding: 6px 12px;
|
padding: 6px 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
nz-table tbody td::before {
|
nz-table tbody td::before {
|
||||||
content: attr(data-label);
|
content: attr(data-label);
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
|
|||||||
@@ -1,18 +1,16 @@
|
|||||||
<nz-table
|
<nz-table
|
||||||
[nzData]="filteredProducts()"
|
[nzData]="products()"
|
||||||
[nzFrontPagination]="false"
|
[nzFrontPagination]="false"
|
||||||
[nzLoading]="productsLoading()"
|
[nzLoading]="productsLoading()"
|
||||||
(nzCurrentPageDataChange)="onCurrentPageDataChange($event)"
|
|
||||||
>
|
>
|
||||||
<thead>
|
<thead>
|
||||||
<tr class="text-center">
|
<tr class="text-center">
|
||||||
<th nzWidth="40px">
|
<th nzWidth="40px">
|
||||||
<label
|
<label nz-checkbox
|
||||||
nz-checkbox
|
[(ngModel)]="checked"
|
||||||
[(ngModel)]="checked"
|
[nzIndeterminate]="indeterminate"
|
||||||
[nzIndeterminate]="indeterminate"
|
(ngModelChange)="allCheck($event)">
|
||||||
(ngModelChange)="onAllChecked($event)"
|
</label>
|
||||||
></label>
|
|
||||||
</th>
|
</th>
|
||||||
<th>Nom</th>
|
<th>Nom</th>
|
||||||
<th>Référence</th>
|
<th>Référence</th>
|
||||||
@@ -27,16 +25,15 @@
|
|||||||
</thead>
|
</thead>
|
||||||
|
|
||||||
<tbody class="text-center">
|
<tbody class="text-center">
|
||||||
@for (product of filteredProducts(); track product.id) {
|
@for (product of products(); track product.id) {
|
||||||
<tr>
|
<tr>
|
||||||
<td nzWidth="40px">
|
<td nzWidth="40px">
|
||||||
<label
|
<label
|
||||||
nz-checkbox
|
nz-checkbox
|
||||||
[ngModel]="setOfCheckedId.has(product.id)"
|
[ngModel]="selectedIds.includes(product.id)"
|
||||||
(ngModelChange)="onItemChecked(product.id, $event)"
|
(ngModelChange)="onItemChecked(product.id, $event)"
|
||||||
></label>
|
></label>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td>{{ product.name }}</td>
|
<td>{{ product.name }}</td>
|
||||||
<td>{{ product.references }}</td>
|
<td>{{ product.references }}</td>
|
||||||
<td>{{ product.nec }}</td>
|
<td>{{ product.nec }}</td>
|
||||||
@@ -47,9 +44,13 @@
|
|||||||
<td>{{ product.minimalQuantity }}</td>
|
<td>{{ product.minimalQuantity }}</td>
|
||||||
<td>
|
<td>
|
||||||
<div style="justify-content: center; display: flex">
|
<div style="justify-content: center; display: flex">
|
||||||
<nz-icon nzType="edit" nzTheme="outline" class="cursor-pointer" (click)="openEditModal(product)"></nz-icon>
|
<nz-icon nzType="edit" nzTheme="outline" class="cursor-pointer"
|
||||||
<nz-divider nzType="vertical"></nz-divider>
|
(click)="openEditModal(product)"></nz-icon>
|
||||||
<nz-icon nzType="delete" nzTheme="outline" (click)="delete(product.id)" class="text-red-600 cursor-pointer"></nz-icon>
|
@if (admin()) {
|
||||||
|
<nz-divider nzType="vertical"></nz-divider>
|
||||||
|
<nz-icon nzType="delete" nzTheme="outline" (click)="delete(product.id)"
|
||||||
|
class="text-red-600 cursor-pointer"></nz-icon>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -58,7 +59,8 @@
|
|||||||
</nz-table>
|
</nz-table>
|
||||||
|
|
||||||
<div class="hidden">
|
<div class="hidden">
|
||||||
<app-modal-nav #modalNav nameIcon="edit" [name]="'Modifier'" (ok)="onModalOk(selectedProduct.id, stockForm, modalNav)" (cancel)="onModalCancel(modalNav)">
|
<app-modal-nav #modalNav nameIcon="edit" [name]="'Modifier'"
|
||||||
|
(ok)="onModalOk(selectedProduct.id, stockForm, modalNav)" (cancel)="onModalCancel(modalNav)">
|
||||||
<app-stock-form #stockForm [product]="selectedProduct"></app-stock-form>
|
<app-stock-form #stockForm [product]="selectedProduct"></app-stock-form>
|
||||||
</app-modal-nav>
|
</app-modal-nav>
|
||||||
</div>
|
</div>
|
||||||
@@ -1,14 +1,15 @@
|
|||||||
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 {NzTableComponent, NzThMeasureDirective} from "ng-zorro-antd/table";
|
||||||
import {ModalNav} from "../modal-nav/modal-nav";
|
import {ModalNav} from "../modal-nav/modal-nav";
|
||||||
import {NzIconDirective} from "ng-zorro-antd/icon";
|
import {NzIconDirective} from "ng-zorro-antd/icon";
|
||||||
import {StockForm} from "../stock-form/stock-form";
|
import {StockForm} from "../stock-form/stock-form";
|
||||||
import {NzDividerComponent} from "ng-zorro-antd/divider";
|
import {NzDividerComponent} from "ng-zorro-antd/divider";
|
||||||
import {FormsModule} from "@angular/forms";
|
import {FormsModule} from "@angular/forms";
|
||||||
import {NzCheckboxComponent} from "ng-zorro-antd/checkbox";
|
|
||||||
import {GetProductDto, ProductsService, WarehouseproductsService} from "../../services/api";
|
import {GetProductDto, ProductsService, WarehouseproductsService} from "../../services/api";
|
||||||
import {NzNotificationService} from "ng-zorro-antd/notification";
|
import {NzNotificationService} from "ng-zorro-antd/notification";
|
||||||
import {firstValueFrom} from "rxjs";
|
import {firstValueFrom} from "rxjs";
|
||||||
|
import {NzCheckboxComponent} from "ng-zorro-antd/checkbox";
|
||||||
|
import {AuthService} from "../../services/auth.service";
|
||||||
|
|
||||||
interface ProductWithQuantity extends GetProductDto {
|
interface ProductWithQuantity extends GetProductDto {
|
||||||
totalQuantity?: number;
|
totalQuantity?: number;
|
||||||
@@ -23,8 +24,8 @@ interface ProductWithQuantity extends GetProductDto {
|
|||||||
StockForm,
|
StockForm,
|
||||||
NzDividerComponent,
|
NzDividerComponent,
|
||||||
FormsModule,
|
FormsModule,
|
||||||
NzCheckboxComponent,
|
|
||||||
NzThMeasureDirective,
|
NzThMeasureDirective,
|
||||||
|
NzCheckboxComponent,
|
||||||
],
|
],
|
||||||
templateUrl: './stock-table.html',
|
templateUrl: './stock-table.html',
|
||||||
styleUrl: './stock-table.css',
|
styleUrl: './stock-table.css',
|
||||||
@@ -34,171 +35,125 @@ export class StockTable implements OnInit {
|
|||||||
private productsService = inject(ProductsService);
|
private productsService = inject(ProductsService);
|
||||||
private wareHousseProductsService = inject(WarehouseproductsService)
|
private wareHousseProductsService = inject(WarehouseproductsService)
|
||||||
private notificationService = inject(NzNotificationService)
|
private notificationService = inject(NzNotificationService)
|
||||||
|
private authService = inject(AuthService);
|
||||||
|
|
||||||
products = signal<ProductWithQuantity[]>([]);
|
products = signal<ProductWithQuantity[]>([]);
|
||||||
productsLoading = signal<boolean>(false);
|
productsLoading = signal<boolean>(false);
|
||||||
updateProduct = viewChild.required<StockForm>('stockForm');
|
admin = signal<boolean>(false);
|
||||||
|
|
||||||
modal = viewChild.required<ModalNav>('modalNav');
|
modal = viewChild.required<ModalNav>('modalNav');
|
||||||
|
|
||||||
checked = false;
|
selectionChange = output<number[]>();
|
||||||
indeterminate = false;
|
productsTables = output<GetProductDto[]>();
|
||||||
setOfCheckedId = new Set<number>();
|
|
||||||
selectionChange = output<boolean>()
|
|
||||||
currentPageData: GetProductDto[] = [];
|
|
||||||
|
|
||||||
private searchQuery = signal<string>('');
|
selectedProduct: GetProductDto | null = null;
|
||||||
|
checked: boolean = false;
|
||||||
filteredProducts = computed(() => {
|
indeterminate: boolean = false;
|
||||||
const q = this.searchQuery().toLowerCase().trim();
|
selectedIds: number[] = [];
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
updateCheckedSet(id: number, checked: boolean): void {
|
|
||||||
if (checked) this.setOfCheckedId.add(id);
|
|
||||||
else this.setOfCheckedId.delete(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
onItemChecked(id: number, checked: boolean): void {
|
|
||||||
this.updateCheckedSet(id, checked);
|
|
||||||
this.refreshCheckedStatus();
|
|
||||||
}
|
|
||||||
|
|
||||||
onAllChecked(checked: boolean): void {
|
|
||||||
this.currentPageData.forEach(item =>
|
|
||||||
this.updateCheckedSet(item.id, checked)
|
|
||||||
);
|
|
||||||
this.refreshCheckedStatus();
|
|
||||||
}
|
|
||||||
|
|
||||||
onCurrentPageDataChange($event: GetProductDto[]): void {
|
|
||||||
this.currentPageData = $event;
|
|
||||||
this.refreshCheckedStatus();
|
|
||||||
}
|
|
||||||
|
|
||||||
refreshCheckedStatus(): void {
|
|
||||||
const total = this.currentPageData.length;
|
|
||||||
const checkedCount = this.currentPageData.filter(p => this.setOfCheckedId.has(p.id)).length;
|
|
||||||
|
|
||||||
this.checked = checkedCount === total;
|
|
||||||
this.indeterminate = checkedCount > 0 && checkedCount < total;
|
|
||||||
|
|
||||||
setTimeout(() => this.selectionChange.emit(this.hasSelection));
|
|
||||||
}
|
|
||||||
|
|
||||||
get selectedIds() {
|
|
||||||
return Array.from(this.setOfCheckedId);
|
|
||||||
}
|
|
||||||
|
|
||||||
async ngOnInit() {
|
async ngOnInit() {
|
||||||
await this.fetchProducts();
|
await this.fetchProducts();
|
||||||
}
|
this.admin.set(this.authService.isAdmin());
|
||||||
|
|
||||||
async fetchTotalQuantity(product: ProductWithQuantity) {
|
|
||||||
try {
|
|
||||||
const res = await firstValueFrom(
|
|
||||||
this.wareHousseProductsService.getTotalQuantityEndpoint(product.id)
|
|
||||||
);
|
|
||||||
product.totalQuantity = res.totalQuantity;
|
|
||||||
} catch (e) {
|
|
||||||
product.totalQuantity = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async fetchProducts() {
|
async fetchProducts() {
|
||||||
this.productsLoading.set(true);
|
this.productsLoading.set(true);
|
||||||
try {
|
try {
|
||||||
const products = await firstValueFrom(this.productsService.getAllProductsEndpoint());
|
const products = await firstValueFrom(this.productsService.getAllProductsEndpoint());
|
||||||
|
this.productsTables.emit(products);
|
||||||
|
|
||||||
// transforme chaque produit en ProductWithQuantity
|
const productsWithQuantity = await Promise.all(
|
||||||
const productsWithQuantity: ProductWithQuantity[] = products.map(p => ({ ...p }));
|
products.map(async (x) => {
|
||||||
|
try {
|
||||||
this.products.set(productsWithQuantity);
|
const quantity = await firstValueFrom(this.wareHousseProductsService.getTotalQuantityEndpoint(x.id));
|
||||||
|
return {
|
||||||
// récupérer la quantité pour chaque produit en parallèle
|
...x,
|
||||||
await Promise.all(productsWithQuantity.map(p => this.fetchTotalQuantity(p)));
|
totalQuantity: quantity.totalQuantity ?? 0
|
||||||
|
};
|
||||||
// déclencher la mise à jour du signal
|
} catch {
|
||||||
this.products.set([...productsWithQuantity]);
|
return {
|
||||||
} catch (e) {
|
...x,
|
||||||
this.notificationService.error(
|
totalQuantity: 0
|
||||||
'Erreur',
|
};
|
||||||
'Erreur de communication avec l\'API'
|
}
|
||||||
|
})
|
||||||
);
|
);
|
||||||
|
this.products.set(productsWithQuantity);
|
||||||
|
} catch {
|
||||||
|
this.notificationService.error('Erreur', 'Impossible de charger le catalogue');
|
||||||
}
|
}
|
||||||
this.productsLoading.set(false);
|
this.productsLoading.set(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
async delete(productId:number) {
|
async delete(productId: number) {
|
||||||
try {
|
try {
|
||||||
await firstValueFrom(this.productsService.deleteProductEndpoint(productId))
|
await firstValueFrom(this.productsService.deleteProductEndpoint(productId))
|
||||||
this.notificationService.success(
|
this.notificationService.success('Success', 'Suppression effectuée');
|
||||||
'Success',
|
} catch {
|
||||||
'Suppression effectuée'
|
this.notificationService.error('Erreur', 'Impossible de supprimer la ligne');
|
||||||
)
|
|
||||||
} catch (e) {
|
|
||||||
this.notificationService.error(
|
|
||||||
'Erreur',
|
|
||||||
'Impossible de supprimer la ligne'
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
await this.fetchProducts();
|
await this.fetchProducts();
|
||||||
}
|
}
|
||||||
|
|
||||||
async edit(id: number, updateProductComponent: StockForm) {
|
async edit(id: number, updateProductComponent: StockForm) {
|
||||||
if (updateProductComponent.stockForm.invalid) {
|
if (updateProductComponent.stockForm.invalid) {
|
||||||
this.notificationService.error(
|
this.notificationService.error('Erreur', 'Formulaire invalide')
|
||||||
'Erreur',
|
|
||||||
'Erreur d\'écriture dans le formulaire'
|
|
||||||
)
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
const products = updateProductComponent.stockForm.getRawValue();
|
const products = updateProductComponent.stockForm.getRawValue();
|
||||||
await firstValueFrom(this.productsService.patchProductMinimalStockEndpoint(id, products))
|
await firstValueFrom(this.productsService.patchProductMinimalStockEndpoint(id, products));
|
||||||
|
await this.fetchProducts();
|
||||||
this.notificationService.success(
|
this.notificationService.success('Success', 'Limite de stock modifiée');
|
||||||
'Success',
|
} catch {
|
||||||
'Limite de stock modifiée'
|
this.notificationService.error('Erreur', 'Erreur lors de la modification');
|
||||||
)
|
|
||||||
} catch (e) {
|
|
||||||
console.error(e);
|
|
||||||
this.notificationService.error(
|
|
||||||
'Erreur',
|
|
||||||
'Erreur lors de la modification'
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
selectedProduct: GetProductDto | null = null;
|
|
||||||
openEditModal(product: GetProductDto) {
|
openEditModal(product: GetProductDto) {
|
||||||
this.selectedProduct = { ...product};
|
this.selectedProduct = {...product};
|
||||||
this.modal().showModal();
|
this.modal().showModal();
|
||||||
}
|
}
|
||||||
|
|
||||||
async onModalOk(productId: number, updateProductComponent: StockForm, modal: ModalNav) {
|
async onModalOk(productId: number, updateProductComponent: StockForm, modal: ModalNav) {
|
||||||
if (!this.selectedProduct) return;
|
if (!this.selectedProduct) return;
|
||||||
|
|
||||||
await this.edit(productId, updateProductComponent);
|
await this.edit(productId, updateProductComponent);
|
||||||
updateProductComponent.stockForm.reset();
|
updateProductComponent.stockForm.reset();
|
||||||
modal.isVisible = false;
|
this.onModalCancel(modal);
|
||||||
await this.fetchProducts();
|
await this.fetchProducts();
|
||||||
}
|
}
|
||||||
|
|
||||||
onModalCancel(modal: ModalNav) {
|
onModalCancel(modal: ModalNav) {
|
||||||
modal.isVisible = false;
|
modal.isVisible = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateCheck(id: number, checked: boolean) {
|
||||||
|
if (checked) {
|
||||||
|
if (!this.selectedIds.includes(id)) {
|
||||||
|
this.selectedIds.push(id);
|
||||||
|
}
|
||||||
|
} else this.selectedIds = this.selectedIds.filter(x => x !== id);
|
||||||
|
}
|
||||||
|
|
||||||
|
refreshCheckStatus() {
|
||||||
|
const total = this.products().length;
|
||||||
|
const checkedCount = this.selectedIds.length;
|
||||||
|
|
||||||
|
this.checked = checkedCount === total;
|
||||||
|
this.indeterminate = checkedCount > 0 && checkedCount < total;
|
||||||
|
|
||||||
|
this.selectionChange.emit(this.selectedIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
allCheck(checked: boolean) {
|
||||||
|
this.products().forEach(x =>
|
||||||
|
this.updateCheck(x.id, checked)
|
||||||
|
);
|
||||||
|
this.refreshCheckStatus();
|
||||||
|
}
|
||||||
|
|
||||||
|
onItemChecked(id: number, checked: boolean): void {
|
||||||
|
this.updateCheck(id, checked);
|
||||||
|
this.refreshCheckStatus();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -22,6 +22,8 @@ import {GetSupplierDto} from "../../services/api";
|
|||||||
styleUrl: './supplier-form.css',
|
styleUrl: './supplier-form.css',
|
||||||
})
|
})
|
||||||
export class SupplierForm {
|
export class SupplierForm {
|
||||||
|
supplier = input<GetSupplierDto>();
|
||||||
|
|
||||||
supplierForm: FormGroup = new FormGroup({
|
supplierForm: FormGroup = new FormGroup({
|
||||||
name: new FormControl<string>(null, [Validators.required]),
|
name: new FormControl<string>(null, [Validators.required]),
|
||||||
email: new FormControl<string>(null, [Validators.required]),
|
email: new FormControl<string>(null, [Validators.required]),
|
||||||
@@ -33,7 +35,6 @@ export class SupplierForm {
|
|||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
supplier= input<GetSupplierDto>();
|
|
||||||
constructor() {
|
constructor() {
|
||||||
effect(() => {
|
effect(() => {
|
||||||
if (this.supplier()) {
|
if (this.supplier()) {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ nz-table {
|
|||||||
background: #fff;
|
background: #fff;
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
box-shadow: 0 2px 6px rgba(0,0,0,0.1);
|
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
|
||||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,18 +66,21 @@ nz-table tbody td p {
|
|||||||
nz-table thead {
|
nz-table thead {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
nz-table tbody tr {
|
nz-table tbody tr {
|
||||||
display: block;
|
display: block;
|
||||||
margin-bottom: 16px;
|
margin-bottom: 16px;
|
||||||
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
|
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
padding: 12px;
|
padding: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
nz-table tbody td {
|
nz-table tbody td {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
padding: 6px 12px;
|
padding: 6px 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
nz-table tbody td::before {
|
nz-table tbody td::before {
|
||||||
content: attr(data-label);
|
content: attr(data-label);
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<nz-table [nzData]="filteredSuppliers()"
|
<nz-table [nzData]="suppliers()"
|
||||||
[nzLoading]="suppliersLoading()"
|
[nzLoading]="suppliersLoading()"
|
||||||
[nzFrontPagination]="false">
|
[nzFrontPagination]="false">
|
||||||
<thead>
|
<thead>
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody style="text-align: center">
|
<tbody style="text-align: center">
|
||||||
@for (supplier of filteredSuppliers(); track supplier.id) {
|
@for (supplier of suppliers(); track supplier.id) {
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ supplier.name }}</td>
|
<td>{{ supplier.name }}</td>
|
||||||
<td>{{ supplier.phone }}</td>
|
<td>{{ supplier.phone }}</td>
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
<td>{{ supplier.deliveryDelay }} jours</td>
|
<td>{{ supplier.deliveryDelay }} jours</td>
|
||||||
<td>
|
<td>
|
||||||
<app-modal-button type="link" [name]="'Voir les produits'" size="45%">
|
<app-modal-button type="link" [name]="'Voir les produits'" size="45%">
|
||||||
<nz-table [nzData]="filteredSuppliers()" [nzFrontPagination]="false">
|
<nz-table [nzData]="suppliers()" [nzFrontPagination]="false">
|
||||||
<thead>
|
<thead>
|
||||||
<tr class="text-center">
|
<tr class="text-center">
|
||||||
<th>Produit</th>
|
<th>Produit</th>
|
||||||
@@ -36,19 +36,22 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody class="text-center">
|
<tbody class="text-center">
|
||||||
@for (product of supplier.prices; track product.id) {
|
@for (product of supplier.prices; track product.productId) {
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ product.productName }}</td>
|
<td>{{ product.productName }}</td>
|
||||||
<td>{{ product.productReferences }}</td>
|
<td>{{ product.productReference }}</td>
|
||||||
<td>{{ product.sellingPrice }}€</td>
|
<td>{{ product.sellingPrice }}€</td>
|
||||||
<td>
|
<td>
|
||||||
<div class="flex items-center justify-center space-x-2">
|
<div class="flex items-center justify-center space-x-2">
|
||||||
<nz-icon nzType="edit" nzTheme="outline"
|
<nz-icon nzType="edit" nzTheme="outline"
|
||||||
class="cursor-pointer text-gray-600 hover:text-gray-900"
|
class="cursor-pointer text-gray-600 hover:text-gray-900"
|
||||||
(click)="openEditProductModal(product, supplier.id)"></nz-icon>
|
(click)="openEditProductModal(product, supplier.id)"></nz-icon>
|
||||||
<nz-divider nzType="vertical"></nz-divider>
|
@if (admin()) {
|
||||||
<nz-icon nzType="delete" nzTheme="outline" class="cursor-pointer text-red-600 hover:text-red-800"
|
<nz-divider nzType="vertical"></nz-divider>
|
||||||
(click)="deleteProduct(product.productId, product.supplierId)"></nz-icon>
|
<nz-icon nzType="delete" nzTheme="outline"
|
||||||
|
class="cursor-pointer text-red-600 hover:text-red-800"
|
||||||
|
(click)="deleteProduct(product.productId, supplier.id)"></nz-icon>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -61,9 +64,11 @@
|
|||||||
<div style="display: flex; align-items: center;">
|
<div style="display: flex; align-items: center;">
|
||||||
<nz-icon nzType="edit" nzTheme="outline" class="cursor-pointer"
|
<nz-icon nzType="edit" nzTheme="outline" class="cursor-pointer"
|
||||||
(click)="openEditModal(supplier)"></nz-icon>
|
(click)="openEditModal(supplier)"></nz-icon>
|
||||||
<nz-divider nzType="vertical"></nz-divider>
|
@if (admin()) {
|
||||||
<nz-icon nzType="delete" nzTheme="outline" (click)="delete(supplier.id)"
|
<nz-divider nzType="vertical"></nz-divider>
|
||||||
class="text-red-600 cursor-pointer"></nz-icon>
|
<nz-icon nzType="delete" nzTheme="outline" (click)="delete(supplier.id)"
|
||||||
|
class="text-red-600 cursor-pointer"></nz-icon>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
@@ -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 {ModalNav} from "../modal-nav/modal-nav";
|
||||||
import {NzDividerComponent} from "ng-zorro-antd/divider";
|
import {NzDividerComponent} from "ng-zorro-antd/divider";
|
||||||
import {NzIconDirective} from "ng-zorro-antd/icon";
|
import {NzIconDirective} from "ng-zorro-antd/icon";
|
||||||
@@ -9,6 +9,7 @@ import {GetPriceDto, GetSupplierDto, PricesService, SuppliersService} from "../.
|
|||||||
import {NzNotificationService} from "ng-zorro-antd/notification";
|
import {NzNotificationService} from "ng-zorro-antd/notification";
|
||||||
import {firstValueFrom} from "rxjs";
|
import {firstValueFrom} from "rxjs";
|
||||||
import {PriceForm} from "../price-form/price-form";
|
import {PriceForm} from "../price-form/price-form";
|
||||||
|
import {AuthService} from "../../services/auth.service";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-supplier-table',
|
selector: 'app-supplier-table',
|
||||||
@@ -29,34 +30,22 @@ export class SupplierTable implements OnInit {
|
|||||||
private suppliersService = inject(SuppliersService);
|
private suppliersService = inject(SuppliersService);
|
||||||
private pricesService = inject(PricesService);
|
private pricesService = inject(PricesService);
|
||||||
private notificationService = inject(NzNotificationService);
|
private notificationService = inject(NzNotificationService);
|
||||||
|
private authService = inject(AuthService);
|
||||||
|
|
||||||
suppliers = signal<GetSupplierDto[]>([]);
|
suppliers = signal<GetSupplierDto[]>([]);
|
||||||
suppliersLoading = signal<boolean>(false);
|
suppliersLoading = signal<boolean>(false);
|
||||||
updateSupplier = viewChild.required<SupplierForm>('supplierForm');
|
admin = signal<boolean>(false);
|
||||||
|
|
||||||
supplierModal = viewChild.required<ModalNav>('supplierModal');
|
supplierModal = viewChild.required<ModalNav>('supplierModal');
|
||||||
productModal = viewChild.required<ModalNav>('productModal');
|
productModal = viewChild.required<ModalNav>('productModal');
|
||||||
|
|
||||||
selectedSupplier: GetSupplierDto | null = null;
|
selectedSupplier: GetSupplierDto | null = null;
|
||||||
selectedProduct: GetPriceDto | null = null;
|
selectedProduct: GetPriceDto | null = null;
|
||||||
selectedProductSupplierId: number | null = null;
|
selectedProductSupplierId: number | null = null;
|
||||||
|
|
||||||
async ngOnInit() {
|
async ngOnInit() {
|
||||||
await this.fetchSuppliers();
|
await this.fetchSuppliers();
|
||||||
}
|
this.admin.set(this.authService.isAdmin());
|
||||||
|
|
||||||
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() {
|
async fetchSuppliers() {
|
||||||
@@ -64,7 +53,7 @@ export class SupplierTable implements OnInit {
|
|||||||
try {
|
try {
|
||||||
const suppliers = await firstValueFrom(this.suppliersService.getAllSuppliersEndpoint());
|
const suppliers = await firstValueFrom(this.suppliersService.getAllSuppliersEndpoint());
|
||||||
this.suppliers.set(suppliers);
|
this.suppliers.set(suppliers);
|
||||||
} catch (e) {
|
} catch {
|
||||||
this.notificationService.error('Erreur', 'Erreur de communication avec l\'API');
|
this.notificationService.error('Erreur', 'Erreur de communication avec l\'API');
|
||||||
}
|
}
|
||||||
this.suppliersLoading.set(false);
|
this.suppliersLoading.set(false);
|
||||||
@@ -79,8 +68,7 @@ export class SupplierTable implements OnInit {
|
|||||||
const suppliers = updateSupplierComponent.supplierForm.getRawValue();
|
const suppliers = updateSupplierComponent.supplierForm.getRawValue();
|
||||||
await firstValueFrom(this.suppliersService.updateSupplierEndpoint(id, suppliers));
|
await firstValueFrom(this.suppliersService.updateSupplierEndpoint(id, suppliers));
|
||||||
this.notificationService.success('Success', 'Fournisseur modifié');
|
this.notificationService.success('Success', 'Fournisseur modifié');
|
||||||
} catch (e) {
|
} catch {
|
||||||
console.error(e);
|
|
||||||
this.notificationService.error('Erreur', 'Erreur lors de la modification');
|
this.notificationService.error('Erreur', 'Erreur lors de la modification');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -90,18 +78,18 @@ export class SupplierTable implements OnInit {
|
|||||||
await firstValueFrom(this.suppliersService.deleteSupplierEndpoint(supplier));
|
await firstValueFrom(this.suppliersService.deleteSupplierEndpoint(supplier));
|
||||||
this.notificationService.success('Succès', 'Suppression effectuée');
|
this.notificationService.success('Succès', 'Suppression effectuée');
|
||||||
await this.fetchSuppliers();
|
await this.fetchSuppliers();
|
||||||
} catch (e) {
|
} catch {
|
||||||
this.notificationService.error('Erreur', 'Impossible de supprimer la ligne');
|
this.notificationService.error('Erreur', 'Impossible de supprimer la ligne');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
openEditModal(supplier: GetSupplierDto) {
|
openEditModal(supplier: GetSupplierDto) {
|
||||||
this.selectedSupplier = { ...supplier };
|
this.selectedSupplier = {...supplier};
|
||||||
this.supplierModal().showModal();
|
this.supplierModal().showModal();
|
||||||
}
|
}
|
||||||
|
|
||||||
openEditProductModal(product: GetPriceDto, supplierId: number) {
|
openEditProductModal(product: GetPriceDto, supplierId: number) {
|
||||||
this.selectedProduct = { ...product };
|
this.selectedProduct = {...product};
|
||||||
this.selectedProductSupplierId = supplierId;
|
this.selectedProductSupplierId = supplierId;
|
||||||
this.productModal().showModal();
|
this.productModal().showModal();
|
||||||
}
|
}
|
||||||
@@ -122,13 +110,13 @@ export class SupplierTable implements OnInit {
|
|||||||
modal: ModalNav
|
modal: ModalNav
|
||||||
) {
|
) {
|
||||||
if (productId == null || supplierId == null || !this.selectedProduct) {
|
if (productId == null || supplierId == null || !this.selectedProduct) {
|
||||||
this.notificationService.error('Erreur', 'Identifiants produit/fournisseur manquants');
|
this.notificationService.error('Erreur', 'Identifiants produit ou fournisseur manquants');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.editPrice(productId, supplierId, updateProductComponent);
|
await this.editPrice(productId, supplierId, updateProductComponent);
|
||||||
updateProductComponent.priceForm.reset();
|
updateProductComponent.priceForm.reset();
|
||||||
modal.isVisible = false;
|
this.onModalCancel(modal);
|
||||||
await this.fetchSuppliers();
|
await this.fetchSuppliers();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -150,8 +138,7 @@ export class SupplierTable implements OnInit {
|
|||||||
};
|
};
|
||||||
await firstValueFrom(this.pricesService.patchPriceEndpoint(productId, supplierId, body));
|
await firstValueFrom(this.pricesService.patchPriceEndpoint(productId, supplierId, body));
|
||||||
this.notificationService.success('Success', 'Prix modifié');
|
this.notificationService.success('Success', 'Prix modifié');
|
||||||
} catch (e) {
|
} catch {
|
||||||
console.error(e);
|
|
||||||
this.notificationService.error('Erreur', 'Erreur lors de la modification');
|
this.notificationService.error('Erreur', 'Erreur lors de la modification');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -159,10 +146,10 @@ export class SupplierTable implements OnInit {
|
|||||||
|
|
||||||
async deleteProduct(idProduct: number, idSupplier: number) {
|
async deleteProduct(idProduct: number, idSupplier: number) {
|
||||||
try {
|
try {
|
||||||
await firstValueFrom(this.pricesService.deletePriceEndpoint(idProduct, idSupplier));
|
await firstValueFrom(this.suppliersService.deleteProductToSupplierEndpoint(idSupplier, idProduct));
|
||||||
this.notificationService.success('Succès', 'Produit supprimé');
|
this.notificationService.success('Succès', 'Produit supprimé');
|
||||||
await this.fetchSuppliers();
|
await this.fetchSuppliers();
|
||||||
} catch (e) {
|
} catch {
|
||||||
this.notificationService.error('Erreur', 'Impossible de supprimer le produit');
|
this.notificationService.error('Erreur', 'Impossible de supprimer le produit');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ nz-table {
|
|||||||
background: #fff;
|
background: #fff;
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
box-shadow: 0 2px 6px rgba(0,0,0,0.1);
|
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
|
||||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,18 +66,21 @@ nz-table tbody td p {
|
|||||||
nz-table thead {
|
nz-table thead {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
nz-table tbody tr {
|
nz-table tbody tr {
|
||||||
display: block;
|
display: block;
|
||||||
margin-bottom: 16px;
|
margin-bottom: 16px;
|
||||||
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
|
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
padding: 12px;
|
padding: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
nz-table tbody td {
|
nz-table tbody td {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
padding: 6px 12px;
|
padding: 6px 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
nz-table tbody td::before {
|
nz-table tbody td::before {
|
||||||
content: attr(data-label);
|
content: attr(data-label);
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
[nzLoading]="usersLoading()"
|
[nzLoading]="usersLoading()"
|
||||||
[nzFrontPagination]="false"
|
[nzFrontPagination]="false"
|
||||||
class="mr-7">
|
class="mr-7">
|
||||||
<thead>
|
<thead>
|
||||||
<tr class="text-center">
|
<tr class="text-center">
|
||||||
<th>Prénom</th>
|
<th>Prénom</th>
|
||||||
<th>Email</th>
|
<th>Email</th>
|
||||||
@@ -13,15 +13,17 @@
|
|||||||
<tbody class="text-center">
|
<tbody class="text-center">
|
||||||
@for (user of users(); track user.id) {
|
@for (user of users(); track user.id) {
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{user.name}}</td>
|
<td>{{ user.name }}</td>
|
||||||
<td>{{user.email}}</td>
|
<td>{{ user.email }}</td>
|
||||||
<td>{{user.fonction}}</td>
|
<td>{{ user.fonction }}</td>
|
||||||
<td>
|
<td>
|
||||||
<div style="justify-content: center; display: flex">
|
<div style="justify-content: center; display: flex">
|
||||||
<nz-icon nzType="edit" nzTheme="outline" class="cursor-pointer" (click)="openEditModal(user)"></nz-icon>
|
<nz-icon nzType="edit" nzTheme="outline" class="cursor-pointer"
|
||||||
|
(click)="openEditModal(user)"></nz-icon>
|
||||||
<nz-divider nzType="vertical"></nz-divider>
|
<nz-divider nzType="vertical"></nz-divider>
|
||||||
<div>
|
<div>
|
||||||
<nz-icon nzType="delete" nzTheme="outline" (click)="delete(user.id)" class="cursor-pointer text-red-700"/>
|
<nz-icon nzType="delete" nzTheme="outline" (click)="delete(user.id)"
|
||||||
|
class="cursor-pointer text-red-700"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
@@ -31,7 +33,8 @@
|
|||||||
</nz-table>
|
</nz-table>
|
||||||
|
|
||||||
<div class="hidden">
|
<div class="hidden">
|
||||||
<app-modal-nav #modalNav nameIcon="edit" [name]="'Modifier'" (ok)="onModalOk(selectedUser.id, updateUser, modalNav)" (cancel)="onModalCancel(modalNav)">
|
<app-modal-nav #modalNav nameIcon="edit" [name]="'Modifier'" (ok)="onModalOk(selectedUser.id, updateUser, modalNav)"
|
||||||
|
(cancel)="onModalCancel(modalNav)">
|
||||||
<app-profil-form #updateUser [user]="selectedUser"></app-profil-form>
|
<app-profil-form #updateUser [user]="selectedUser"></app-profil-form>
|
||||||
</app-modal-nav>
|
</app-modal-nav>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import {NzNotificationService} from "ng-zorro-antd/notification";
|
|||||||
import {firstValueFrom} from "rxjs";
|
import {firstValueFrom} from "rxjs";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-user-table',
|
selector: 'app-user-table',
|
||||||
imports: [
|
imports: [
|
||||||
ModalNav,
|
ModalNav,
|
||||||
NzIconDirective,
|
NzIconDirective,
|
||||||
@@ -17,15 +17,16 @@ import {firstValueFrom} from "rxjs";
|
|||||||
ProfilForm,
|
ProfilForm,
|
||||||
NzDividerComponent
|
NzDividerComponent
|
||||||
],
|
],
|
||||||
templateUrl: './user-table.html',
|
templateUrl: './user-table.html',
|
||||||
styleUrl: './user-table.css',
|
styleUrl: './user-table.css',
|
||||||
})
|
})
|
||||||
export class UserTable implements OnInit {
|
export class UserTable implements OnInit {
|
||||||
private usersService = inject(UsersService);
|
private usersService = inject(UsersService);
|
||||||
private notificationService = inject(NzNotificationService)
|
private notificationService = inject(NzNotificationService)
|
||||||
|
|
||||||
users = signal<GetUserDto[]>([]);
|
users = signal<GetUserDto[]>([]);
|
||||||
usersLoading = signal<boolean>(false);
|
usersLoading = signal<boolean>(false);
|
||||||
updateUser = viewChild.required<ProfilForm>('profilForm');
|
|
||||||
modal = viewChild.required<ModalNav>('modalNav');
|
modal = viewChild.required<ModalNav>('modalNav');
|
||||||
|
|
||||||
async ngOnInit() {
|
async ngOnInit() {
|
||||||
@@ -38,37 +39,25 @@ export class UserTable implements OnInit {
|
|||||||
try {
|
try {
|
||||||
const users = await firstValueFrom(this.usersService.getAllUsersEndpoint())
|
const users = await firstValueFrom(this.usersService.getAllUsersEndpoint())
|
||||||
this.users.set(users);
|
this.users.set(users);
|
||||||
} catch (e) {
|
} catch {
|
||||||
this.notificationService.error(
|
this.notificationService.error('Erreur', 'Impossible de charger les utilisateurs')
|
||||||
'Erreur',
|
|
||||||
'Erreur de communication avec l\'API'
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
this.usersLoading.set(false)
|
this.usersLoading.set(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
async delete(user:number) {
|
async delete(user: number) {
|
||||||
try {
|
try {
|
||||||
await firstValueFrom(this.usersService.deleteUserEndpoint(user))
|
await firstValueFrom(this.usersService.deleteUserEndpoint(user))
|
||||||
this.notificationService.success(
|
this.notificationService.success('Success', 'Suppression effectuée')
|
||||||
'Success',
|
} catch {
|
||||||
'Suppression effectuée'
|
this.notificationService.error('Erreur', 'Impossible de supprimer la ligne')
|
||||||
)
|
|
||||||
} catch (e) {
|
|
||||||
this.notificationService.error(
|
|
||||||
'Erreur',
|
|
||||||
'Impossible de supprimer la ligne'
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
await this.fetchUsers();
|
await this.fetchUsers();
|
||||||
}
|
}
|
||||||
|
|
||||||
async edit(id: number, updateUserComponent: ProfilForm) {
|
async edit(id: number, updateUserComponent: ProfilForm) {
|
||||||
if (updateUserComponent.profilForm.invalid) {
|
if (updateUserComponent.profilForm.invalid) {
|
||||||
this.notificationService.error(
|
this.notificationService.error('Erreur', 'Formulaire invalide')
|
||||||
'Erreur',
|
|
||||||
'Erreur d\'écriture dans le formulaire'
|
|
||||||
)
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,21 +65,16 @@ export class UserTable implements OnInit {
|
|||||||
const users = updateUserComponent.profilForm.getRawValue();
|
const users = updateUserComponent.profilForm.getRawValue();
|
||||||
await firstValueFrom(this.usersService.updateUserEndpoint(id, users))
|
await firstValueFrom(this.usersService.updateUserEndpoint(id, users))
|
||||||
|
|
||||||
this.notificationService.success(
|
this.notificationService.success('Success', 'Utilisateur modifié')
|
||||||
'Success',
|
} catch {
|
||||||
'Utilisateur modifié'
|
this.notificationService.error('Erreur', 'Erreur lors de la modification')
|
||||||
)
|
|
||||||
} catch (e) {
|
|
||||||
this.notificationService.error(
|
|
||||||
'Erreur',
|
|
||||||
'Erreur lors de la modification'
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
selectedUser: GetUserDto | null = null;
|
selectedUser: GetUserDto | null = null;
|
||||||
|
|
||||||
openEditModal(user: GetUserDto) {
|
openEditModal(user: GetUserDto) {
|
||||||
this.selectedUser = { ...user };
|
this.selectedUser = {...user};
|
||||||
this.modal().showModal();
|
this.modal().showModal();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,13 +83,11 @@ export class UserTable implements OnInit {
|
|||||||
|
|
||||||
await this.edit(userId, updateUserComponent);
|
await this.edit(userId, updateUserComponent);
|
||||||
updateUserComponent.profilForm.reset();
|
updateUserComponent.profilForm.reset();
|
||||||
modal.isVisible = false;
|
this.onModalCancel(modal);
|
||||||
await this.fetchUsers();
|
await this.fetchUsers();
|
||||||
}
|
}
|
||||||
|
|
||||||
onModalCancel(modal: ModalNav) {
|
onModalCancel(modal: ModalNav) {
|
||||||
modal.isVisible = false;
|
modal.isVisible = false;
|
||||||
}
|
}
|
||||||
filterUser(input: string, option: any) {
|
|
||||||
return option.nzLabel.toLowerCase().includes(input.toLowerCase());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
import { inject } from '@angular/core';
|
||||||
|
import { Router } from '@angular/router';
|
||||||
|
import { AuthService} from "../services/auth.service";
|
||||||
|
|
||||||
|
export const authGuard = async () => {
|
||||||
|
const auth = inject(AuthService);
|
||||||
|
const router = inject(Router);
|
||||||
|
|
||||||
|
if(!auth.userAuthenticated()) {
|
||||||
|
await router.navigateByUrl('/login');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
};
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
import {HttpInterceptorFn, HttpErrorResponse, HttpRequest, HttpHandlerFn} from '@angular/common/http';
|
||||||
|
import {inject} from '@angular/core';
|
||||||
|
import {AuthService} from '../services/auth.service';
|
||||||
|
import {RefreshService} from '../services/api';
|
||||||
|
import {NzNotificationService} from 'ng-zorro-antd/notification';
|
||||||
|
import {catchError, switchMap, throwError} from 'rxjs';
|
||||||
|
|
||||||
|
export const authInterceptor: HttpInterceptorFn = (req: HttpRequest<any>, next: HttpHandlerFn) => {
|
||||||
|
const authService = inject(AuthService);
|
||||||
|
const refreshService = inject(RefreshService);
|
||||||
|
const notification = inject(NzNotificationService);
|
||||||
|
const token = authService.getToken();
|
||||||
|
|
||||||
|
let authReq = req;
|
||||||
|
if (token) {
|
||||||
|
authReq = req.clone({
|
||||||
|
setHeaders: {Authorization: `Bearer ${token}`}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return next(authReq).pipe(
|
||||||
|
catchError((error: HttpErrorResponse) => {
|
||||||
|
if (error.status === 401 && token) {
|
||||||
|
return refreshService.refreshTokenEndpoint({token})
|
||||||
|
.pipe(
|
||||||
|
switchMap((res: any) => {
|
||||||
|
authService.setToken(res.token);
|
||||||
|
const newReq = req.clone({
|
||||||
|
setHeaders: {Authorization: `Bearer ${res.token}`}
|
||||||
|
});
|
||||||
|
return next(newReq);
|
||||||
|
}),
|
||||||
|
catchError((refreshErr) => {
|
||||||
|
authService.logout();
|
||||||
|
notification.error('Session expirée', 'Veuillez vous reconnecter.');
|
||||||
|
return throwError(() => refreshErr);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (error.status === 403) {
|
||||||
|
notification.error('Accès refusé', 'Vous n’avez pas les droits pour cette action.');
|
||||||
|
}
|
||||||
|
|
||||||
|
return throwError(() => error);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
export interface NotifInfo {
|
|
||||||
author: string;
|
|
||||||
title: string;
|
|
||||||
content: string;
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
export interface SettingInfo {
|
export interface SettingInfo {
|
||||||
logo: string;
|
logo: string;
|
||||||
signature: string;
|
electronicSignature: string;
|
||||||
}
|
}
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
export interface UserInfo {
|
|
||||||
name: string;
|
|
||||||
email: string;
|
|
||||||
fonction: string;
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
<div class="flex w-full px-4 gap-4 items-start mt-6">
|
||||||
|
<div class="w-1/2">
|
||||||
|
<app-delivery-validator></app-delivery-validator>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="w-1/2 mt-10 flex flex-col gap-4">
|
||||||
|
<p class="text-2xl font-bold">Tableau de bord</p>
|
||||||
|
<div class="grid grid-cols-2 gap-4">
|
||||||
|
<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 partenaires.">
|
||||||
|
</app-info-card>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
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, GetSupplierDto, ProductsService, SuppliersService} from "../../services/api";
|
||||||
|
import {firstValueFrom} from "rxjs";
|
||||||
|
import {StockAlert} from "../../services/stock.alert";
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-dashboard',
|
||||||
|
imports: [
|
||||||
|
InfoCard,
|
||||||
|
DeliveryValidator,
|
||||||
|
],
|
||||||
|
templateUrl: './dashboard.html',
|
||||||
|
styleUrl: './dashboard.css'
|
||||||
|
})
|
||||||
|
|
||||||
|
export class Dashboard {
|
||||||
|
private productsService = inject(ProductsService);
|
||||||
|
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 {
|
||||||
|
this.notificationsService.error('Erreur', 'Impossible de charger les transporteurs');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async getSuppliers() {
|
||||||
|
try {
|
||||||
|
const suppliers = await firstValueFrom(this.suppliersService.getAllSuppliersEndpoint());
|
||||||
|
this.suppliers.set(suppliers);
|
||||||
|
this.suppliersCount.set(suppliers.length);
|
||||||
|
} catch {
|
||||||
|
this.notificationsService.error('Erreur', 'Impossible de charger les fournisseurs');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async getProductsUnderLimit() {
|
||||||
|
try {
|
||||||
|
const products = await firstValueFrom(this.productsService.getAllProductsUnderLimitEndpoint());
|
||||||
|
this.productsUnderLimitCount.set(products.length);
|
||||||
|
await this.stockAlertService.generatePurchaseOrder(products, this.suppliers());
|
||||||
|
} catch {
|
||||||
|
this.notificationsService.error('Error', 'Impossible de charger les produits.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async ngOnInit() {
|
||||||
|
await this.getDeliverers();
|
||||||
|
await this.getSuppliers();
|
||||||
|
await this.getProductsUnderLimit();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,12 +8,8 @@
|
|||||||
|
|
||||||
<app-deliverer-form #delivererForm></app-deliverer-form>
|
<app-deliverer-form #delivererForm></app-deliverer-form>
|
||||||
</app-modal-button>
|
</app-modal-button>
|
||||||
|
|
||||||
<div class="ml-95 w-150">
|
|
||||||
<app-search class="w-full"></app-search>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mt-1">
|
<div class="mt-4">
|
||||||
<app-deliverer-table #delivererTable></app-deliverer-table>
|
<app-deliverer-table #delivererTable></app-deliverer-table>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -2,21 +2,19 @@ import {Component, inject, viewChild} from '@angular/core';
|
|||||||
import {ModalButton} from "../../components/modal-button/modal-button";
|
import {ModalButton} from "../../components/modal-button/modal-button";
|
||||||
import {DelivererTable} from "../../components/deliverer-table/deliverer-table";
|
import {DelivererTable} from "../../components/deliverer-table/deliverer-table";
|
||||||
import {DelivererForm} from "../../components/deliverer-form/deliverer-form";
|
import {DelivererForm} from "../../components/deliverer-form/deliverer-form";
|
||||||
import {Search} from "../../components/search/search";
|
|
||||||
import {DeliverersService} from "../../services/api";
|
import {DeliverersService} from "../../services/api";
|
||||||
import {NzNotificationService} from "ng-zorro-antd/notification";
|
import {NzNotificationService} from "ng-zorro-antd/notification";
|
||||||
import {firstValueFrom} from "rxjs";
|
import {firstValueFrom} from "rxjs";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-deliverer',
|
selector: 'app-deliverer',
|
||||||
imports: [
|
imports: [
|
||||||
ModalButton,
|
ModalButton,
|
||||||
DelivererTable,
|
DelivererTable,
|
||||||
DelivererForm,
|
DelivererForm,
|
||||||
Search
|
|
||||||
],
|
],
|
||||||
templateUrl: './deliverer.html',
|
templateUrl: './deliverer.html',
|
||||||
styleUrl: './deliverer.css',
|
styleUrl: './deliverer.css',
|
||||||
})
|
})
|
||||||
export class Deliverer {
|
export class Deliverer {
|
||||||
modal = viewChild.required<ModalButton>('modalButton');
|
modal = viewChild.required<ModalButton>('modalButton');
|
||||||
@@ -28,7 +26,7 @@ export class Deliverer {
|
|||||||
async onModalOk() {
|
async onModalOk() {
|
||||||
await this.addDeliverer()
|
await this.addDeliverer()
|
||||||
this.createDeliverer().delivererForm.reset();
|
this.createDeliverer().delivererForm.reset();
|
||||||
this.modal().isVisible = false;
|
this.onModalCancel();
|
||||||
await this.delivererTable().fetchDeliverers()
|
await this.delivererTable().fetchDeliverers()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -37,26 +35,16 @@ export class Deliverer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async addDeliverer() {
|
async addDeliverer() {
|
||||||
if (this.createDeliverer().delivererForm.invalid)
|
if (this.createDeliverer().delivererForm.invalid) {
|
||||||
{
|
this.notificationService.error('Erreur', 'Formulaire invalide')
|
||||||
this.notificationService.error(
|
|
||||||
'Erreur',
|
|
||||||
'Erreur d\'écriture dans le formulaire'
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const deliverers = this.createDeliverer().delivererForm.getRawValue();
|
const deliverers = this.createDeliverer().delivererForm.getRawValue();
|
||||||
await firstValueFrom(this.deliverersService.createDelivererEndpoint(deliverers))
|
await firstValueFrom(this.deliverersService.createDelivererEndpoint(deliverers))
|
||||||
|
|
||||||
this.notificationService.success(
|
this.notificationService.success('Success', 'Transporteur enregistré')
|
||||||
'Success',
|
} catch {
|
||||||
'Transporteur enregistré'
|
this.notificationService.error('Erreur', 'Erreur d\'enregistrement')
|
||||||
)
|
|
||||||
} catch (e) {
|
|
||||||
this.notificationService.error(
|
|
||||||
'Erreur',
|
|
||||||
'Erreur d\'enregistrement'
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,13 +1,3 @@
|
|||||||
<div class="flex mt-2">
|
<div class="mt-2">
|
||||||
<app-modal-button type="primary" name="Créer un bon de livraison" size="32%">
|
|
||||||
<app-deliverery-note-form></app-deliverery-note-form>
|
|
||||||
</app-modal-button>
|
|
||||||
|
|
||||||
<div class="ml-95 w-150">
|
|
||||||
<app-search></app-search>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="mt-1">
|
|
||||||
<app-deliverery-note-table></app-deliverery-note-table>
|
<app-deliverery-note-table></app-deliverery-note-table>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,19 +1,13 @@
|
|||||||
import { Component } from '@angular/core';
|
import {Component} from '@angular/core';
|
||||||
import {DelivereryNoteTable} from "../../components/deliverery-note-table/deliverery-note-table";
|
import {DelivereryNoteTable} from "../../components/deliverery-note-table/deliverery-note-table";
|
||||||
import {ModalButton} from "../../components/modal-button/modal-button";
|
|
||||||
import {DelivereryNoteForm} from "../../components/deliverery-note-form/deliverery-note-form";
|
|
||||||
import {Search} from "../../components/search/search";
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-delivery-note',
|
selector: 'app-delivery-note',
|
||||||
imports: [
|
imports: [
|
||||||
DelivereryNoteTable,
|
DelivereryNoteTable,
|
||||||
ModalButton,
|
|
||||||
DelivereryNoteForm,
|
|
||||||
Search
|
|
||||||
],
|
],
|
||||||
templateUrl: './delivery-note.html',
|
templateUrl: './delivery-note.html',
|
||||||
styleUrl: './delivery-note.css',
|
styleUrl: './delivery-note.css',
|
||||||
})
|
})
|
||||||
export class DeliveryNote {
|
export class DeliveryNote {
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,46 @@
|
|||||||
|
<div class="grid grid-cols-9 min-h-screen bg-blue-950">
|
||||||
|
<div class="col-span-6 w-full h-full border rounded-r-4xl overflow-hidden">
|
||||||
|
<img src="https://www.pyro-fetes.com/wp-content/uploads/2023/03/5I9A3180-scaled.jpg"
|
||||||
|
class="w-full h-full object-cover"
|
||||||
|
alt=""
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-span-3 w-full flex items-center justify-center">
|
||||||
|
|
||||||
|
<div class="flex flex-col items-center">
|
||||||
|
<img src="https://www.pyro-fetes.com/wp-content/uploads/2020/10/PyroFetes-logo-OR.png"
|
||||||
|
class="w-9/12 mb-10"
|
||||||
|
alt=""
|
||||||
|
/>
|
||||||
|
|
||||||
|
<div class="bg-white border rounded-2xl p-8 w-80 shadow-lg">
|
||||||
|
<form nz-form nzLayout="vertical" [formGroup]="loginForm">
|
||||||
|
<nz-form-item>
|
||||||
|
<nz-form-label nzRequired>
|
||||||
|
Nom d'utilisateur
|
||||||
|
</nz-form-label>
|
||||||
|
<nz-form-control nzErrorTip="Ce champ est requis">
|
||||||
|
<input nz-input placeholder="Nom d'utilisateur" formControlName="name">
|
||||||
|
</nz-form-control>
|
||||||
|
</nz-form-item>
|
||||||
|
|
||||||
|
<nz-form-item>
|
||||||
|
<nz-form-label nzRequired class="mt-3">
|
||||||
|
Mot de passe
|
||||||
|
</nz-form-label>
|
||||||
|
<nz-form-control nzErrorTip="Ce champ est requis">
|
||||||
|
<input nz-input type="password" placeholder="Mot de passe" formControlName="password">
|
||||||
|
</nz-form-control>
|
||||||
|
</nz-form-item>
|
||||||
|
|
||||||
|
<button class="mt-4 rounded-xl w-full" nz-button nzType="primary" (click)="connectUser()">
|
||||||
|
Connexion
|
||||||
|
</button>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
import {Component, inject, OnInit} from '@angular/core';
|
||||||
|
import {NzColDirective} from "ng-zorro-antd/grid";
|
||||||
|
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 {NzButtonComponent} from "ng-zorro-antd/button";
|
||||||
|
import {AuthService} from "../../services/auth.service";
|
||||||
|
import {Router} from "@angular/router";
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-login',
|
||||||
|
imports: [
|
||||||
|
NzColDirective,
|
||||||
|
NzFormControlComponent,
|
||||||
|
NzFormDirective,
|
||||||
|
NzFormItemComponent,
|
||||||
|
NzFormLabelComponent,
|
||||||
|
NzInputDirective,
|
||||||
|
ReactiveFormsModule,
|
||||||
|
NzButtonComponent
|
||||||
|
],
|
||||||
|
templateUrl: './login.html',
|
||||||
|
styleUrl: './login.css',
|
||||||
|
})
|
||||||
|
export class Login implements OnInit {
|
||||||
|
private authService = inject(AuthService);
|
||||||
|
private router = inject(Router);
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.authService.logout();
|
||||||
|
}
|
||||||
|
|
||||||
|
loginForm: FormGroup = new FormGroup({
|
||||||
|
name: new FormControl<string>(null, [Validators.required]),
|
||||||
|
password: new FormControl<string>(null, [Validators.required])
|
||||||
|
})
|
||||||
|
|
||||||
|
async connectUser() {
|
||||||
|
if (this.loginForm.invalid) return;
|
||||||
|
const ok = await this.authService.connectUser(this.loginForm.value.name, this.loginForm.value.password);
|
||||||
|
if (ok) await this.router.navigate(['/dashboard']);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,10 +1,4 @@
|
|||||||
<div class="flex mt-2">
|
<div class="mt-2">
|
||||||
<div class="ml-95 w-150">
|
|
||||||
<app-search></app-search>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="mt-1">
|
|
||||||
<app-purchase-order-table></app-purchase-order-table>
|
<app-purchase-order-table></app-purchase-order-table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +1,13 @@
|
|||||||
import { Component } from '@angular/core';
|
import {Component} from '@angular/core';
|
||||||
import {Search} from "../../components/search/search";
|
|
||||||
import {PurchaseOrderTable} from "../../components/purchase-order-table/purchase-order-table";
|
import {PurchaseOrderTable} from "../../components/purchase-order-table/purchase-order-table";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-purchase-order',
|
selector: 'app-purchase-order',
|
||||||
imports: [
|
imports: [
|
||||||
Search,
|
|
||||||
PurchaseOrderTable,
|
PurchaseOrderTable,
|
||||||
],
|
],
|
||||||
templateUrl: './purchase-order.html',
|
templateUrl: './purchase-order.html',
|
||||||
styleUrl: './purchase-order.css',
|
styleUrl: './purchase-order.css',
|
||||||
})
|
})
|
||||||
export class PurchaseOrder {
|
export class PurchaseOrder {
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,3 @@
|
|||||||
<div class="flex mt-2">
|
<div class="mt-2">
|
||||||
<div class="ml-95 w-150">
|
|
||||||
<app-search></app-search>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="mt-1">
|
|
||||||
<app-quotation-table></app-quotation-table>
|
<app-quotation-table></app-quotation-table>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,15 +1,13 @@
|
|||||||
import { Component } from '@angular/core';
|
import {Component} from '@angular/core';
|
||||||
import {Search} from "../../components/search/search";
|
|
||||||
import {QuotationTable} from "../../components/quotation-table/quotation-table";
|
import {QuotationTable} from "../../components/quotation-table/quotation-table";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-quotation',
|
selector: 'app-quotation',
|
||||||
imports: [
|
imports: [
|
||||||
Search,
|
|
||||||
QuotationTable
|
QuotationTable
|
||||||
],
|
],
|
||||||
templateUrl: './quotation.html',
|
templateUrl: './quotation.html',
|
||||||
styleUrl: './quotation.css',
|
styleUrl: './quotation.css',
|
||||||
})
|
})
|
||||||
export class Quotation {
|
export class Quotation {
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,17 @@
|
|||||||
<div class="flex mt-2">
|
<div class="flex mt-2">
|
||||||
@if (hasSelection) {
|
@if (productIds().length) {
|
||||||
<app-modal-button #modalButtonPurchaseOrder
|
<app-modal-button #modalButtonPurchaseOrder
|
||||||
(click)="openPurchaseOrderForm()"
|
(click)="openPurchaseOrderForm()"
|
||||||
(ok)="onModalOk()"
|
(ok)="onModalPurchaseOrderOk()"
|
||||||
(cancel)="onModalCancel()"
|
(cancel)="onModalPurchaseOrderCancel()"
|
||||||
type="default"
|
type="default"
|
||||||
name="Créer un bon de commande"
|
name="Créer un bon de commande"
|
||||||
size="35%"
|
size="35%"
|
||||||
class="ml-4">
|
class="ml-4">
|
||||||
<app-create-purchaseorder-form #purchaseOrderForm></app-create-purchaseorder-form>
|
<app-create-purchaseorder-form #purchaseOrderForm
|
||||||
|
[suppliers]="suppliers()"
|
||||||
|
[products]="selectedProducts()">
|
||||||
|
</app-create-purchaseorder-form>
|
||||||
</app-modal-button>
|
</app-modal-button>
|
||||||
|
|
||||||
<app-modal-button #modalButtonQuotation
|
<app-modal-button #modalButtonQuotation
|
||||||
@@ -19,16 +22,30 @@
|
|||||||
(click)="openQuotationForm()"
|
(click)="openQuotationForm()"
|
||||||
(ok)="onModalQuotationOk()"
|
(ok)="onModalQuotationOk()"
|
||||||
(cancel)="onModalQuotationCancel()">
|
(cancel)="onModalQuotationCancel()">
|
||||||
<app-create-quotation-form #quotationForm></app-create-quotation-form>
|
<app-create-quotation-form #quotationForm
|
||||||
|
[suppliers]="suppliers()"
|
||||||
|
[products]="selectedProducts()">
|
||||||
|
</app-create-quotation-form>
|
||||||
|
</app-modal-button>
|
||||||
|
|
||||||
|
<app-modal-button #modalButtonSupplier
|
||||||
|
type="default"
|
||||||
|
name="Associer à un fournisseur"
|
||||||
|
size="35%"
|
||||||
|
class="ml-4"
|
||||||
|
(click)="openSupplierForm()"
|
||||||
|
(ok)="onModalSupplierOk()"
|
||||||
|
(cancel)="onModalSupplierCancel()">
|
||||||
|
<app-add-product-supplier-form #supplierForm
|
||||||
|
[suppliers]="suppliers()"
|
||||||
|
[products]="selectedProducts()">
|
||||||
|
</app-add-product-supplier-form>
|
||||||
</app-modal-button>
|
</app-modal-button>
|
||||||
}
|
}
|
||||||
|
|
||||||
<div class="ml-95 w-150">
|
|
||||||
<app-search (searchEvent)="onProductSearch($event)"></app-search>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mt-1">
|
<div class="mt-4">
|
||||||
<app-stock-table #stockTable (selectionChange)="onSelectionChange($event)"></app-stock-table>
|
<app-stock-table (selectionChange)="onSelectionChange($event)"
|
||||||
|
(productsTables)="products.set($event)">
|
||||||
|
</app-stock-table>
|
||||||
</div>
|
</div>
|
||||||
+136
-64
@@ -1,138 +1,210 @@
|
|||||||
import {Component, inject, viewChild} from '@angular/core';
|
import {Component, inject, OnInit, signal, viewChild} from '@angular/core';
|
||||||
import {StockTable} from "../../components/stock-table/stock-table";
|
import {StockTable} from "../../components/stock-table/stock-table";
|
||||||
import {Search} from "../../components/search/search";
|
|
||||||
import {ModalButton} from "../../components/modal-button/modal-button";
|
import {ModalButton} from "../../components/modal-button/modal-button";
|
||||||
import {QuotationForm} from "../../components/quotation-form/quotation-form";
|
|
||||||
import {PurchaseordersService, QuotationsService} from "../../services/api";
|
|
||||||
import {NzNotificationService} from "ng-zorro-antd/notification";
|
|
||||||
import {firstValueFrom} from "rxjs";
|
|
||||||
import {CreatePurchaseorderForm} from "../../components/create-purchaseorder-form/create-purchaseorder-form";
|
import {CreatePurchaseorderForm} from "../../components/create-purchaseorder-form/create-purchaseorder-form";
|
||||||
|
import {NzNotificationService} from "ng-zorro-antd/notification";
|
||||||
|
import {
|
||||||
|
CreatePurchaseOrderDto, CreateQuotationDto,
|
||||||
|
GetProductDto,
|
||||||
|
GetSupplierDto,
|
||||||
|
PurchaseordersService,
|
||||||
|
QuotationsService,
|
||||||
|
SuppliersService
|
||||||
|
} from "../../services/api";
|
||||||
|
import {firstValueFrom} from "rxjs";
|
||||||
import {CreateQuotationForm} from "../../components/create-quotation-form/create-quotation-form";
|
import {CreateQuotationForm} from "../../components/create-quotation-form/create-quotation-form";
|
||||||
|
import {AddProductSupplierForm} from "../../components/add-product-supplier-form/add-product-supplier-form";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-stock',
|
selector: 'app-stock',
|
||||||
imports: [
|
imports: [
|
||||||
StockTable,
|
StockTable,
|
||||||
Search,
|
|
||||||
ModalButton,
|
ModalButton,
|
||||||
CreatePurchaseorderForm,
|
CreatePurchaseorderForm,
|
||||||
CreateQuotationForm,
|
CreateQuotationForm,
|
||||||
|
AddProductSupplierForm,
|
||||||
],
|
],
|
||||||
templateUrl: './stock.html',
|
templateUrl: './stock.html',
|
||||||
styleUrl: './stock.css',
|
styleUrl: './stock.css',
|
||||||
})
|
})
|
||||||
|
|
||||||
export class Stock {
|
export class Stock implements OnInit {
|
||||||
createPurchaseOrder = viewChild.required<CreatePurchaseorderForm>('purchaseOrderForm');
|
createPurchaseOrder = viewChild.required<CreatePurchaseorderForm>('purchaseOrderForm');
|
||||||
createQuotation = viewChild.required<CreateQuotationForm>('quotationForm');
|
createQuotation = viewChild.required<CreateQuotationForm>('quotationForm');
|
||||||
productTable = viewChild.required<StockTable>('stockTable');
|
addProduct = viewChild.required<AddProductSupplierForm>('supplierForm');
|
||||||
private purchaseordersService = inject(PurchaseordersService)
|
|
||||||
private quotationsService = inject(QuotationsService)
|
|
||||||
private notificationService = inject(NzNotificationService)
|
|
||||||
modalButtonPurchaseOrder = viewChild.required<ModalButton>('modalButtonPurchaseOrder');
|
modalButtonPurchaseOrder = viewChild.required<ModalButton>('modalButtonPurchaseOrder');
|
||||||
modalButtonQuotation = viewChild.required<ModalButton>('modalButtonQuotation');
|
modalButtonQuotation = viewChild.required<ModalButton>('modalButtonQuotation');
|
||||||
|
modalButtonSupplier = viewChild.required<ModalButton>('modalButtonSupplier');
|
||||||
|
|
||||||
hasSelection = false;
|
private purchaseOrdersService = inject(PurchaseordersService);
|
||||||
|
private quotationsService = inject(QuotationsService);
|
||||||
|
private suppliersService = inject(SuppliersService);
|
||||||
|
private notificationService = inject(NzNotificationService);
|
||||||
|
|
||||||
onSelectionChange(value: boolean) {
|
products = signal<GetProductDto[]>([]);
|
||||||
this.hasSelection = value;
|
suppliers = signal<GetSupplierDto[]>([]);
|
||||||
|
selectedProducts = signal([]);
|
||||||
|
|
||||||
|
productIds = signal<number[]>([]);
|
||||||
|
|
||||||
|
async ngOnInit() {
|
||||||
|
try {
|
||||||
|
const suppliers = await firstValueFrom(this.suppliersService.getAllSuppliersEndpoint());
|
||||||
|
this.suppliers.set(suppliers);
|
||||||
|
} catch {
|
||||||
|
this.notificationService.error('Erreur', 'Impossible de charger les fournisseurs');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onProductSearch(query: string) {
|
onSelectionChange(ids: number[]) {
|
||||||
this.productTable().applySearch(query);
|
this.productIds.set(ids);
|
||||||
|
this.selectedProducts.set(this.products().filter(x => ids.includes(x.id)));
|
||||||
|
}
|
||||||
|
|
||||||
|
openPurchaseOrderForm() {
|
||||||
|
this.createPurchaseOrder().addProductToForm();
|
||||||
|
}
|
||||||
|
|
||||||
|
openQuotationForm() {
|
||||||
|
this.createQuotation().addProductToForm();
|
||||||
|
}
|
||||||
|
|
||||||
|
openSupplierForm() {
|
||||||
|
this.addProduct().addProductToForm();
|
||||||
}
|
}
|
||||||
|
|
||||||
async addPurchaseOrder() {
|
async addPurchaseOrder() {
|
||||||
const form = this.createPurchaseOrder().createPurchaseOrderForm;
|
const form = this.createPurchaseOrder().createPurchaseOrderForm;
|
||||||
|
|
||||||
if (form.invalid) {
|
if (form.invalid) {
|
||||||
this.notificationService.error('Erreur', 'Formulaire invalide');
|
this.notificationService.error('Erreur', 'Formulaire invalide');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const orderLines = this.createPurchaseOrder().lines.value.map(line => ({
|
|
||||||
|
const orderLines = this.createPurchaseOrder().lines.value.map((line: { productId: any; quantity: any; }) => ({
|
||||||
productId: line.productId,
|
productId: line.productId,
|
||||||
quantity: line.quantity
|
quantity: line.quantity
|
||||||
}));
|
}));
|
||||||
if (orderLines.length === 0) {
|
|
||||||
|
if (!orderLines.length) {
|
||||||
this.notificationService.error('Erreur', 'Aucun produit sélectionné');
|
this.notificationService.error('Erreur', 'Aucun produit sélectionné');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const purchaseOrder = {
|
|
||||||
purchaseConditions: form.get('purchaseConditions')!.value,
|
const purchaseOrder: CreatePurchaseOrderDto = {
|
||||||
products: orderLines
|
purchaseConditions: form.value.purchaseConditions,
|
||||||
|
products: orderLines,
|
||||||
|
supplierId: form.value.supplierId
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await firstValueFrom(
|
await firstValueFrom(this.purchaseOrdersService.createPurchaseOrder(purchaseOrder));
|
||||||
this.purchaseordersService.createPurchaseOrder(purchaseOrder)
|
|
||||||
);
|
|
||||||
this.notificationService.success('Succès', 'Bon de commande créé');
|
this.notificationService.success('Succès', 'Bon de commande créé');
|
||||||
} catch (e) {
|
} catch {
|
||||||
this.notificationService.error('Erreur', 'Erreur lors de la création du bon de commande.');
|
this.notificationService.error('Erreur', 'Erreur lors de la création du bon de commande.');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
async onModalOk() {
|
|
||||||
await this.addPurchaseOrder();
|
|
||||||
this.createPurchaseOrder().createPurchaseOrderForm.reset();
|
|
||||||
this.modalButtonPurchaseOrder().isVisible = false;
|
|
||||||
await this.productTable().fetchProducts();
|
|
||||||
}
|
|
||||||
|
|
||||||
onModalCancel() {
|
|
||||||
this.modalButtonPurchaseOrder().isVisible = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
openPurchaseOrderForm() {
|
|
||||||
const selectedProducts = this.productTable().products().filter(p =>
|
|
||||||
this.productTable().selectedIds.includes(p.id)
|
|
||||||
);
|
|
||||||
this.createPurchaseOrder().syncSelectedProducts(selectedProducts);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async addQuotation() {
|
async addQuotation() {
|
||||||
if (this.createQuotation().createQuotationForm.invalid) {
|
const form = this.createQuotation().createQuotationForm;
|
||||||
|
|
||||||
|
if (form.invalid) {
|
||||||
this.notificationService.error('Erreur', 'Formulaire invalide');
|
this.notificationService.error('Erreur', 'Formulaire invalide');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const orderLines = this.createQuotation().lines.value.map(line => ({
|
|
||||||
|
const orderLines = this.createQuotation().lines.value.map((line: { productId: any; quantity: any; }) => ({
|
||||||
productId: line.productId,
|
productId: line.productId,
|
||||||
quantity: line.quantity
|
quantity: line.quantity
|
||||||
}));
|
}));
|
||||||
if (orderLines.length === 0) {
|
|
||||||
|
if (!orderLines.length) {
|
||||||
this.notificationService.error('Erreur', 'Aucun produit sélectionné');
|
this.notificationService.error('Erreur', 'Aucun produit sélectionné');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const quotation = {
|
|
||||||
message: this.createQuotation().createQuotationForm.get('message')!.value,
|
const quotation: CreateQuotationDto = {
|
||||||
purchaseConditions: this.createQuotation().createQuotationForm.get('purchaseConditions')!.value,
|
message: this.createQuotation().createQuotationForm.value.message,
|
||||||
|
conditionsSale: this.createQuotation().createQuotationForm.value.conditionsSale,
|
||||||
|
customerId: this.createQuotation().createQuotationForm.value.customerId,
|
||||||
|
supplierId: this.createQuotation().createQuotationForm.value.supplierId,
|
||||||
products: orderLines
|
products: orderLines
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await firstValueFrom(
|
await firstValueFrom(this.quotationsService.createQuotationEndpoint(quotation));
|
||||||
this.quotationsService.createQuotationEndpoint(quotation)
|
|
||||||
);
|
|
||||||
this.notificationService.success('Succès', 'Devis créé');
|
this.notificationService.success('Succès', 'Devis créé');
|
||||||
} catch (e) {
|
} catch {
|
||||||
this.notificationService.error('Erreur', 'Erreur lors de la création du devis.');
|
this.notificationService.error('Erreur', 'Erreur lors de la création du devis.');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async addProductFromSupplier() {
|
||||||
|
const form = this.addProduct().addProductForm;
|
||||||
|
let success = 0;
|
||||||
|
|
||||||
|
if (form.invalid) {
|
||||||
|
this.notificationService.error('Erreur', 'Formulaire invalide');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const supplierId = form.value.supplierId;
|
||||||
|
const lines = this.addProduct().lines.value;
|
||||||
|
|
||||||
|
if (!lines.length) {
|
||||||
|
this.notificationService.error('Erreur', 'Aucun produit sélectionné');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const line of lines) {
|
||||||
|
try {
|
||||||
|
await firstValueFrom(
|
||||||
|
this.suppliersService.addProductToSupplierEndpoint(
|
||||||
|
supplierId,
|
||||||
|
line.productId,
|
||||||
|
{
|
||||||
|
sellingPrice: line.price
|
||||||
|
}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
success++;
|
||||||
|
} catch {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.notificationService.success('Succès', `${success} produits ajoutés`);
|
||||||
|
}
|
||||||
|
|
||||||
|
async onModalPurchaseOrderOk() {
|
||||||
|
await this.addPurchaseOrder();
|
||||||
|
this.createPurchaseOrder().createPurchaseOrderForm.reset();
|
||||||
|
this.modalButtonPurchaseOrder().isVisible = false;
|
||||||
|
this.onModalPurchaseOrderCancel();
|
||||||
|
}
|
||||||
|
|
||||||
|
onModalPurchaseOrderCancel() {
|
||||||
|
this.modalButtonPurchaseOrder().isVisible = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
async onModalQuotationOk() {
|
async onModalQuotationOk() {
|
||||||
await this.addQuotation();
|
await this.addQuotation();
|
||||||
this.createQuotation().createQuotationForm.reset();
|
this.createQuotation().createQuotationForm.reset();
|
||||||
this.modalButtonQuotation().isVisible = false;
|
this.modalButtonQuotation().isVisible = false;
|
||||||
await this.productTable().fetchProducts();
|
this.onModalQuotationCancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
onModalQuotationCancel() {
|
onModalQuotationCancel() {
|
||||||
this.modalButtonQuotation().isVisible = false;
|
this.modalButtonQuotation().isVisible = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
openQuotationForm() {
|
async onModalSupplierOk() {
|
||||||
const selectedProducts = this.productTable().products().filter(p =>
|
await this.addProductFromSupplier();
|
||||||
this.productTable().selectedIds.includes(p.id)
|
this.addProduct().addProductForm.reset();
|
||||||
);
|
this.modalButtonSupplier().isVisible = false;
|
||||||
this.createQuotation().syncSelectedProducts(selectedProducts);
|
this.onModalSupplierCancel();
|
||||||
|
}
|
||||||
|
|
||||||
|
onModalSupplierCancel() {
|
||||||
|
this.modalButtonSupplier().isVisible = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,11 +8,8 @@
|
|||||||
|
|
||||||
<app-supplier-form #supplierForm></app-supplier-form>
|
<app-supplier-form #supplierForm></app-supplier-form>
|
||||||
</app-modal-button>
|
</app-modal-button>
|
||||||
<div class="ml-95 w-150">
|
|
||||||
<app-search (searchEvent)="onSupplierSearch($event)"></app-search>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mt-1">
|
<div class="mt-4">
|
||||||
<app-supplier-table #supplierTable></app-supplier-table>
|
<app-supplier-table #supplierTable></app-supplier-table>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import {Component, inject, viewChild} 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 {ModalButton} from "../../components/modal-button/modal-button";
|
||||||
import {SupplierTable} from "../../components/supplier-table/supplier-table";
|
import {SupplierTable} from "../../components/supplier-table/supplier-table";
|
||||||
import {SupplierForm} from "../../components/supplier-form/supplier-form";
|
import {SupplierForm} from "../../components/supplier-form/supplier-form";
|
||||||
@@ -8,15 +7,14 @@ import {NzNotificationService} from "ng-zorro-antd/notification";
|
|||||||
import {firstValueFrom} from "rxjs";
|
import {firstValueFrom} from "rxjs";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-supplier',
|
selector: 'app-supplier',
|
||||||
imports: [
|
imports: [
|
||||||
Search,
|
|
||||||
SupplierForm,
|
SupplierForm,
|
||||||
SupplierTable,
|
SupplierTable,
|
||||||
ModalButton
|
ModalButton
|
||||||
],
|
],
|
||||||
templateUrl: './supplier.html',
|
templateUrl: './supplier.html',
|
||||||
styleUrl: './supplier.css',
|
styleUrl: './supplier.css',
|
||||||
})
|
})
|
||||||
export class Supplier {
|
export class Supplier {
|
||||||
modal = viewChild.required<ModalButton>('modalButton');
|
modal = viewChild.required<ModalButton>('modalButton');
|
||||||
@@ -28,7 +26,7 @@ export class Supplier {
|
|||||||
async onModalOk() {
|
async onModalOk() {
|
||||||
await this.addSupplier()
|
await this.addSupplier()
|
||||||
this.createSupplier().supplierForm.reset();
|
this.createSupplier().supplierForm.reset();
|
||||||
this.modal().isVisible = false;
|
this.onModalCancel();
|
||||||
await this.supplierTable().fetchSuppliers()
|
await this.supplierTable().fetchSuppliers()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,31 +34,17 @@ export class Supplier {
|
|||||||
this.modal().isVisible = false;
|
this.modal().isVisible = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
onSupplierSearch(query: string) {
|
|
||||||
this.supplierTable().applySearch(query);
|
|
||||||
}
|
|
||||||
|
|
||||||
async addSupplier() {
|
async addSupplier() {
|
||||||
if (this.createSupplier().supplierForm.invalid)
|
if (this.createSupplier().supplierForm.invalid) {
|
||||||
{
|
this.notificationService.error('Erreur', 'Formulaire invalide')
|
||||||
this.notificationService.error(
|
|
||||||
'Erreur',
|
|
||||||
'Erreur d\'écriture dans le formulaire'
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const suppliers = this.createSupplier().supplierForm.getRawValue();
|
const suppliers = this.createSupplier().supplierForm.getRawValue();
|
||||||
await firstValueFrom(this.suppliersService.createSupplierEndpoint(suppliers))
|
await firstValueFrom(this.suppliersService.createSupplierEndpoint(suppliers))
|
||||||
|
|
||||||
this.notificationService.success(
|
this.notificationService.success('Success', 'Fournisseur enregistré')
|
||||||
'Success',
|
} catch {
|
||||||
'Fournisseur enregistré'
|
this.notificationService.error('Erreur', 'Erreur d\'enregistrement')
|
||||||
)
|
|
||||||
} catch (e) {
|
|
||||||
this.notificationService.error(
|
|
||||||
'Erreur',
|
|
||||||
'Erreur d\'enregistrement'
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,13 +7,19 @@
|
|||||||
size="35%">
|
size="35%">
|
||||||
|
|
||||||
<app-profil-form #profilForm></app-profil-form>
|
<app-profil-form #profilForm></app-profil-form>
|
||||||
|
<div class="text-[12px] text-gray-400 flex justify-center items-center flex-col">
|
||||||
|
<p>Consignes du mot de passe :</p>
|
||||||
|
<ul class="ml-10">
|
||||||
|
<li>12 caractères</li>
|
||||||
|
<li>Au moins une majuscule</li>
|
||||||
|
<li>Au moins une minuscule</li>
|
||||||
|
<li>Au moins un chiffre</li>
|
||||||
|
<li>Au moins un caractère spécial</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
</app-modal-button>
|
</app-modal-button>
|
||||||
|
|
||||||
<div class="ml-95 w-150">
|
|
||||||
<app-search></app-search>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mt-1">
|
<div class="mt-4">
|
||||||
<app-user-table #userTable></app-user-table>
|
<app-user-table #userTable></app-user-table>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user