Compare commits
245 Commits
Kartik_Tas
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 5b3f002772 | |||
| 0d9037dbdc | |||
| 55d455bb10 | |||
| 767e218987 | |||
| e0eec8ff69 | |||
| c38efe9934 | |||
| 9e5555ff9d | |||
| 8a18c0860e | |||
| e5b01e9e0f | |||
| b7268f9294 | |||
| 43ecdadfa9 | |||
| 005261abab | |||
| 9527427f47 | |||
| 10fc88c022 | |||
| 3b0097f46b | |||
| ecd726bbb1 | |||
| d14fb130c6 | |||
| b6ef3e0d22 | |||
| b3f489fe9f | |||
| edae70f8af | |||
| 4563e328a5 | |||
| 8f0ca4a9ca | |||
| dec959c495 | |||
| cb7e044b27 | |||
| 4c059afb72 | |||
| 6e89fbd680 | |||
| 9648d1a98b | |||
| aa947b791b | |||
| 51cca64dd5 | |||
| ca88928850 | |||
| 962286a4da | |||
| 76df08e921 | |||
| 0052fed1e6 | |||
| e2035e1fd8 | |||
| 7176a86913 | |||
| a26e4d1dc2 | |||
| f91c7d6da1 | |||
| 272645f0b4 | |||
| 301684a12b | |||
| 9288ac1fbc | |||
| 376a2a397f | |||
| 58c2fbdf1b | |||
| 12b632f087 | |||
| 6ee4fb6d04 | |||
| 67bb685d4b | |||
| 8fd4e7f3f1 | |||
| aca2decb00 | |||
| f7f4b68997 | |||
| f839613066 | |||
| b58bd33774 | |||
| 136bc94c5b | |||
| 281a956ac8 | |||
| 31882c3d12 | |||
| a64635cd37 | |||
| 9b8c8c34ab | |||
| 704ba79289 | |||
| 3440467107 | |||
| f4edcfd2f3 | |||
| 62e5c6899a | |||
| 00a23b3de9 | |||
| 79161a8ede | |||
| 860779d096 | |||
| a2067e150d | |||
| edce5ef614 | |||
| dd944b3414 | |||
| 13d3572cf6 | |||
| 0dd7c19457 | |||
| 3cc4f0b416 | |||
| f8095ac9bf | |||
| 6280abf95e | |||
| 1200937097 | |||
| 5d1ccb9572 | |||
| 91ffc5a0e0 | |||
| 1c4804fed2 | |||
| 0e5e716df2 | |||
| aecaee7116 | |||
| 97dca1a10b | |||
| c35eacca5a | |||
| 5e27ed36fa | |||
| 8bcfcc5718 | |||
| ad1bef4f7b | |||
| 9886fac03e | |||
| a28a7fb444 | |||
| 470421b730 | |||
| 7505b790a7 | |||
| 8fd13247c7 | |||
| 0fec257354 | |||
| 638c033705 | |||
| 7872e21477 | |||
| 6928bbd309 | |||
| 3693af3d00 | |||
| d5df200ede | |||
| 9c6450496e | |||
| cfd3986479 | |||
| 764b145ad9 | |||
| 20c7cf7f37 | |||
| 6d74940c0c | |||
| 02dcd8611f | |||
| 02600308e8 | |||
| d1c72291a3 | |||
| fdbd81c5e7 | |||
| 28d5ef653d | |||
| 550b142d74 | |||
| 68335f0695 | |||
| 4ea20981fc | |||
| 965e1e4808 | |||
| 1c376fe91f | |||
| 61835cb189 | |||
| 375c482b61 | |||
| 72424eee53 | |||
| 22514b1fa0 | |||
| 61b209a082 | |||
| 198e31290c | |||
| 482f8a9bcb | |||
| 2489095b0b | |||
| eb8d269662 | |||
| bbd8ed12f6 | |||
| 1e7b4ba21e | |||
| 4de3987a37 | |||
| 7455d8a221 | |||
| 3f4b7d08d4 | |||
| 7ac3268514 | |||
| f8740472de | |||
| be72ca9a58 | |||
| c71c00c0f7 | |||
| 112e0ff798 | |||
| 96eb030457 | |||
| a873ace109 | |||
| fb164bd2f2 | |||
| 0d6708619f | |||
| edba191a2e | |||
| ddfe09b570 | |||
| acb899dd2e | |||
| ae66cb3705 | |||
| d52fa00de0 | |||
| ca8a41bb63 | |||
| 265c74f079 | |||
| 2ef1fcfd1d | |||
| 3233043cf2 | |||
| 3fddb686d3 | |||
| 4fd6e5cc1a | |||
| 1fb8eb9ef1 | |||
| 1a3890e837 | |||
| 2dbf08e330 | |||
| b044b88c49 | |||
| db815ba038 | |||
| 53fa013c39 | |||
| 22a1ad45e7 | |||
| 91dcd7c132 | |||
| 7d18edfa9b | |||
| fb08e48edd | |||
| 69c225ac72 | |||
| 182280e91d | |||
| 38bd8d36c0 | |||
| a4bccc9bf6 | |||
| 0e6dd93260 | |||
| 245219ad71 | |||
| 978a497f28 | |||
| 451d0a785f | |||
| 84f9cb2e29 | |||
| 9d9ca28bad | |||
| 1d218056ac | |||
| 58837cef0c | |||
| 1cd3bf6c7f | |||
| d2b10495bd | |||
| ae9c4833b3 | |||
| e69efe61cb | |||
| 92b1531b75 | |||
| 57edd92dce | |||
| 49eaf857ad | |||
| ccdfc193c6 | |||
| 817b31379e | |||
| b36120f73d | |||
| e2ae2e5fbd | |||
| 521e6690cb | |||
| 1f4a7e5e9c | |||
| 1d3fcff859 | |||
| 1286184e1f | |||
| 4e315aafcf | |||
| 52e12426af | |||
| d975664023 | |||
| d87dae4799 | |||
| 4683eff749 | |||
| 772a3e2829 | |||
| ca7b0cda13 | |||
| a380a7ab29 | |||
| c609387924 | |||
| 69cc3b9383 | |||
| 6ebbc853bc | |||
| 71dd35adc2 | |||
| 533b40d1bf | |||
| 42a80bbd68 | |||
| 397020ccb4 | |||
| 71932ea6dc | |||
| 693cabf63d | |||
| 4afe43d116 | |||
| b9b3788dda | |||
| 5e1ccc9b05 | |||
| aee510f527 | |||
| 7e6020e3db | |||
| cf78d17cf5 | |||
| 72dbdb0fe0 | |||
| afcd1934f9 | |||
|
|
3e5afe0bc6 | ||
|
|
070fa93fca | ||
| 53a9cbc30b | |||
| 70acf57266 | |||
| b2d7349fc9 | |||
| a0f7e5c57b | |||
| fa7dc2860c | |||
| a1a935b0d5 | |||
|
|
e610cc08c1 | ||
| 9711144236 | |||
| 1a88f5fec5 | |||
| ce73cfad21 | |||
| 7dafd4a45f | |||
| 2e3e3aa6ca | |||
| 158c934a9f | |||
| f6d864d42e | |||
| 90b96864be | |||
| 5a048f7066 | |||
| 731d2dbed7 | |||
| 25de45b31b | |||
| 58b5da1793 | |||
| 0746e5c349 | |||
| 83143dff0a | |||
| 994f22e8c0 | |||
| 84a5be52f8 | |||
| b39df5f665 | |||
| 9bdcc74486 | |||
| 005fdb3490 | |||
| 9223f7a176 | |||
| 27b62c858d | |||
| 1ef82ad0b2 | |||
| 1da587d010 | |||
| 164b82e1c7 | |||
| e9d8b6daea | |||
| 9b37288901 | |||
| 7d17422681 | |||
| d67121c150 | |||
| e154bac64a | |||
| ea350db98b | |||
| ea219b7176 | |||
| af5519fd60 | |||
| 08194dd8ef |
119
package-lock.json
generated
119
package-lock.json
generated
@ -809,9 +809,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@jridgewell/source-map": {
|
"node_modules/@jridgewell/source-map": {
|
||||||
"version": "0.3.6",
|
"version": "0.3.11",
|
||||||
"resolved": "https://registry.npmjs.org/@jridgewell/source-map/-/source-map-0.3.6.tgz",
|
"resolved": "https://registry.npmjs.org/@jridgewell/source-map/-/source-map-0.3.11.tgz",
|
||||||
"integrity": "sha512-1ZJTZebgqllO79ue2bm3rIGud/bOe0pP5BjSRCRxxYkEZS8STV7zN84UBbiYu7jy+eCKSnVIUgoWWE/tt+shMQ==",
|
"integrity": "sha512-ZMp1V8ZFcPG5dIWnQLr3NSI1MiCU7UETdS/A0G8V/XWHvJv3ZsFqutJn1Y5RPmAPX6F3BiE397OqveU/9NCuIA==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"peer": true,
|
"peer": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@ -1552,13 +1552,13 @@
|
|||||||
"peer": true
|
"peer": true
|
||||||
},
|
},
|
||||||
"node_modules/@types/node": {
|
"node_modules/@types/node": {
|
||||||
"version": "22.13.13",
|
"version": "24.5.2",
|
||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.13.13.tgz",
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-24.5.2.tgz",
|
||||||
"integrity": "sha512-ClsL5nMwKaBRwPcCvH8E7+nU4GxHVx1axNvMZTFHMEfNI7oahimt26P5zjVCRrjiIWj6YFXfE1v3dEp94wLcGQ==",
|
"integrity": "sha512-FYxk1I7wPv3K2XBaoyH2cTnocQEu8AOZ60hPbsyukMPLv5/5qr7V1i8PLHdl6Zf87I+xZXFvPCXYjiTFq+YSDQ==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"peer": true,
|
"peer": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"undici-types": "~6.20.0"
|
"undici-types": "~7.12.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@types/prop-types": {
|
"node_modules/@types/prop-types": {
|
||||||
@ -1835,9 +1835,10 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/acorn": {
|
"node_modules/acorn": {
|
||||||
"version": "8.14.0",
|
"version": "8.15.0",
|
||||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.14.0.tgz",
|
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.15.0.tgz",
|
||||||
"integrity": "sha512-cl669nCJTZBsL97OF4kUQm5g5hC2uihk0NxY3WENAC0TYdILVkAyHymAntgxGkl7K+t0cXIrH5siy5S4XkFycA==",
|
"integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==",
|
||||||
|
"license": "MIT",
|
||||||
"bin": {
|
"bin": {
|
||||||
"acorn": "bin/acorn"
|
"acorn": "bin/acorn"
|
||||||
},
|
},
|
||||||
@ -1845,6 +1846,19 @@
|
|||||||
"node": ">=0.4.0"
|
"node": ">=0.4.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/acorn-import-phases": {
|
||||||
|
"version": "1.0.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/acorn-import-phases/-/acorn-import-phases-1.0.4.tgz",
|
||||||
|
"integrity": "sha512-wKmbr/DDiIXzEOiWrTTUcDm24kQ2vGfZQvM2fwg2vXqR5uW6aapr7ObPtj1th32b9u90/Pf4AItvdTh42fBmVQ==",
|
||||||
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
|
"engines": {
|
||||||
|
"node": ">=10.13.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"acorn": "^8.14.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/acorn-jsx": {
|
"node_modules/acorn-jsx": {
|
||||||
"version": "5.3.2",
|
"version": "5.3.2",
|
||||||
"resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz",
|
"resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz",
|
||||||
@ -2625,9 +2639,9 @@
|
|||||||
"integrity": "sha512-ZpSAUOZ2Izby7qnZluSrAlGgGQzucmFbN0n64dYzocYxnxV5ufurpj3VgEe4cUp7ir9LmeLxNYo8bVnlM8bQHw=="
|
"integrity": "sha512-ZpSAUOZ2Izby7qnZluSrAlGgGQzucmFbN0n64dYzocYxnxV5ufurpj3VgEe4cUp7ir9LmeLxNYo8bVnlM8bQHw=="
|
||||||
},
|
},
|
||||||
"node_modules/enhanced-resolve": {
|
"node_modules/enhanced-resolve": {
|
||||||
"version": "5.18.1",
|
"version": "5.18.3",
|
||||||
"resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.18.1.tgz",
|
"resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.18.3.tgz",
|
||||||
"integrity": "sha512-ZSW3ma5GkcQBIpwZTSRAI8N71Uuwgs93IezB7mf7R60tC8ZbJideoDNKjHn2O9KIlx6rkGTTEk1xUCK2E1Y2Yg==",
|
"integrity": "sha512-d4lC8xfavMeBjzGr2vECC3fsGXziXZQyJxD868h2M/mBI3PwAuODxAkLkq5HYuvrPYcUtiLzsTo8U3PgX3Ocww==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"peer": true,
|
"peer": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@ -2741,9 +2755,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/es-module-lexer": {
|
"node_modules/es-module-lexer": {
|
||||||
"version": "1.6.0",
|
"version": "1.7.0",
|
||||||
"resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.6.0.tgz",
|
"resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.7.0.tgz",
|
||||||
"integrity": "sha512-qqnD1yMU6tk/jnaMosogGySTZP8YtUgAffA9nMN+E/rjxcfRQ6IEk7IiozUjgxKoFHBGjTLnrHB/YC45r/59EQ==",
|
"integrity": "sha512-jEQoCwk8hyb2AZziIOLhDqpm5+2ww5uIE6lkO/6jcOCusfk6LhMHpXXfBLXTZ7Ydyt0j4VoUQv6uGNYbdW+kBA==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"peer": true
|
"peer": true
|
||||||
},
|
},
|
||||||
@ -3138,9 +3152,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/fast-uri": {
|
"node_modules/fast-uri": {
|
||||||
"version": "3.0.6",
|
"version": "3.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.0.6.tgz",
|
"resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.0.tgz",
|
||||||
"integrity": "sha512-Atfo14OibSv5wAp4VWNsFYE1AchQRTv9cBGWET4pZWHzYshFSS9NQI6I57rdKn9croWVMbYFbLhJ+yJvmZIIHw==",
|
"integrity": "sha512-iPeeDKJSWf4IEOasVVrknXpaBV0IApz/gp7S2bb7Z4Lljbl2MGJRqInZiUrQwV16cpzw/D3S5j5Julj/gT52AA==",
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"type": "github",
|
"type": "github",
|
||||||
@ -5163,9 +5177,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/schema-utils": {
|
"node_modules/schema-utils": {
|
||||||
"version": "4.3.0",
|
"version": "4.3.2",
|
||||||
"resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-4.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-4.3.2.tgz",
|
||||||
"integrity": "sha512-Gf9qqc58SpCA/xdziiHz35F4GNIWYWZrEshUc/G/r5BnLph6xpKuLeoJoQuj5WfBIx/eQLf+hmVPYHaxJu7V2g==",
|
"integrity": "sha512-Gn/JaSk/Mt9gYubxTtSn/QCV4em9mpAPiR1rqy/Ocu19u/G9J5WWdNoUT4SiV6mFC3y6cxyFcFwdzPM3FgxGAQ==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"peer": true,
|
"peer": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@ -5567,24 +5581,28 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/tapable": {
|
"node_modules/tapable": {
|
||||||
"version": "2.2.1",
|
"version": "2.2.3",
|
||||||
"resolved": "https://registry.npmjs.org/tapable/-/tapable-2.2.1.tgz",
|
"resolved": "https://registry.npmjs.org/tapable/-/tapable-2.2.3.tgz",
|
||||||
"integrity": "sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ==",
|
"integrity": "sha512-ZL6DDuAlRlLGghwcfmSn9sK3Hr6ArtyudlSAiCqQ6IfE+b+HHbydbYDIG15IfS5do+7XQQBdBiubF/cV2dnDzg==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"peer": true,
|
"peer": true,
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=6"
|
"node": ">=6"
|
||||||
|
},
|
||||||
|
"funding": {
|
||||||
|
"type": "opencollective",
|
||||||
|
"url": "https://opencollective.com/webpack"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/terser": {
|
"node_modules/terser": {
|
||||||
"version": "5.39.0",
|
"version": "5.44.0",
|
||||||
"resolved": "https://registry.npmjs.org/terser/-/terser-5.39.0.tgz",
|
"resolved": "https://registry.npmjs.org/terser/-/terser-5.44.0.tgz",
|
||||||
"integrity": "sha512-LBAhFyLho16harJoWMg/nZsQYgTrg5jXOn2nCYjRUcZZEdE3qa2zb8QEDRUGVZBW4rlazf2fxkg8tztybTaqWw==",
|
"integrity": "sha512-nIVck8DK+GM/0Frwd+nIhZ84pR/BX7rmXMfYwyg+Sri5oGVE99/E3KvXqpC2xHFxyqXyGHTKBSioxxplrO4I4w==",
|
||||||
"license": "BSD-2-Clause",
|
"license": "BSD-2-Clause",
|
||||||
"peer": true,
|
"peer": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@jridgewell/source-map": "^0.3.3",
|
"@jridgewell/source-map": "^0.3.3",
|
||||||
"acorn": "^8.8.2",
|
"acorn": "^8.15.0",
|
||||||
"commander": "^2.20.0",
|
"commander": "^2.20.0",
|
||||||
"source-map-support": "~0.5.20"
|
"source-map-support": "~0.5.20"
|
||||||
},
|
},
|
||||||
@ -5777,9 +5795,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/undici-types": {
|
"node_modules/undici-types": {
|
||||||
"version": "6.20.0",
|
"version": "7.12.0",
|
||||||
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.20.0.tgz",
|
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.12.0.tgz",
|
||||||
"integrity": "sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg==",
|
"integrity": "sha512-goOacqME2GYyOZZfb5Lgtu+1IDmAlAEu5xnD3+xTzS10hT0vzpf0SPjkXwAw9Jm+4n/mQGDP3LO8CPbYROeBfQ==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"peer": true
|
"peer": true
|
||||||
},
|
},
|
||||||
@ -5907,9 +5925,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/watchpack": {
|
"node_modules/watchpack": {
|
||||||
"version": "2.4.2",
|
"version": "2.4.4",
|
||||||
"resolved": "https://registry.npmjs.org/watchpack/-/watchpack-2.4.2.tgz",
|
"resolved": "https://registry.npmjs.org/watchpack/-/watchpack-2.4.4.tgz",
|
||||||
"integrity": "sha512-TnbFSbcOCcDgjZ4piURLCbJ3nJhznVh9kw6F6iokjiFPl8ONxe9A6nMDVXDiNbrSfLILs6vB07F7wLBrwPYzJw==",
|
"integrity": "sha512-c5EGNOiyxxV5qmTtAB7rbiXxi1ooX1pQKMLX/MIabJjRA0SJBQOjKF+KSVfHkr9U1cADPon0mRiVe/riyaiDUA==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"peer": true,
|
"peer": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@ -5927,21 +5945,23 @@
|
|||||||
"license": "BSD-2-Clause"
|
"license": "BSD-2-Clause"
|
||||||
},
|
},
|
||||||
"node_modules/webpack": {
|
"node_modules/webpack": {
|
||||||
"version": "5.98.0",
|
"version": "5.101.3",
|
||||||
"resolved": "https://registry.npmjs.org/webpack/-/webpack-5.98.0.tgz",
|
"resolved": "https://registry.npmjs.org/webpack/-/webpack-5.101.3.tgz",
|
||||||
"integrity": "sha512-UFynvx+gM44Gv9qFgj0acCQK2VE1CtdfwFdimkapco3hlPCJ/zeq73n2yVKimVbtm+TnApIugGhLJnkU6gjYXA==",
|
"integrity": "sha512-7b0dTKR3Ed//AD/6kkx/o7duS8H3f1a4w3BYpIriX4BzIhjkn4teo05cptsxvLesHFKK5KObnadmCHBwGc+51A==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"peer": true,
|
"peer": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/eslint-scope": "^3.7.7",
|
"@types/eslint-scope": "^3.7.7",
|
||||||
"@types/estree": "^1.0.6",
|
"@types/estree": "^1.0.8",
|
||||||
|
"@types/json-schema": "^7.0.15",
|
||||||
"@webassemblyjs/ast": "^1.14.1",
|
"@webassemblyjs/ast": "^1.14.1",
|
||||||
"@webassemblyjs/wasm-edit": "^1.14.1",
|
"@webassemblyjs/wasm-edit": "^1.14.1",
|
||||||
"@webassemblyjs/wasm-parser": "^1.14.1",
|
"@webassemblyjs/wasm-parser": "^1.14.1",
|
||||||
"acorn": "^8.14.0",
|
"acorn": "^8.15.0",
|
||||||
|
"acorn-import-phases": "^1.0.3",
|
||||||
"browserslist": "^4.24.0",
|
"browserslist": "^4.24.0",
|
||||||
"chrome-trace-event": "^1.0.2",
|
"chrome-trace-event": "^1.0.2",
|
||||||
"enhanced-resolve": "^5.17.1",
|
"enhanced-resolve": "^5.17.3",
|
||||||
"es-module-lexer": "^1.2.1",
|
"es-module-lexer": "^1.2.1",
|
||||||
"eslint-scope": "5.1.1",
|
"eslint-scope": "5.1.1",
|
||||||
"events": "^3.2.0",
|
"events": "^3.2.0",
|
||||||
@ -5951,11 +5971,11 @@
|
|||||||
"loader-runner": "^4.2.0",
|
"loader-runner": "^4.2.0",
|
||||||
"mime-types": "^2.1.27",
|
"mime-types": "^2.1.27",
|
||||||
"neo-async": "^2.6.2",
|
"neo-async": "^2.6.2",
|
||||||
"schema-utils": "^4.3.0",
|
"schema-utils": "^4.3.2",
|
||||||
"tapable": "^2.1.1",
|
"tapable": "^2.1.1",
|
||||||
"terser-webpack-plugin": "^5.3.11",
|
"terser-webpack-plugin": "^5.3.11",
|
||||||
"watchpack": "^2.4.1",
|
"watchpack": "^2.4.1",
|
||||||
"webpack-sources": "^3.2.3"
|
"webpack-sources": "^3.3.3"
|
||||||
},
|
},
|
||||||
"bin": {
|
"bin": {
|
||||||
"webpack": "bin/webpack.js"
|
"webpack": "bin/webpack.js"
|
||||||
@ -5974,15 +5994,22 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/webpack-sources": {
|
"node_modules/webpack-sources": {
|
||||||
"version": "3.2.3",
|
"version": "3.3.3",
|
||||||
"resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-3.2.3.tgz",
|
"resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-3.3.3.tgz",
|
||||||
"integrity": "sha512-/DyMEOrDgLKKIG0fmvtz+4dUX/3Ghozwgm6iPp8KRhvn+eQf9+Q7GWxVNMk3+uCPWfdXYC4ExGBckIXdFEfH1w==",
|
"integrity": "sha512-yd1RBzSGanHkitROoPFd6qsrxt+oFhg/129YzheDGqeustzX0vTZJZsSsQjVQC4yzBQ56K55XU8gaNCtIzOnTg==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"peer": true,
|
"peer": true,
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=10.13.0"
|
"node": ">=10.13.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/webpack/node_modules/@types/estree": {
|
||||||
|
"version": "1.0.8",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.8.tgz",
|
||||||
|
"integrity": "sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==",
|
||||||
|
"license": "MIT",
|
||||||
|
"peer": true
|
||||||
|
},
|
||||||
"node_modules/webpack/node_modules/eslint-scope": {
|
"node_modules/webpack/node_modules/eslint-scope": {
|
||||||
"version": "5.1.1",
|
"version": "5.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz",
|
||||||
|
|||||||
@ -10,3 +10,287 @@
|
|||||||
.table_header_border {
|
.table_header_border {
|
||||||
border-bottom:2px solid var(--bs-table-border-color) ;
|
border-bottom:2px solid var(--bs-table-border-color) ;
|
||||||
}
|
}
|
||||||
|
.text-gary-80 {
|
||||||
|
color:var(--bs-gray-500)
|
||||||
|
}
|
||||||
|
|
||||||
|
.text-royalblue{
|
||||||
|
color: #1796e3;
|
||||||
|
}
|
||||||
|
|
||||||
|
.text-md {
|
||||||
|
font-size: 2rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.text-md-b {
|
||||||
|
font-weight: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
.text-xxs { font-size: 0.55rem; } /* 8px */
|
||||||
|
.text-xs { font-size: 0.75rem; } /* 12px */
|
||||||
|
.text-sm { font-size: 0.875rem; } /* 14px */
|
||||||
|
.text-base { font-size: 1rem; } /* 16px */
|
||||||
|
.text-lg { font-size: 1.125rem; } /* 18px */
|
||||||
|
.text-xl { font-size: 1.25rem; } /* 20px */
|
||||||
|
.text-2xl { font-size: 1.5rem; } /* 24px */
|
||||||
|
.text-3xl { font-size: 1.875rem; } /* 30px */
|
||||||
|
.text-4xl { font-size: 2.25rem; } /* 36px */
|
||||||
|
.text-5xl { font-size: 3rem; } /* 48px */
|
||||||
|
.text-6xl { font-size: 3.75rem; } /* 60px */
|
||||||
|
.text-7xl { font-size: 4.5rem; } /* 72px */
|
||||||
|
.text-8xl { font-size: 6rem; } /* 96px */
|
||||||
|
.text-9xl { font-size: 8rem; } /* 128px */
|
||||||
|
|
||||||
|
|
||||||
|
/* */
|
||||||
|
|
||||||
|
.w-0 { width: 0px; }
|
||||||
|
.w-px { width: 1px; }
|
||||||
|
.w-1 { width: 0.25rem; } /* 4px */
|
||||||
|
.w-2 { width: 0.5rem; } /* 8px */
|
||||||
|
.w-3 { width: 0.75rem; } /* 12px */
|
||||||
|
.w-4 { width: 1rem; } /* 16px */
|
||||||
|
.w-5 { width: 1.25rem; } /* 20px */
|
||||||
|
.w-6 { width: 1.5rem; } /* 24px */
|
||||||
|
.w-8 { width: 2rem; } /* 32px */
|
||||||
|
.w-10 { width: 2.5rem; } /* 40px */
|
||||||
|
.w-12 { width: 3rem; } /* 48px */
|
||||||
|
.w-16 { width: 4rem; } /* 64px */
|
||||||
|
.w-20 { width: 5rem; } /* 80px */
|
||||||
|
.w-24 { width: 6rem; } /* 96px */
|
||||||
|
.w-32 { width: 8rem; } /* 128px */
|
||||||
|
.w-40 { width: 10rem; } /* 160px */
|
||||||
|
.w-48 { width: 12rem; } /* 192px */
|
||||||
|
.w-56 { width: 14rem; } /* 224px */
|
||||||
|
.w-64 { width: 16rem; } /* 256px */
|
||||||
|
.w-auto { width: auto; }
|
||||||
|
.w-full { width: 100%; }
|
||||||
|
.w-screen{ width: 100vw; }
|
||||||
|
.w-min { width: min-content; }
|
||||||
|
.w-max { width: max-content; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
.h-0 { height: 0px; }
|
||||||
|
.h-px { height: 1px; }
|
||||||
|
.h-1 { height: 0.25rem; } /* 4px */
|
||||||
|
.h-2 { height: 0.5rem; } /* 8px */
|
||||||
|
.h-3 { height: 0.75rem; } /* 12px */
|
||||||
|
.h-4 { height: 1rem; } /* 16px */
|
||||||
|
.h-5 { height: 1.25rem; } /* 20px */
|
||||||
|
.h-6 { height: 1.5rem; } /* 24px */
|
||||||
|
.h-8 { height: 2rem; } /* 32px */
|
||||||
|
.h-10 { height: 2.5rem; } /* 40px */
|
||||||
|
.h-12 { height: 3rem; } /* 48px */
|
||||||
|
.h-16 { height: 4rem; } /* 64px */
|
||||||
|
.h-20 { height: 5rem; } /* 80px */
|
||||||
|
.h-24 { height: 6rem; } /* 96px */
|
||||||
|
.h-32 { height: 8rem; } /* 128px */
|
||||||
|
.h-40 { height: 10rem; } /* 160px */
|
||||||
|
.h-48 { height: 12rem; } /* 192px */
|
||||||
|
.h-56 { height: 14rem; } /* 224px */
|
||||||
|
.h-64 { height: 16rem; } /* 256px */
|
||||||
|
.h-auto { height: auto; }
|
||||||
|
.h-full { height: 100%; }
|
||||||
|
.h-screen{ height: 100vh; }
|
||||||
|
.h-min { height: min-content; }
|
||||||
|
.h-max { height: max-content; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* ==========================
|
||||||
|
Base Font Sizes (mobile first)
|
||||||
|
========================== */
|
||||||
|
.text-xxs { font-size: 0.55rem; } /* 8px */
|
||||||
|
.text-xs { font-size: 0.75rem; } /* 12px */
|
||||||
|
.text-sm { font-size: 0.875rem; } /* 14px */
|
||||||
|
.text-base{ font-size: 1rem; } /* 16px */
|
||||||
|
.text-lg { font-size: 1.125rem; } /* 18px */
|
||||||
|
.text-xl { font-size: 1.25rem; } /* 20px */
|
||||||
|
.text-2xl { font-size: 1.5rem; } /* 24px */
|
||||||
|
.text-3xl { font-size: 1.875rem; } /* 30px */
|
||||||
|
.text-4xl { font-size: 2.25rem; } /* 36px */
|
||||||
|
.text-5xl { font-size: 3rem; } /* 48px */
|
||||||
|
.text-6xl { font-size: 3.75rem; } /* 60px */
|
||||||
|
.text-7xl { font-size: 4.5rem; } /* 72px */
|
||||||
|
.text-8xl { font-size: 6rem; } /* 96px */
|
||||||
|
.text-9xl { font-size: 8rem; } /* 128px */
|
||||||
|
|
||||||
|
/* ==========================
|
||||||
|
Base Heights
|
||||||
|
========================== */
|
||||||
|
.h-0 { height: 0; }
|
||||||
|
.h-px { height: 1px; }
|
||||||
|
.h-1 { height: 0.25rem; } /* 4px */
|
||||||
|
.h-2 { height: 0.5rem; } /* 8px */
|
||||||
|
.h-3 { height: 0.75rem; } /* 12px */
|
||||||
|
.h-4 { height: 1rem; } /* 16px */
|
||||||
|
.h-5 { height: 1.25rem; } /* 20px */
|
||||||
|
.h-6 { height: 1.5rem; } /* 24px */
|
||||||
|
.h-8 { height: 2rem; } /* 32px */
|
||||||
|
.h-10 { height: 2.5rem; } /* 40px */
|
||||||
|
.h-12 { height: 3rem; } /* 48px */
|
||||||
|
.h-16 { height: 4rem; } /* 64px */
|
||||||
|
.h-20 { height: 5rem; } /* 80px */
|
||||||
|
.h-24 { height: 6rem; } /* 96px */
|
||||||
|
.h-32 { height: 8rem; } /* 128px */
|
||||||
|
.h-40 { height: 10rem; } /* 160px */
|
||||||
|
.h-48 { height: 12rem; } /* 192px */
|
||||||
|
.h-56 { height: 14rem; } /* 224px */
|
||||||
|
.h-64 { height: 16rem; } /* 256px */
|
||||||
|
.h-full { height: 100%; }
|
||||||
|
.h-screen{ height: 100vh; }
|
||||||
|
|
||||||
|
/* ==========================
|
||||||
|
Base Widths
|
||||||
|
========================== */
|
||||||
|
.w-0 { width: 0; }
|
||||||
|
.w-px { width: 1px; }
|
||||||
|
.w-1 { width: 0.25rem; }
|
||||||
|
.w-2 { width: 0.5rem; }
|
||||||
|
.w-3 { width: 0.75rem; }
|
||||||
|
.w-4 { width: 1rem; }
|
||||||
|
.w-5 { width: 1.25rem; }
|
||||||
|
.w-6 { width: 1.5rem; }
|
||||||
|
.w-8 { width: 2rem; }
|
||||||
|
.w-10 { width: 2.5rem; }
|
||||||
|
.w-12 { width: 3rem; }
|
||||||
|
.w-16 { width: 4rem; }
|
||||||
|
.w-20 { width: 5rem; }
|
||||||
|
.w-24 { width: 6rem; }
|
||||||
|
.w-32 { width: 8rem; }
|
||||||
|
.w-40 { width: 10rem; }
|
||||||
|
.w-48 { width: 12rem; }
|
||||||
|
.w-56 { width: 14rem; }
|
||||||
|
.w-64 { width: 16rem; }
|
||||||
|
.w-full { width: 100%; }
|
||||||
|
.w-screen{ width: 100vw; }
|
||||||
|
|
||||||
|
/* ==========================
|
||||||
|
Responsive Variants
|
||||||
|
========================== */
|
||||||
|
@media (min-width: 576px) { /* sm */
|
||||||
|
/* Font */
|
||||||
|
.text-xxs-sm { font-size: 0.55rem; }
|
||||||
|
.text-xs-sm { font-size: 0.75rem; }
|
||||||
|
.text-sm-sm { font-size: 0.875rem; }
|
||||||
|
.text-base-sm{ font-size: 1rem; }
|
||||||
|
.text-lg-sm { font-size: 1.125rem; }
|
||||||
|
.text-xl-sm { font-size: 1.25rem; }
|
||||||
|
.text-2xl-sm{ font-size: 1.5rem; }
|
||||||
|
|
||||||
|
/* Height */
|
||||||
|
.h-1-sm{ height: 0.25rem; }
|
||||||
|
.h-2-sm{ height: 0.5rem; }
|
||||||
|
.h-3-sm{ height: 0.75rem; }
|
||||||
|
.h-4-sm{ height: 1rem; }
|
||||||
|
.h-5-sm{ height: 1.25rem; }
|
||||||
|
.h-6-sm{ height: 1.5rem; }
|
||||||
|
.h-8-sm{ height: 2rem; }
|
||||||
|
.h-10-sm{ height: 2.5rem; }
|
||||||
|
|
||||||
|
/* Width */
|
||||||
|
.w-1-sm{ width: 0.25rem; }
|
||||||
|
.w-2-sm{ width: 0.5rem; }
|
||||||
|
.w-3-sm{ width: 0.75rem; }
|
||||||
|
.w-4-sm{ width: 1rem; }
|
||||||
|
.w-5-sm{ width: 1.25rem; }
|
||||||
|
.w-6-sm{ width: 1.5rem; }
|
||||||
|
.w-8-sm{ width: 2rem; }
|
||||||
|
.w-10-sm{ width: 2.5rem; }
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (min-width: 768px) { /* md */
|
||||||
|
/* Font */
|
||||||
|
.text-xxs-md { font-size: 0.55rem; }
|
||||||
|
.text-xs-md { font-size: 0.75rem; }
|
||||||
|
.text-sm-md { font-size: 0.875rem; }
|
||||||
|
.text-base-md{ font-size: 1rem; }
|
||||||
|
.text-lg-md { font-size: 1.125rem; }
|
||||||
|
.text-xl-md { font-size: 1.25rem; }
|
||||||
|
.text-2xl-md{ font-size: 1.5rem; }
|
||||||
|
|
||||||
|
/* Height */
|
||||||
|
.h-1-md{ height: 0.25rem; }
|
||||||
|
.h-2-md{ height: 0.5rem; }
|
||||||
|
.h-3-md{ height: 0.75rem; }
|
||||||
|
.h-4-md{ height: 1rem; }
|
||||||
|
.h-5-md{ height: 1.25rem; }
|
||||||
|
.h-6-md{ height: 1.5rem; }
|
||||||
|
.h-8-md{ height: 2rem; }
|
||||||
|
.h-10-md{ height: 2.5rem; }
|
||||||
|
|
||||||
|
/* Width */
|
||||||
|
.w-1-md{ width: 0.25rem; }
|
||||||
|
.w-2-md{ width: 0.5rem; }
|
||||||
|
.w-3-md{ width: 0.75rem; }
|
||||||
|
.w-4-md{ width: 1rem; }
|
||||||
|
.w-5-md{ width: 1.25rem; }
|
||||||
|
.w-6-md{ width: 1.5rem; }
|
||||||
|
.w-8-md{ width: 2rem; }
|
||||||
|
.w-10-md{ width: 2.5rem; }
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (min-width: 992px) { /* lg */
|
||||||
|
/* Font */
|
||||||
|
.text-xxs-lg { font-size: 0.55rem; }
|
||||||
|
.text-xs-lg { font-size: 0.75rem; }
|
||||||
|
.text-sm-lg { font-size: 0.875rem; }
|
||||||
|
.text-base-lg{ font-size: 1rem; }
|
||||||
|
.text-lg-lg { font-size: 1.125rem; }
|
||||||
|
.text-xl-lg { font-size: 1.25rem; }
|
||||||
|
.text-2xl-lg{ font-size: 1.5rem; }
|
||||||
|
|
||||||
|
/* Height */
|
||||||
|
.h-1-lg{ height: 0.25rem; }
|
||||||
|
.h-2-lg{ height: 0.5rem; }
|
||||||
|
.h-3-lg{ height: 0.75rem; }
|
||||||
|
.h-4-lg{ height: 1rem; }
|
||||||
|
.h-5-lg{ height: 1.25rem; }
|
||||||
|
.h-6-lg{ height: 1.5rem; }
|
||||||
|
.h-8-lg{ height: 2rem; }
|
||||||
|
.h-10-lg{ height: 2.5rem; }
|
||||||
|
|
||||||
|
/* Width */
|
||||||
|
.w-1-lg{ width: 0.25rem; }
|
||||||
|
.w-2-lg{ width: 0.5rem; }
|
||||||
|
.w-3-lg{ width: 0.75rem; }
|
||||||
|
.w-4-lg{ width: 1rem; }
|
||||||
|
.w-5-lg{ width: 1.25rem; }
|
||||||
|
.w-6-lg{ width: 1.5rem; }
|
||||||
|
.w-8-lg{ width: 2rem; }
|
||||||
|
.w-10-lg{ width: 2.5rem; }
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (min-width: 1200px) { /* xl */
|
||||||
|
/* Font */
|
||||||
|
.text-xxs-xl { font-size: 0.55rem; }
|
||||||
|
.text-xs-xl { font-size: 0.75rem; }
|
||||||
|
.text-sm-xl { font-size: 0.875rem; }
|
||||||
|
.text-base-xl{ font-size: 1rem; }
|
||||||
|
.text-lg-xl { font-size: 1.125rem; }
|
||||||
|
.text-xl-xl { font-size: 1.25rem; }
|
||||||
|
.text-2xl-xl{ font-size: 1.5rem; }
|
||||||
|
|
||||||
|
/* Height */
|
||||||
|
.h-1-xl{ height: 0.25rem; }
|
||||||
|
.h-2-xl{ height: 0.5rem; }
|
||||||
|
.h-3-xl{ height: 0.75rem; }
|
||||||
|
.h-4-xl{ height: 1rem; }
|
||||||
|
.h-5-xl{ height: 1.25rem; }
|
||||||
|
.h-6-xl{ height: 1.5rem; }
|
||||||
|
.h-8-xl{ height: 2rem; }
|
||||||
|
.h-10-xl{ height: 2.5rem; }
|
||||||
|
|
||||||
|
/* Width */
|
||||||
|
.w-1-xl{ width: 0.25rem; }
|
||||||
|
.w-2-xl{ width: 0.5rem; }
|
||||||
|
.w-3-xl{ width: 0.75rem; }
|
||||||
|
.w-4-xl{ width: 1rem; }
|
||||||
|
.w-5-xl{ width: 1.25rem; }
|
||||||
|
.w-6-xl{ width: 1.5rem; }
|
||||||
|
.w-8-xl{ width: 2rem; }
|
||||||
|
.w-10-xl{ width: 2.5rem; }
|
||||||
|
}
|
||||||
|
|||||||
5
public/assets/img/SP-Placeholdeer.svg
Normal file
5
public/assets/img/SP-Placeholdeer.svg
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
|
||||||
|
<svg width="800px" height="800px" viewBox="0 0 120 120" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<rect width="120" height="120" fill="#EFF1F3"/>
|
||||||
|
<path fill-rule="evenodd" clip-rule="evenodd" d="M33.2503 38.4816C33.2603 37.0472 34.4199 35.8864 35.8543 35.875H83.1463C84.5848 35.875 85.7503 37.0431 85.7503 38.4816V80.5184C85.7403 81.9528 84.5807 83.1136 83.1463 83.125H35.8543C34.4158 83.1236 33.2503 81.957 33.2503 80.5184V38.4816ZM80.5006 41.1251H38.5006V77.8751L62.8921 53.4783C63.9172 52.4536 65.5788 52.4536 66.6039 53.4783L80.5006 67.4013V41.1251ZM43.75 51.6249C43.75 54.5244 46.1005 56.8749 49 56.8749C51.8995 56.8749 54.25 54.5244 54.25 51.6249C54.25 48.7254 51.8995 46.3749 49 46.3749C46.1005 46.3749 43.75 48.7254 43.75 51.6249Z" fill="#687787"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 888 B |
BIN
public/assets/img/orglogo.png
Normal file
BIN
public/assets/img/orglogo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7.2 KiB |
4
public/assets/vendor/css/core.css
vendored
4
public/assets/vendor/css/core.css
vendored
@ -18613,6 +18613,10 @@ li:not(:first-child) .dropdown-item,
|
|||||||
min-height: 70vh !important;
|
min-height: 70vh !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.modal-min-h{
|
||||||
|
min-height: 60vh !important;
|
||||||
|
}
|
||||||
|
|
||||||
.flex-fill {
|
.flex-fill {
|
||||||
flex: 1 1 auto !important;
|
flex: 1 1 auto !important;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,12 +1,25 @@
|
|||||||
import React from 'react'
|
import React, { useEffect } from "react";
|
||||||
import ManageOrganization from './components/Organization/ManageOrganization'
|
import { useOrganizationModal } from "./hooks/useOrganization";
|
||||||
import { useOrganizationModal } from './hooks/useOrganization';
|
import OrganizationModal from "./components/Organization/OrganizationModal";
|
||||||
|
import { useAuthModal, useModal } from "./hooks/useAuth";
|
||||||
|
import SwitchTenant from "./pages/authentication/SwitchTenant";
|
||||||
|
import ChangePasswordPage from "./pages/authentication/ChangePassword";
|
||||||
|
import NewCollection from "./components/collections/ManageCollection";
|
||||||
|
|
||||||
const ModalProvider = () => {
|
const ModalProvider = () => {
|
||||||
const { isOpen } = useOrganizationModal();
|
const { isOpen, onClose } = useOrganizationModal();
|
||||||
|
const { isOpen: isAuthOpen } = useAuthModal();
|
||||||
|
const {isOpen:isChangePass} = useModal("ChangePassword")
|
||||||
|
const {isOpen:isCollectionNew} = useModal("newCollection");
|
||||||
|
|
||||||
return <>{isOpen && <ManageOrganization />}</>;
|
return (
|
||||||
|
<>
|
||||||
|
{isOpen && <OrganizationModal />}
|
||||||
|
{isAuthOpen && <SwitchTenant />}
|
||||||
|
{isChangePass && <ChangePasswordPage /> }
|
||||||
|
{isCollectionNew && <NewCollection/>}
|
||||||
|
</>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export default ModalProvider;
|
||||||
export default ModalProvider
|
|
||||||
@ -12,22 +12,19 @@ import { useQueryClient } from "@tanstack/react-query";
|
|||||||
import eventBus from "../../services/eventBus";
|
import eventBus from "../../services/eventBus";
|
||||||
import { useSelectedProject } from "../../slices/apiDataManager";
|
import { useSelectedProject } from "../../slices/apiDataManager";
|
||||||
|
|
||||||
const Attendance = ({ getRole, handleModalData, searchTerm }) => {
|
const Attendance = ({ getRole, handleModalData, searchTerm, projectId, organizationId, }) => {
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const [todayDate, setTodayDate] = useState(new Date());
|
const [todayDate, setTodayDate] = useState(new Date());
|
||||||
const [ShowPending, setShowPending] = useState(false);
|
const [ShowPending, setShowPending] = useState(false);
|
||||||
// const selectedProject = useSelector(
|
|
||||||
// (store) => store.localVariables.projectId
|
|
||||||
// );
|
|
||||||
const selectedProject = useSelectedProject();
|
const selectedProject = useSelectedProject();
|
||||||
const {
|
const {
|
||||||
attendance,
|
attendance,
|
||||||
loading: attLoading,
|
loading: attLoading,
|
||||||
recall: attrecall,
|
recall: attrecall,
|
||||||
isFetching
|
isFetching
|
||||||
} = useAttendance(selectedProject);
|
} = useAttendance(selectedProject, organizationId);
|
||||||
const filteredAttendance = ShowPending
|
const filteredAttendance = ShowPending
|
||||||
? attendance?.filter(
|
? attendance?.filter(
|
||||||
(att) => att?.checkInTime !== null && att?.checkOutTime === null
|
(att) => att?.checkInTime !== null && att?.checkOutTime === null
|
||||||
@ -62,12 +59,11 @@ const Attendance = ({ getRole, handleModalData, searchTerm }) => {
|
|||||||
const role = item.jobRoleName?.toLowerCase() || "";
|
const role = item.jobRoleName?.toLowerCase() || "";
|
||||||
return (
|
return (
|
||||||
fullName.includes(lowercasedSearchTerm) ||
|
fullName.includes(lowercasedSearchTerm) ||
|
||||||
role.includes(lowercasedSearchTerm) // ✅ also search by role
|
role.includes(lowercasedSearchTerm) // also search by role
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}, [group1, group2, searchTerm]);
|
}, [group1, group2, searchTerm]);
|
||||||
|
|
||||||
|
|
||||||
const { currentPage, totalPages, currentItems, paginate } = usePagination(
|
const { currentPage, totalPages, currentItems, paginate } = usePagination(
|
||||||
finalFilteredData,
|
finalFilteredData,
|
||||||
ITEMS_PER_PAGE
|
ITEMS_PER_PAGE
|
||||||
@ -116,7 +112,7 @@ const Attendance = ({ getRole, handleModalData, searchTerm }) => {
|
|||||||
<>
|
<>
|
||||||
<div
|
<div
|
||||||
className="table-responsive text-nowrap h-100"
|
className="table-responsive text-nowrap h-100"
|
||||||
style={{ minHeight: "200px" }} // 🔹 Ensures fixed height
|
style={{ minHeight: "200px" }} // Ensures fixed height
|
||||||
>
|
>
|
||||||
<div className="d-flex text-start align-items-center py-2">
|
<div className="d-flex text-start align-items-center py-2">
|
||||||
<strong>Date : {formatUTCToLocalTime(todayDate)}</strong>
|
<strong>Date : {formatUTCToLocalTime(todayDate)}</strong>
|
||||||
@ -142,6 +138,7 @@ const Attendance = ({ getRole, handleModalData, searchTerm }) => {
|
|||||||
<tr className="border-top-1">
|
<tr className="border-top-1">
|
||||||
<th colSpan={2}>Name</th>
|
<th colSpan={2}>Name</th>
|
||||||
<th>Role</th>
|
<th>Role</th>
|
||||||
|
<th>Organization</th>
|
||||||
<th>
|
<th>
|
||||||
<i className="bx bxs-down-arrow-alt text-success"></i>
|
<i className="bx bxs-down-arrow-alt text-success"></i>
|
||||||
Check-In
|
Check-In
|
||||||
@ -190,6 +187,8 @@ const Attendance = ({ getRole, handleModalData, searchTerm }) => {
|
|||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td>{item.jobRoleName}</td>
|
<td>{item.jobRoleName}</td>
|
||||||
|
<td>{item.organizationName || "--"}</td>
|
||||||
|
|
||||||
<td>
|
<td>
|
||||||
{item.checkInTime
|
{item.checkInTime
|
||||||
? convertShortTime(item.checkInTime)
|
? convertShortTime(item.checkInTime)
|
||||||
@ -213,7 +212,11 @@ const Attendance = ({ getRole, handleModalData, searchTerm }) => {
|
|||||||
))}
|
))}
|
||||||
{!attendance && (
|
{!attendance && (
|
||||||
<tr>
|
<tr>
|
||||||
<td colSpan={6} className="text-center text-secondary" style={{ height: "200px" }}>
|
<td
|
||||||
|
colSpan={7}
|
||||||
|
className="text-center text-secondary"
|
||||||
|
style={{ height: "200px" }}
|
||||||
|
>
|
||||||
No employees assigned to the project!
|
No employees assigned to the project!
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@ -221,6 +224,7 @@ const Attendance = ({ getRole, handleModalData, searchTerm }) => {
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
|
||||||
{!loading && finalFilteredData.length > ITEMS_PER_PAGE && (
|
{!loading && finalFilteredData.length > ITEMS_PER_PAGE && (
|
||||||
<nav aria-label="Page ">
|
<nav aria-label="Page ">
|
||||||
<ul className="pagination pagination-sm justify-content-end py-1">
|
<ul className="pagination pagination-sm justify-content-end py-1">
|
||||||
|
|||||||
@ -5,7 +5,11 @@ import { convertShortTime } from "../../utils/dateUtils";
|
|||||||
import RenderAttendanceStatus from "./RenderAttendanceStatus";
|
import RenderAttendanceStatus from "./RenderAttendanceStatus";
|
||||||
import { useSelector, useDispatch } from "react-redux";
|
import { useSelector, useDispatch } from "react-redux";
|
||||||
import DateRangePicker from "../common/DateRangePicker";
|
import DateRangePicker from "../common/DateRangePicker";
|
||||||
import { clearCacheKey, getCachedData, useSelectedProject } from "../../slices/apiDataManager";
|
import {
|
||||||
|
clearCacheKey,
|
||||||
|
getCachedData,
|
||||||
|
useSelectedProject,
|
||||||
|
} from "../../slices/apiDataManager";
|
||||||
import eventBus from "../../services/eventBus";
|
import eventBus from "../../services/eventBus";
|
||||||
import AttendanceRepository from "../../repositories/AttendanceRepository";
|
import AttendanceRepository from "../../repositories/AttendanceRepository";
|
||||||
import { useAttendancesLogs } from "../../hooks/useAttendance";
|
import { useAttendancesLogs } from "../../hooks/useAttendance";
|
||||||
@ -33,195 +37,142 @@ const usePagination = (data, itemsPerPage) => {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
const AttendanceLog = ({ handleModalData, searchTerm }) => {
|
const AttendanceLog = ({ handleModalData, searchTerm, organizationId }) => {
|
||||||
// const selectedProject = useSelector(
|
const selectedProject = useSelectedProject();
|
||||||
// (store) => store.localVariables.projectId
|
const [dateRange, setDateRange] = useState({ startDate: "", endDate: "" });
|
||||||
// );
|
const dispatch = useDispatch();
|
||||||
const selectedProject = useSelectedProject();
|
const [loading, setLoading] = useState(false);
|
||||||
const [dateRange, setDateRange] = useState({ startDate: "", endDate: "" });
|
const [showPending, setShowPending] = useState(false);
|
||||||
const dispatch = useDispatch();
|
const [isRefreshing, setIsRefreshing] = useState(false);
|
||||||
const [loading, setLoading] = useState(false);
|
|
||||||
const [showPending, setShowPending] = useState(false)
|
|
||||||
|
|
||||||
const [isRefreshing, setIsRefreshing] = useState(false);
|
const today = new Date();
|
||||||
const [processedData, setProcessedData] = useState([]);
|
today.setHours(0, 0, 0, 0);
|
||||||
|
|
||||||
const today = new Date();
|
const yesterday = new Date();
|
||||||
today.setHours(0, 0, 0, 0);
|
yesterday.setDate(yesterday.getDate() - 1);
|
||||||
|
|
||||||
const yesterday = new Date();
|
const isSameDay = (dateStr) => {
|
||||||
yesterday.setDate(yesterday.getDate() - 1);
|
if (!dateStr) return false;
|
||||||
|
const d = new Date(dateStr);
|
||||||
|
d.setHours(0, 0, 0, 0);
|
||||||
|
return d.getTime() === today.getTime();
|
||||||
|
};
|
||||||
|
|
||||||
const isSameDay = (dateStr) => {
|
const isBeforeToday = (dateStr) => {
|
||||||
if (!dateStr) return false;
|
if (!dateStr) return false;
|
||||||
const d = new Date(dateStr);
|
const d = new Date(dateStr);
|
||||||
d.setHours(0, 0, 0, 0);
|
d.setHours(0, 0, 0, 0);
|
||||||
return d.getTime() === today.getTime();
|
return d.getTime() < today.getTime();
|
||||||
};
|
};
|
||||||
|
|
||||||
const isBeforeToday = (dateStr) => {
|
const sortByName = (a, b) => {
|
||||||
if (!dateStr) return false;
|
const nameA = (a.firstName + a.lastName).toLowerCase();
|
||||||
const d = new Date(dateStr);
|
const nameB = (b.firstName + b.lastName).toLowerCase();
|
||||||
d.setHours(0, 0, 0, 0);
|
return nameA.localeCompare(nameB);
|
||||||
return d.getTime() < today.getTime();
|
};
|
||||||
};
|
|
||||||
|
|
||||||
const sortByName = (a, b) => {
|
const { data = [], isLoading, error, refetch, isFetching } = useAttendancesLogs(
|
||||||
const nameA = a.firstName.toLowerCase() + a.lastName.toLowerCase();
|
selectedProject,
|
||||||
const nameB = b.firstName.toLowerCase() + b.lastName.toLowerCase();
|
dateRange.startDate,
|
||||||
return nameA?.localeCompare(nameB);
|
dateRange.endDate,
|
||||||
};
|
organizationId
|
||||||
|
);
|
||||||
|
|
||||||
const {
|
const processedData = useMemo(() => {
|
||||||
data = [],
|
const filteredData = showPending
|
||||||
isLoading,
|
? data.filter((item) => item.checkOutTime === null)
|
||||||
error,
|
: data;
|
||||||
refetch,
|
|
||||||
isFetching,
|
|
||||||
} = useAttendancesLogs(
|
|
||||||
selectedProject,
|
|
||||||
dateRange.startDate,
|
|
||||||
dateRange.endDate
|
|
||||||
);
|
|
||||||
const filtering = (data) => {
|
|
||||||
const filteredData = showPending
|
|
||||||
? data.filter((item) => item.checkOutTime === null)
|
|
||||||
: data;
|
|
||||||
|
|
||||||
const group1 = filteredData
|
const group1 = filteredData.filter((d) => d.activity === 1 && isSameDay(d.checkInTime)).sort(sortByName);
|
||||||
.filter((d) => d.activity === 1 && isSameDay(d.checkInTime))
|
const group2 = filteredData.filter((d) => d.activity === 4 && isSameDay(d.checkOutTime)).sort(sortByName);
|
||||||
.sort(sortByName);
|
const group3 = filteredData.filter((d) => d.activity === 1 && isBeforeToday(d.checkInTime)).sort(sortByName);
|
||||||
const group2 = filteredData
|
const group4 = filteredData.filter((d) => d.activity === 4 && isBeforeToday(d.checkOutTime));
|
||||||
.filter((d) => d.activity === 4 && isSameDay(d.checkOutTime))
|
const group5 = filteredData.filter((d) => d.activity === 2 && isBeforeToday(d.checkOutTime)).sort(sortByName);
|
||||||
.sort(sortByName);
|
const group6 = filteredData.filter((d) => d.activity === 5).sort(sortByName);
|
||||||
const group3 = filteredData
|
|
||||||
.filter((d) => d.activity === 1 && isBeforeToday(d.checkInTime))
|
|
||||||
.sort(sortByName);
|
|
||||||
const group4 = filteredData.filter(
|
|
||||||
(d) => d.activity === 4 && isBeforeToday(d.checkOutTime)
|
|
||||||
);
|
|
||||||
const group5 = filteredData
|
|
||||||
.filter((d) => d.activity === 2 && isBeforeToday(d.checkOutTime))
|
|
||||||
.sort(sortByName);
|
|
||||||
const group6 = filteredData
|
|
||||||
.filter((d) => d.activity === 5)
|
|
||||||
.sort(sortByName);
|
|
||||||
|
|
||||||
const sortedList = [
|
const sortedList = [...group1, ...group2, ...group3, ...group4, ...group5, ...group6];
|
||||||
...group1,
|
|
||||||
...group2,
|
|
||||||
...group3,
|
|
||||||
...group4,
|
|
||||||
...group5,
|
|
||||||
...group6,
|
|
||||||
];
|
|
||||||
|
|
||||||
// Group by date
|
const groupedByDate = sortedList.reduce((acc, item) => {
|
||||||
const groupedByDate = sortedList.reduce((acc, item) => {
|
const date = (item.checkInTime || item.checkOutTime)?.split("T")[0];
|
||||||
const date = (item.checkInTime || item.checkOutTime)?.split("T")[0];
|
if (date) {
|
||||||
if (date) {
|
acc[date] = acc[date] || [];
|
||||||
acc[date] = acc[date] || [];
|
acc[date].push(item);
|
||||||
acc[date].push(item);
|
|
||||||
}
|
|
||||||
return acc;
|
|
||||||
}, {});
|
|
||||||
|
|
||||||
const sortedDates = Object.keys(groupedByDate).sort(
|
|
||||||
(a, b) => new Date(b) - new Date(a)
|
|
||||||
);
|
|
||||||
|
|
||||||
const finalData = sortedDates.flatMap((date) => groupedByDate[date]);
|
|
||||||
setProcessedData(finalData);
|
|
||||||
};
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
filtering(data);
|
|
||||||
}, [data, showPending]);
|
|
||||||
|
|
||||||
// New useEffect to handle search filtering
|
|
||||||
const filteredSearchData = useMemo(() => {
|
|
||||||
if (!searchTerm) {
|
|
||||||
return processedData;
|
|
||||||
}
|
}
|
||||||
const lowercasedSearchTerm = searchTerm.toLowerCase();
|
return acc;
|
||||||
return processedData.filter((item) => {
|
}, {});
|
||||||
const fullName = `${item.firstName} ${item.lastName}`.toLowerCase();
|
|
||||||
return fullName.includes(lowercasedSearchTerm);
|
|
||||||
});
|
|
||||||
}, [processedData, searchTerm]);
|
|
||||||
|
|
||||||
const {
|
const sortedDates = Object.keys(groupedByDate).sort((a, b) => new Date(b) - new Date(a));
|
||||||
currentPage,
|
return sortedDates.flatMap((date) => groupedByDate[date]);
|
||||||
totalPages,
|
}, [data, showPending]);
|
||||||
currentItems: paginatedAttendances,
|
|
||||||
paginate,
|
|
||||||
resetPage,
|
|
||||||
} = usePagination(filteredSearchData, 20);
|
|
||||||
|
|
||||||
useEffect(() => {
|
const filteredSearchData = useMemo(() => {
|
||||||
resetPage();
|
if (!searchTerm) return processedData;
|
||||||
}, [filteredSearchData, resetPage]);
|
|
||||||
|
|
||||||
const handler = useCallback(
|
const lowercased = searchTerm.toLowerCase();
|
||||||
(msg) => {
|
return processedData.filter((item) =>
|
||||||
const { startDate, endDate } = dateRange;
|
`${item.firstName} ${item.lastName}`.toLowerCase().includes(lowercased)
|
||||||
const checkIn = msg.response.checkInTime.substring(0, 10);
|
|
||||||
if (
|
|
||||||
selectedProject === msg.projectId &&
|
|
||||||
startDate <= checkIn &&
|
|
||||||
checkIn <= endDate
|
|
||||||
) {
|
|
||||||
queryClient.setQueriesData(["attendanceLogs"], (oldData) => {
|
|
||||||
if (!oldData) {
|
|
||||||
queryClient.invalidateQueries({ queryKey: ["attendanceLogs"] });
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const updatedAttendance = oldData.map((record) =>
|
|
||||||
record.id === msg.response.id
|
|
||||||
? { ...record, ...msg.response }
|
|
||||||
: record
|
|
||||||
);
|
|
||||||
filtering(updatedAttendance);
|
|
||||||
return updatedAttendance;
|
|
||||||
});
|
|
||||||
resetPage();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
[selectedProject, dateRange, filtering, resetPage]
|
|
||||||
);
|
);
|
||||||
|
}, [processedData, searchTerm]);
|
||||||
|
|
||||||
useEffect(() => {
|
const {
|
||||||
eventBus.on("attendance_log", handler);
|
currentPage,
|
||||||
return () => eventBus.off("attendance_log", handler);
|
totalPages,
|
||||||
}, [handler]);
|
currentItems: paginatedAttendances,
|
||||||
|
paginate,
|
||||||
|
resetPage,
|
||||||
|
} = usePagination(filteredSearchData, 20);
|
||||||
|
|
||||||
const employeeHandler = useCallback(
|
useEffect(() => {
|
||||||
(msg) => {
|
resetPage();
|
||||||
const { startDate, endDate } = dateRange;
|
}, [filteredSearchData]);
|
||||||
if (data.some((item) => item.employeeId == msg.employeeId)) {
|
|
||||||
// dispatch(
|
const handler = useCallback(
|
||||||
// fetchAttendanceData({
|
(msg) => {
|
||||||
// ,
|
const { startDate, endDate } = dateRange;
|
||||||
// fromDate: startDate,
|
const checkIn = msg.response.checkInTime.substring(0, 10);
|
||||||
// toDate: endDate,
|
|
||||||
// })
|
if (selectedProject === msg.projectId && startDate <= checkIn && checkIn <= endDate) {
|
||||||
// );
|
queryClient.setQueriesData(["attendanceLogs"], (oldData) => {
|
||||||
|
if (!oldData) {
|
||||||
|
queryClient.invalidateQueries({ queryKey: ["attendanceLogs"] });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return oldData.map((record) =>
|
||||||
|
record.id === msg.response.id ? { ...record, ...msg.response } : record
|
||||||
|
);
|
||||||
|
});
|
||||||
|
resetPage();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[selectedProject, dateRange, resetPage]
|
||||||
|
);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
eventBus.on("attendance_log", handler);
|
||||||
|
return () => eventBus.off("attendance_log", handler);
|
||||||
|
}, [handler]);
|
||||||
|
|
||||||
|
const employeeHandler = useCallback(
|
||||||
|
(msg) => {
|
||||||
|
const { startDate, endDate } = dateRange;
|
||||||
|
if (data.some((item) => item.employeeId == msg.employeeId)) {
|
||||||
|
refetch();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[data, refetch]
|
||||||
|
);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
eventBus.on("employee", employeeHandler);
|
||||||
|
return () => eventBus.off("employee", employeeHandler);
|
||||||
|
}, [employeeHandler]);
|
||||||
|
|
||||||
refetch()
|
|
||||||
}
|
|
||||||
},
|
|
||||||
[selectedProject, dateRange, data, refetch]
|
|
||||||
);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
eventBus.on("employee", employeeHandler);
|
|
||||||
return () => eventBus.off("employee", employeeHandler);
|
|
||||||
}, [employeeHandler]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div
|
<div
|
||||||
className="dataTables_length text-start py-2 d-flex justify-content-between"
|
className="dataTables_length text-start py-2 d-flex justify-content-between "
|
||||||
id="DataTables_Table_0_length"
|
id="DataTables_Table_0_length"
|
||||||
>
|
>
|
||||||
<div className="d-flex align-items-center my-0 ">
|
<div className="d-flex align-items-center my-0 ">
|
||||||
@ -229,7 +180,7 @@ const AttendanceLog = ({ handleModalData, searchTerm }) => {
|
|||||||
onRangeChange={setDateRange}
|
onRangeChange={setDateRange}
|
||||||
defaultStartDate={yesterday}
|
defaultStartDate={yesterday}
|
||||||
/>
|
/>
|
||||||
<div className="form-check form-switch text-start m-0 ms-5">
|
<div className="form-check form-switch text-start ms-1 ms-md-2 align-items-center mb-0">
|
||||||
<input
|
<input
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
className="form-check-input"
|
className="form-check-input"
|
||||||
@ -242,18 +193,16 @@ const AttendanceLog = ({ handleModalData, searchTerm }) => {
|
|||||||
<label className="form-check-label ms-0">Show Pending</label>
|
<label className="form-check-label ms-0">Show Pending</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="col-md-2 m-0 text-end">
|
|
||||||
<i
|
|
||||||
className={`bx bx-refresh cursor-pointer fs-4 ${isFetching ? "spin" : ""
|
|
||||||
}`}
|
|
||||||
title="Refresh"
|
|
||||||
onClick={() => refetch()}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div className="table-responsive text-nowrap" style={{ minHeight: "200px" }}>
|
<div
|
||||||
|
className="table-responsive text-nowrap"
|
||||||
|
style={{ minHeight: "200px" }}
|
||||||
|
>
|
||||||
{isLoading ? (
|
{isLoading ? (
|
||||||
<div className="d-flex justify-content-center align-items-center" style={{ height: "200px" }}>
|
<div
|
||||||
|
className="d-flex justify-content-center align-items-center"
|
||||||
|
style={{ height: "200px" }}
|
||||||
|
>
|
||||||
<p className="text-secondary">Loading...</p>
|
<p className="text-secondary">Loading...</p>
|
||||||
</div>
|
</div>
|
||||||
) : filteredSearchData?.length > 0 ? (
|
) : filteredSearchData?.length > 0 ? (
|
||||||
@ -264,6 +213,7 @@ const AttendanceLog = ({ handleModalData, searchTerm }) => {
|
|||||||
Name
|
Name
|
||||||
</th>
|
</th>
|
||||||
<th className="border-top-1">Date</th>
|
<th className="border-top-1">Date</th>
|
||||||
|
<th>Organization</th>
|
||||||
<th>
|
<th>
|
||||||
<i className="bx bxs-down-arrow-alt text-success"></i>{" "}
|
<i className="bx bxs-down-arrow-alt text-success"></i>{" "}
|
||||||
Check-In
|
Check-In
|
||||||
@ -282,9 +232,9 @@ const AttendanceLog = ({ handleModalData, searchTerm }) => {
|
|||||||
const previousAttendance = arr[index - 1];
|
const previousAttendance = arr[index - 1];
|
||||||
const previousDate = previousAttendance
|
const previousDate = previousAttendance
|
||||||
? moment(
|
? moment(
|
||||||
previousAttendance.checkInTime ||
|
previousAttendance.checkInTime ||
|
||||||
previousAttendance.checkOutTime
|
previousAttendance.checkOutTime
|
||||||
).format("YYYY-MM-DD")
|
).format("YYYY-MM-DD")
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
if (!previousDate || currentDate !== previousDate) {
|
if (!previousDate || currentDate !== previousDate) {
|
||||||
@ -293,7 +243,7 @@ const AttendanceLog = ({ handleModalData, searchTerm }) => {
|
|||||||
key={`header-${currentDate}`}
|
key={`header-${currentDate}`}
|
||||||
className="table-row-header"
|
className="table-row-header"
|
||||||
>
|
>
|
||||||
<td colSpan={6} className="text-start">
|
<td colSpan={8} className="text-start">
|
||||||
<strong>
|
<strong>
|
||||||
{moment(currentDate).format("DD-MM-YYYY")}
|
{moment(currentDate).format("DD-MM-YYYY")}
|
||||||
</strong>
|
</strong>
|
||||||
@ -323,6 +273,7 @@ const AttendanceLog = ({ handleModalData, searchTerm }) => {
|
|||||||
attendance.checkInTime || attendance.checkOutTime
|
attendance.checkInTime || attendance.checkOutTime
|
||||||
).format("DD-MMM-YYYY")}
|
).format("DD-MMM-YYYY")}
|
||||||
</td>
|
</td>
|
||||||
|
<td>{attendance.organizationName || "--"}</td>
|
||||||
<td>{convertShortTime(attendance.checkInTime)}</td>
|
<td>{convertShortTime(attendance.checkInTime)}</td>
|
||||||
<td>
|
<td>
|
||||||
{attendance.checkOutTime
|
{attendance.checkOutTime
|
||||||
@ -344,7 +295,12 @@ const AttendanceLog = ({ handleModalData, searchTerm }) => {
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
) : (
|
) : (
|
||||||
<div className="my-4"><span className="text-secondary">No Record Available !</span></div>
|
<div className="my-12">
|
||||||
|
<span className="text-secondary">
|
||||||
|
No data available for the selected date range. Please Select
|
||||||
|
another date.
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
{paginatedAttendances?.length == 0 && filteredSearchData?.length > 0 && (
|
{paginatedAttendances?.length == 0 && filteredSearchData?.length > 0 && (
|
||||||
@ -370,8 +326,9 @@ const AttendanceLog = ({ handleModalData, searchTerm }) => {
|
|||||||
(pageNumber) => (
|
(pageNumber) => (
|
||||||
<li
|
<li
|
||||||
key={pageNumber}
|
key={pageNumber}
|
||||||
className={`page-item ${currentPage === pageNumber ? "active" : ""
|
className={`page-item ${
|
||||||
}`}
|
currentPage === pageNumber ? "active" : ""
|
||||||
|
}`}
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
className="page-link"
|
className="page-link"
|
||||||
@ -383,8 +340,9 @@ const AttendanceLog = ({ handleModalData, searchTerm }) => {
|
|||||||
)
|
)
|
||||||
)}
|
)}
|
||||||
<li
|
<li
|
||||||
className={`page-item ${currentPage === totalPages ? "disabled" : ""
|
className={`page-item ${
|
||||||
}`}
|
currentPage === totalPages ? "disabled" : ""
|
||||||
|
}`}
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
className="page-link"
|
className="page-link"
|
||||||
|
|||||||
@ -33,7 +33,7 @@ const createSchema = (modeldata) => {
|
|||||||
const checkOut = new Date(checkIn);
|
const checkOut = new Date(checkIn);
|
||||||
checkOut.setHours(hour, minute, 0, 0);
|
checkOut.setHours(hour, minute, 0, 0);
|
||||||
|
|
||||||
return checkOut > checkIn;
|
return checkOut >= checkIn;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}, {
|
}, {
|
||||||
@ -96,12 +96,12 @@ const CheckInCheckOut = ({ modeldata, closeModal, handleSubmitForm }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<form className="row g-2" onSubmit={handleSubmit(onSubmit)}>
|
<form className="row p-2" onSubmit={handleSubmit(onSubmit)}>
|
||||||
<div className="col-12 d-flex justify-content-center">
|
<div className="col-12 d-flex justify-content-center mb-4">
|
||||||
<label className="fs-5 text-dark text-center">
|
<label className="fs-5 tex-semibold text-center">
|
||||||
{modeldata?.checkInTime && !modeldata?.checkOutTime
|
{modeldata?.checkInTime && !modeldata?.checkOutTime
|
||||||
? "Check-out :"
|
? "Check-Out "
|
||||||
: "Check-in :"}
|
: "Check-In "}
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
import React, { useState, useEffect } from "react";
|
import React, { useState, useEffect } from "react";
|
||||||
import "../../components/Project/ProjectInfra.css";
|
import "../../components/Project/ProjectInfra.css";
|
||||||
import BuildingModel from "../Project/Infrastructure/BuildingModel";
|
import BuildingModel from "../Project/Infrastructure/BuildingModel";
|
||||||
@ -8,25 +7,33 @@ import WorkAreaModel from "../Project/Infrastructure/WorkAreaModel";
|
|||||||
import TaskModel from "../Project/Infrastructure/TaskModel";
|
import TaskModel from "../Project/Infrastructure/TaskModel";
|
||||||
import ProjectRepository from "../../repositories/ProjectRepository";
|
import ProjectRepository from "../../repositories/ProjectRepository";
|
||||||
import Breadcrumb from "../../components/common/Breadcrumb";
|
import Breadcrumb from "../../components/common/Breadcrumb";
|
||||||
import {useProjectDetails, useProjectInfra, useProjects} from "../../hooks/useProjects";
|
import {
|
||||||
import {useHasUserPermission} from "../../hooks/useHasUserPermission";
|
useCurrentService,
|
||||||
import {APPROVE_TASK, ASSIGN_REPORT_TASK, MANAGE_PROJECT_INFRA} from "../../utils/constants";
|
useProjectDetails,
|
||||||
import {useDispatch, useSelector} from "react-redux";
|
useProjectInfra,
|
||||||
import {useProfile} from "../../hooks/useProfile";
|
useProjects,
|
||||||
import {refreshData, setProjectId} from "../../slices/localVariablesSlice";
|
} from "../../hooks/useProjects";
|
||||||
|
import { useHasUserPermission } from "../../hooks/useHasUserPermission";
|
||||||
|
import {
|
||||||
|
APPROVE_TASK,
|
||||||
|
ASSIGN_REPORT_TASK,
|
||||||
|
MANAGE_PROJECT_INFRA,
|
||||||
|
} from "../../utils/constants";
|
||||||
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
|
import { useProfile } from "../../hooks/useProfile";
|
||||||
|
import { refreshData, setProjectId } from "../../slices/localVariablesSlice";
|
||||||
import InfraTable from "../Project/Infrastructure/InfraTable";
|
import InfraTable from "../Project/Infrastructure/InfraTable";
|
||||||
import { useSelectedProject } from "../../slices/apiDataManager";
|
import { useSelectedProject } from "../../slices/apiDataManager";
|
||||||
import Loader from "../common/Loader";
|
import Loader from "../common/Loader";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const InfraPlanning = () => {
|
const InfraPlanning = () => {
|
||||||
const { profile: LoggedUser, refetch: fetchData } = useProfile();
|
const { profile: LoggedUser, refetch: fetchData } = useProfile();
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const selectedProject = useSelectedProject();
|
const selectedProject = useSelectedProject();
|
||||||
|
const selectedService = useCurrentService();
|
||||||
|
|
||||||
const { projectInfra, isLoading, isError, error, isFetched } = useProjectInfra(selectedProject);
|
const { projectInfra, isLoading, isError, error, isFetched } =
|
||||||
|
useProjectInfra(selectedProject, selectedService || "" );
|
||||||
|
|
||||||
const canManageInfra = useHasUserPermission(MANAGE_PROJECT_INFRA);
|
const canManageInfra = useHasUserPermission(MANAGE_PROJECT_INFRA);
|
||||||
const canApproveTask = useHasUserPermission(APPROVE_TASK);
|
const canApproveTask = useHasUserPermission(APPROVE_TASK);
|
||||||
@ -55,7 +62,7 @@ const InfraPlanning = () => {
|
|||||||
|
|
||||||
if (isFetched && (!projectInfra || projectInfra.length === 0)) {
|
if (isFetched && (!projectInfra || projectInfra.length === 0)) {
|
||||||
return (
|
return (
|
||||||
<div className="card text-center">
|
<div className="text-center">
|
||||||
<p className="my-3">No Result Found</p>
|
<p className="my-3">No Result Found</p>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@ -63,11 +70,9 @@ const InfraPlanning = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="col-md-12 col-lg-12 col-xl-12 order-0 mb-4">
|
<div className="col-md-12 col-lg-12 col-xl-12 order-0 mb-4">
|
||||||
<div className="card">
|
<div className="card-body" style={{ padding: "0.5rem" }}>
|
||||||
<div className="card-body" style={{ padding: "0.5rem" }}>
|
<div className="row">
|
||||||
<div className="row">
|
<InfraTable buildings={projectInfra} projectId={selectedProject} />
|
||||||
<InfraTable buildings={projectInfra} projectId={selectedProject} />
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -75,4 +80,3 @@ const InfraPlanning = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export default InfraPlanning;
|
export default InfraPlanning;
|
||||||
|
|
||||||
|
|||||||
@ -1,25 +1,43 @@
|
|||||||
import React, { useCallback, useEffect, useState, useMemo } from "react";
|
import React, { useCallback, useEffect, useState, useMemo } from "react";
|
||||||
import Avatar from "../common/Avatar";
|
import Avatar from "../common/Avatar";
|
||||||
import { convertShortTime } from "../../utils/dateUtils";
|
import { convertShortTime, formatUTCToLocalTime } from "../../utils/dateUtils";
|
||||||
import RegularizationActions from "./RegularizationActions";
|
import RegularizationActions from "./RegularizationActions";
|
||||||
import { useSelector } from "react-redux";
|
import { useSelector } from "react-redux";
|
||||||
import { useRegularizationRequests } from "../../hooks/useAttendance";
|
import { useRegularizationRequests } from "../../hooks/useAttendance";
|
||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
import usePagination from "../../hooks/usePagination";
|
import usePagination from "../../hooks/usePagination";
|
||||||
import eventBus from "../../services/eventBus";
|
import eventBus from "../../services/eventBus";
|
||||||
import { cacheData, clearCacheKey, useSelectedProject } from "../../slices/apiDataManager";
|
import {
|
||||||
|
cacheData,
|
||||||
|
clearCacheKey,
|
||||||
|
useSelectedProject,
|
||||||
|
} from "../../slices/apiDataManager";
|
||||||
import { useQueryClient } from "@tanstack/react-query";
|
import { useQueryClient } from "@tanstack/react-query";
|
||||||
|
import Pagination from "../../components/common/Pagination";
|
||||||
|
|
||||||
const Regularization = ({ handleRequest, searchTerm }) => {
|
const Regularization = ({
|
||||||
|
handleRequest,
|
||||||
|
searchTerm,
|
||||||
|
projectId,
|
||||||
|
organizationId,
|
||||||
|
IncludeInActive,
|
||||||
|
}) => {
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
// var selectedProject = useSelector((store) => store.localVariables.projectId);
|
// var selectedProject = useSelector((store) => store.localVariables.projectId);
|
||||||
const selectedProject = useSelectedProject();
|
const selectedProject = useSelectedProject();
|
||||||
const [regularizesList, setregularizedList] = useState([]);
|
const [regularizesList, setregularizedList] = useState([]);
|
||||||
const { regularizes, loading, error, refetch } =
|
const { regularizes, loading, error, refetch } = useRegularizationRequests(
|
||||||
useRegularizationRequests(selectedProject);
|
selectedProject,
|
||||||
|
organizationId,
|
||||||
|
IncludeInActive
|
||||||
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if(!regularizes) return
|
||||||
|
if(regularizes?.length) {
|
||||||
setregularizedList(regularizes);
|
setregularizedList(regularizes);
|
||||||
|
|
||||||
|
}
|
||||||
}, [regularizes]);
|
}, [regularizes]);
|
||||||
|
|
||||||
const sortByName = (a, b) => {
|
const sortByName = (a, b) => {
|
||||||
@ -54,18 +72,15 @@ const Regularization = ({ handleRequest, searchTerm }) => {
|
|||||||
}
|
}
|
||||||
const lowercasedSearchTerm = searchTerm.toLowerCase();
|
const lowercasedSearchTerm = searchTerm.toLowerCase();
|
||||||
return sortedList.filter((item) => {
|
return sortedList.filter((item) => {
|
||||||
const fullName = `${item.firstName} ${item.lastName}`.toLowerCase();
|
const fullName = `${item?.firstName} ${item?.lastName}`.toLowerCase();
|
||||||
return fullName.includes(lowercasedSearchTerm);
|
return fullName.includes(lowercasedSearchTerm);
|
||||||
});
|
});
|
||||||
}, [regularizesList, searchTerm]);
|
}, [regularizesList, searchTerm]);
|
||||||
|
|
||||||
const { currentPage, totalPages, currentItems, paginate } =
|
const { currentPage, totalPages, currentItems, paginate } = usePagination(
|
||||||
usePagination(filteredSearchData, 20);
|
filteredSearchData,
|
||||||
|
20
|
||||||
// Reset pagination when the search term or data changes
|
);
|
||||||
useEffect(() => {
|
|
||||||
|
|
||||||
}, [filteredSearchData]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
eventBus.on("regularization", handler);
|
eventBus.on("regularization", handler);
|
||||||
@ -87,9 +102,15 @@ const Regularization = ({ handleRequest, searchTerm }) => {
|
|||||||
}, [employeeHandler]);
|
}, [employeeHandler]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="table-responsive text-nowrap pb-4" style={{ minHeight: "200px" }}>
|
<div
|
||||||
|
className="table-responsive text-nowrap pb-4"
|
||||||
|
style={{ minHeight: "200px" }}
|
||||||
|
>
|
||||||
{loading ? (
|
{loading ? (
|
||||||
<div className="d-flex justify-content-center align-items-center" style={{ height: "200px" }}>
|
<div
|
||||||
|
className="d-flex justify-content-center align-items-center"
|
||||||
|
style={{ height: "200px" }}
|
||||||
|
>
|
||||||
<p className="text-secondary">Loading...</p>
|
<p className="text-secondary">Loading...</p>
|
||||||
</div>
|
</div>
|
||||||
) : currentItems?.length > 0 ? (
|
) : currentItems?.length > 0 ? (
|
||||||
@ -98,24 +119,28 @@ const Regularization = ({ handleRequest, searchTerm }) => {
|
|||||||
<tr>
|
<tr>
|
||||||
<th colSpan={2}>Name</th>
|
<th colSpan={2}>Name</th>
|
||||||
<th>Date</th>
|
<th>Date</th>
|
||||||
|
<th>Organization</th>
|
||||||
<th>
|
<th>
|
||||||
<i className="bx bxs-down-arrow-alt text-success"></i>Check-In
|
<i className="bx bxs-down-arrow-alt text-success"></i>Check-In
|
||||||
</th>
|
</th>
|
||||||
<th>
|
<th>
|
||||||
<i className="bx bxs-up-arrow-alt text-danger"></i>Check-Out
|
<i className="bx bxs-up-arrow-alt text-danger"></i>Check-Out
|
||||||
</th>
|
</th>
|
||||||
|
<th colSpan={2}>
|
||||||
|
Requested By
|
||||||
|
</th>
|
||||||
|
<th >
|
||||||
|
Requested At
|
||||||
|
</th>
|
||||||
<th>Action</th>
|
<th>Action</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{currentItems?.map((att, index) => (
|
{currentItems?.map((att, index) => (
|
||||||
<tr key={index}>
|
<tr key={index}>
|
||||||
<td colSpan={2}>
|
<td colSpan={2}>
|
||||||
<div className="d-flex justify-content-start align-items-center">
|
<div className="d-flex justify-content-start align-items-center">
|
||||||
<Avatar
|
<Avatar firstName={att.firstName} lastName={att.lastName} />
|
||||||
firstName={att.firstName}
|
|
||||||
lastName={att.lastName}
|
|
||||||
></Avatar>
|
|
||||||
<div className="d-flex flex-column">
|
<div className="d-flex flex-column">
|
||||||
<a href="#" className="text-heading text-truncate">
|
<a href="#" className="text-heading text-truncate">
|
||||||
<span className="fw-normal">
|
<span className="fw-normal">
|
||||||
@ -126,9 +151,28 @@ const Regularization = ({ handleRequest, searchTerm }) => {
|
|||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td>{moment(att.checkOutTime).format("DD-MMM-YYYY")}</td>
|
<td>{moment(att.checkOutTime).format("DD-MMM-YYYY")}</td>
|
||||||
|
|
||||||
|
<td>{att.organizationName || "--"}</td>
|
||||||
|
|
||||||
<td>{convertShortTime(att.checkInTime)}</td>
|
<td>{convertShortTime(att.checkInTime)}</td>
|
||||||
<td>
|
<td>
|
||||||
{att.checkOutTime ? convertShortTime(att.checkOutTime) : "--"}
|
{att.requestedAt ? convertShortTime(att.checkOutTime) : "--"}
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<td colSpan={2}>
|
||||||
|
{att.requestedBy ? ( <div className="d-flex justify-content-start align-items-center">
|
||||||
|
<Avatar firstName={att?.requestedBy?.firstName} lastName={att?.requestedBy?.lastName} />
|
||||||
|
<div className="d-flex flex-column">
|
||||||
|
<a href="#" className="text-heading text-truncate">
|
||||||
|
<span className="fw-normal">
|
||||||
|
{att?.requestedBy?.firstName} {att?.requestedBy?.lastName}
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>):(<small>--</small>)}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{att?.requestedAt ? formatUTCToLocalTime(att.requestedAt,true) : "--"}
|
||||||
</td>
|
</td>
|
||||||
<td className="text-center ">
|
<td className="text-center ">
|
||||||
<RegularizationActions
|
<RegularizationActions
|
||||||
@ -136,7 +180,6 @@ const Regularization = ({ handleRequest, searchTerm }) => {
|
|||||||
handleRequest={handleRequest}
|
handleRequest={handleRequest}
|
||||||
refresh={refetch}
|
refresh={refetch}
|
||||||
/>
|
/>
|
||||||
{/* </div> */}
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
))}
|
))}
|
||||||
@ -154,7 +197,7 @@ const Regularization = ({ handleRequest, searchTerm }) => {
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{!loading && totalPages > 1 && (
|
{/* {!loading && totalPages > 1 && (
|
||||||
<nav aria-label="Page ">
|
<nav aria-label="Page ">
|
||||||
<ul className="pagination pagination-sm justify-content-end py-1 mt-3">
|
<ul className="pagination pagination-sm justify-content-end py-1 mt-3">
|
||||||
<li className={`page-item ${currentPage === 1 ? "disabled" : ""}`}>
|
<li className={`page-item ${currentPage === 1 ? "disabled" : ""}`}>
|
||||||
@ -192,6 +235,14 @@ const Regularization = ({ handleRequest, searchTerm }) => {
|
|||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
|
)} */}
|
||||||
|
|
||||||
|
{totalPages > 0 && (
|
||||||
|
<Pagination
|
||||||
|
currentPage={currentPage}
|
||||||
|
totalPages={totalPages}
|
||||||
|
onPageChange={paginate}
|
||||||
|
/>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -77,7 +77,7 @@ export const ReportTask = ({ report, closeModal }) => {
|
|||||||
return (
|
return (
|
||||||
<div className="container m-0">
|
<div className="container m-0">
|
||||||
<div className="text-center">
|
<div className="text-center">
|
||||||
<p className="fs-6 fw-semibold">Report Task</p>
|
<p className="fs-5 fw-semibold">Report Task</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="mb-1 row text-start">
|
<div className="mb-1 row text-start">
|
||||||
<label htmlFor="html5-text-input" className="col-md-4 col-form-label">
|
<label htmlFor="html5-text-input" className="col-md-4 col-form-label">
|
||||||
@ -101,16 +101,14 @@ export const ReportTask = ({ report, closeModal }) => {
|
|||||||
<label htmlFor="html5-email-input" className="col-md-4 col-form-label">
|
<label htmlFor="html5-email-input" className="col-md-4 col-form-label">
|
||||||
Wrok Area :
|
Wrok Area :
|
||||||
</label>
|
</label>
|
||||||
<div className="col-md-8 text-start text-wrap">
|
<div className="col-md-8 text-start">
|
||||||
<label className=" col-form-label">
|
<div className="text-wrap">
|
||||||
{" "}
|
{report?.workItem?.workArea?.floor?.building?.name} <i className="bx bx-chevron-right"></i>
|
||||||
{report?.workItem?.workArea?.floor?.building?.name}{" "}
|
{report?.workItem?.workArea?.floor?.floorName} <i className="bx bx-chevron-right"></i>
|
||||||
<i className="bx bx-chevron-right"></i>{" "}
|
{report?.workItem?.workArea?.areaName}
|
||||||
{report?.workItem?.workArea?.floor?.floorName}{" "}
|
</div>
|
||||||
<i className="bx bx-chevron-right"> </i>
|
</div>
|
||||||
{report?.workItem?.workArea?.areaName}
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div className="mb-1 row text-start">
|
<div className="mb-1 row text-start">
|
||||||
<label htmlFor="html5-email-input" className="col-md-4 col-form-label">
|
<label htmlFor="html5-email-input" className="col-md-4 col-form-label">
|
||||||
|
|||||||
@ -110,6 +110,8 @@ const ReportTaskComments = ({
|
|||||||
approvedTask: defaultCompletedTask || 0,
|
approvedTask: defaultCompletedTask || 0,
|
||||||
});
|
});
|
||||||
}, [defaultCompletedTask]);
|
}, [defaultCompletedTask]);
|
||||||
|
|
||||||
|
const completed_Task = watch("approvedTask")
|
||||||
return (
|
return (
|
||||||
<div className="p-2 p-sm-1">
|
<div className="p-2 p-sm-1">
|
||||||
<div className="modal-body p-sm-4 p-0">
|
<div className="modal-body p-sm-4 p-0">
|
||||||
@ -339,13 +341,13 @@ const ReportTaskComments = ({
|
|||||||
<div
|
<div
|
||||||
className={` ${
|
className={` ${
|
||||||
actionAllow && !commentsData.approvedBy
|
actionAllow && !commentsData.approvedBy
|
||||||
? " d-flex justify-content-between"
|
? " d-flex justify-content-between align-items-center"
|
||||||
: "text-end"
|
: "text-end"
|
||||||
} mt-2`}
|
} mt-2`}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
className={`form-check ${
|
className={`form-check ${
|
||||||
!(actionAllow && !commentsData.approvedBy) && "d-none"
|
!(actionAllow && !commentsData.approvedBy && defaultCompletedTask > completed_Task ) && "d-none"
|
||||||
} `}
|
} `}
|
||||||
>
|
>
|
||||||
<input
|
<input
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import { zodResolver } from "@hookform/resolvers/zod";
|
|||||||
import { string, z } from "zod";
|
import { string, z } from "zod";
|
||||||
import {
|
import {
|
||||||
useActivitiesMaster,
|
useActivitiesMaster,
|
||||||
|
useServices,
|
||||||
useWorkCategoriesMaster,
|
useWorkCategoriesMaster,
|
||||||
} from "../../hooks/masterHook/useMaster";
|
} from "../../hooks/masterHook/useMaster";
|
||||||
import showToast from "../../services/toastService";
|
import showToast from "../../services/toastService";
|
||||||
@ -25,6 +26,8 @@ const SubTask = ({ activity, onClose }) => {
|
|||||||
const { activities, loading } = useActivitiesMaster();
|
const { activities, loading } = useActivitiesMaster();
|
||||||
const { categories, categoryLoading } = useWorkCategoriesMaster();
|
const { categories, categoryLoading } = useWorkCategoriesMaster();
|
||||||
const { Task, loading: TaskLoading } = useTaskById(activity?.id);
|
const { Task, loading: TaskLoading } = useTaskById(activity?.id);
|
||||||
|
const {data,isError,isLoading,error} = useServices();
|
||||||
|
|
||||||
const {
|
const {
|
||||||
register,
|
register,
|
||||||
handleSubmit,
|
handleSubmit,
|
||||||
@ -97,8 +100,8 @@ const SubTask = ({ activity, onClose }) => {
|
|||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
<div className="container-xxl my-1">
|
<div className="container-xxl my-1">
|
||||||
<p className="fw-semibold">Create Sub Task</p>
|
<p className="fw-semibold fs-5">Create Sub Task</p>
|
||||||
<form className="row g-2" onSubmit={handleSubmit(onSubmitForm)}>
|
<form className="row g-2 text-start" onSubmit={handleSubmit(onSubmitForm)}>
|
||||||
<div className="col-6">
|
<div className="col-6">
|
||||||
<label className="form-label">Building</label>
|
<label className="form-label">Building</label>
|
||||||
<input
|
<input
|
||||||
@ -128,26 +131,14 @@ const SubTask = ({ activity, onClose }) => {
|
|||||||
disabled
|
disabled
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
<div className="col-12">
|
||||||
<div className="col-12">
|
<label className="form-label">Service</label>
|
||||||
<label className="form-label">Work Category</label>
|
<input
|
||||||
<select
|
type="text"
|
||||||
className="form-select form-select-sm"
|
className="form-control form-control-sm"
|
||||||
{...register("workCategoryId")}
|
value={activity?.workItem?.activityMaster?.activityGroup?.service?.name || ""}
|
||||||
onChange={handleCategoryChange}
|
disabled
|
||||||
>
|
/>
|
||||||
<option value="">
|
|
||||||
{categoryLoading ? "Loading..." : "-- Select Category --"}
|
|
||||||
</option>
|
|
||||||
{categoryData.map((category) => (
|
|
||||||
<option key={category.id} value={category.id}>
|
|
||||||
{category.name}
|
|
||||||
</option>
|
|
||||||
))}
|
|
||||||
</select>
|
|
||||||
{errors.workCategoryId && (
|
|
||||||
<div className="danger-text">{errors.workCategoryId.message}</div>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
<div className="col-12">
|
<div className="col-12">
|
||||||
<label className="form-label">Select Activity</label>
|
<label className="form-label">Select Activity</label>
|
||||||
@ -172,6 +163,27 @@ const SubTask = ({ activity, onClose }) => {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div className="col-12">
|
||||||
|
<label className="form-label">Work Category</label>
|
||||||
|
<select
|
||||||
|
className="form-select form-select-sm"
|
||||||
|
{...register("workCategoryId")}
|
||||||
|
onChange={handleCategoryChange}
|
||||||
|
>
|
||||||
|
<option value="">
|
||||||
|
{categoryLoading ? "Loading..." : "-- Select Category --"}
|
||||||
|
</option>
|
||||||
|
{categoryData.map((category) => (
|
||||||
|
<option key={category.id} value={category.id}>
|
||||||
|
{category.name}
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
|
</select>
|
||||||
|
{errors.workCategoryId && (
|
||||||
|
<div className="danger-text">{errors.workCategoryId.message}</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
<div className="col-4">
|
<div className="col-4">
|
||||||
<label className="form-label">Planned Work</label>
|
<label className="form-label">Planned Work</label>
|
||||||
<input
|
<input
|
||||||
@ -219,7 +231,15 @@ const SubTask = ({ activity, onClose }) => {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="col-12 text-center">
|
<div className="d-flex flex-row gap-3 justify-content-end py-2">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="btn btn-sm btn-label-secondary"
|
||||||
|
onClick={() => onClose()}
|
||||||
|
disabled={isPending}
|
||||||
|
>
|
||||||
|
Cancel
|
||||||
|
</button>
|
||||||
<button
|
<button
|
||||||
type="submit"
|
type="submit"
|
||||||
className="btn btn-sm btn-primary me-2"
|
className="btn btn-sm btn-primary me-2"
|
||||||
@ -227,14 +247,7 @@ const SubTask = ({ activity, onClose }) => {
|
|||||||
>
|
>
|
||||||
{isPending ? "Please wait..." : "Submit"}
|
{isPending ? "Please wait..." : "Submit"}
|
||||||
</button>
|
</button>
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
className="btn btn-sm btn-secondary"
|
|
||||||
onClick={() => onClose()}
|
|
||||||
disabled={isPending}
|
|
||||||
>
|
|
||||||
Cancel
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -1,42 +0,0 @@
|
|||||||
import React, { createContext, useState, useContext } from "react";
|
|
||||||
import ChangePasswordPage from "../../pages/authentication/ChangePassword";
|
|
||||||
|
|
||||||
const ChangePasswordContext = createContext();
|
|
||||||
|
|
||||||
export const ChangePasswordProvider = ({ children }) => {
|
|
||||||
const [isChangePasswordOpen, setIsChangePasswordOpen] = useState(false);
|
|
||||||
|
|
||||||
const openChangePassword = () => setIsChangePasswordOpen(true);
|
|
||||||
const closeChangePassword = () => setIsChangePasswordOpen(false);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<ChangePasswordContext.Provider
|
|
||||||
value={{ isChangePasswordOpen, openChangePassword, closeChangePassword }}
|
|
||||||
>
|
|
||||||
{children}
|
|
||||||
|
|
||||||
{isChangePasswordOpen && (
|
|
||||||
<>
|
|
||||||
{/* This is the main Bootstrap modal container */}
|
|
||||||
{/* It provides the fixed positioning and high z-index */}
|
|
||||||
<div
|
|
||||||
className="modal fade show" // 'fade' for animation, 'show' to make it visible
|
|
||||||
style={{ display: 'block' }} // Explicitly set display: block for immediate visibility
|
|
||||||
tabIndex="-1" // Makes the modal focusable
|
|
||||||
role="dialog" // ARIA role for accessibility
|
|
||||||
aria-labelledby="changePasswordModalLabel" // Link to a heading for accessibility
|
|
||||||
aria-modal="true" // Indicate it's a modal dialog
|
|
||||||
>
|
|
||||||
{/* The ChangePasswordPage component itself contains the modal-dialog and modal-content */}
|
|
||||||
<ChangePasswordPage onClose={closeChangePassword} />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* The modal backdrop */}
|
|
||||||
<div className="modal-backdrop fade show"></div>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</ChangePasswordContext.Provider>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export const useChangePassword = () => useContext(ChangePasswordContext);
|
|
||||||
107
src/components/DailyProgressRport/TaskReportFilterPanel.jsx
Normal file
107
src/components/DailyProgressRport/TaskReportFilterPanel.jsx
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
import React, { useState } from "react";
|
||||||
|
import { useCurrentService } from "../../hooks/useProjects";
|
||||||
|
import { useSelectedProject } from "../../slices/apiDataManager";
|
||||||
|
import { FormProvider, useForm } from "react-hook-form";
|
||||||
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
|
import {
|
||||||
|
TaskReportDefaultValue,
|
||||||
|
TaskReportFilterSchema,
|
||||||
|
} from "./TaskRportScheam";
|
||||||
|
import { DateRangePicker1 } from "../common/DateRangePicker";
|
||||||
|
import SelectMultiple from "../common/SelectMultiple";
|
||||||
|
import { localToUtc } from "../../utils/appUtils";
|
||||||
|
import { useTaskFilter } from "../../hooks/useTasks";
|
||||||
|
|
||||||
|
const TaskReportFilterPanel = ({ handleFilter }) => {
|
||||||
|
const [resetKey, setResetKey] = useState(0);
|
||||||
|
const selectedProject = useSelectedProject();
|
||||||
|
const selectedService = useCurrentService();
|
||||||
|
const { data } = useTaskFilter(selectedProject);
|
||||||
|
|
||||||
|
const methods = useForm({
|
||||||
|
resolver: zodResolver(TaskReportFilterSchema),
|
||||||
|
defaultValues: TaskReportDefaultValue,
|
||||||
|
});
|
||||||
|
|
||||||
|
const {
|
||||||
|
register,
|
||||||
|
reset,
|
||||||
|
handleSubmit,
|
||||||
|
formState: { errors },
|
||||||
|
} = methods;
|
||||||
|
|
||||||
|
const onSubmit = (formData) => {
|
||||||
|
const filterPayload = {
|
||||||
|
...formData,
|
||||||
|
dateFrom: localToUtc(formData.dateFrom),
|
||||||
|
dateTo: localToUtc(formData.dateTo),
|
||||||
|
};
|
||||||
|
handleFilter(filterPayload);
|
||||||
|
};
|
||||||
|
|
||||||
|
const onClear = () => {
|
||||||
|
setResetKey((prev) => prev + 1);
|
||||||
|
handleFilter(TaskReportDefaultValue);
|
||||||
|
reset(TaskReportDefaultValue);
|
||||||
|
};
|
||||||
|
return (
|
||||||
|
<FormProvider {...methods}>
|
||||||
|
<form onSubmit={handleSubmit(onSubmit)} className="p-2 text-start">
|
||||||
|
<div className="mb-3 w-100">
|
||||||
|
<label className="fw-semibold">Choose Date Range:</label>
|
||||||
|
<DateRangePicker1
|
||||||
|
placeholder="DD-MM-YYYY To DD-MM-YYYY"
|
||||||
|
startField="dateFrom"
|
||||||
|
endField="dateTo"
|
||||||
|
resetSignal={resetKey}
|
||||||
|
defaultRange={false}
|
||||||
|
maxDate={new Date()}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="row mb-2">
|
||||||
|
<SelectMultiple
|
||||||
|
name="buildingIds"
|
||||||
|
label="Building"
|
||||||
|
options={data?.buildings}
|
||||||
|
labelKey="name"
|
||||||
|
valueKey="id"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="row mb-2">
|
||||||
|
<SelectMultiple
|
||||||
|
name="floorIds"
|
||||||
|
label="Floor"
|
||||||
|
options={data?.floors}
|
||||||
|
labelKey="name"
|
||||||
|
valueKey="id"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="row mb-2">
|
||||||
|
<SelectMultiple
|
||||||
|
name="activityIds"
|
||||||
|
label="Activities"
|
||||||
|
options={data?.activities}
|
||||||
|
labelKey="name"
|
||||||
|
valueKey="id"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="d-flex justify-content-end py-3 gap-2">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="btn btn-label-secondary btn-sm"
|
||||||
|
onClick={onClear}
|
||||||
|
>
|
||||||
|
Clear
|
||||||
|
</button>
|
||||||
|
<button type="submit" className="btn btn-primary btn-sm">
|
||||||
|
Apply
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</FormProvider>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default TaskReportFilterPanel;
|
||||||
301
src/components/DailyProgressRport/TaskReportList.jsx
Normal file
301
src/components/DailyProgressRport/TaskReportList.jsx
Normal file
@ -0,0 +1,301 @@
|
|||||||
|
import React, { useState, useEffect, useMemo } from "react";
|
||||||
|
import { useTaskList } from "../../hooks/useTasks";
|
||||||
|
import { useSelectedProject } from "../../slices/apiDataManager";
|
||||||
|
import { useProjectName } from "../../hooks/useProjects";
|
||||||
|
import DailyProgrssReport, {
|
||||||
|
useDailyProgrssContext,
|
||||||
|
} from "../../pages/DailyProgressReport/DailyProgrssReport";
|
||||||
|
import { useDispatch } from "react-redux";
|
||||||
|
import { setProjectId } from "../../slices/localVariablesSlice";
|
||||||
|
import {
|
||||||
|
APPROVE_TASK,
|
||||||
|
ASSIGN_REPORT_TASK,
|
||||||
|
ITEMS_PER_PAGE,
|
||||||
|
} from "../../utils/constants";
|
||||||
|
import { formatNumber, formatUTCToLocalTime } from "../../utils/dateUtils";
|
||||||
|
import { useHasUserPermission } from "../../hooks/useHasUserPermission";
|
||||||
|
import Pagination from "../common/Pagination";
|
||||||
|
import { TaskReportListSkeleton } from "./TaskRepprtListSkeleton";
|
||||||
|
import HoverPopup from "../common/HoverPopup";
|
||||||
|
|
||||||
|
const TaskReportList = () => {
|
||||||
|
const [currentPage, setCurrentPage] = useState(1);
|
||||||
|
const [filters, setFilters] = useState({
|
||||||
|
selectedBuilding: "",
|
||||||
|
selectedFloors: [],
|
||||||
|
selectedActivities: [],
|
||||||
|
});
|
||||||
|
const dispatch = useDispatch();
|
||||||
|
const ApprovedTaskRights = useHasUserPermission(APPROVE_TASK);
|
||||||
|
const ReportTaskRights = useHasUserPermission(ASSIGN_REPORT_TASK);
|
||||||
|
|
||||||
|
const { service, openModal, closeModal,filter } = useDailyProgrssContext();
|
||||||
|
const selectedProject = useSelectedProject();
|
||||||
|
const { projectNames } = useProjectName();
|
||||||
|
|
||||||
|
const { data, isLoading, isError, error } = useTaskList(
|
||||||
|
selectedProject,
|
||||||
|
ITEMS_PER_PAGE,
|
||||||
|
currentPage,
|
||||||
|
service,filter
|
||||||
|
);
|
||||||
|
|
||||||
|
const ProgrssReportColumn = [
|
||||||
|
{
|
||||||
|
key: "activity",
|
||||||
|
label: "Activity",
|
||||||
|
getValue: (task) => task.workItem.activityMaster?.activityName || "N/A",
|
||||||
|
align: "text-start",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "assigned",
|
||||||
|
label: "Total Assigned",
|
||||||
|
getValue: (task) => task.plannedTask ?? "N/A",
|
||||||
|
align: "text-start",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "completed",
|
||||||
|
label: "Completed",
|
||||||
|
getValue: (task) => task.completedTask ?? "N/A",
|
||||||
|
align: "text-start",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "assignAt",
|
||||||
|
label: "Assign Date",
|
||||||
|
getValue: (task) =>
|
||||||
|
task.assignmentDate ? formatUTCToLocalTime(task.assignmentDate) : "N/A",
|
||||||
|
align: "text-start",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "team",
|
||||||
|
label: "Team",
|
||||||
|
getValue: (task) =>
|
||||||
|
task.teamMembers?.map((m) => `${m.firstName} ${m.lastName}`).join(", ") ||
|
||||||
|
"N/A",
|
||||||
|
align: "text-start",
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
const paginate = (page) => {
|
||||||
|
if (page >= 1 && page <= (data?.totalPages ?? 1)) {
|
||||||
|
setCurrentPage(page);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!selectedProject && projectNames.length > 0) {
|
||||||
|
dispatch(setProjectId(projectNames[0].id));
|
||||||
|
}
|
||||||
|
}, [selectedProject, projectNames, dispatch]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setFilters({
|
||||||
|
selectedBuilding: "",
|
||||||
|
selectedFloors: [],
|
||||||
|
selectedActivities: [],
|
||||||
|
});
|
||||||
|
}, [selectedProject]);
|
||||||
|
|
||||||
|
// Filter and Group wise data
|
||||||
|
|
||||||
|
const filteredTasks = useMemo(() => {
|
||||||
|
if (!data?.data) return [];
|
||||||
|
return data?.data.filter((task) => {
|
||||||
|
const { selectedBuilding, selectedFloors, selectedActivities } = filters;
|
||||||
|
|
||||||
|
if (
|
||||||
|
selectedBuilding &&
|
||||||
|
task?.workItem?.workArea?.floor?.building?.name !== selectedBuilding
|
||||||
|
)
|
||||||
|
return false;
|
||||||
|
if (
|
||||||
|
selectedFloors.length > 0 &&
|
||||||
|
!selectedFloors.includes(task?.workItem?.workArea?.floor?.floorName)
|
||||||
|
)
|
||||||
|
return false;
|
||||||
|
if (
|
||||||
|
selectedActivities.length > 0 &&
|
||||||
|
!selectedActivities.includes(
|
||||||
|
task?.workItem?.activityMaster?.activityName
|
||||||
|
)
|
||||||
|
)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
}, [data?.data, filters, currentPage]);
|
||||||
|
|
||||||
|
const groupedTasks = useMemo(() => {
|
||||||
|
const groups = {};
|
||||||
|
filteredTasks.forEach((task) => {
|
||||||
|
const date = task.assignmentDate.split("T")[0];
|
||||||
|
if (!groups[date]) groups[date] = [];
|
||||||
|
groups[date].push(task);
|
||||||
|
});
|
||||||
|
return Object.keys(groups)
|
||||||
|
.sort((a, b) => new Date(b) - new Date(a))
|
||||||
|
.map((date) => ({ date, tasks: groups[date] }));
|
||||||
|
}, [filteredTasks, paginate, currentPage, selectedProject]);
|
||||||
|
|
||||||
|
const renderTeamMembers = (task, refIndex) => (
|
||||||
|
<div
|
||||||
|
key={refIndex}
|
||||||
|
tabIndex="0"
|
||||||
|
className="d-flex align-items-center avatar-group justify-content-center"
|
||||||
|
data-bs-toggle="popover"
|
||||||
|
data-bs-trigger="focus"
|
||||||
|
data-bs-placement="left"
|
||||||
|
data-bs-html="true"
|
||||||
|
data-bs-content={`
|
||||||
|
<div class="border border-secondary rounded custom-popover p-2 px-3">
|
||||||
|
${task.teamMembers
|
||||||
|
.map(
|
||||||
|
(m) => `
|
||||||
|
<div class="d-flex align-items-center gap-2 mb-2">
|
||||||
|
<div class="avatar avatar-xs">
|
||||||
|
<span class="avatar-initial rounded-circle bg-label-primary">
|
||||||
|
${m?.firstName?.charAt(0) || ""}${m?.lastName?.charAt(0) || ""
|
||||||
|
}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<span>${m.firstName} ${m.lastName}</span>
|
||||||
|
</div>`
|
||||||
|
)
|
||||||
|
.join("")}
|
||||||
|
</div>
|
||||||
|
`}
|
||||||
|
>
|
||||||
|
{task.teamMembers.slice(0, 3).map((m) => (
|
||||||
|
<div
|
||||||
|
key={m.id}
|
||||||
|
className="avatar avatar-xs"
|
||||||
|
title={`${m.firstName} ${m.lastName}`}
|
||||||
|
>
|
||||||
|
<span className="avatar-initial rounded-circle bg-label-primary">
|
||||||
|
{m?.firstName.slice(0, 1)}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
{task.teamMembers.length > 3 && (
|
||||||
|
<div
|
||||||
|
className="avatar avatar-xs"
|
||||||
|
title={`${task.teamMembers.length - 3} more`}
|
||||||
|
>
|
||||||
|
<span className="avatar-initial rounded-circle bg-label-secondary">
|
||||||
|
+{task.teamMembers.length - 3}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
|
if (isLoading) return <TaskReportListSkeleton />;
|
||||||
|
if (isError) return <div>Loading....</div>;
|
||||||
|
return (
|
||||||
|
<div className="mt-2 table-responsive text-nowrap">
|
||||||
|
<table className="table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th className="text-start">Activity</th>
|
||||||
|
<th>
|
||||||
|
<span>
|
||||||
|
Total Pending{" "}
|
||||||
|
<HoverPopup
|
||||||
|
title="Total Pending Task"
|
||||||
|
content={<p>This shows the total pending tasks for each activity on that date.</p>}
|
||||||
|
>
|
||||||
|
<i className="bx bx-xs ms-1 bx-info-circle cursor-pointer"></i>
|
||||||
|
</HoverPopup>
|
||||||
|
</span>
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
<span>
|
||||||
|
Reported/Planned{" "}
|
||||||
|
<HoverPopup
|
||||||
|
title="Reported and Planned Task"
|
||||||
|
content={<p>This shows the reported versus planned tasks for each activity on that date.</p>}
|
||||||
|
>
|
||||||
|
<i className="bx bx-xs ms-1 bx-info-circle cursor-pointer"></i>
|
||||||
|
</HoverPopup>
|
||||||
|
</span>
|
||||||
|
</th>
|
||||||
|
<th>Assign Date</th>
|
||||||
|
<th>Team</th>
|
||||||
|
<th className="text-center">Actions</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{groupedTasks.length === 0 && (
|
||||||
|
<tr>
|
||||||
|
<td colSpan={6} className="text-center align-middle" style={{ height: "200px", borderBottom: "none" }}>
|
||||||
|
No reports available
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{groupedTasks.map(({ date, tasks }) => (
|
||||||
|
<React.Fragment key={date}>
|
||||||
|
<tr className="table-row-header text-start">
|
||||||
|
<td colSpan={6}>
|
||||||
|
<strong>{formatUTCToLocalTime(date)}</strong>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{tasks.map((task, idx) => (
|
||||||
|
<tr key={task.id || idx}>
|
||||||
|
<td className="flex-wrap text-start">
|
||||||
|
<div>
|
||||||
|
{task.workItem.activityMaster?.activityName || "No Activity Name"}
|
||||||
|
</div>
|
||||||
|
<div className="text-sm py-2">
|
||||||
|
{task.workItem.workArea?.floor?.building?.name} ›{" "}
|
||||||
|
{task.workItem.workArea?.floor?.floorName} ›{" "}
|
||||||
|
{task.workItem.workArea?.areaName}
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{formatNumber(task.workItem.plannedWork)}
|
||||||
|
</td>
|
||||||
|
<td>{`${formatNumber(task.completedTask)} / ${formatNumber(task.plannedTask)}`}</td>
|
||||||
|
<td>{formatUTCToLocalTime(task.assignmentDate)}</td>
|
||||||
|
<td className="text-center">{renderTeamMembers(task, idx)}</td>
|
||||||
|
<td className="text-center">
|
||||||
|
<div className="d-flex justify-content-end gap-2">
|
||||||
|
{ReportTaskRights && !task.reportedDate && (
|
||||||
|
<button className="btn btn-xs btn-primary" onClick={() => openModal("report", task)}>
|
||||||
|
Report
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
{ApprovedTaskRights && task.reportedDate && !task.approvedBy && (
|
||||||
|
<button
|
||||||
|
className="btn btn-xs btn-warning"
|
||||||
|
onClick={() => openModal("comments", { task, isActionAllow: true })}
|
||||||
|
>
|
||||||
|
QC
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
<button
|
||||||
|
className="btn btn-xs btn-primary"
|
||||||
|
onClick={() => openModal("comments", { task, isActionAllow: false })}
|
||||||
|
>
|
||||||
|
Comment
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
))}
|
||||||
|
</React.Fragment>
|
||||||
|
))}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
{data?.data?.length > 0 && (
|
||||||
|
<Pagination
|
||||||
|
currentPage={currentPage}
|
||||||
|
totalPages={data.totalPages}
|
||||||
|
onPageChange={paginate}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default TaskReportList;
|
||||||
62
src/components/DailyProgressRport/TaskRepprtListSkeleton.jsx
Normal file
62
src/components/DailyProgressRport/TaskRepprtListSkeleton.jsx
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
|
||||||
|
const SkeletonLine = ({ height = 20, width = "100%", className = "" }) => (
|
||||||
|
<div
|
||||||
|
className={`skeleton mb-2 ${className}`}
|
||||||
|
style={{
|
||||||
|
height,
|
||||||
|
width,
|
||||||
|
}}
|
||||||
|
></div>
|
||||||
|
);
|
||||||
|
export const TaskReportListSkeleton = () => {
|
||||||
|
const skeletonRows = 8; // Number of placeholder rows
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<table className="table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Activity</th>
|
||||||
|
<th>Assigned</th>
|
||||||
|
<th>Completed</th>
|
||||||
|
<th>Assign On</th>
|
||||||
|
<th>Team</th>
|
||||||
|
<th>Actions</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{[...Array(skeletonRows)].map((_, idx) => (
|
||||||
|
<tr key={idx}>
|
||||||
|
<td>
|
||||||
|
<SkeletonLine height={16} width="70%" />
|
||||||
|
<SkeletonLine height={12} width="50%" />
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<SkeletonLine height={16} width="60%" />
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<SkeletonLine height={16} width="60%" />
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<SkeletonLine height={16} width="80%" />
|
||||||
|
</td>
|
||||||
|
<td className="text-center">
|
||||||
|
<div className="d-flex justify-content-center gap-1">
|
||||||
|
{[...Array(3)].map((_, i) => (
|
||||||
|
<SkeletonLine key={i} height={24} width={24} className="rounded-circle" />
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div className="d-flex justify-content-end gap-2">
|
||||||
|
<SkeletonLine height={24} width="60px" />
|
||||||
|
<SkeletonLine height={24} width="60px" />
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
))}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
17
src/components/DailyProgressRport/TaskRportScheam.jsx
Normal file
17
src/components/DailyProgressRport/TaskRportScheam.jsx
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
import { z } from "zod";
|
||||||
|
|
||||||
|
export const TaskReportFilterSchema = z.object({
|
||||||
|
buildingIds: z.array(z.string()).optional(),
|
||||||
|
floorIds: z.array(z.string()).optional(),
|
||||||
|
activityIds: z.array(z.string()).optional(),
|
||||||
|
dateFrom: z.string().optional(),
|
||||||
|
dateTo: z.string().optional(),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const TaskReportDefaultValue = {
|
||||||
|
buildingIds:[],
|
||||||
|
floorIds:[],
|
||||||
|
activityIds:[],
|
||||||
|
dateFrom:null,
|
||||||
|
dateTo:null
|
||||||
|
}
|
||||||
@ -1,194 +1,194 @@
|
|||||||
import React, { useState, useEffect } from "react";
|
// import React, { useState, useEffect } from "react";
|
||||||
import LineChart from "../Charts/LineChart";
|
// import LineChart from "../Charts/LineChart";
|
||||||
import { useProjects } from "../../hooks/useProjects";
|
// import { useProjects } from "../../hooks/useProjects";
|
||||||
import { useDashboard_ActivityData } from "../../hooks/useDashboard_Data";
|
// import { useDashboard_ActivityData } from "../../hooks/useDashboard_Data";
|
||||||
import ApexChart from "../Charts/Circlechart";
|
// import ApexChart from "../Charts/Circlechart";
|
||||||
|
|
||||||
const LOCAL_STORAGE_PROJECT_KEY = "selectedActivityProjectId";
|
// const LOCAL_STORAGE_PROJECT_KEY = "selectedActivityProjectId";
|
||||||
|
|
||||||
const Activity = () => {
|
// const Activity = () => {
|
||||||
const { projects } = useProjects();
|
// const { projects } = useProjects();
|
||||||
const today = new Date().toISOString().split("T")[0]; // Format: YYYY-MM-DD
|
// const today = new Date().toISOString().split("T")[0]; // Format: YYYY-MM-DD
|
||||||
const [selectedDate, setSelectedDate] = useState(today);
|
// const [selectedDate, setSelectedDate] = useState(today);
|
||||||
const storedProjectId = localStorage.getItem(LOCAL_STORAGE_PROJECT_KEY);
|
// const storedProjectId = localStorage.getItem(LOCAL_STORAGE_PROJECT_KEY);
|
||||||
const initialProjectId = storedProjectId || "all";
|
// const initialProjectId = storedProjectId || "all";
|
||||||
const [selectedProjectId, setSelectedProjectId] = useState(initialProjectId);
|
// const [selectedProjectId, setSelectedProjectId] = useState(initialProjectId);
|
||||||
const [displayedProjectName, setDisplayedProjectName] = useState("Select Project");
|
// const [displayedProjectName, setDisplayedProjectName] = useState("Select Project");
|
||||||
const [activeTab, setActiveTab] = useState("all");
|
// const [activeTab, setActiveTab] = useState("all");
|
||||||
|
|
||||||
const { dashboard_Activitydata: ActivityData, isLoading, error: isError } =
|
// const { dashboard_Activitydata: ActivityData, isLoading, error: isError } =
|
||||||
useDashboard_ActivityData(selectedDate, selectedProjectId);
|
// useDashboard_ActivityData(selectedDate, selectedProjectId);
|
||||||
|
|
||||||
useEffect(() => {
|
// useEffect(() => {
|
||||||
if (selectedProjectId === "all") {
|
// if (selectedProjectId === "all") {
|
||||||
setDisplayedProjectName("All Projects");
|
// setDisplayedProjectName("All Projects");
|
||||||
} else if (projects) {
|
// } else if (projects) {
|
||||||
const foundProject = projects.find((p) => p.id === selectedProjectId);
|
// const foundProject = projects.find((p) => p.id === selectedProjectId);
|
||||||
setDisplayedProjectName(foundProject ? foundProject.name : "Select Project");
|
// setDisplayedProjectName(foundProject ? foundProject.name : "Select Project");
|
||||||
} else {
|
// } else {
|
||||||
setDisplayedProjectName("Select Project");
|
// setDisplayedProjectName("Select Project");
|
||||||
}
|
// }
|
||||||
|
|
||||||
localStorage.setItem(LOCAL_STORAGE_PROJECT_KEY, selectedProjectId);
|
// localStorage.setItem(LOCAL_STORAGE_PROJECT_KEY, selectedProjectId);
|
||||||
}, [selectedProjectId, projects]);
|
// }, [selectedProjectId, projects]);
|
||||||
|
|
||||||
const handleProjectSelect = (projectId) => {
|
// const handleProjectSelect = (projectId) => {
|
||||||
setSelectedProjectId(projectId);
|
// setSelectedProjectId(projectId);
|
||||||
};
|
// };
|
||||||
|
|
||||||
const handleDateChange = (e) => {
|
// const handleDateChange = (e) => {
|
||||||
setSelectedDate(e.target.value);
|
// setSelectedDate(e.target.value);
|
||||||
};
|
// };
|
||||||
|
|
||||||
return (
|
// return (
|
||||||
<div className="card h-100">
|
// <div className="card h-100">
|
||||||
<div className="card-header">
|
// <div className="card-header">
|
||||||
<div className="d-flex flex-wrap justify-content-between align-items-center mb-0">
|
// <div className="d-flex flex-wrap justify-content-between align-items-center mb-0">
|
||||||
<div className="card-title mb-0 text-start">
|
// <div className="card-title mb-0 text-start">
|
||||||
<h5 className="mb-1">Activity</h5>
|
// <h5 className="mb-1">Activity</h5>
|
||||||
<p className="card-subtitle">Activity Progress Chart</p>
|
// <p className="card-subtitle text-primary">Activity Progress Chart</p>
|
||||||
</div>
|
// </div>
|
||||||
|
|
||||||
<div className="btn-group">
|
// <div className="btn-group">
|
||||||
<button
|
// <button
|
||||||
className="btn btn-outline-primary btn-sm dropdown-toggle"
|
// className="btn btn-outline-primary btn-sm dropdown-toggle"
|
||||||
type="button"
|
// type="button"
|
||||||
data-bs-toggle="dropdown"
|
// data-bs-toggle="dropdown"
|
||||||
aria-expanded="false"
|
// aria-expanded="false"
|
||||||
>
|
// >
|
||||||
{displayedProjectName}
|
// {displayedProjectName}
|
||||||
</button>
|
// </button>
|
||||||
<ul className="dropdown-menu">
|
// <ul className="dropdown-menu">
|
||||||
<li>
|
// <li>
|
||||||
<button className="dropdown-item" onClick={() => handleProjectSelect("all")}>
|
// <button className="dropdown-item" onClick={() => handleProjectSelect("all")}>
|
||||||
All Projects
|
// All Projects
|
||||||
</button>
|
// </button>
|
||||||
</li>
|
// </li>
|
||||||
{projects?.map((project) => (
|
// {projects?.map((project) => (
|
||||||
<li key={project.id}>
|
// <li key={project.id}>
|
||||||
<button
|
// <button
|
||||||
className="dropdown-item"
|
// className="dropdown-item"
|
||||||
onClick={() => handleProjectSelect(project.id)}
|
// onClick={() => handleProjectSelect(project.id)}
|
||||||
>
|
// >
|
||||||
{project.name}
|
// {project.name}
|
||||||
</button>
|
// </button>
|
||||||
</li>
|
// </li>
|
||||||
))}
|
// ))}
|
||||||
</ul>
|
// </ul>
|
||||||
</div>
|
// </div>
|
||||||
</div>
|
// </div>
|
||||||
</div>
|
// </div>
|
||||||
|
|
||||||
{/* ✅ Date Picker Aligned Left with Padding */}
|
// {/* ✅ Date Picker Aligned Left with Padding */}
|
||||||
<div className="d-flex justify-content-start ps-3 mb-3">
|
// <div className="d-flex justify-content-start ps-3 mb-3">
|
||||||
<div style={{ width: "150px" }}>
|
// <div style={{ width: "150px" }}>
|
||||||
<input
|
// <input
|
||||||
type="date"
|
// type="date"
|
||||||
className="form-control"
|
// className="form-control"
|
||||||
value={selectedDate}
|
// value={selectedDate}
|
||||||
onChange={handleDateChange}
|
// onChange={handleDateChange}
|
||||||
/>
|
// />
|
||||||
</div>
|
// </div>
|
||||||
</div>
|
// </div>
|
||||||
|
|
||||||
{/* Tabs */}
|
// {/* Tabs */}
|
||||||
<ul className="nav nav-tabs " role="tablist">
|
// <ul className="nav nav-tabs " role="tablist">
|
||||||
<li className="nav-item">
|
// <li className="nav-item">
|
||||||
<button
|
// <button
|
||||||
type="button"
|
// type="button"
|
||||||
className={`nav-link ${activeTab === "all" ? "active" : ""}`}
|
// className={`nav-link ${activeTab === "all" ? "active" : ""}`}
|
||||||
onClick={() => setActiveTab("all")}
|
// onClick={() => setActiveTab("all")}
|
||||||
data-bs-toggle="tab"
|
// data-bs-toggle="tab"
|
||||||
>
|
// >
|
||||||
Summary
|
// Summary
|
||||||
</button>
|
// </button>
|
||||||
</li>
|
// </li>
|
||||||
<li className="nav-item">
|
// <li className="nav-item">
|
||||||
<button
|
// <button
|
||||||
type="button"
|
// type="button"
|
||||||
className={`nav-link ${activeTab === "logs" ? "active" : ""}`}
|
// className={`nav-link ${activeTab === "logs" ? "active" : ""}`}
|
||||||
onClick={() => setActiveTab("logs")}
|
// onClick={() => setActiveTab("logs")}
|
||||||
data-bs-toggle="tab"
|
// data-bs-toggle="tab"
|
||||||
>
|
// >
|
||||||
Details
|
// Details
|
||||||
</button>
|
// </button>
|
||||||
</li>
|
// </li>
|
||||||
</ul>
|
// </ul>
|
||||||
|
|
||||||
<div className="card-body">
|
// <div className="card-body">
|
||||||
{activeTab === "all" && (
|
// {activeTab === "all" && (
|
||||||
<div className="row justify-content-between">
|
// <div className="row justify-content-between">
|
||||||
<div className="col-md-6 d-flex flex-column align-items-center text-center mb-4">
|
// <div className="col-md-6 d-flex flex-column align-items-center text-center mb-4">
|
||||||
{isLoading ? (
|
// {isLoading ? (
|
||||||
<p>Loading activity data...</p>
|
// <p>Loading activity data...</p>
|
||||||
) : isError ? (
|
// ) : isError ? (
|
||||||
<p>No data available.</p>
|
// <p>No data available.</p>
|
||||||
) : (
|
// ) : (
|
||||||
ActivityData && (
|
// ActivityData && (
|
||||||
<>
|
// <>
|
||||||
<h5 className="fw-bold mb-0 text-start w-80">
|
// <h5 className="fw-bold mb-0 text-start w-80">
|
||||||
<i className="bx bx-task text-info"></i> Allocated Task
|
// <i className="bx bx-task text-info"></i> Allocated Task
|
||||||
</h5>
|
// </h5>
|
||||||
<h4 className="mb-0 fw-bold">
|
// <h4 className="mb-0 fw-bold">
|
||||||
{ActivityData.totalCompletedWork?.toLocaleString()}/
|
// {ActivityData.totalCompletedWork?.toLocaleString()}/
|
||||||
{ActivityData.totalPlannedWork?.toLocaleString()}
|
// {ActivityData.totalPlannedWork?.toLocaleString()}
|
||||||
</h4>
|
// </h4>
|
||||||
<small className="text-muted">Completed / Assigned</small>
|
// <small className="text-muted">Completed / Assigned</small>
|
||||||
<div style={{ maxWidth: "180px" }}>
|
// <div style={{ maxWidth: "180px" }}>
|
||||||
<ApexChart />
|
// <ApexChart />
|
||||||
</div>
|
// </div>
|
||||||
</>
|
// </>
|
||||||
)
|
// )
|
||||||
)}
|
// )}
|
||||||
</div>
|
// </div>
|
||||||
|
|
||||||
<div className="col-md-6 d-flex flex-column align-items-center text-center mb-4">
|
// <div className="col-md-6 d-flex flex-column align-items-center text-center mb-4">
|
||||||
{!isLoading && !isError && ActivityData && (
|
// {!isLoading && !isError && ActivityData && (
|
||||||
<>
|
// <>
|
||||||
<h5 className="fw-bold mb-0 text-start w-110">
|
// <h5 className="fw-bold mb-0 text-start w-110">
|
||||||
<i className="bx bx-task text-info"></i> Activities
|
// <i className="bx bx-task text-info"></i> Activities
|
||||||
</h5>
|
// </h5>
|
||||||
<h4 className="mb-0 fw-bold">
|
// <h4 className="mb-0 fw-bold">
|
||||||
{ActivityData.totalCompletedWork?.toLocaleString()}/
|
// {ActivityData.totalCompletedWork?.toLocaleString()}/
|
||||||
{ActivityData.totalPlannedWork?.toLocaleString()}
|
// {ActivityData.totalPlannedWork?.toLocaleString()}
|
||||||
</h4>
|
// </h4>
|
||||||
<small className="text-muted ">Pending / Assigned</small>
|
// <small className="text-muted ">Pending / Assigned</small>
|
||||||
<div style={{ maxWidth: "180px" }}>
|
// <div style={{ maxWidth: "180px" }}>
|
||||||
<ApexChart />
|
// <ApexChart />
|
||||||
</div>
|
// </div>
|
||||||
</>
|
// </>
|
||||||
)}
|
// )}
|
||||||
</div>
|
// </div>
|
||||||
</div>
|
// </div>
|
||||||
)}
|
// )}
|
||||||
|
|
||||||
{activeTab === "logs" && (
|
// {activeTab === "logs" && (
|
||||||
<div className="table-responsive">
|
// <div className="table-responsive">
|
||||||
<table className="table table-bordered table-hover">
|
// <table className="table table-bordered table-hover">
|
||||||
<thead>
|
// <thead>
|
||||||
<tr>
|
// <tr>
|
||||||
<th>Activity / Location</th>
|
// <th>Activity / Location</th>
|
||||||
<th>Assigned / Completed</th>
|
// <th>Assigned / Completed</th>
|
||||||
</tr>
|
// </tr>
|
||||||
</thead>
|
// </thead>
|
||||||
<tbody>
|
// <tbody>
|
||||||
{[{
|
// {[{
|
||||||
activity: "Code Review / Remote",
|
// activity: "Code Review / Remote",
|
||||||
assignedToday: 3,
|
// assignedToday: 3,
|
||||||
completed: 2
|
// completed: 2
|
||||||
}].map((log, index) => (
|
// }].map((log, index) => (
|
||||||
<tr key={index}>
|
// <tr key={index}>
|
||||||
<td>{log.activity}</td>
|
// <td>{log.activity}</td>
|
||||||
<td>{log.assignedToday} / {log.completed}</td>
|
// <td>{log.assignedToday} / {log.completed}</td>
|
||||||
</tr>
|
// </tr>
|
||||||
))}
|
// ))}
|
||||||
</tbody>
|
// </tbody>
|
||||||
</table>
|
// </table>
|
||||||
</div>
|
// </div>
|
||||||
)}
|
// )}
|
||||||
</div>
|
// </div>
|
||||||
</div>
|
// </div>
|
||||||
);
|
// );
|
||||||
};
|
// };
|
||||||
|
|
||||||
export default Activity;
|
// export default Activity;
|
||||||
|
|||||||
@ -1,21 +1,16 @@
|
|||||||
import React, { useState, useEffect } from "react";
|
import React, { useState, useMemo } from "react";
|
||||||
import LineChart from "../Charts/LineChart";
|
import ApexChart from "../Charts/Circle";
|
||||||
import { useProjects } from "../../hooks/useProjects";
|
import { useProjects } from "../../hooks/useProjects";
|
||||||
import { useDashboard_AttendanceData } from "../../hooks/useDashboard_Data";
|
import { useDashboard_AttendanceData } from "../../hooks/useDashboard_Data";
|
||||||
import ApexChart from "../Charts/Circle";
|
import { useSelectedProject } from "../../hooks/useSelectedProject"; // ✅ your custom hook
|
||||||
|
|
||||||
const LOCAL_STORAGE_PROJECT_KEY = "selectedAttendanceProjectId";
|
|
||||||
|
|
||||||
const Attendance = () => {
|
const Attendance = () => {
|
||||||
const { projects } = useProjects();
|
const { projects } = useProjects();
|
||||||
const today = new Date().toISOString().split("T")[0]; // Format: YYYY-MM-DD
|
const today = new Date().toISOString().split("T")[0]; // YYYY-MM-DD
|
||||||
const [selectedDate, setSelectedDate] = useState(today);
|
const [selectedDate, setSelectedDate] = useState(today);
|
||||||
const storedProjectId = localStorage.getItem(LOCAL_STORAGE_PROJECT_KEY);
|
|
||||||
const initialProjectId = storedProjectId || "all";
|
// central project selection hook
|
||||||
const [selectedProjectId, setSelectedProjectId] = useState(initialProjectId);
|
const selectedProjectId = useSelectedProject()
|
||||||
const [displayedProjectName, setDisplayedProjectName] =
|
|
||||||
useState("Select Project");
|
|
||||||
const [activeTab, setActiveTab] = useState("Summary");
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
dashboard_Attendancedata: AttendanceData,
|
dashboard_Attendancedata: AttendanceData,
|
||||||
@ -23,38 +18,24 @@ const Attendance = () => {
|
|||||||
error: isError,
|
error: isError,
|
||||||
} = useDashboard_AttendanceData(selectedDate, selectedProjectId);
|
} = useDashboard_AttendanceData(selectedDate, selectedProjectId);
|
||||||
|
|
||||||
useEffect(() => {
|
// project name derived once
|
||||||
if (selectedProjectId === "all") {
|
const displayedProjectName = useMemo(() => {
|
||||||
setDisplayedProjectName("All Projects");
|
if (selectedProjectId === "all") return "All Projects";
|
||||||
} else if (projects) {
|
const found = projects?.find((p) => p.id === selectedProjectId);
|
||||||
const foundProject = projects.find((p) => p.id === selectedProjectId);
|
return found?.name || "Select Project";
|
||||||
setDisplayedProjectName(
|
|
||||||
foundProject ? foundProject.name : "Select Project"
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
setDisplayedProjectName("Select Project");
|
|
||||||
}
|
|
||||||
|
|
||||||
localStorage.setItem(LOCAL_STORAGE_PROJECT_KEY, selectedProjectId);
|
|
||||||
}, [selectedProjectId, projects]);
|
}, [selectedProjectId, projects]);
|
||||||
|
|
||||||
const handleProjectSelect = (projectId) => {
|
|
||||||
setSelectedProjectId(projectId);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleDateChange = (e) => {
|
|
||||||
setSelectedDate(e.target.value);
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="card h-100">
|
<div className="card h-100">
|
||||||
<div className="card-header mb-1 pb-0 ">
|
{/* Header */}
|
||||||
<div className="d-flex flex-wrap justify-content-between align-items-center mb-0 pb-0 ">
|
<div className="card-header mb-1 pb-0">
|
||||||
|
<div className="d-flex flex-wrap justify-content-between align-items-center">
|
||||||
<div className="card-title mb-0 text-start">
|
<div className="card-title mb-0 text-start">
|
||||||
<h5 className="mb-1">Attendance</h5>
|
<h5 className="mb-1">Attendance</h5>
|
||||||
<p className="card-subtitle">Daily Attendance Data</p>
|
<p className="card-subtitle">Daily Attendance Data</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{/* Project Dropdown */}
|
||||||
<div className="btn-group">
|
<div className="btn-group">
|
||||||
<button
|
<button
|
||||||
className="btn btn-outline-primary btn-sm dropdown-toggle"
|
className="btn btn-outline-primary btn-sm dropdown-toggle"
|
||||||
@ -68,7 +49,7 @@ const Attendance = () => {
|
|||||||
<li>
|
<li>
|
||||||
<button
|
<button
|
||||||
className="dropdown-item"
|
className="dropdown-item"
|
||||||
onClick={() => handleProjectSelect("all")}
|
onClick={() => setSelectedProjectId("all")}
|
||||||
>
|
>
|
||||||
All Projects
|
All Projects
|
||||||
</button>
|
</button>
|
||||||
@ -77,7 +58,7 @@ const Attendance = () => {
|
|||||||
<li key={project.id}>
|
<li key={project.id}>
|
||||||
<button
|
<button
|
||||||
className="dropdown-item"
|
className="dropdown-item"
|
||||||
onClick={() => handleProjectSelect(project.id)}
|
onClick={() => setSelectedProjectId(project.id)}
|
||||||
>
|
>
|
||||||
{project.name}
|
{project.name}
|
||||||
</button>
|
</button>
|
||||||
@ -88,52 +69,43 @@ const Attendance = () => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="d-flex flex-wrap justify-content-between align-items-center mb-0 mt-0 me-5 ms-5">
|
{/* Tabs + Date Picker */}
|
||||||
{/* Tabs */}
|
<div className="d-flex flex-wrap justify-content-between align-items-center me-5 ms-5">
|
||||||
<div>
|
<ul className="nav nav-tabs">
|
||||||
<ul className="nav nav-tabs " role="tablist">
|
<li className="nav-item">
|
||||||
<li className="nav-item">
|
<button
|
||||||
<button
|
type="button"
|
||||||
type="button"
|
className={`nav-link ${AttendanceData?.activeTab === "Summary" ? "active" : ""}`}
|
||||||
className={`nav-link ${
|
onClick={() => (AttendanceData.activeTab = "Summary")}
|
||||||
activeTab === "Summary" ? "active" : ""
|
>
|
||||||
}`}
|
Summary
|
||||||
onClick={() => setActiveTab("Summary")}
|
</button>
|
||||||
data-bs-toggle="tab"
|
</li>
|
||||||
>
|
<li className="nav-item">
|
||||||
Summary
|
<button
|
||||||
</button>
|
type="button"
|
||||||
</li>
|
className={`nav-link ${AttendanceData?.activeTab === "Details" ? "active" : ""}`}
|
||||||
<li className="nav-item">
|
onClick={() => (AttendanceData.activeTab = "Details")}
|
||||||
<button
|
>
|
||||||
type="button"
|
Details
|
||||||
className={`nav-link ${
|
</button>
|
||||||
activeTab === "Details" ? "active" : ""
|
</li>
|
||||||
}`}
|
</ul>
|
||||||
onClick={() => setActiveTab("Details")}
|
<div className="ps-6 mb-3">
|
||||||
data-bs-toggle="tab"
|
<input
|
||||||
>
|
type="date"
|
||||||
Details
|
className="form-control p-1"
|
||||||
</button>
|
style={{ width: "120px" }}
|
||||||
</li>
|
value={selectedDate}
|
||||||
</ul>
|
onChange={(e) => setSelectedDate(e.target.value)}
|
||||||
</div>
|
/>
|
||||||
{/* ✅ Date Picker Aligned Left with Padding */}
|
|
||||||
<div className="ps-6 mb-3 mt-0">
|
|
||||||
<div style={{ width: "120px" }}>
|
|
||||||
<input
|
|
||||||
type="date"
|
|
||||||
className="form-control p-1"
|
|
||||||
// style={{ fontSize: "1rem" }}
|
|
||||||
value={selectedDate}
|
|
||||||
onChange={handleDateChange}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{/* Body */}
|
||||||
<div className="card-body">
|
<div className="card-body">
|
||||||
{activeTab === "Summary" && (
|
{/* Summary */}
|
||||||
|
{AttendanceData?.activeTab === "Summary" && (
|
||||||
<div className="row justify-content-center">
|
<div className="row justify-content-center">
|
||||||
<div className="col-12 col-md-6 d-flex flex-column align-items-center text-center mb-4">
|
<div className="col-12 col-md-6 d-flex flex-column align-items-center text-center mb-4">
|
||||||
{isLoading ? (
|
{isLoading ? (
|
||||||
@ -143,7 +115,7 @@ const Attendance = () => {
|
|||||||
) : (
|
) : (
|
||||||
AttendanceData && (
|
AttendanceData && (
|
||||||
<>
|
<>
|
||||||
<h5 className="fw-bold mb-0 text-center w-100">
|
<h5 className="fw-bold mb-0">
|
||||||
<i className="bx bx-task text-info"></i> Attendance
|
<i className="bx bx-task text-info"></i> Attendance
|
||||||
</h5>
|
</h5>
|
||||||
<h4 className="mb-0 fw-bold">
|
<h4 className="mb-0 fw-bold">
|
||||||
@ -164,11 +136,9 @@ const Attendance = () => {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{activeTab === "Details" && (
|
{/* Details */}
|
||||||
<div
|
{AttendanceData?.activeTab === "Details" && (
|
||||||
className="table-responsive"
|
<div className="table-responsive" style={{ maxHeight: "300px" }}>
|
||||||
style={{ maxHeight: "300px", overflowY: "auto" }}
|
|
||||||
>
|
|
||||||
<table className="table table-hover mb-0 text-start">
|
<table className="table table-hover mb-0 text-start">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@ -178,32 +148,17 @@ const Attendance = () => {
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{AttendanceData?.attendanceTable &&
|
{AttendanceData?.attendanceTable?.length ? (
|
||||||
AttendanceData.attendanceTable.length > 0 ? (
|
AttendanceData.attendanceTable.map((r, i) => (
|
||||||
AttendanceData.attendanceTable.map((record, index) => (
|
<tr key={i}>
|
||||||
<tr key={index}>
|
<td>{r.firstName} {r.lastName}</td>
|
||||||
<td>
|
<td>{r.inTime ? new Date(r.inTime).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }) : "-"}</td>
|
||||||
{record.firstName} {record.lastName}
|
<td>{r.outTime ? new Date(r.outTime).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }) : "-"}</td>
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
{new Date(record.inTime).toLocaleTimeString([], {
|
|
||||||
hour: "2-digit",
|
|
||||||
minute: "2-digit",
|
|
||||||
})}
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
{new Date(record.outTime).toLocaleTimeString([], {
|
|
||||||
hour: "2-digit",
|
|
||||||
minute: "2-digit",
|
|
||||||
})}
|
|
||||||
</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
))
|
))
|
||||||
) : (
|
) : (
|
||||||
<tr>
|
<tr>
|
||||||
<td colSpan="3" className="text-center">
|
<td colSpan="3" className="text-center">No attendance data available</td>
|
||||||
No attendance data available
|
|
||||||
</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
)}
|
)}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
@ -132,7 +132,7 @@ const AttendanceOverview = () => {
|
|||||||
onClick={() => setView("table")}
|
onClick={() => setView("table")}
|
||||||
title="Table View"
|
title="Table View"
|
||||||
>
|
>
|
||||||
<i class="bx bx-list-ul fs-5"></i>
|
<i className="bx bx-list-ul fs-5"></i>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -1,33 +1,28 @@
|
|||||||
import React, { useCallback, useEffect, useState } from "react";
|
import React, { useEffect } from "react";
|
||||||
import { useDashboardProjectsCardData } from "../../hooks/useDashboard_Data";
|
import { useDashboardProjectsCardData } from "../../hooks/useDashboard_Data";
|
||||||
import eventBus from "../../services/eventBus";
|
import eventBus from "../../services/eventBus";
|
||||||
import GlobalRepository from "../../repositories/GlobalRepository";
|
|
||||||
|
|
||||||
const Projects = () => {
|
const Projects = () => {
|
||||||
const { projectsCardData } = useDashboardProjectsCardData();
|
const {
|
||||||
const [projectData, setProjectsData] = useState(projectsCardData);
|
data: projectsCardData,
|
||||||
|
isLoading,
|
||||||
|
isError,
|
||||||
|
error,
|
||||||
|
refetch,
|
||||||
|
} = useDashboardProjectsCardData();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setProjectsData(projectsCardData);
|
// When "project" event happens, just refetch
|
||||||
}, [projectsCardData]);
|
const handler = () => {
|
||||||
|
refetch();
|
||||||
|
};
|
||||||
|
|
||||||
const handler = useCallback(
|
|
||||||
async (msg) => {
|
|
||||||
try {
|
|
||||||
const response =
|
|
||||||
await GlobalRepository.getDashboardProjectsCardData();
|
|
||||||
setProjectsData(response.data);
|
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
[GlobalRepository]
|
|
||||||
);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
eventBus.on("project", handler);
|
eventBus.on("project", handler);
|
||||||
return () => eventBus.off("project", handler);
|
return () => eventBus.off("project", handler);
|
||||||
}, [handler]);
|
}, [refetch]);
|
||||||
|
|
||||||
|
const totalProjects = projectsCardData?.totalProjects ?? 0;
|
||||||
|
const ongoingProjects = projectsCardData?.ongoingProjects ?? 0;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="card p-3 h-100 text-center d-flex justify-content-between">
|
<div className="card p-3 h-100 text-center d-flex justify-content-between">
|
||||||
@ -37,20 +32,29 @@ const Projects = () => {
|
|||||||
Projects
|
Projects
|
||||||
</h5>
|
</h5>
|
||||||
</div>
|
</div>
|
||||||
<div className="d-flex justify-content-around align-items-start mt-n2">
|
|
||||||
<div>
|
{isLoading ? (
|
||||||
<h4 className="mb-0 fw-bold">
|
<div className="d-flex justify-content-center align-items-center flex-grow-1">
|
||||||
{projectData.totalProjects?.toLocaleString()}
|
<div className="spinner-border text-primary" role="status">
|
||||||
</h4>
|
<span className="visually-hidden">Loading...</span>
|
||||||
<small className="text-muted">Total</small>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
) : isError ? (
|
||||||
<h4 className="mb-0 fw-bold">
|
<div className="text-danger flex-grow-1 d-flex justify-content-center align-items-center">
|
||||||
{projectData.ongoingProjects?.toLocaleString()}
|
{error?.message || "Error loading data"}
|
||||||
</h4>
|
|
||||||
<small className="text-muted">Ongoing</small>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
) : (
|
||||||
|
<div className="d-flex justify-content-around align-items-start mt-n2">
|
||||||
|
<div>
|
||||||
|
<h4 className="mb-0 fw-bold">{totalProjects.toLocaleString()}</h4>
|
||||||
|
<small className="text-muted">Total</small>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<h4 className="mb-0 fw-bold">{ongoingProjects.toLocaleString()}</h4>
|
||||||
|
<small className="text-muted">Ongoing</small>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,10 +1,16 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { useSelector } from "react-redux";
|
import { useSelectedProject } from "../../slices/apiDataManager";
|
||||||
import { useDashboardTasksCardData } from "../../hooks/useDashboard_Data";
|
import { useDashboardTasksCardData } from "../../hooks/useDashboard_Data";
|
||||||
|
|
||||||
const TasksCard = () => {
|
const TasksCard = () => {
|
||||||
const projectId = useSelector((store) => store.localVariables?.projectId);
|
const projectId = useSelectedProject();
|
||||||
const { tasksCardData, loading, error } = useDashboardTasksCardData(projectId);
|
|
||||||
|
const {
|
||||||
|
data: tasksCardData,
|
||||||
|
isLoading,
|
||||||
|
isError,
|
||||||
|
error,
|
||||||
|
} = useDashboardTasksCardData(projectId);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="card p-3 h-100 text-center d-flex justify-content-between">
|
<div className="card p-3 h-100 text-center d-flex justify-content-between">
|
||||||
@ -14,28 +20,30 @@ const TasksCard = () => {
|
|||||||
</h5>
|
</h5>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{loading ? (
|
{isLoading ? (
|
||||||
// Loader will be displayed when loading is true
|
// Loader while fetching
|
||||||
<div className="d-flex justify-content-center align-items-center flex-grow-1">
|
<div className="d-flex justify-content-center align-items-center flex-grow-1">
|
||||||
<div className="spinner-border text-primary" role="status">
|
<div className="spinner-border text-primary" role="status">
|
||||||
<span className="visually-hidden">Loading...</span>
|
<span className="visually-hidden">Loading...</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
) : error ? (
|
) : isError ? (
|
||||||
// Error message if there's an error
|
// Show error
|
||||||
<div className="text-danger flex-grow-1 d-flex justify-content-center align-items-center">{error}</div>
|
<div className="text-danger flex-grow-1 d-flex justify-content-center align-items-center">
|
||||||
|
{error?.message || "Error loading data"}
|
||||||
|
</div>
|
||||||
) : (
|
) : (
|
||||||
// Actual data when loaded successfully
|
// Show data
|
||||||
<div className="d-flex justify-content-around align-items-start mt-n2">
|
<div className="d-flex justify-content-around align-items-start mt-n2">
|
||||||
<div>
|
<div>
|
||||||
<h4 className="mb-0 fw-bold">
|
<h4 className="mb-0 fw-bold">
|
||||||
{tasksCardData?.totalTasks?.toLocaleString()}
|
{tasksCardData?.totalTasks?.toLocaleString() ?? 0}
|
||||||
</h4>
|
</h4>
|
||||||
<small className="text-muted">Total</small>
|
<small className="text-muted">Total</small>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<h4 className="mb-0 fw-bold">
|
<h4 className="mb-0 fw-bold">
|
||||||
{tasksCardData?.completedTasks?.toLocaleString()}
|
{tasksCardData?.completedTasks?.toLocaleString() ?? 0}
|
||||||
</h4>
|
</h4>
|
||||||
<small className="text-muted">Completed</small>
|
<small className="text-muted">Completed</small>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -1,33 +1,45 @@
|
|||||||
import React, { useCallback, useEffect, useState } from "react";
|
import React, { useCallback, useEffect } from "react";
|
||||||
import { useSelector } from "react-redux";
|
import { useSelector } from "react-redux";
|
||||||
import { useDashboardTeamsCardData } from "../../hooks/useDashboard_Data";
|
import { useDashboardTeamsCardData } from "../../hooks/useDashboard_Data";
|
||||||
import eventBus from "../../services/eventBus";
|
import eventBus from "../../services/eventBus";
|
||||||
|
import { useQueryClient } from "@tanstack/react-query";
|
||||||
|
import { useSelectedProject } from "../../slices/apiDataManager";
|
||||||
|
|
||||||
const Teams = () => {
|
const Teams = () => {
|
||||||
const projectId = useSelector((store) => store.localVariables?.projectId);
|
const queryClient = useQueryClient();
|
||||||
const { teamsCardData, loading, error } = useDashboardTeamsCardData(projectId);
|
const projectId = useSelectedProject()
|
||||||
|
|
||||||
const [totalEmployees, setTotalEmployee] = useState(0);
|
const {
|
||||||
const [inToday, setInToday] = useState(0);
|
data: teamsCardData,
|
||||||
|
isLoading,
|
||||||
// Update state when API data arrives
|
isError,
|
||||||
useEffect(() => {
|
error,
|
||||||
setTotalEmployee(teamsCardData?.totalEmployees || 0);
|
} = useDashboardTeamsCardData(projectId);
|
||||||
setInToday(teamsCardData?.inToday || 0);
|
|
||||||
}, [teamsCardData]);
|
|
||||||
|
|
||||||
// Handle real-time updates via eventBus
|
// Handle real-time updates via eventBus
|
||||||
const handler = useCallback((msg) => {
|
const handler = useCallback(
|
||||||
if (msg.activity === 1) {
|
(msg) => {
|
||||||
setInToday((prev) => prev + 1);
|
if (msg.activity === 1) {
|
||||||
}
|
queryClient.setQueryData(["dashboardTeams", projectId], (old) => {
|
||||||
}, []);
|
if (!old) return old;
|
||||||
|
return {
|
||||||
|
...old,
|
||||||
|
inToday: (old.inToday || 0) + 1,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[queryClient, projectId]
|
||||||
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
eventBus.on("attendance", handler);
|
eventBus.on("attendance", handler);
|
||||||
return () => eventBus.off("attendance", handler);
|
return () => eventBus.off("attendance", handler);
|
||||||
}, [handler]);
|
}, [handler]);
|
||||||
|
|
||||||
|
const inToday = teamsCardData?.inToday ?? 0;
|
||||||
|
const totalEmployees = teamsCardData?.totalEmployees ?? 0;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="card p-3 h-100 text-center d-flex justify-content-between">
|
<div className="card p-3 h-100 text-center d-flex justify-content-between">
|
||||||
<div className="d-flex justify-content-start align-items-center mb-3">
|
<div className="d-flex justify-content-start align-items-center mb-3">
|
||||||
@ -36,18 +48,17 @@ const Teams = () => {
|
|||||||
</h5>
|
</h5>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{loading ? (
|
{isLoading ? (
|
||||||
// Blue spinner loader
|
|
||||||
<div className="d-flex justify-content-center align-items-center flex-grow-1">
|
<div className="d-flex justify-content-center align-items-center flex-grow-1">
|
||||||
<div className="spinner-border text-primary" role="status">
|
<div className="spinner-border text-primary" role="status">
|
||||||
<span className="visually-hidden">Loading...</span>
|
<span className="visually-hidden">Loading...</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
) : error ? (
|
) : isError ? (
|
||||||
// Error message if data fetching fails
|
<div className="text-danger flex-grow-1 d-flex justify-content-center align-items-center">
|
||||||
<div className="text-danger flex-grow-1 d-flex justify-content-center align-items-center">{error}</div>
|
{error?.message || "Error loading data"}
|
||||||
|
</div>
|
||||||
) : (
|
) : (
|
||||||
// Display data once loaded
|
|
||||||
<div className="d-flex justify-content-around align-items-start mt-n2">
|
<div className="d-flex justify-content-around align-items-start mt-n2">
|
||||||
<div>
|
<div>
|
||||||
<h4 className="mb-0 fw-bold">{totalEmployees.toLocaleString()}</h4>
|
<h4 className="mb-0 fw-bold">{totalEmployees.toLocaleString()}</h4>
|
||||||
|
|||||||
@ -179,7 +179,7 @@ const ListViewContact = ({ data, Pagination }) => {
|
|||||||
<tr style={{ height: "200px" }}>
|
<tr style={{ height: "200px" }}>
|
||||||
<td
|
<td
|
||||||
colSpan={contactList.length + 1}
|
colSpan={contactList.length + 1}
|
||||||
className="text-center align-middle"
|
className="text-center border-0 align-middle"
|
||||||
>
|
>
|
||||||
No contacts found
|
No contacts found
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
@ -23,7 +23,6 @@ const ManageBucket1 = () => {
|
|||||||
const handleClose = () => {
|
const handleClose = () => {
|
||||||
setAction(null);
|
setAction(null);
|
||||||
setSelectedBucket(null);
|
setSelectedBucket(null);
|
||||||
setDeleteId(null);
|
|
||||||
};
|
};
|
||||||
const { mutate: createBucket, isPending: creating } = useCreateBucket(() => {
|
const { mutate: createBucket, isPending: creating } = useCreateBucket(() => {
|
||||||
handleClose();
|
handleClose();
|
||||||
@ -49,23 +48,26 @@ const ManageBucket1 = () => {
|
|||||||
<p className="fs-5 fw-semibold m-0">Manage Buckets</p>
|
<p className="fs-5 fw-semibold m-0">Manage Buckets</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{action == "create" ? (
|
{action ? (
|
||||||
<>
|
<>
|
||||||
<BucketForm
|
{action && (
|
||||||
selectedBucket={selectedBucket}
|
<div>
|
||||||
mode={action} // pass create | edit
|
<BucketForm
|
||||||
onSubmit={handleSubmit}
|
selectedBucket={selectedBucket}
|
||||||
onCancel={() => {
|
mode={action} // pass create | edit
|
||||||
setAction(null);
|
onSubmit={handleSubmit}
|
||||||
setSelectedBucket(null);
|
onCancel={() => {
|
||||||
}}
|
setAction(null);
|
||||||
isPending={creating || updating}
|
setSelectedBucket(null);
|
||||||
/>
|
}}
|
||||||
{action === "edit" && selectedBucket && (
|
isPending={creating || updating}
|
||||||
<AssignedBucket
|
/>
|
||||||
selectedBucket={selectedBucket}
|
{action === "edit" && (
|
||||||
handleClose={handleClose}
|
<AssignedBucket
|
||||||
/>
|
selectedBucket={selectedBucket}
|
||||||
|
handleClose={handleClose}
|
||||||
|
/>)}
|
||||||
|
</div>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
@ -91,11 +93,19 @@ const ManageBucket1 = () => {
|
|||||||
buckets={data}
|
buckets={data}
|
||||||
loading={isLoading}
|
loading={isLoading}
|
||||||
searchTerm={searchTerm}
|
searchTerm={searchTerm}
|
||||||
onDelete={(id) => setDeleteBucket({isOpen:true,bucketId:id})}
|
onDelete={(id) => setDeleteBucket({ isOpen: true, bucketId: id })}
|
||||||
|
onEdit={(b) => {
|
||||||
|
setAction("edit")
|
||||||
|
setSelectedBucket(b)
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
export default ManageBucket1;
|
export default ManageBucket1;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -23,7 +23,7 @@ import Label from "../common/Label";
|
|||||||
const ManageContact = ({ contactId, closeModal }) => {
|
const ManageContact = ({ contactId, closeModal }) => {
|
||||||
// fetch master data
|
// fetch master data
|
||||||
const { buckets, loading: bucketsLoaging } = useBuckets();
|
const { buckets, loading: bucketsLoaging } = useBuckets();
|
||||||
const { projects, loading: projectLoading } = useProjects();
|
const { data:projects, loading: projectLoading } = useProjects();
|
||||||
const { contactCategory, loading: contactCategoryLoading } =
|
const { contactCategory, loading: contactCategoryLoading } =
|
||||||
useContactCategory();
|
useContactCategory();
|
||||||
const { organizationList } = useOrganization();
|
const { organizationList } = useOrganization();
|
||||||
|
|||||||
@ -96,7 +96,7 @@ const DocumentFilterPanel = ({ entityTypeId, onApply }) => {
|
|||||||
placeholder="DD-MM-YYYY To DD-MM-YYYY"
|
placeholder="DD-MM-YYYY To DD-MM-YYYY"
|
||||||
startField="startDate"
|
startField="startDate"
|
||||||
endField="endDate"
|
endField="endDate"
|
||||||
defaultRange={true}
|
defaultRange={false}
|
||||||
resetSignal={resetKey}
|
resetSignal={resetKey}
|
||||||
maxDate={new Date()}
|
maxDate={new Date()}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@ -118,7 +118,7 @@ const Documents = ({ Document_Entity, Entity }) => {
|
|||||||
return (
|
return (
|
||||||
<DocumentContext.Provider value={contextValues}>
|
<DocumentContext.Provider value={contextValues}>
|
||||||
<div className="mt-5">
|
<div className="mt-5">
|
||||||
<div className="card d-flex p-2">
|
<div className="card page-min-h d-flex p-2">
|
||||||
<div className="row align-items-center">
|
<div className="row align-items-center">
|
||||||
{/* Search */}
|
{/* Search */}
|
||||||
<div className="d-flex col-8 col-md-8 col-lg-4 mb-md-0 align-items-center">
|
<div className="d-flex col-8 col-md-8 col-lg-4 mb-md-0 align-items-center">
|
||||||
@ -149,30 +149,11 @@ const Documents = ({ Document_Entity, Entity }) => {
|
|||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Actions */}
|
|
||||||
<div className="col-6 col-md-6 col-lg-8 text-end">
|
<div className="col-6 col-md-6 col-lg-8 text-end">
|
||||||
{/* <span
|
|
||||||
className="text-tiny text-muted p-1 border-0 bg-none lead mx-3 cursor-pointer"
|
|
||||||
disabled={isRefetching}
|
|
||||||
onClick={() => {
|
|
||||||
setSearchText("");
|
|
||||||
setFilter(DocumentFilterDefaultValues);
|
|
||||||
refetchFn && refetchFn();
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Refresh
|
|
||||||
<i
|
|
||||||
className={`bx bx-refresh ms-1 ${
|
|
||||||
isRefetching ? "bx-spin" : ""
|
|
||||||
}`}
|
|
||||||
></i>
|
|
||||||
</span> */}
|
|
||||||
|
|
||||||
{(isSelf || canUploadDocument) && (
|
{(isSelf || canUploadDocument) && (
|
||||||
<button
|
<button
|
||||||
|
className="btn btn-sm btn-primary me-3"
|
||||||
type="button"
|
type="button"
|
||||||
title="Add New Document"
|
|
||||||
className="p-1 bg-primary rounded-circle cursor-pointer"
|
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
setManageDoc({
|
setManageDoc({
|
||||||
document: null,
|
document: null,
|
||||||
@ -180,7 +161,10 @@ const Documents = ({ Document_Entity, Entity }) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<i className="bx bx-plus fs-4 text-white"></i>
|
<i className="bx bx-plus-circle me-2"></i>
|
||||||
|
<span className="d-none d-md-inline-block">
|
||||||
|
Add New Document
|
||||||
|
</span>
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -1,172 +0,0 @@
|
|||||||
import React from "react";
|
|
||||||
|
|
||||||
const DemoTable = () => {
|
|
||||||
return (
|
|
||||||
<div className="content-wrapper">
|
|
||||||
<div className="container-fluid">
|
|
||||||
<div className="card">
|
|
||||||
<div className="card-datatable table-responsive">
|
|
||||||
<table className="datatables-basic table border-top">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th></th>
|
|
||||||
<th></th>
|
|
||||||
<th>id</th>
|
|
||||||
<th>Name</th>
|
|
||||||
<th>Email</th>
|
|
||||||
<th>Date</th>
|
|
||||||
<th>Salary</th>
|
|
||||||
<th>Status</th>
|
|
||||||
<th>Action</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="offcanvas offcanvas-end" id="add-new-record">
|
|
||||||
<div className="offcanvas-header border-bottom">
|
|
||||||
<h5 className="offcanvas-title" id="exampleModalLabel">
|
|
||||||
New Record
|
|
||||||
</h5>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
className="btn-close text-reset"
|
|
||||||
data-bs-dismiss="offcanvas"
|
|
||||||
aria-label="Close"
|
|
||||||
></button>
|
|
||||||
</div>
|
|
||||||
<div className="offcanvas-body flex-grow-1">
|
|
||||||
<form
|
|
||||||
className="add-new-record pt-0 row g-2"
|
|
||||||
id="form-add-new-record"
|
|
||||||
onsubmit="return false"
|
|
||||||
>
|
|
||||||
<div className="col-sm-12">
|
|
||||||
<label className="form-label" for="basicFullname">
|
|
||||||
Full Name
|
|
||||||
</label>
|
|
||||||
<div className="input-group input-group-merge">
|
|
||||||
<span id="basicFullname2" className="input-group-text">
|
|
||||||
<i className="bx bx-user"></i>
|
|
||||||
</span>
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
id="basicFullname"
|
|
||||||
className="form-control dt-full-name"
|
|
||||||
name="basicFullname"
|
|
||||||
placeholder="John Doe"
|
|
||||||
aria-label="John Doe"
|
|
||||||
aria-describedby="basicFullname2"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="col-sm-12">
|
|
||||||
<label className="form-label" for="basicPost">
|
|
||||||
Post
|
|
||||||
</label>
|
|
||||||
<div className="input-group input-group-merge">
|
|
||||||
<span id="basicPost2" className="input-group-text">
|
|
||||||
<i className="bx bxs-briefcase"></i>
|
|
||||||
</span>
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
id="basicPost"
|
|
||||||
name="basicPost"
|
|
||||||
className="form-control dt-post"
|
|
||||||
placeholder="Web Developer"
|
|
||||||
aria-label="Web Developer"
|
|
||||||
aria-describedby="basicPost2"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="col-sm-12">
|
|
||||||
<label className="form-label" for="basicEmail">
|
|
||||||
Email
|
|
||||||
</label>
|
|
||||||
<div className="input-group input-group-merge">
|
|
||||||
<span className="input-group-text">
|
|
||||||
<i className="bx bx-envelope"></i>
|
|
||||||
</span>
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
id="basicEmail"
|
|
||||||
name="basicEmail"
|
|
||||||
className="form-control dt-email"
|
|
||||||
placeholder="john.doe@example.com"
|
|
||||||
aria-label="john.doe@example.com"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div className="form-text">
|
|
||||||
You can use letters, numbers & periods
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="col-sm-12">
|
|
||||||
<label className="form-label" for="basicDate">
|
|
||||||
Joining Date
|
|
||||||
</label>
|
|
||||||
<div className="input-group input-group-merge">
|
|
||||||
<span id="basicDate2" className="input-group-text">
|
|
||||||
<i className="bx bx-calendar"></i>
|
|
||||||
</span>
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
className="form-control dt-date"
|
|
||||||
id="basicDate"
|
|
||||||
name="basicDate"
|
|
||||||
aria-describedby="basicDate2"
|
|
||||||
placeholder="MM/DD/YYYY"
|
|
||||||
aria-label="MM/DD/YYYY"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="col-sm-12">
|
|
||||||
<label className="form-label" for="basicSalary">
|
|
||||||
Salary
|
|
||||||
</label>
|
|
||||||
<div className="input-group input-group-merge">
|
|
||||||
<span id="basicSalary2" className="input-group-text">
|
|
||||||
<i className="bx bx-dollar"></i>
|
|
||||||
</span>
|
|
||||||
<input
|
|
||||||
type="number"
|
|
||||||
id="basicSalary"
|
|
||||||
name="basicSalary"
|
|
||||||
className="form-control dt-salary"
|
|
||||||
placeholder="12000"
|
|
||||||
aria-label="12000"
|
|
||||||
aria-describedby="basicSalary2"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="col-sm-12">
|
|
||||||
<button
|
|
||||||
type="submit"
|
|
||||||
className="btn btn-primary data-submit me-sm-4 me-1"
|
|
||||||
>
|
|
||||||
Submit
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
type="reset"
|
|
||||||
className="btn btn-outline-secondary"
|
|
||||||
data-bs-dismiss="offcanvas"
|
|
||||||
>
|
|
||||||
Cancel
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<hr className="my-12" />
|
|
||||||
|
|
||||||
<hr className="my-12" />
|
|
||||||
|
|
||||||
<hr className="my-12" />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="content-backdrop fade"></div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default DemoTable;
|
|
||||||
@ -14,28 +14,24 @@ import { FormProvider, useForm } from "react-hook-form";
|
|||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
import { localToUtc } from "../../utils/appUtils";
|
import { localToUtc } from "../../utils/appUtils";
|
||||||
|
import { useParams } from "react-router-dom";
|
||||||
|
|
||||||
const EmpAttendance = ({ employee }) => {
|
const EmpAttendance = () => {
|
||||||
|
const { employeeId } = useParams();
|
||||||
const [attendances, setAttendnaces] = useState([]);
|
const [attendances, setAttendnaces] = useState([]);
|
||||||
const [selectedDate, setSelectedDate] = useState("");
|
const [selectedDate, setSelectedDate] = useState("");
|
||||||
const [isModalOpen, setIsModalOpen] = useState(false);
|
const [isModalOpen, setIsModalOpen] = useState(false);
|
||||||
const [attendanceId, setAttendanecId] = useState();
|
const [attendanceId, setAttendanecId] = useState();
|
||||||
|
|
||||||
const methods = useForm({
|
const methods = useForm({
|
||||||
resolver: zodResolver(
|
|
||||||
z.object({
|
|
||||||
startDate: z.string(),
|
|
||||||
endDate: z.string(),
|
|
||||||
})
|
|
||||||
),
|
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
startDate: "",
|
startDate: moment().subtract(6, "days").format("DD-MM-YYYY"),
|
||||||
endDate: "",
|
endDate: moment().format("DD-MM-YYYY"),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const { control, register, handleSubmit, reset, watch } = methods;
|
const { watch } = methods;
|
||||||
const startDate = watch("startDate");
|
|
||||||
const endDate = watch("endDate");
|
const [startDate, endDate] = watch(["startDate", "endDate"]);
|
||||||
const {
|
const {
|
||||||
data = [],
|
data = [],
|
||||||
isLoading: loading,
|
isLoading: loading,
|
||||||
@ -44,76 +40,21 @@ const EmpAttendance = ({ employee }) => {
|
|||||||
error,
|
error,
|
||||||
refetch,
|
refetch,
|
||||||
} = useAttendanceByEmployee(
|
} = useAttendanceByEmployee(
|
||||||
employee,
|
employeeId,
|
||||||
localToUtc(startDate),
|
startDate ? localToUtc(startDate) : null,
|
||||||
localToUtc(endDate)
|
endDate ? localToUtc(endDate) : null
|
||||||
);
|
);
|
||||||
|
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
|
const sorted = [...data].sort(
|
||||||
const today = new Date();
|
|
||||||
today.setHours(0, 0, 0, 0);
|
|
||||||
|
|
||||||
const isSameDay = (dateStr) => {
|
|
||||||
if (!dateStr) return false;
|
|
||||||
const d = new Date(dateStr);
|
|
||||||
d.setHours(0, 0, 0, 0);
|
|
||||||
return d.getTime() === today.getTime();
|
|
||||||
};
|
|
||||||
|
|
||||||
const isBeforeToday = (dateStr) => {
|
|
||||||
if (!dateStr) return false;
|
|
||||||
const d = new Date(dateStr);
|
|
||||||
d.setHours(0, 0, 0, 0);
|
|
||||||
return d.getTime() < today.getTime();
|
|
||||||
};
|
|
||||||
|
|
||||||
const sortByName = (a, b) => {
|
|
||||||
const nameA = a.firstName.toLowerCase() + a.lastName.toLowerCase();
|
|
||||||
const nameB = b.firstName.toLowerCase() + b.lastName.toLowerCase();
|
|
||||||
return nameA?.localeCompare(nameB);
|
|
||||||
};
|
|
||||||
|
|
||||||
const group1 = data
|
|
||||||
.filter((d) => d.activity === 1 && isSameDay(d.checkInTime))
|
|
||||||
.sort(sortByName);
|
|
||||||
const group2 = data
|
|
||||||
.filter((d) => d.activity === 4 && isSameDay(d.checkOutTime))
|
|
||||||
.sort(sortByName);
|
|
||||||
const group3 = data
|
|
||||||
.filter((d) => d.activity === 1 && isBeforeToday(d.checkInTime))
|
|
||||||
.sort(sortByName);
|
|
||||||
const group4 = data
|
|
||||||
.filter((d) => d.activity === 4 && isBeforeToday(d.checkOutTime))
|
|
||||||
.sort(sortByName);
|
|
||||||
const group5 = data.filter((d) => d.activity === 5).sort(sortByName);
|
|
||||||
|
|
||||||
|
|
||||||
const uniqueMap = new Map();
|
|
||||||
|
|
||||||
[...group1, ...group2, ...group3, ...group4, ...group5].forEach((rec) => {
|
|
||||||
const date = moment(rec.checkInTime || rec.checkOutTime).format(
|
|
||||||
"YYYY-MM-DD"
|
|
||||||
);
|
|
||||||
const key = `${rec.employeeId}-${date}`;
|
|
||||||
const existing = uniqueMap.get(key);
|
|
||||||
if (
|
|
||||||
!existing ||
|
|
||||||
new Date(rec.checkInTime || rec.checkOutTime) >
|
|
||||||
new Date(existing.checkInTime || existing.checkOutTime)
|
|
||||||
) {
|
|
||||||
uniqueMap.set(key, rec);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const sortedFinalList = [...uniqueMap.values()].sort(
|
|
||||||
(a, b) =>
|
(a, b) =>
|
||||||
new Date(b.checkInTime || b.checkOutTime) -
|
new Date(b?.checkInTime).getTime() - new Date(a?.checkInTime).getTime()
|
||||||
new Date(a.checkInTime || a.checkOutTime)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const currentDate = new Date().toLocaleDateString("en-CA");
|
console.log(sorted);
|
||||||
|
|
||||||
const { currentPage, totalPages, currentItems, paginate } = usePagination(
|
const { currentPage, totalPages, currentItems, paginate } = usePagination(
|
||||||
sortedFinalList,
|
sorted,
|
||||||
ITEMS_PER_PAGE
|
ITEMS_PER_PAGE
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -123,7 +64,6 @@ const EmpAttendance = ({ employee }) => {
|
|||||||
};
|
};
|
||||||
const closeModal = () => setIsModalOpen(false);
|
const closeModal = () => setIsModalOpen(false);
|
||||||
|
|
||||||
const onSubmit = (formData) => {};
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{isModalOpen && (
|
{isModalOpen && (
|
||||||
@ -136,20 +76,10 @@ const EmpAttendance = ({ employee }) => {
|
|||||||
className="dataTables_length text-start py-2 d-flex justify-content-between "
|
className="dataTables_length text-start py-2 d-flex justify-content-between "
|
||||||
id="DataTables_Table_0_length"
|
id="DataTables_Table_0_length"
|
||||||
>
|
>
|
||||||
<div className="col-3 my-0 ">
|
<div className="col-4 col-md-3 my-0 ">
|
||||||
<>
|
<>
|
||||||
<FormProvider {...methods}>
|
<FormProvider {...methods}>
|
||||||
<form
|
<DateRangePicker1 />
|
||||||
onSubmit={handleSubmit(onSubmit)}
|
|
||||||
className="p-2 text-start"
|
|
||||||
>
|
|
||||||
<DateRangePicker1
|
|
||||||
placeholder="DD-MM-YYYY To DD-MM-YYYY"
|
|
||||||
startField="startDate"
|
|
||||||
endField="endDate"
|
|
||||||
defaultRange={true}
|
|
||||||
/>
|
|
||||||
</form>
|
|
||||||
</FormProvider>
|
</FormProvider>
|
||||||
</>
|
</>
|
||||||
</div>
|
</div>
|
||||||
@ -234,7 +164,7 @@ const EmpAttendance = ({ employee }) => {
|
|||||||
</table>
|
</table>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
{!loading && sortedFinalList.length > 20 && (
|
{!loading && data.length > 20 && (
|
||||||
<nav aria-label="Page ">
|
<nav aria-label="Page ">
|
||||||
<ul className="pagination pagination-sm justify-content-end py-1">
|
<ul className="pagination pagination-sm justify-content-end py-1">
|
||||||
<li
|
<li
|
||||||
|
|||||||
@ -1,12 +1,13 @@
|
|||||||
import React, { useState, useEffect } from "react";
|
import React, { useState, useEffect } from "react";
|
||||||
|
|
||||||
import { useChangePassword } from "../../components/Context/ChangePasswordContext";
|
|
||||||
import GlobalModel from "../common/GlobalModel";
|
import GlobalModel from "../common/GlobalModel";
|
||||||
import ManageEmployee from "./ManageEmployee";
|
import ManageEmployee from "./ManageEmployee";
|
||||||
import { formatUTCToLocalTime } from "../../utils/dateUtils";
|
import { formatUTCToLocalTime } from "../../utils/dateUtils";
|
||||||
|
import { useModal } from "../../hooks/useAuth";
|
||||||
|
|
||||||
const EmpBanner = ({ profile, loggedInUser }) => {
|
const EmpBanner = ({ profile, loggedInUser }) => {
|
||||||
const { openChangePassword } = useChangePassword();
|
const {onOpen} = useModal("ChangePassword")
|
||||||
const [showModal, setShowModal] = useState(false);
|
const [showModal, setShowModal] = useState(false);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -86,7 +87,7 @@ const EmpBanner = ({ profile, loggedInUser }) => {
|
|||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<ul className="list-inline mb-0 d-flex align-items-center flex-wrap justify-content-sm-start justify-content-center mt-4">
|
<ul className="list-inline mb-0 d-flex align-items-center flex-wrap justify-content-sm-start justify-content-center mt-4">
|
||||||
{profile?.isActive && ( // ✅ show only if active
|
{profile?.isActive && (
|
||||||
<li className="list-inline-item">
|
<li className="list-inline-item">
|
||||||
<button
|
<button
|
||||||
className="btn btn-sm btn-primary btn-block"
|
className="btn btn-sm btn-primary btn-block"
|
||||||
@ -101,7 +102,7 @@ const EmpBanner = ({ profile, loggedInUser }) => {
|
|||||||
{profile?.id === loggedInUser?.employeeInfo?.id && (
|
{profile?.id === loggedInUser?.employeeInfo?.id && (
|
||||||
<button
|
<button
|
||||||
className="btn btn-sm btn-outline-primary btn-block"
|
className="btn btn-sm btn-outline-primary btn-block"
|
||||||
onClick={() => openChangePassword()}
|
onClick={onOpen}
|
||||||
>
|
>
|
||||||
Change Password
|
Change Password
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@ -1,7 +0,0 @@
|
|||||||
import React from "react";
|
|
||||||
|
|
||||||
const EmployeeList = () => {
|
|
||||||
return <div>EmployeeList</div>;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default EmployeeList;
|
|
||||||
124
src/components/Employee/EmployeeSchema.jsx
Normal file
124
src/components/Employee/EmployeeSchema.jsx
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
import { z } from "zod"
|
||||||
|
|
||||||
|
|
||||||
|
const mobileNumberRegex = /^[0-9]\d{9}$/;
|
||||||
|
|
||||||
|
export const employeeSchema =
|
||||||
|
z.object({
|
||||||
|
firstName: z.string().min(1, { message: "First Name is required" }),
|
||||||
|
middleName: z.string().optional(),
|
||||||
|
lastName: z.string().min(1, { message: "Last Name is required" }),
|
||||||
|
email: z
|
||||||
|
.string()
|
||||||
|
.max(80, "Email cannot exceed 80 characters")
|
||||||
|
.optional()
|
||||||
|
.refine((val) => !val || /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(val), {
|
||||||
|
message: "Invalid email format",
|
||||||
|
})
|
||||||
|
.refine(
|
||||||
|
(val) => {
|
||||||
|
if (!val) return true;
|
||||||
|
const [local, domain] = val.split("@");
|
||||||
|
return (
|
||||||
|
val.length <= 320 && local?.length <= 64 && domain?.length <= 255
|
||||||
|
);
|
||||||
|
},
|
||||||
|
{
|
||||||
|
message: "Email local or domain part is too long",
|
||||||
|
}
|
||||||
|
),
|
||||||
|
currentAddress: z
|
||||||
|
.string()
|
||||||
|
.min(1, { message: "Current Address is required" })
|
||||||
|
.max(500, { message: "Address cannot exceed 500 characters" }),
|
||||||
|
birthDate: z
|
||||||
|
.string()
|
||||||
|
.min(1, { message: "Birth Date is required" })
|
||||||
|
.refine(
|
||||||
|
(date, ctx) => {
|
||||||
|
return new Date(date) <= new Date();
|
||||||
|
},
|
||||||
|
{
|
||||||
|
message: "Birth date cannot be in the future",
|
||||||
|
}
|
||||||
|
),
|
||||||
|
joiningDate: z
|
||||||
|
.string()
|
||||||
|
.min(1, { message: "Joining Date is required" })
|
||||||
|
.refine(
|
||||||
|
(date, ctx) => {
|
||||||
|
return new Date(date) <= new Date();
|
||||||
|
},
|
||||||
|
{
|
||||||
|
message: "Joining date cannot be in the future",
|
||||||
|
}
|
||||||
|
),
|
||||||
|
emergencyPhoneNumber: z
|
||||||
|
.string()
|
||||||
|
.min(1, { message: "Phone Number is required" })
|
||||||
|
.regex(mobileNumberRegex, { message: "Invalid phone number " }),
|
||||||
|
emergencyContactPerson: z
|
||||||
|
.string()
|
||||||
|
.min(1, { message: "Emergency Contact Person is required" })
|
||||||
|
.regex(/^[A-Za-z\s]+$/, {
|
||||||
|
message: "Emergency Contact Person must contain only letters",
|
||||||
|
}),
|
||||||
|
aadharNumber: z
|
||||||
|
.string()
|
||||||
|
.optional()
|
||||||
|
.refine((val) => !val || /^\d{12}$/.test(val), {
|
||||||
|
message: "Aadhar card must be exactly 12 digits long",
|
||||||
|
}),
|
||||||
|
gender: z
|
||||||
|
.string()
|
||||||
|
.min(1, { message: "Gender is required" })
|
||||||
|
.refine((val) => val !== "Select Gender", {
|
||||||
|
message: "Please select a gender",
|
||||||
|
}),
|
||||||
|
panNumber: z
|
||||||
|
.string()
|
||||||
|
.optional()
|
||||||
|
.refine((val) => !val || /^[A-Z]{5}[0-9]{4}[A-Z]{1}$/.test(val), {
|
||||||
|
message: "Invalid PAN number",
|
||||||
|
}),
|
||||||
|
permanentAddress: z
|
||||||
|
.string()
|
||||||
|
.min(1, { message: "Permanent Address is required" })
|
||||||
|
.max(500, { message: "Address cannot exceed 500 characters" }),
|
||||||
|
phoneNumber: z
|
||||||
|
.string()
|
||||||
|
.min(1, { message: "Phone Number is required" })
|
||||||
|
.regex(mobileNumberRegex, { message: "Invalid phone number " }),
|
||||||
|
jobRoleId: z.string().min(1, { message: "Role is required" }),
|
||||||
|
organizationId:z.string().min(1,{message:"Organization is required"}),
|
||||||
|
hasApplicationAccess:z.boolean().default(false),
|
||||||
|
}).refine((data) => {
|
||||||
|
if (data.hasApplicationAccess) {
|
||||||
|
return data.email && data.email.trim() !== "";
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}, {
|
||||||
|
message: "Email is required when employee has access",
|
||||||
|
path: ["email"],
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
export const defatEmployeeObj = {
|
||||||
|
firstName: "",
|
||||||
|
middleName: "",
|
||||||
|
lastName: "",
|
||||||
|
email: "",
|
||||||
|
currentAddress: "",
|
||||||
|
birthDate: "",
|
||||||
|
joiningDate: "",
|
||||||
|
emergencyPhoneNumber: "",
|
||||||
|
emergencyContactPerson: "",
|
||||||
|
aadharNumber: "",
|
||||||
|
gender: "",
|
||||||
|
panNumber: "",
|
||||||
|
permanentAddress: "",
|
||||||
|
phoneNumber: "",
|
||||||
|
jobRoleId: null,
|
||||||
|
organizationId:"",
|
||||||
|
hasApplicationAccess:false
|
||||||
|
}
|
||||||
@ -1,36 +1,37 @@
|
|||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import showToast from "../../services/toastService";
|
|
||||||
import EmployeeRepository from "../../repositories/EmployeeRepository";
|
|
||||||
import { useForm } from "react-hook-form";
|
import { useForm } from "react-hook-form";
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
import { z } from "zod";
|
|
||||||
import useMaster from "../../hooks/masterHook/useMaster";
|
import useMaster from "../../hooks/masterHook/useMaster";
|
||||||
import { useDispatch } from "react-redux";
|
import { useDispatch } from "react-redux";
|
||||||
import { changeMaster } from "../../slices/localVariablesSlice";
|
import { changeMaster } from "../../slices/localVariablesSlice";
|
||||||
import { Link, useNavigate, useParams } from "react-router-dom";
|
import { Link, useNavigate, useParams } from "react-router-dom";
|
||||||
import { formatDate } from "../../utils/dateUtils";
|
import { formatDate } from "../../utils/dateUtils";
|
||||||
import { useEmployeeProfile, useUpdateEmployee } from "../../hooks/useEmployees";
|
|
||||||
import {
|
import {
|
||||||
cacheData,
|
useEmployeeProfile,
|
||||||
clearCacheKey,
|
useUpdateEmployee,
|
||||||
getCachedData,
|
} from "../../hooks/useEmployees";
|
||||||
} from "../../slices/apiDataManager";
|
|
||||||
import { clearApiCacheKey } from "../../slices/apiCacheSlice";
|
|
||||||
import { useMutation } from "@tanstack/react-query";
|
|
||||||
import Label from "../common/Label";
|
import Label from "../common/Label";
|
||||||
import DatePicker from "../common/DatePicker";
|
import DatePicker from "../common/DatePicker";
|
||||||
|
import { defatEmployeeObj, employeeSchema } from "./EmployeeSchema";
|
||||||
|
import { useOrganizationsList } from "../../hooks/useOrganization";
|
||||||
|
import { ITEMS_PER_PAGE } from "../../utils/constants";
|
||||||
|
|
||||||
const mobileNumberRegex = /^[0-9]\d{9}$/;
|
const ManageEmployee = ({ employeeId, onClosed }) => {
|
||||||
|
|
||||||
const ManageEmployee = ({ employeeId, onClosed, IsAllEmployee }) => {
|
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const { mutate: updateEmployee, isPending } = useUpdateEmployee();
|
const { mutate: updateEmployee, isPending } = useUpdateEmployee();
|
||||||
|
const {
|
||||||
|
data: organzationList,
|
||||||
|
isLoading,
|
||||||
|
isError,
|
||||||
|
error: EempError,
|
||||||
|
} = useOrganizationsList(ITEMS_PER_PAGE, 1, true);
|
||||||
const {
|
const {
|
||||||
employee,
|
employee,
|
||||||
error,
|
error,
|
||||||
loading: empLoading,
|
loading: empLoading,
|
||||||
refetch
|
refetch,
|
||||||
} = useEmployeeProfile(employeeId);
|
} = useEmployeeProfile(employeeId);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -38,6 +39,7 @@ const ManageEmployee = ({ employeeId, onClosed, IsAllEmployee }) => {
|
|||||||
}, [employeeId]);
|
}, [employeeId]);
|
||||||
|
|
||||||
const [disabledEmail, setDisabledEmail] = useState(false);
|
const [disabledEmail, setDisabledEmail] = useState(false);
|
||||||
|
|
||||||
const { data: job_role, loading } = useMaster();
|
const { data: job_role, loading } = useMaster();
|
||||||
const [isloading, setLoading] = useState(false);
|
const [isloading, setLoading] = useState(false);
|
||||||
const navigation = useNavigate();
|
const navigation = useNavigate();
|
||||||
@ -45,98 +47,9 @@ const ManageEmployee = ({ employeeId, onClosed, IsAllEmployee }) => {
|
|||||||
const [currentAddressLength, setCurrentAddressLength] = useState(0);
|
const [currentAddressLength, setCurrentAddressLength] = useState(0);
|
||||||
const [permanentAddressLength, setPermanentAddressLength] = useState(0);
|
const [permanentAddressLength, setPermanentAddressLength] = useState(0);
|
||||||
|
|
||||||
const userSchema = z.object({
|
|
||||||
...(employeeId ? { id: z.string().optional() } : {}),
|
|
||||||
firstName: z.string().min(1, { message: "First Name is required" }),
|
|
||||||
middleName: z.string().optional(),
|
|
||||||
lastName: z.string().min(1, { message: "Last Name is required" }),
|
|
||||||
email: z
|
|
||||||
.string()
|
|
||||||
.max(80, "Email cannot exceed 80 characters")
|
|
||||||
.optional()
|
|
||||||
.refine((val) => !val || /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(val), {
|
|
||||||
message: "Invalid email format",
|
|
||||||
})
|
|
||||||
.refine(
|
|
||||||
(val) => {
|
|
||||||
if (!val) return true;
|
|
||||||
const [local, domain] = val.split("@");
|
|
||||||
return (
|
|
||||||
val.length <= 320 && local?.length <= 64 && domain?.length <= 255
|
|
||||||
);
|
|
||||||
},
|
|
||||||
{
|
|
||||||
message: "Email local or domain part is too long",
|
|
||||||
}
|
|
||||||
),
|
|
||||||
currentAddress: z
|
|
||||||
.string()
|
|
||||||
.min(1, { message: "Current Address is required" })
|
|
||||||
.max(500, { message: "Address cannot exceed 500 characters" }),
|
|
||||||
birthDate: z
|
|
||||||
.string()
|
|
||||||
.min(1, { message: "Birth Date is required" })
|
|
||||||
.refine(
|
|
||||||
(date, ctx) => {
|
|
||||||
return new Date(date) <= new Date();
|
|
||||||
},
|
|
||||||
{
|
|
||||||
message: "Birth date cannot be in the future",
|
|
||||||
}
|
|
||||||
),
|
|
||||||
joiningDate: z
|
|
||||||
.string()
|
|
||||||
.min(1, { message: "Joining Date is required" })
|
|
||||||
.refine(
|
|
||||||
(date, ctx) => {
|
|
||||||
return new Date(date) <= new Date();
|
|
||||||
},
|
|
||||||
{
|
|
||||||
message: "Joining date cannot be in the future",
|
|
||||||
}
|
|
||||||
),
|
|
||||||
emergencyPhoneNumber: z
|
|
||||||
.string()
|
|
||||||
.min(1, { message: "Phone Number is required" })
|
|
||||||
.regex(mobileNumberRegex, { message: "Invalid phone number " }),
|
|
||||||
emergencyContactPerson: z
|
|
||||||
.string()
|
|
||||||
.min(1, { message: "Emergency Contact Person is required" })
|
|
||||||
.regex(/^[A-Za-z\s]+$/, {
|
|
||||||
message: "Emergency Contact Person must contain only letters",
|
|
||||||
}),
|
|
||||||
aadharNumber: z
|
|
||||||
.string()
|
|
||||||
.optional()
|
|
||||||
.refine((val) => !val || /^\d{12}$/.test(val), {
|
|
||||||
message: "Aadhar card must be exactly 12 digits long",
|
|
||||||
}),
|
|
||||||
gender: z
|
|
||||||
.string()
|
|
||||||
.min(1, { message: "Gender is required" })
|
|
||||||
.refine((val) => val !== "Select Gender", {
|
|
||||||
message: "Please select a gender",
|
|
||||||
}),
|
|
||||||
panNumber: z
|
|
||||||
.string()
|
|
||||||
.optional()
|
|
||||||
.refine((val) => !val || /^[A-Z]{5}[0-9]{4}[A-Z]{1}$/.test(val), {
|
|
||||||
message: "Invalid PAN number",
|
|
||||||
}),
|
|
||||||
permanentAddress: z
|
|
||||||
.string()
|
|
||||||
.min(1, { message: "Permanent Address is required" })
|
|
||||||
.max(500, { message: "Address cannot exceed 500 characters" }),
|
|
||||||
phoneNumber: z
|
|
||||||
.string()
|
|
||||||
.min(1, { message: "Phone Number is required" })
|
|
||||||
.regex(mobileNumberRegex, { message: "Invalid phone number " }),
|
|
||||||
jobRoleId: z.string().min(1, { message: "Role is required" }),
|
|
||||||
});
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
refetch()
|
refetch();
|
||||||
}, [])
|
}, []);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
register,
|
register,
|
||||||
@ -147,25 +60,8 @@ const ManageEmployee = ({ employeeId, onClosed, IsAllEmployee }) => {
|
|||||||
reset,
|
reset,
|
||||||
getValues,
|
getValues,
|
||||||
} = useForm({
|
} = useForm({
|
||||||
resolver: zodResolver(userSchema),
|
resolver: zodResolver(employeeSchema),
|
||||||
defaultValues: {
|
defaultValues: defatEmployeeObj,
|
||||||
id: currentEmployee?.id || null,
|
|
||||||
firstName: currentEmployee?.firstName || "",
|
|
||||||
middleName: currentEmployee?.middleName || "",
|
|
||||||
lastName: currentEmployee?.lastName || "",
|
|
||||||
email: currentEmployee?.email || "",
|
|
||||||
currentAddress: currentEmployee?.currentAddress || "",
|
|
||||||
birthDate: formatDate(currentEmployee?.birthDate) || "",
|
|
||||||
joiningDate: formatDate(currentEmployee?.joiningDate) || "",
|
|
||||||
emergencyPhoneNumber: currentEmployee?.emergencyPhoneNumber || "",
|
|
||||||
emergencyContactPerson: currentEmployee?.emergencyContactPerson || "",
|
|
||||||
aadharNumber: currentEmployee?.aadharNumber || "",
|
|
||||||
gender: currentEmployee?.gender || "",
|
|
||||||
panNumber: currentEmployee?.panNumber || "",
|
|
||||||
permanentAddress: currentEmployee?.permanentAddress || "",
|
|
||||||
phoneNumber: currentEmployee?.phoneNumber || "",
|
|
||||||
jobRoleId: currentEmployee?.jobRoleId.toString() || null,
|
|
||||||
},
|
|
||||||
mode: "onChange",
|
mode: "onChange",
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -176,7 +72,13 @@ const ManageEmployee = ({ employeeId, onClosed, IsAllEmployee }) => {
|
|||||||
data.email = null;
|
data.email = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateEmployee({ ...data, IsAllEmployee }, {
|
const payload = { ...data };
|
||||||
|
|
||||||
|
if (employeeId) {
|
||||||
|
payload.id = employeeId;
|
||||||
|
}
|
||||||
|
|
||||||
|
updateEmployee(payload, {
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
reset();
|
reset();
|
||||||
onClosed();
|
onClosed();
|
||||||
@ -184,7 +86,6 @@ const ManageEmployee = ({ employeeId, onClosed, IsAllEmployee }) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!loading && !error && employee) {
|
if (!loading && !error && employee) {
|
||||||
setCurrentEmployee(employee);
|
setCurrentEmployee(employee);
|
||||||
@ -195,37 +96,47 @@ const ManageEmployee = ({ employeeId, onClosed, IsAllEmployee }) => {
|
|||||||
reset(
|
reset(
|
||||||
currentEmployee
|
currentEmployee
|
||||||
? {
|
? {
|
||||||
id: currentEmployee.id || null,
|
id: currentEmployee.id || null,
|
||||||
firstName: currentEmployee.firstName || "",
|
firstName: currentEmployee.firstName || "",
|
||||||
middleName: currentEmployee.middleName || "",
|
middleName: currentEmployee.middleName || "",
|
||||||
lastName: currentEmployee.lastName || "",
|
lastName: currentEmployee.lastName || "",
|
||||||
email: currentEmployee.email || "",
|
email: currentEmployee.email || "",
|
||||||
currentAddress: currentEmployee.currentAddress || "",
|
currentAddress: currentEmployee.currentAddress || "",
|
||||||
birthDate: formatDate(currentEmployee.birthDate) || "",
|
birthDate: formatDate(currentEmployee.birthDate) || "",
|
||||||
joiningDate: formatDate(currentEmployee.joiningDate) || "",
|
joiningDate: formatDate(currentEmployee.joiningDate) || "",
|
||||||
emergencyPhoneNumber: currentEmployee.emergencyPhoneNumber || "",
|
emergencyPhoneNumber: currentEmployee.emergencyPhoneNumber || "",
|
||||||
emergencyContactPerson:
|
emergencyContactPerson:
|
||||||
currentEmployee.emergencyContactPerson || "",
|
currentEmployee.emergencyContactPerson || "",
|
||||||
aadharNumber: currentEmployee.aadharNumber || "",
|
aadharNumber: currentEmployee.aadharNumber || "",
|
||||||
gender: currentEmployee.gender || "",
|
gender: currentEmployee.gender || "",
|
||||||
panNumber: currentEmployee.panNumber || "",
|
panNumber: currentEmployee.panNumber || "",
|
||||||
permanentAddress: currentEmployee.permanentAddress || "",
|
permanentAddress: currentEmployee.permanentAddress || "",
|
||||||
phoneNumber: currentEmployee.phoneNumber || "",
|
phoneNumber: currentEmployee.phoneNumber || "",
|
||||||
jobRoleId: currentEmployee.jobRoleId?.toString() || "",
|
jobRoleId: currentEmployee.jobRoleId?.toString() || "",
|
||||||
}
|
organizationId: currentEmployee.organizationId || "",
|
||||||
|
hasApplicationAccess: currentEmployee.hasApplicationAccess || false,
|
||||||
|
}
|
||||||
: {}
|
: {}
|
||||||
);
|
);
|
||||||
setCurrentAddressLength(currentEmployee?.currentAddress?.length || 0);
|
setCurrentAddressLength(currentEmployee?.currentAddress?.length || 0);
|
||||||
setPermanentAddressLength(currentEmployee?.permanentAddress?.length || 0);
|
setPermanentAddressLength(currentEmployee?.permanentAddress?.length || 0);
|
||||||
}, [currentEmployee, reset]);
|
}, [currentEmployee, reset]);
|
||||||
|
|
||||||
|
const hasAccessAplication = watch("hasApplicationAccess");
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<form onSubmit={handleSubmit(onSubmit)} className="p-sm-0 p-2">
|
<form onSubmit={handleSubmit(onSubmit)} className="p-sm-0 p-2">
|
||||||
<div className="text-center"><p className="fs-5 fw-semibold"> {employee ? "Update Employee" : "Create Employee"}</p> </div>
|
<div className="text-center">
|
||||||
|
<p className="fs-5 fw-semibold">
|
||||||
|
{" "}
|
||||||
|
{employee ? "Update Employee" : "Create Employee"}
|
||||||
|
</p>{" "}
|
||||||
|
</div>
|
||||||
<div className="row mb-3">
|
<div className="row mb-3">
|
||||||
<div className="col-sm-4">
|
<div className="col-sm-4">
|
||||||
<Label className="form-text text-start" required>First Name</Label>
|
<Label className="form-text text-start" required>
|
||||||
|
First Name
|
||||||
|
</Label>
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
name="firstName"
|
name="firstName"
|
||||||
@ -244,7 +155,10 @@ const ManageEmployee = ({ employeeId, onClosed, IsAllEmployee }) => {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
{errors.firstName && (
|
{errors.firstName && (
|
||||||
<div className="danger-text text-start" style={{ fontSize: "12px" }}>
|
<div
|
||||||
|
className="danger-text text-start"
|
||||||
|
style={{ fontSize: "12px" }}
|
||||||
|
>
|
||||||
{errors.firstName.message}
|
{errors.firstName.message}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
@ -267,14 +181,18 @@ const ManageEmployee = ({ employeeId, onClosed, IsAllEmployee }) => {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
{errors.middleName && (
|
{errors.middleName && (
|
||||||
<div className="danger-text text-start " style={{ fontSize: "12px" }}>
|
<div
|
||||||
|
className="danger-text text-start "
|
||||||
|
style={{ fontSize: "12px" }}
|
||||||
|
>
|
||||||
{errors.middleName.message}
|
{errors.middleName.message}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="col-sm-4">
|
<div className="col-sm-4">
|
||||||
<Label className="form-text text-start" required>Last Name</Label>
|
<Label className="form-text text-start" required>
|
||||||
|
Last Name
|
||||||
|
</Label>
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
{...register("lastName", {
|
{...register("lastName", {
|
||||||
@ -291,16 +209,24 @@ const ManageEmployee = ({ employeeId, onClosed, IsAllEmployee }) => {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
{errors.lastName && (
|
{errors.lastName && (
|
||||||
<div className="danger-text text-start" style={{ fontSize: "12px" }}>
|
<div
|
||||||
|
className="danger-text text-start"
|
||||||
|
style={{ fontSize: "12px" }}
|
||||||
|
>
|
||||||
{errors.lastName.message}
|
{errors.lastName.message}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div className="row mb-3">
|
<div className="row mb-3">
|
||||||
<div className="col-sm-6">
|
<div className="col-sm-6">
|
||||||
<div className="form-text text-start">Email</div>
|
<Label
|
||||||
|
htmlFor="email"
|
||||||
|
className="text-start form-text"
|
||||||
|
required={hasAccessAplication}
|
||||||
|
>
|
||||||
|
Email
|
||||||
|
</Label>
|
||||||
<input
|
<input
|
||||||
type="email"
|
type="email"
|
||||||
id="email"
|
id="email"
|
||||||
@ -321,7 +247,9 @@ const ManageEmployee = ({ employeeId, onClosed, IsAllEmployee }) => {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="col-sm-6">
|
<div className="col-sm-6">
|
||||||
<Label className="form-text text-start" required>Phone Number</Label>
|
<Label className="form-text text-start" required>
|
||||||
|
Phone Number
|
||||||
|
</Label>
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
keyboardType="numeric"
|
keyboardType="numeric"
|
||||||
@ -345,7 +273,9 @@ const ManageEmployee = ({ employeeId, onClosed, IsAllEmployee }) => {
|
|||||||
<div className="row mb-3"></div>
|
<div className="row mb-3"></div>
|
||||||
<div className="row mb-3">
|
<div className="row mb-3">
|
||||||
<div className="col-sm-4">
|
<div className="col-sm-4">
|
||||||
<Label className="form-text text-start" required>Gender</Label>
|
<Label className="form-text text-start" required>
|
||||||
|
Gender
|
||||||
|
</Label>
|
||||||
|
|
||||||
<div className="input-group">
|
<div className="input-group">
|
||||||
<select
|
<select
|
||||||
@ -387,7 +317,10 @@ const ManageEmployee = ({ employeeId, onClosed, IsAllEmployee }) => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{errors.birthDate && (
|
{errors.birthDate && (
|
||||||
<div className="danger-text text-start" style={{ fontSize: "12px" }}>
|
<div
|
||||||
|
className="danger-text text-start"
|
||||||
|
style={{ fontSize: "12px" }}
|
||||||
|
>
|
||||||
{errors.birthDate.message}
|
{errors.birthDate.message}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
@ -408,7 +341,10 @@ const ManageEmployee = ({ employeeId, onClosed, IsAllEmployee }) => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{errors.joiningDate && (
|
{errors.joiningDate && (
|
||||||
<div className="danger-text text-start" style={{ fontSize: "12px" }}>
|
<div
|
||||||
|
className="danger-text text-start"
|
||||||
|
style={{ fontSize: "12px" }}
|
||||||
|
>
|
||||||
{errors.joiningDate.message}
|
{errors.joiningDate.message}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
@ -416,7 +352,9 @@ const ManageEmployee = ({ employeeId, onClosed, IsAllEmployee }) => {
|
|||||||
</div>
|
</div>
|
||||||
<div className="row mb-3">
|
<div className="row mb-3">
|
||||||
<div className="col-sm-6">
|
<div className="col-sm-6">
|
||||||
<Label className="form-text text-start" required>Current Address</Label>
|
<Label className="form-text text-start" required>
|
||||||
|
Current Address
|
||||||
|
</Label>
|
||||||
|
|
||||||
<textarea
|
<textarea
|
||||||
id="currentAddress"
|
id="currentAddress"
|
||||||
@ -428,15 +366,11 @@ const ManageEmployee = ({ employeeId, onClosed, IsAllEmployee }) => {
|
|||||||
maxLength={500}
|
maxLength={500}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
setCurrentAddressLength(e.target.value.length);
|
setCurrentAddressLength(e.target.value.length);
|
||||||
// let react-hook-form still handle it
|
|
||||||
register("currentAddress").onChange(e);
|
register("currentAddress").onChange(e);
|
||||||
}}
|
}}
|
||||||
></textarea>
|
></textarea>
|
||||||
<div className="text-end muted">
|
<div className="text-end muted">
|
||||||
<small>
|
<small> {500 - currentAddressLength} characters left</small>
|
||||||
{" "}
|
|
||||||
{500 - currentAddressLength} characters left
|
|
||||||
</small>
|
|
||||||
</div>
|
</div>
|
||||||
{errors.currentAddress && (
|
{errors.currentAddress && (
|
||||||
<div
|
<div
|
||||||
@ -466,9 +400,7 @@ const ManageEmployee = ({ employeeId, onClosed, IsAllEmployee }) => {
|
|||||||
}}
|
}}
|
||||||
></textarea>
|
></textarea>
|
||||||
<div className="text-end muted">
|
<div className="text-end muted">
|
||||||
<small>
|
<small>{500 - permanentAddressLength} characters left</small>
|
||||||
{500 - permanentAddressLength} characters left
|
|
||||||
</small>
|
|
||||||
</div>
|
</div>
|
||||||
{errors.permanentAddress && (
|
{errors.permanentAddress && (
|
||||||
<div
|
<div
|
||||||
@ -480,6 +412,55 @@ const ManageEmployee = ({ employeeId, onClosed, IsAllEmployee }) => {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{/* -------------- */}
|
||||||
|
<div className="row mb-3">
|
||||||
|
<div className="col-sm-6">
|
||||||
|
<Label className="form-text text-start" required>
|
||||||
|
Organization
|
||||||
|
</Label>
|
||||||
|
<div className="input-group">
|
||||||
|
<select
|
||||||
|
className="form-select form-select-sm"
|
||||||
|
{...register("organizationId")}
|
||||||
|
id="organizationId"
|
||||||
|
aria-label=""
|
||||||
|
>
|
||||||
|
<option disabled value="">
|
||||||
|
Select Organization
|
||||||
|
</option>
|
||||||
|
{organzationList?.data
|
||||||
|
.sort((a, b) => a?.name?.localeCompare(b?.name))
|
||||||
|
.map((item) => (
|
||||||
|
<option value={item?.id} key={item?.id}>
|
||||||
|
{item?.name}
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
{errors.organizationId && (
|
||||||
|
<div
|
||||||
|
className="danger-text text-start justify-content-center"
|
||||||
|
style={{ fontSize: "12px" }}
|
||||||
|
>
|
||||||
|
{errors.organizationId.message}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="col-sm-6 d-flex align-items-center mt-2">
|
||||||
|
<label className="form-check-label d-flex align-items-center">
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
className="form-check-input me-2"
|
||||||
|
{...register("hasApplicationAccess")}
|
||||||
|
/>
|
||||||
|
Has Application Access ?
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* --------------- */}
|
||||||
<div className="row mb-3">
|
<div className="row mb-3">
|
||||||
{" "}
|
{" "}
|
||||||
<div className="divider">
|
<div className="divider">
|
||||||
@ -488,7 +469,9 @@ const ManageEmployee = ({ employeeId, onClosed, IsAllEmployee }) => {
|
|||||||
</div>
|
</div>
|
||||||
<div className="row mb-3">
|
<div className="row mb-3">
|
||||||
<div className="col-sm-4">
|
<div className="col-sm-4">
|
||||||
<Label className="form-text text-start" required>Official Designation</Label>
|
<Label className="form-text text-start" required>
|
||||||
|
Official Designation
|
||||||
|
</Label>
|
||||||
<div className="input-group">
|
<div className="input-group">
|
||||||
<select
|
<select
|
||||||
className="form-select form-select-sm"
|
className="form-select form-select-sm"
|
||||||
@ -601,15 +584,6 @@ const ManageEmployee = ({ employeeId, onClosed, IsAllEmployee }) => {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{employeeId && (
|
|
||||||
<div className="row mb-3 d-none">
|
|
||||||
<div className="col-sm-12">
|
|
||||||
<input type="text" name="id" {...register("id")} />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<div className="row text-end">
|
<div className="row text-end">
|
||||||
<div className="col-sm-12">
|
<div className="col-sm-12">
|
||||||
<button
|
<button
|
||||||
@ -626,18 +600,11 @@ const ManageEmployee = ({ employeeId, onClosed, IsAllEmployee }) => {
|
|||||||
className="btn btn-sm btn-primary"
|
className="btn btn-sm btn-primary"
|
||||||
disabled={isPending}
|
disabled={isPending}
|
||||||
>
|
>
|
||||||
{isPending
|
{isPending ? "Please Wait..." : employeeId ? "Update" : "Create"}
|
||||||
? "Please Wait..."
|
|
||||||
: employeeId
|
|
||||||
? "Update"
|
|
||||||
: "Create"}
|
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import React, { useEffect, useState,useMemo } from "react";
|
import React, { useEffect, useState, useMemo } from "react";
|
||||||
import { FormProvider, useForm, Controller } from "react-hook-form";
|
import { FormProvider, useForm, Controller } from "react-hook-form";
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
import { defaultFilter, SearchSchema } from "./ExpenseSchema";
|
import { defaultFilter, SearchSchema } from "./ExpenseSchema";
|
||||||
@ -16,8 +16,11 @@ import { ExpenseFilterSkeleton } from "./ExpenseSkeleton";
|
|||||||
import { useLocation } from "react-router-dom";
|
import { useLocation } from "react-router-dom";
|
||||||
|
|
||||||
const ExpenseFilterPanel = ({ onApply, handleGroupBy }) => {
|
const ExpenseFilterPanel = ({ onApply, handleGroupBy }) => {
|
||||||
const selectedProjectId = useSelector((store) => store.localVariables.projectId);
|
const selectedProjectId = useSelector(
|
||||||
const { data, isLoading,isError,error,isFetching , isFetched} = useExpenseFilter();
|
(store) => store.localVariables.projectId
|
||||||
|
);
|
||||||
|
const { data, isLoading, isError, error, isFetching, isFetched } =
|
||||||
|
useExpenseFilter();
|
||||||
|
|
||||||
const groupByList = useMemo(() => {
|
const groupByList = useMemo(() => {
|
||||||
return [
|
return [
|
||||||
@ -27,11 +30,10 @@ const ExpenseFilterPanel = ({ onApply, handleGroupBy }) => {
|
|||||||
{ id: "project", name: "Project" },
|
{ id: "project", name: "Project" },
|
||||||
{ id: "paymentMode", name: "Payment Mode" },
|
{ id: "paymentMode", name: "Payment Mode" },
|
||||||
{ id: "expensesType", name: "Expense Type" },
|
{ id: "expensesType", name: "Expense Type" },
|
||||||
{ id: "createdAt", name: "Submitted Date" }
|
{ id: "createdAt", name: "Submitted Date" },
|
||||||
].sort((a, b) => a.name.localeCompare(b.name));
|
].sort((a, b) => a.name.localeCompare(b.name));
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
|
||||||
const [selectedGroup, setSelectedGroup] = useState(groupByList[0]);
|
const [selectedGroup, setSelectedGroup] = useState(groupByList[0]);
|
||||||
const [resetKey, setResetKey] = useState(0);
|
const [resetKey, setResetKey] = useState(0);
|
||||||
|
|
||||||
@ -40,7 +42,7 @@ const ExpenseFilterPanel = ({ onApply, handleGroupBy }) => {
|
|||||||
defaultValues: defaultFilter,
|
defaultValues: defaultFilter,
|
||||||
});
|
});
|
||||||
|
|
||||||
const { control, register, handleSubmit, reset, watch } = methods;
|
const { control, handleSubmit, reset, setValue, watch } = methods;
|
||||||
const isTransactionDate = watch("isTransactionDate");
|
const isTransactionDate = watch("isTransactionDate");
|
||||||
|
|
||||||
const closePanel = () => {
|
const closePanel = () => {
|
||||||
@ -78,34 +80,44 @@ const ExpenseFilterPanel = ({ onApply, handleGroupBy }) => {
|
|||||||
}, [location]);
|
}, [location]);
|
||||||
|
|
||||||
if (isLoading || isFetching) return <ExpenseFilterSkeleton />;
|
if (isLoading || isFetching) return <ExpenseFilterSkeleton />;
|
||||||
if(isError && isFetched) return <div>Something went wrong Here- {error.message} </div>
|
if (isError && isFetched)
|
||||||
|
return <div>Something went wrong Here- {error.message} </div>;
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|
||||||
<FormProvider {...methods}>
|
<FormProvider {...methods}>
|
||||||
<form onSubmit={handleSubmit(onSubmit)} className="p-2 text-start">
|
<form onSubmit={handleSubmit(onSubmit)} className="p-2 text-start">
|
||||||
<div className="mb-3 w-100">
|
<div className="mb-3 w-100">
|
||||||
<div className="d-flex align-items-center mb-2">
|
<div className="d-flex align-items-center mb-2">
|
||||||
<label className="form-label me-2">Choose Date:</label>
|
<label className="form-label me-2">Filter By:</label>
|
||||||
<div className="form-check form-switch m-0">
|
<div className="d-inline-flex border rounded-pill mb-1 overflow-hidden shadow-none">
|
||||||
<input
|
<button
|
||||||
className="form-check-input"
|
type="button"
|
||||||
type="checkbox"
|
className={`btn px-2 py-1 rounded-0 text-tiny ${
|
||||||
id="switchOption1"
|
isTransactionDate ? "active btn-primary text-white" : ""
|
||||||
{...register("isTransactionDate")}
|
}`}
|
||||||
/>
|
onClick={() => setValue("isTransactionDate", true)}
|
||||||
|
>
|
||||||
|
Transaction Date
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className={`btn px-2 py-1 rounded-0 text-tiny ${
|
||||||
|
!isTransactionDate ? "active btn-primary text-white" : ""
|
||||||
|
}`}
|
||||||
|
onClick={() => setValue("isTransactionDate", false)}
|
||||||
|
>
|
||||||
|
Submitted Date
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<label className="form-label mb-0 ms-2">
|
|
||||||
{isTransactionDate ? "Submitted": "Transaction" }
|
|
||||||
</label>
|
|
||||||
</div>
|
</div>
|
||||||
|
<label className="fw-semibold">Choose Date Range:</label>
|
||||||
<DateRangePicker1
|
<DateRangePicker1
|
||||||
placeholder="DD-MM-YYYY To DD-MM-YYYY"
|
placeholder="DD-MM-YYYY To DD-MM-YYYY"
|
||||||
startField="startDate"
|
startField="startDate"
|
||||||
endField="endDate"
|
endField="endDate"
|
||||||
resetSignal={resetKey}
|
resetSignal={resetKey}
|
||||||
defaultRange={false}
|
defaultRange={false}
|
||||||
|
maxDate={new Date()}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -169,7 +181,9 @@ const ExpenseFilterPanel = ({ onApply, handleGroupBy }) => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="mb-2 text-start ">
|
<div className="mb-2 text-start ">
|
||||||
<label htmlFor="groupBySelect" className="form-label">Group By :</label>
|
<label htmlFor="groupBySelect" className="form-label">
|
||||||
|
Group By :
|
||||||
|
</label>
|
||||||
<select
|
<select
|
||||||
id="groupBySelect"
|
id="groupBySelect"
|
||||||
className="form-select form-select-sm"
|
className="form-select form-select-sm"
|
||||||
@ -187,18 +201,17 @@ const ExpenseFilterPanel = ({ onApply, handleGroupBy }) => {
|
|||||||
<div className="d-flex justify-content-end py-3 gap-2">
|
<div className="d-flex justify-content-end py-3 gap-2">
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className="btn btn-label-secondary btn-xs"
|
className="btn btn-label-secondary btn-sm"
|
||||||
onClick={onClear}
|
onClick={onClear}
|
||||||
>
|
>
|
||||||
Clear
|
Clear
|
||||||
</button>
|
</button>
|
||||||
<button type="submit" className="btn btn-primary btn-xs">
|
<button type="submit" className="btn btn-primary btn-sm">
|
||||||
Apply
|
Apply
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</FormProvider>
|
</FormProvider>
|
||||||
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -28,6 +28,7 @@ import moment from "moment";
|
|||||||
import DatePicker from "../common/DatePicker";
|
import DatePicker from "../common/DatePicker";
|
||||||
import ErrorPage from "../../pages/ErrorPage";
|
import ErrorPage from "../../pages/ErrorPage";
|
||||||
import Label from "../common/Label";
|
import Label from "../common/Label";
|
||||||
|
import EmployeeSearchInput from "../common/EmployeeSearchInput";
|
||||||
|
|
||||||
const ManageExpense = ({ closeModal, expenseToEdit = null }) => {
|
const ManageExpense = ({ closeModal, expenseToEdit = null }) => {
|
||||||
const {
|
const {
|
||||||
@ -142,8 +143,7 @@ const ManageExpense = ({ closeModal, expenseToEdit = null }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (expenseToEdit && data ) {
|
if (expenseToEdit && data) {
|
||||||
|
|
||||||
reset({
|
reset({
|
||||||
projectId: data.project.id || "",
|
projectId: data.project.id || "",
|
||||||
expensesTypeId: data.expensesType.id || "",
|
expensesTypeId: data.expensesType.id || "",
|
||||||
@ -156,7 +156,7 @@ const ManageExpense = ({ closeModal, expenseToEdit = null }) => {
|
|||||||
supplerName: data.supplerName || "",
|
supplerName: data.supplerName || "",
|
||||||
amount: data.amount || "",
|
amount: data.amount || "",
|
||||||
noOfPersons: data.noOfPersons || "",
|
noOfPersons: data.noOfPersons || "",
|
||||||
gstNumber:data.gstNumber || "",
|
gstNumber: data.gstNumber || "",
|
||||||
billAttachments: data.documents
|
billAttachments: data.documents
|
||||||
? data.documents.map((doc) => ({
|
? data.documents.map((doc) => ({
|
||||||
fileName: doc.fileName,
|
fileName: doc.fileName,
|
||||||
@ -183,8 +183,7 @@ const ManageExpense = ({ closeModal, expenseToEdit = null }) => {
|
|||||||
const onSubmit = (fromdata) => {
|
const onSubmit = (fromdata) => {
|
||||||
let payload = {
|
let payload = {
|
||||||
...fromdata,
|
...fromdata,
|
||||||
transactionDate: localToUtc(fromdata.transactionDate)
|
transactionDate: localToUtc(fromdata.transactionDate),
|
||||||
|
|
||||||
};
|
};
|
||||||
if (expenseToEdit) {
|
if (expenseToEdit) {
|
||||||
const editPayload = { ...payload, id: data.id };
|
const editPayload = { ...payload, id: data.id };
|
||||||
@ -206,7 +205,6 @@ const ManageExpense = ({ closeModal, expenseToEdit = null }) => {
|
|||||||
if (StatusLoadding || projectLoading || ExpenseLoading || isLoading)
|
if (StatusLoadding || projectLoading || ExpenseLoading || isLoading)
|
||||||
return <ExpenseSkeleton />;
|
return <ExpenseSkeleton />;
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="container p-3">
|
<div className="container p-3">
|
||||||
<h5 className="m-0">
|
<h5 className="m-0">
|
||||||
@ -215,7 +213,9 @@ const ManageExpense = ({ closeModal, expenseToEdit = null }) => {
|
|||||||
<form id="expenseForm" onSubmit={handleSubmit(onSubmit)}>
|
<form id="expenseForm" onSubmit={handleSubmit(onSubmit)}>
|
||||||
<div className="row my-2 text-start">
|
<div className="row my-2 text-start">
|
||||||
<div className="col-md-6">
|
<div className="col-md-6">
|
||||||
<Label className="form-label" required>Select Project</Label>
|
<Label className="form-label" required>
|
||||||
|
Select Project
|
||||||
|
</Label>
|
||||||
<select
|
<select
|
||||||
className="form-select form-select-sm"
|
className="form-select form-select-sm"
|
||||||
{...register("projectId")}
|
{...register("projectId")}
|
||||||
@ -296,11 +296,11 @@ const ManageExpense = ({ closeModal, expenseToEdit = null }) => {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="col-md-6">
|
<div className="col-12 col-md-6 text-start">
|
||||||
<Label htmlFor="paidById" className="form-label" required>
|
<Label htmlFor="paidById" className="form-label" required>
|
||||||
Paid By
|
Paid By
|
||||||
</Label>
|
</Label>
|
||||||
<select
|
{/* <select
|
||||||
className="form-select form-select-sm"
|
className="form-select form-select-sm"
|
||||||
id="paymentModeId"
|
id="paymentModeId"
|
||||||
{...register("paidById")}
|
{...register("paidById")}
|
||||||
@ -321,7 +321,14 @@ const ManageExpense = ({ closeModal, expenseToEdit = null }) => {
|
|||||||
</select>
|
</select>
|
||||||
{errors.paidById && (
|
{errors.paidById && (
|
||||||
<small className="danger-text">{errors.paidById.message}</small>
|
<small className="danger-text">{errors.paidById.message}</small>
|
||||||
)}
|
)} */}
|
||||||
|
|
||||||
|
<EmployeeSearchInput
|
||||||
|
control={control}
|
||||||
|
name="paidById"
|
||||||
|
projectId={null}
|
||||||
|
forAll={expenseToEdit ? true : false}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -330,7 +337,11 @@ const ManageExpense = ({ closeModal, expenseToEdit = null }) => {
|
|||||||
<Label htmlFor="transactionDate" className="form-label" required>
|
<Label htmlFor="transactionDate" className="form-label" required>
|
||||||
Transaction Date
|
Transaction Date
|
||||||
</Label>
|
</Label>
|
||||||
<DatePicker name="transactionDate" control={control} maxDate={new Date()}/>
|
<DatePicker
|
||||||
|
name="transactionDate"
|
||||||
|
control={control}
|
||||||
|
maxDate={new Date()}
|
||||||
|
/>
|
||||||
|
|
||||||
{errors.transactionDate && (
|
{errors.transactionDate && (
|
||||||
<small className="danger-text">
|
<small className="danger-text">
|
||||||
@ -409,9 +420,9 @@ const ManageExpense = ({ closeModal, expenseToEdit = null }) => {
|
|||||||
</small>
|
</small>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="col-md-6">
|
<div className="col-md-6">
|
||||||
<label htmlFor="statusId" className="form-label ">
|
<label htmlFor="statusId" className="form-label ">
|
||||||
GST Number
|
GST Number
|
||||||
</label>
|
</label>
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
@ -421,9 +432,7 @@ const ManageExpense = ({ closeModal, expenseToEdit = null }) => {
|
|||||||
{...register("gstNumber")}
|
{...register("gstNumber")}
|
||||||
/>
|
/>
|
||||||
{errors.gstNumber && (
|
{errors.gstNumber && (
|
||||||
<small className="danger-text">
|
<small className="danger-text">{errors.gstNumber.message}</small>
|
||||||
{errors.gstNumber.message}
|
|
||||||
</small>
|
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -448,7 +457,9 @@ const ManageExpense = ({ closeModal, expenseToEdit = null }) => {
|
|||||||
|
|
||||||
<div className="row my-2 text-start">
|
<div className="row my-2 text-start">
|
||||||
<div className="col-md-12">
|
<div className="col-md-12">
|
||||||
<Label htmlFor="description" className="form-label" required>Description</Label>
|
<Label htmlFor="description" className="form-label" required>
|
||||||
|
Description
|
||||||
|
</Label>
|
||||||
<textarea
|
<textarea
|
||||||
id="description"
|
id="description"
|
||||||
className="form-control form-control-sm"
|
className="form-control form-control-sm"
|
||||||
@ -465,7 +476,9 @@ const ManageExpense = ({ closeModal, expenseToEdit = null }) => {
|
|||||||
|
|
||||||
<div className="row my-2 text-start">
|
<div className="row my-2 text-start">
|
||||||
<div className="col-md-12">
|
<div className="col-md-12">
|
||||||
<Label className="form-label" required>Upload Bill </Label>
|
<Label className="form-label" required>
|
||||||
|
Upload Bill{" "}
|
||||||
|
</Label>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
className="border border-secondary border-dashed rounded p-4 text-center bg-textMuted position-relative"
|
className="border border-secondary border-dashed rounded p-4 text-center bg-textMuted position-relative"
|
||||||
@ -549,7 +562,7 @@ const ManageExpense = ({ closeModal, expenseToEdit = null }) => {
|
|||||||
|
|
||||||
<div className="d-flex justify-content-end gap-3">
|
<div className="d-flex justify-content-end gap-3">
|
||||||
{" "}
|
{" "}
|
||||||
<button
|
<button
|
||||||
type="reset"
|
type="reset"
|
||||||
disabled={isPending || createPending}
|
disabled={isPending || createPending}
|
||||||
onClick={handleClose}
|
onClick={handleClose}
|
||||||
@ -568,7 +581,6 @@ const ManageExpense = ({ closeModal, expenseToEdit = null }) => {
|
|||||||
? "Update"
|
? "Update"
|
||||||
: "Submit"}
|
: "Submit"}
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -1,27 +1,53 @@
|
|||||||
import { useState } from 'react';
|
import { useState } from "react";
|
||||||
|
|
||||||
const PreviewDocument = ({ imageUrl }) => {
|
const PreviewDocument = ({ imageUrl }) => {
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
|
const [rotation, setRotation] = useState(0);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="d-flex justify-content-center align-items-center" style={{ minHeight: "50vh" }}>
|
<>
|
||||||
|
<div className="d-flex justify-content-start">
|
||||||
|
<i
|
||||||
|
className="bx bx-rotate-right cursor-pointer"
|
||||||
|
onClick={() => setRotation((prev) => prev + 90)}
|
||||||
|
></i>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
className="d-flex flex-column justify-content-center align-items-center"
|
||||||
|
style={{ minHeight: "60%" }}
|
||||||
|
>
|
||||||
|
|
||||||
{loading && (
|
{loading && (
|
||||||
<div className="text-secondary text-center mb-2">
|
<div className="text-secondary text-center mb-2">Loading...</div>
|
||||||
Loading...
|
|
||||||
</div>
|
|
||||||
)}
|
)}
|
||||||
<img
|
|
||||||
src={imageUrl}
|
<div className="mb-3 d-flex justify-content-center align-items-center">
|
||||||
alt="Full View"
|
<img
|
||||||
className="img-fluid"
|
src={imageUrl}
|
||||||
style={{
|
alt="Full View"
|
||||||
maxHeight: "100vh",
|
className="img-fluid"
|
||||||
objectFit: "contain",
|
style={{
|
||||||
display: loading ? "none" : "block",
|
maxHeight: "80vh",
|
||||||
}}
|
objectFit: "contain",
|
||||||
onLoad={() => setLoading(false)}
|
display: loading ? "none" : "block",
|
||||||
/>
|
transform: `rotate(${rotation}deg)`,
|
||||||
|
transition: "transform 0.3s ease",
|
||||||
|
}}
|
||||||
|
onLoad={() => setLoading(false)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="d-flex justify-content-center gap-2">
|
||||||
|
<button
|
||||||
|
className="btn btn-outline-secondary"
|
||||||
|
onClick={() => setRotation(0)}
|
||||||
|
title="Reset Rotation"
|
||||||
|
>
|
||||||
|
<i className="bx bx-reset"></i> Reset
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -9,7 +9,7 @@ import { useForm } from "react-hook-form";
|
|||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
import { defaultActionValues, ExpenseActionScheam } from "./ExpenseSchema";
|
import { defaultActionValues, ExpenseActionScheam } from "./ExpenseSchema";
|
||||||
import { useExpenseContext } from "../../pages/Expense/ExpensePage";
|
import { useExpenseContext } from "../../pages/Expense/ExpensePage";
|
||||||
import { getColorNameFromHex, getIconByFileType } from "../../utils/appUtils";
|
import { getColorNameFromHex, getIconByFileType, localToUtc } from "../../utils/appUtils";
|
||||||
import { ExpenseDetailsSkeleton } from "./ExpenseSkeleton";
|
import { ExpenseDetailsSkeleton } from "./ExpenseSkeleton";
|
||||||
import { useHasUserPermission } from "../../hooks/useHasUserPermission";
|
import { useHasUserPermission } from "../../hooks/useHasUserPermission";
|
||||||
import {
|
import {
|
||||||
@ -91,9 +91,7 @@ const ViewExpense = ({ ExpenseId }) => {
|
|||||||
const onSubmit = (formData) => {
|
const onSubmit = (formData) => {
|
||||||
const Payload = {
|
const Payload = {
|
||||||
...formData,
|
...formData,
|
||||||
reimburseDate: moment
|
reimburseDate: localToUtc(formData.reimburseDate),
|
||||||
.utc(formData.reimburseDate, "DD-MM-YYYY")
|
|
||||||
.toISOString(),
|
|
||||||
expenseId: ExpenseId,
|
expenseId: ExpenseId,
|
||||||
comment: formData.comment,
|
comment: formData.comment,
|
||||||
};
|
};
|
||||||
@ -398,6 +396,7 @@ const ViewExpense = ({ ExpenseId }) => {
|
|||||||
name="reimburseDate"
|
name="reimburseDate"
|
||||||
control={control}
|
control={control}
|
||||||
minDate={data?.transactionDate}
|
minDate={data?.transactionDate}
|
||||||
|
maxDate={new Date()}
|
||||||
/>
|
/>
|
||||||
{errors.reimburseDate && (
|
{errors.reimburseDate && (
|
||||||
<small className="danger-text">
|
<small className="danger-text">
|
||||||
|
|||||||
@ -12,13 +12,13 @@ import useMaster from "../../hooks/masterHook/useMaster";
|
|||||||
import { useProfile } from "../../hooks/useProfile";
|
import { useProfile } from "../../hooks/useProfile";
|
||||||
import { useLocation, useNavigate, useParams } from "react-router-dom";
|
import { useLocation, useNavigate, useParams } from "react-router-dom";
|
||||||
import Avatar from "../../components/common/Avatar";
|
import Avatar from "../../components/common/Avatar";
|
||||||
import { useChangePassword } from "../Context/ChangePasswordContext";
|
|
||||||
import { useProjects } from "../../hooks/useProjects";
|
import { useProjects } from "../../hooks/useProjects";
|
||||||
import { useCallback, useEffect, useState } from "react";
|
import { useCallback, useEffect, useState } from "react";
|
||||||
import { useProjectName } from "../../hooks/useProjects";
|
import { useProjectName } from "../../hooks/useProjects";
|
||||||
import eventBus from "../../services/eventBus";
|
import eventBus from "../../services/eventBus";
|
||||||
import { useHasUserPermission } from "../../hooks/useHasUserPermission";
|
import { useHasUserPermission } from "../../hooks/useHasUserPermission";
|
||||||
import { MANAGE_PROJECT } from "../../utils/constants";
|
import { MANAGE_PROJECT } from "../../utils/constants";
|
||||||
|
import { useAuthModal, useLogout, useModal } from "../../hooks/useAuth";
|
||||||
|
|
||||||
const Header = () => {
|
const Header = () => {
|
||||||
const { profile } = useProfile();
|
const { profile } = useProfile();
|
||||||
@ -26,14 +26,16 @@ const Header = () => {
|
|||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const { data, loading } = useMaster();
|
const { data, loading } = useMaster();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
const {onOpen} = useAuthModal()
|
||||||
|
const { onOpen:changePass } = useModal("ChangePassword");
|
||||||
const HasManageProjectPermission = useHasUserPermission(MANAGE_PROJECT);
|
const HasManageProjectPermission = useHasUserPermission(MANAGE_PROJECT);
|
||||||
// {
|
const { mutate : logout,isPending:logouting} = useLogout()
|
||||||
// console.log(location.pathname);
|
|
||||||
// }
|
|
||||||
|
|
||||||
const isDashboardPath =
|
const isDashboardPath =
|
||||||
/^\/dashboard$/.test(location.pathname) || /^\/$/.test(location.pathname);
|
/^\/dashboard$/.test(location.pathname) || /^\/$/.test(location.pathname);
|
||||||
const isProjectPath = /^\/projects$/.test(location.pathname);
|
const isProjectPath = /^\/projects$/.test(location.pathname);
|
||||||
|
const isCollectionPath =
|
||||||
|
/^\/collection$/.test(location.pathname) || /^\/$/.test(location.pathname);
|
||||||
|
|
||||||
const showProjectDropdown = (pathname) => {
|
const showProjectDropdown = (pathname) => {
|
||||||
const isDirectoryPath = /^\/directory$/.test(pathname);
|
const isDirectoryPath = /^\/directory$/.test(pathname);
|
||||||
@ -59,41 +61,9 @@ const Header = () => {
|
|||||||
return role ? role.name : "User";
|
return role ? role.name : "User";
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleLogout = (e) => {
|
|
||||||
e.preventDefault();
|
|
||||||
logout();
|
|
||||||
};
|
|
||||||
|
|
||||||
const logout = async () => {
|
|
||||||
try {
|
|
||||||
let data = {
|
|
||||||
refreshToken: localStorage.getItem("refreshToken"),
|
|
||||||
};
|
|
||||||
|
|
||||||
AuthRepository.logout(data)
|
|
||||||
.then(() => {
|
|
||||||
localStorage.removeItem("jwtToken");
|
|
||||||
localStorage.removeItem("refreshToken");
|
|
||||||
localStorage.removeItem("user");
|
|
||||||
localStorage.clear();
|
|
||||||
clearAllCache();
|
|
||||||
window.location.href = "/auth/login";
|
|
||||||
})
|
|
||||||
.catch(() => {
|
|
||||||
localStorage.removeItem("jwtToken");
|
|
||||||
localStorage.removeItem("refreshToken");
|
|
||||||
localStorage.removeItem("user");
|
|
||||||
localStorage.clear();
|
|
||||||
clearAllCache();
|
|
||||||
window.location.href = "/auth/login";
|
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
console.error(
|
|
||||||
"Error during logout:",
|
|
||||||
error?.response?.data || error.message
|
|
||||||
);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleProfilePage = () => {
|
const handleProfilePage = () => {
|
||||||
navigate(`/employee/${profile?.employeeInfo?.id}`);
|
navigate(`/employee/${profile?.employeeInfo?.id}`);
|
||||||
@ -129,7 +99,7 @@ const Header = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const { openChangePassword } = useChangePassword();
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (
|
if (
|
||||||
@ -221,7 +191,8 @@ const Header = () => {
|
|||||||
className="navbar-nav-right d-flex align-items-center justify-content-between"
|
className="navbar-nav-right d-flex align-items-center justify-content-between"
|
||||||
id="navbar-collapse"
|
id="navbar-collapse"
|
||||||
>
|
>
|
||||||
{showProjectDropdown(location.pathname) && (
|
<div className="d-flex align-items-center">
|
||||||
|
{showProjectDropdown(location.pathname) && (
|
||||||
<div className="align-items-center">
|
<div className="align-items-center">
|
||||||
<i className="rounded-circle bx bx-building-house bx-sm-lg bx-md me-2"></i>
|
<i className="rounded-circle bx bx-building-house bx-sm-lg bx-md me-2"></i>
|
||||||
<div className="btn-group">
|
<div className="btn-group">
|
||||||
@ -247,7 +218,7 @@ const Header = () => {
|
|||||||
className="dropdown-menu"
|
className="dropdown-menu"
|
||||||
style={{ overflow: "auto", maxHeight: "300px" }}
|
style={{ overflow: "auto", maxHeight: "300px" }}
|
||||||
>
|
>
|
||||||
{isDashboardPath && (
|
{(isDashboardPath|| isCollectionPath) &&(
|
||||||
<li>
|
<li>
|
||||||
<button
|
<button
|
||||||
className="dropdown-item"
|
className="dropdown-item"
|
||||||
@ -279,6 +250,7 @@ const Header = () => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
<ul className="navbar-nav flex-row align-items-center ms-md-auto">
|
<ul className="navbar-nav flex-row align-items-center ms-md-auto">
|
||||||
<li className="nav-item dropdown-shortcuts navbar-dropdown dropdown me-2 me-xl-0">
|
<li className="nav-item dropdown-shortcuts navbar-dropdown dropdown me-2 me-xl-0">
|
||||||
@ -426,6 +398,15 @@ const Header = () => {
|
|||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<div className="dropdown-divider"></div>
|
<div className="dropdown-divider"></div>
|
||||||
|
</li>
|
||||||
|
<li onClick={()=>onOpen()}>
|
||||||
|
{" "}
|
||||||
|
<a
|
||||||
|
className="dropdown-item cusor-pointer"
|
||||||
|
>
|
||||||
|
<i className="bx bx-transfer-alt me-2"></i>
|
||||||
|
<span className="align-middle">Switch Workspace</span>
|
||||||
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li onClick={handleProfilePage}>
|
<li onClick={handleProfilePage}>
|
||||||
<a
|
<a
|
||||||
@ -445,7 +426,7 @@ const Header = () => {
|
|||||||
<span className="align-middle">Settings</span>
|
<span className="align-middle">Settings</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li onClick={openChangePassword}>
|
<li onClick={changePass}>
|
||||||
{" "}
|
{" "}
|
||||||
<a
|
<a
|
||||||
aria-label="go to profile"
|
aria-label="go to profile"
|
||||||
@ -455,6 +436,8 @@ const Header = () => {
|
|||||||
<span className="align-middle">Change Password</span>
|
<span className="align-middle">Change Password</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
|
|
||||||
<li>
|
<li>
|
||||||
<div className="dropdown-divider"></div>
|
<div className="dropdown-divider"></div>
|
||||||
</li>
|
</li>
|
||||||
@ -462,11 +445,10 @@ const Header = () => {
|
|||||||
<a
|
<a
|
||||||
aria-label="click to log out"
|
aria-label="click to log out"
|
||||||
className="dropdown-item cusor-pointer"
|
className="dropdown-item cusor-pointer"
|
||||||
href="/logout"
|
onClick={()=>logout()}
|
||||||
onClick={handleLogout}
|
|
||||||
>
|
>
|
||||||
<i className="bx bx-power-off me-2"></i>
|
{logouting ? "Please Wait":<> <i className="bx bx-log-out me-2"></i>
|
||||||
<span className="align-middle">Log Out</span>
|
<span className="align-middle">SignOut</span></>}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
@ -1,9 +1,268 @@
|
|||||||
import React from 'react'
|
import React, { useMemo, useState } from "react";
|
||||||
|
import { useProjectAssignedServices } from "../../hooks/useProjects";
|
||||||
|
import { useSelectedProject } from "../../slices/apiDataManager";
|
||||||
|
import {
|
||||||
|
useOrganizationType,
|
||||||
|
useServices,
|
||||||
|
} from "../../hooks/masterHook/useMaster";
|
||||||
|
import Label from "../common/Label";
|
||||||
|
import { useForm } from "react-hook-form";
|
||||||
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
|
import { assignedOrgToProject } from "./OrganizationSchema";
|
||||||
|
import {
|
||||||
|
useAssignOrgToProject,
|
||||||
|
useAssignOrgToTenant,
|
||||||
|
useOrganizationModal,
|
||||||
|
} from "../../hooks/useOrganization";
|
||||||
|
|
||||||
|
const AssignOrg = ({ setStep }) => {
|
||||||
|
const { isOpen, orgData, startStep, onOpen, flowType, prevStep, onClose } =
|
||||||
|
useOrganizationModal();
|
||||||
|
const selectedProject = useSelectedProject();
|
||||||
|
const { data: masterService, isLoading: isMasterserviceLoading } =
|
||||||
|
useServices();
|
||||||
|
const { data: projectServices, isLoading } =
|
||||||
|
useProjectAssignedServices(selectedProject);
|
||||||
|
const { data: orgType, isLoading: orgLoading } = useOrganizationType();
|
||||||
|
|
||||||
|
const { mutate: AssignToProject, isPending: isPendingProject } =
|
||||||
|
useAssignOrgToProject(() => onClose());
|
||||||
|
const { mutate: AssignToTenant, isPending: isPendingTenat } =
|
||||||
|
useAssignOrgToTenant(() => {
|
||||||
|
onClose();
|
||||||
|
});
|
||||||
|
const isPending = isPendingProject || isPendingTenat;
|
||||||
|
const mergedServices = useMemo(() => {
|
||||||
|
if (!masterService || !projectServices) return [];
|
||||||
|
const combined = [...masterService?.data, ...projectServices];
|
||||||
|
return combined.filter(
|
||||||
|
(item, index, self) => index === self.findIndex((s) => s.id === item.id)
|
||||||
|
);
|
||||||
|
}, [masterService, projectServices]);
|
||||||
|
|
||||||
|
const resolver =
|
||||||
|
flowType === "default" ? undefined : zodResolver(assignedOrgToProject);
|
||||||
|
|
||||||
|
const {
|
||||||
|
register,
|
||||||
|
handleSubmit,
|
||||||
|
setValue,
|
||||||
|
formState: { errors },
|
||||||
|
} = useForm({
|
||||||
|
resolver,
|
||||||
|
defaultValues: {
|
||||||
|
organizationTypeId: "",
|
||||||
|
serviceIds: [],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const onSubmit = (formData) => {
|
||||||
|
if (flowType === "default") {
|
||||||
|
const payload = orgData.id;
|
||||||
|
|
||||||
|
AssignToTenant(payload);
|
||||||
|
} else {
|
||||||
|
const payload = {
|
||||||
|
...formData,
|
||||||
|
projectId: selectedProject,
|
||||||
|
organizationId: orgData.id,
|
||||||
|
parentOrganizationId: null,
|
||||||
|
};
|
||||||
|
AssignToProject(payload);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleEdit = () => {
|
||||||
|
onOpen({ startStep: 4, orgData });
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleBack = () => {
|
||||||
|
if (prevStep === 1 && flowType === "assign") {
|
||||||
|
onOpen({ startStep: prevStep });
|
||||||
|
} else if (prevStep === 1 && flowType !== "assign") {
|
||||||
|
onOpen({ startStep: 1 });
|
||||||
|
} else {
|
||||||
|
onOpen({ startStep: 2 });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (isMasterserviceLoading || isLoading)
|
||||||
|
return <div className="text-center">Loading....</div>;
|
||||||
|
|
||||||
const AssignOrg = () => {
|
|
||||||
return (
|
return (
|
||||||
<div>AssignOrg</div>
|
<div className="row text-black text-start mb-3">
|
||||||
)
|
{/* Organization Info Display */}
|
||||||
}
|
<div className="col-12 mb-3">
|
||||||
|
<div className="d-flex justify-content-between align-items-center text-start mb-1">
|
||||||
|
<div className="d-flex flex-row gap-2 align-items-center text-wrap">
|
||||||
|
<img
|
||||||
|
src="/public/assets/img/orgLogo.png"
|
||||||
|
alt="logo"
|
||||||
|
width={40}
|
||||||
|
height={40}
|
||||||
|
/> <p className="fw-semibold fs-6 m-0">{orgData.name}</p>
|
||||||
|
</div>
|
||||||
|
<div className="text-end">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={handleEdit}
|
||||||
|
className="btn btn-link p-0"
|
||||||
|
>
|
||||||
|
<i className="bx bx-edit text-secondary"></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="d-flex text-secondary mb-2"> <i className="bx bx-sm bx-info-circle me-1" /> Organization Info</div>
|
||||||
|
{/* Contact Info */}
|
||||||
|
<div className="col-md-6 mb-3">
|
||||||
|
<div className="d-flex">
|
||||||
|
<label
|
||||||
|
className="form-label me-2 mb-0 fw-semibold"
|
||||||
|
style={{ minWidth: "130px" }}
|
||||||
|
>
|
||||||
|
<i className="bx bx-sm bx-user me-1" /> Contact Person :
|
||||||
|
</label>
|
||||||
|
<div className="text-muted">{orgData.contactPerson}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="col-md-6 mb-3">
|
||||||
|
<div className="d-flex">
|
||||||
|
<label
|
||||||
|
className="form-label me-2 mb-0 fw-semibold"
|
||||||
|
style={{ minWidth: "130px" }}
|
||||||
|
>
|
||||||
|
<i className='bx bx-sm me-1 bx-phone'></i> Contact Number :
|
||||||
|
</label>
|
||||||
|
<div className="text-muted">{orgData.contactNumber}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="col-md-6 mb-3">
|
||||||
|
<div className="d-flex">
|
||||||
|
<label
|
||||||
|
className="form-label me-2 mb-0 fw-semibold"
|
||||||
|
style={{ minWidth: "130px" }}
|
||||||
|
>
|
||||||
|
<i className='bx bx-sm me-1 bx-envelope'></i> Email Address :
|
||||||
|
</label>
|
||||||
|
<div className="text-muted">{orgData.email}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="col-12 mb-3">
|
||||||
|
<div className="d-flex">
|
||||||
|
<label
|
||||||
|
className="form-label me-2 mb-0 fw-semibold"
|
||||||
|
style={{ maxWidth: "130px" }}
|
||||||
|
>
|
||||||
|
<i className="bx bx-sm me-1 bx-barcode"></i>
|
||||||
|
Service Provider Id (SPRID) :
|
||||||
|
</label>
|
||||||
|
<div className="text-muted">{orgData.sprid}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="col-12 mb-3">
|
||||||
|
<div className="d-flex">
|
||||||
|
<label
|
||||||
|
className="form-label me-1 mb-0 fw-semibold"
|
||||||
|
style={{ minWidth: "130px" }}
|
||||||
|
>
|
||||||
|
<i className='bx bx-sm me-1 bx-map'></i> Address :
|
||||||
|
</label>
|
||||||
|
<div className="text-muted text-start">{orgData.address}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
export default AssignOrg
|
{/* Form */}
|
||||||
|
<div className="text-black text-start">
|
||||||
|
<form onSubmit={handleSubmit(onSubmit)}>
|
||||||
|
{/* Show fields only if flowType is NOT default */}
|
||||||
|
{flowType !== "default" && (
|
||||||
|
<>
|
||||||
|
{/* Organization Type */}
|
||||||
|
<div className="mb-3 text-start">
|
||||||
|
<Label htmlFor="organizationTypeId" className="mb-3 fw-semibold" required>
|
||||||
|
Organization Type
|
||||||
|
</Label>
|
||||||
|
<div className="d-flex flex-wrap gap-3 mt-1">
|
||||||
|
{orgType?.data.map((type) => (
|
||||||
|
<div
|
||||||
|
key={type.id}
|
||||||
|
className="form-check d-flex align-items-center gap-2 p-0 m-0"
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
type="radio"
|
||||||
|
id={`organizationType-${type.id}`}
|
||||||
|
value={type.id}
|
||||||
|
{...register("organizationTypeId")}
|
||||||
|
className="form-check-input m-0"
|
||||||
|
/>
|
||||||
|
<label
|
||||||
|
className="form-check-label m-0"
|
||||||
|
htmlFor={`organizationType-${type.id}`}
|
||||||
|
>
|
||||||
|
{type.name}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
{errors.organizationTypeId && (
|
||||||
|
<span className="text-danger">
|
||||||
|
{errors.organizationTypeId.message}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Services */}
|
||||||
|
<div className="mb-3">
|
||||||
|
<Label htmlFor="serviceIds" className="mb-3 fw-semibold" required>
|
||||||
|
Select Services
|
||||||
|
</Label>
|
||||||
|
{mergedServices?.map((service) => (
|
||||||
|
<div key={service.id} className="form-check mb-3">
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
value={service.id}
|
||||||
|
{...register("serviceIds")}
|
||||||
|
className="form-check-input"
|
||||||
|
/>
|
||||||
|
<label className="form-check-label">{service.name}</label>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
{errors.serviceIds && (
|
||||||
|
<div className="text-danger small">
|
||||||
|
{errors.serviceIds.message}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* Buttons: Always visible */}
|
||||||
|
<div className="d-flex justify-content-between mt-5">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="btn btn-sm btn-outline-secondary"
|
||||||
|
onClick={handleBack}
|
||||||
|
disabled={isPending}
|
||||||
|
>
|
||||||
|
<i className="bx bx-chevron-left"></i>Back
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="submit"
|
||||||
|
className="btn btn-sm btn-primary"
|
||||||
|
disabled={isPending}
|
||||||
|
>
|
||||||
|
{isPending
|
||||||
|
? "Please wait..."
|
||||||
|
: flowType === "default"
|
||||||
|
? "Assign to Organization"
|
||||||
|
: "Assign to Project"}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default AssignOrg;
|
||||||
|
|||||||
212
src/components/Organization/ManagOrg.jsx
Normal file
212
src/components/Organization/ManagOrg.jsx
Normal file
@ -0,0 +1,212 @@
|
|||||||
|
import React, { useEffect } from "react";
|
||||||
|
import { FormProvider, useForm } from "react-hook-form";
|
||||||
|
import {
|
||||||
|
useCreateOrganization,
|
||||||
|
useOrganization,
|
||||||
|
useOrganizationModal,
|
||||||
|
useUpdateOrganization,
|
||||||
|
} from "../../hooks/useOrganization";
|
||||||
|
import {
|
||||||
|
defaultOrganizationValues,
|
||||||
|
organizationSchema,
|
||||||
|
} from "./OrganizationSchema";
|
||||||
|
import Label from "../common/Label";
|
||||||
|
import { useGlobalServices } from "../../hooks/masterHook/useMaster";
|
||||||
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
|
import SelectMultiple from "../common/SelectMultiple";
|
||||||
|
|
||||||
|
const ManagOrg = () => {
|
||||||
|
const { data: service, isLoading } = useGlobalServices();
|
||||||
|
const { flowType, orgData, startStep, onOpen, onClose, prevStep } =
|
||||||
|
useOrganizationModal();
|
||||||
|
const {
|
||||||
|
data: organization,
|
||||||
|
isLoading: organizationLoading,
|
||||||
|
isError,
|
||||||
|
error,
|
||||||
|
} = useOrganization(orgData?.id);
|
||||||
|
|
||||||
|
const method = useForm({
|
||||||
|
resolver: zodResolver(organizationSchema),
|
||||||
|
defaultValues: defaultOrganizationValues,
|
||||||
|
});
|
||||||
|
|
||||||
|
const {
|
||||||
|
handleSubmit,
|
||||||
|
register,
|
||||||
|
reset,
|
||||||
|
formState: { errors },
|
||||||
|
} = method;
|
||||||
|
|
||||||
|
// Create & Update mutations
|
||||||
|
const { mutate: createOrganization, isPending: isCreating } =
|
||||||
|
useCreateOrganization(() => {
|
||||||
|
reset(defaultOrganizationValues);
|
||||||
|
onOpen({ startStep: 1 });
|
||||||
|
onClose();
|
||||||
|
});
|
||||||
|
|
||||||
|
const { mutate: updateOrganization, isPending: isUpdating } =
|
||||||
|
useUpdateOrganization(() => {
|
||||||
|
reset(defaultOrganizationValues);
|
||||||
|
onOpen({ startStep: 1 });
|
||||||
|
onClose();
|
||||||
|
});
|
||||||
|
// Prefill form if editing
|
||||||
|
useEffect(() => {
|
||||||
|
if (organization) {
|
||||||
|
reset({
|
||||||
|
name: organization.name || "",
|
||||||
|
contactPerson: organization.contactPerson || "",
|
||||||
|
contactNumber: organization.contactNumber || "",
|
||||||
|
email: organization.email || "",
|
||||||
|
serviceIds: organization.services?.map((s) => s.id) || [],
|
||||||
|
address: organization.address || "",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, [organization, reset, service?.data]);
|
||||||
|
|
||||||
|
const onSubmit = (formData) => {
|
||||||
|
let payload = { ...formData };
|
||||||
|
if (organization?.id) {
|
||||||
|
updateOrganization({
|
||||||
|
orgId: organization.id,
|
||||||
|
payload: { ...payload, id: organization.id },
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
createOrganization(payload);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const handleBack = () => {
|
||||||
|
if (flowType === "edit") {
|
||||||
|
onClose();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flowType === "assign") {
|
||||||
|
if (prevStep === 1) {
|
||||||
|
onOpen({ startStep: 1 });
|
||||||
|
} else {
|
||||||
|
onOpen({ startStep: prevStep ?? 2 });
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
onOpen({ startStep: 2 });
|
||||||
|
};
|
||||||
|
return (
|
||||||
|
<FormProvider {...method}>
|
||||||
|
<form className="form" onSubmit={handleSubmit(onSubmit)}>
|
||||||
|
<div className="mb-1 text-start">
|
||||||
|
<Label htmlFor="name" required>
|
||||||
|
Organization Name
|
||||||
|
</Label>
|
||||||
|
<input
|
||||||
|
className="form-control form-control-sm"
|
||||||
|
{...register("name")}
|
||||||
|
/>
|
||||||
|
{errors.name && (
|
||||||
|
<span className="danger-text">{errors.name.message}</span>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="mb-1 text-start">
|
||||||
|
<Label htmlFor="contactPerson" required>
|
||||||
|
Contact Person
|
||||||
|
</Label>
|
||||||
|
<input
|
||||||
|
className="form-control form-control-sm"
|
||||||
|
{...register("contactPerson")}
|
||||||
|
/>
|
||||||
|
{errors.contactPerson && (
|
||||||
|
<span className="danger-text">{errors.contactPerson.message}</span>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="mb-1 text-start">
|
||||||
|
<Label htmlFor="contactNumber" required>
|
||||||
|
Contact Number
|
||||||
|
</Label>
|
||||||
|
<input
|
||||||
|
className="form-control form-control-sm"
|
||||||
|
{...register("contactNumber")}
|
||||||
|
/>
|
||||||
|
{errors.contactNumber && (
|
||||||
|
<span className="danger-text">{errors.contactNumber.message}</span>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="mb-1 text-start">
|
||||||
|
<Label htmlFor="email" required>
|
||||||
|
Email Address
|
||||||
|
</Label>
|
||||||
|
<input
|
||||||
|
className="form-control form-control-sm"
|
||||||
|
{...register("email")}
|
||||||
|
/>
|
||||||
|
{errors.email && (
|
||||||
|
<span className="danger-text">{errors.email.message}</span>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="mb-1 text-start">
|
||||||
|
<SelectMultiple
|
||||||
|
name="serviceIds"
|
||||||
|
label="Select Service"
|
||||||
|
options={service?.data}
|
||||||
|
labelKey="name"
|
||||||
|
valueKey="id"
|
||||||
|
IsLoading={isLoading}
|
||||||
|
/>
|
||||||
|
{errors.serviceIds && (
|
||||||
|
<span className="danger-text">{errors.serviceIds.message}</span>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="mb-1 text-start">
|
||||||
|
<Label htmlFor="address" required>
|
||||||
|
Address
|
||||||
|
</Label>
|
||||||
|
<textarea
|
||||||
|
className="form-control form-control-sm"
|
||||||
|
{...register("address")}
|
||||||
|
rows={2}
|
||||||
|
/>
|
||||||
|
{errors.address && (
|
||||||
|
<span className="danger-text">{errors.address.message}</span>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="d-flex justify-content-between gap-2 my-2">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="btn btn-sm btn-outline-secondary"
|
||||||
|
onClick={handleBack}
|
||||||
|
>
|
||||||
|
{flowType === "edit" ? (
|
||||||
|
"Close"
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<i className="bx bx-chevron-left"></i>Back
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</button>
|
||||||
|
<div>
|
||||||
|
<button
|
||||||
|
type="submit"
|
||||||
|
className="btn btn-sm btn-primary"
|
||||||
|
disabled={isCreating || isUpdating || isLoading}
|
||||||
|
>
|
||||||
|
{isCreating || isUpdating
|
||||||
|
? "Please Wait..."
|
||||||
|
: orgData
|
||||||
|
? "Update"
|
||||||
|
: "Submit"}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</FormProvider>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ManagOrg;
|
||||||
@ -1,471 +0,0 @@
|
|||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
|
||||||
import React, { useMemo, useState } from "react";
|
|
||||||
import { FormProvider, useForm } from "react-hook-form";
|
|
||||||
import {
|
|
||||||
defaultOrganizationValues,
|
|
||||||
organizationSchema,
|
|
||||||
} from "./OrganizationSchema";
|
|
||||||
import Modal from "../common/Modal";
|
|
||||||
import {
|
|
||||||
useCreateOrganization,
|
|
||||||
useOrganizationBySPRID,
|
|
||||||
useOrganizationModal,
|
|
||||||
useOrganizationsList,
|
|
||||||
} from "../../hooks/useOrganization";
|
|
||||||
import Label from "../common/Label";
|
|
||||||
import SelectMultiple from "../common/SelectMultiple";
|
|
||||||
import { useServices } from "../../hooks/masterHook/useMaster";
|
|
||||||
|
|
||||||
const ManageOrganization = ({
|
|
||||||
projectOrganizations = ["ee"],
|
|
||||||
organizationId = null,
|
|
||||||
}) => {
|
|
||||||
const [step, setStep] = useState(1);
|
|
||||||
const orgModal = useOrganizationModal();
|
|
||||||
const { data: masterService, isLoading } = useServices();
|
|
||||||
const [searchText, setSearchText] = useState();
|
|
||||||
const [SPRID, setSPRID] = useState("");
|
|
||||||
const { data: orgList, isLoading: orgLoading } = useOrganizationsList(
|
|
||||||
20,
|
|
||||||
1,
|
|
||||||
true,
|
|
||||||
searchText
|
|
||||||
);
|
|
||||||
const { data: OrgListbySPRID, isLoading: isLoadingBySPRID } =
|
|
||||||
useOrganizationBySPRID(SPRID);
|
|
||||||
const [Organization, setOrganization] = useState({});
|
|
||||||
|
|
||||||
const method = useForm({
|
|
||||||
resolver: zodResolver(organizationSchema),
|
|
||||||
defaultValues: defaultOrganizationValues,
|
|
||||||
});
|
|
||||||
console.log(masterService);
|
|
||||||
|
|
||||||
const {
|
|
||||||
handleSubmit,
|
|
||||||
register,
|
|
||||||
reset,
|
|
||||||
formState: { errors },
|
|
||||||
} = method;
|
|
||||||
|
|
||||||
const { mutate: CreateOrganization, isPending } = useCreateOrganization(
|
|
||||||
() => {
|
|
||||||
reset(defaultOrganizationValues);
|
|
||||||
orgModal.onClose();
|
|
||||||
setStep(1); // reset to first step
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
const onSubmit = (OrgPayload) => {
|
|
||||||
CreateOrganization(OrgPayload);
|
|
||||||
};
|
|
||||||
|
|
||||||
const RenderTitle = useMemo(() => {
|
|
||||||
if (organizationId) {
|
|
||||||
return "Update Organization";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (step === 1) {
|
|
||||||
return projectOrganizations && projectOrganizations !== null
|
|
||||||
? "Add Organization"
|
|
||||||
: "Find Organization";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (step === 2) {
|
|
||||||
return "Organization Details";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (step === 3) {
|
|
||||||
return "Create Organization";
|
|
||||||
}
|
|
||||||
|
|
||||||
return "Manage Organization"; // fallback
|
|
||||||
}, [step, orgModal?.orgData, organizationId]);
|
|
||||||
|
|
||||||
const contentBody = (
|
|
||||||
<div>
|
|
||||||
{/* ---------- STEP 1: Service Provider- Form Own Tenant list ---------- */}
|
|
||||||
{step === 1 && (
|
|
||||||
<div className="d-block">
|
|
||||||
<div className="text-start mb-1">
|
|
||||||
<Label className="text-secondary">Find Organization</Label>
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
value={SPRID}
|
|
||||||
className="form-control form-control-sm w-auto"
|
|
||||||
placeholder="Enter Organization"
|
|
||||||
aria-describedby="search-label"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="py-2 text-tiny text-center">
|
|
||||||
<div className="d-flex flex-column gap-2 border-0 bg-none">
|
|
||||||
{orgList?.map((org) => (
|
|
||||||
<div className="list-group-item list-group-item-action d-flex align-items-center cursor-pointer border-0">
|
|
||||||
<div className="d-flex align-items-center justify-content-center me-3">
|
|
||||||
<i className="bx bx-building-house bx-md text-primary"></i>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="w-100">
|
|
||||||
<div className="d-flex justify-content-between">
|
|
||||||
<div className="user-info text-start">
|
|
||||||
<h6 className="mb-1 fw-normal">{org.name}</h6>
|
|
||||||
<small className="text-body-secondary">
|
|
||||||
{org.contactPerson}
|
|
||||||
</small>
|
|
||||||
<div className="user-status">
|
|
||||||
<small>In Meeting</small>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="add-btn">
|
|
||||||
<button
|
|
||||||
className="btn btn-primary btn-xs"
|
|
||||||
onClick={() => {
|
|
||||||
setOrganization(org);
|
|
||||||
setStep(3);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Add
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{orgModal.orgData && (
|
|
||||||
<p className="text-secondary">
|
|
||||||
Don't have required organization, Please find using{" "}
|
|
||||||
<span
|
|
||||||
className="text-mutes cursor-pointer text-decoration-underline"
|
|
||||||
onClick={() => setStep(2)}
|
|
||||||
>
|
|
||||||
SPRID
|
|
||||||
</span>
|
|
||||||
</p>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div
|
|
||||||
className={`d-flex ${
|
|
||||||
projectOrganizations
|
|
||||||
? "justify-content-end"
|
|
||||||
: "justify-content-between"
|
|
||||||
} text-secondary mt-3`}
|
|
||||||
>
|
|
||||||
{!projectOrganizations && (
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
className="btn btn-xs btn-outline-secondary"
|
|
||||||
onClick={() => setStep(1)}
|
|
||||||
>
|
|
||||||
<i className="bx bx-left-arrow-alt"></i> Back
|
|
||||||
</button>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
className="btn btn-xs btn-secondary"
|
|
||||||
onClick={() => setStep(4)}
|
|
||||||
>
|
|
||||||
<i className="bx bx-plus-circle me-2"></i>
|
|
||||||
Add New Organization
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{/* ---------- STEP 1: Service Provider From Own Other Tenant ---------- */}
|
|
||||||
{step === 2 && (
|
|
||||||
<div className="d-block">
|
|
||||||
<div className="text-start mb-1">
|
|
||||||
<Label className="text-secondary">Find Organization</Label>
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
className="form-control form-control-sm w-auto"
|
|
||||||
placeholder="Enter Servicee Provider Id"
|
|
||||||
aria-describedby="search-label"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
{/* ======== org list ======*/}
|
|
||||||
<div className="d-flex flex-column gap-2 border-0 bg-none">
|
|
||||||
{OrgListbySPRID?.map((org) => (
|
|
||||||
<div className="list-group-item list-group-item-action d-flex align-items-center cursor-pointer border-0">
|
|
||||||
<div className="d-flex align-items-center justify-content-center me-3">
|
|
||||||
<i className="bx bx-building-house bx-md text-primary"></i>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="w-100">
|
|
||||||
<div className="d-flex justify-content-between">
|
|
||||||
<div className="user-info text-start">
|
|
||||||
<h6 className="mb-1 fw-normal">Icing sweet gummies</h6>
|
|
||||||
<small className="text-body-secondary">15 minutes</small>
|
|
||||||
<div className="user-status">
|
|
||||||
<small>In Meeting</small>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="add-btn">
|
|
||||||
<button
|
|
||||||
className="btn btn-primary btn-xs"
|
|
||||||
onClick={() => setStep(3)}
|
|
||||||
>
|
|
||||||
Add
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="d-flex justify-content-between gap-2 mt-3">
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
className="btn btn-xs btn-outline-secondary"
|
|
||||||
onClick={() => setStep(1)}
|
|
||||||
>
|
|
||||||
<i className="bx bx-left-arrow-alt"></i> Back
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
className="btn btn-xs btn-secondary"
|
|
||||||
onClick={() => setStep(4)}
|
|
||||||
>
|
|
||||||
<i className="bx bx-plus-circle me-2"></i>
|
|
||||||
Add New Organization
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{/* ---------- STEP 2: Existing Organization Details ---------- */}
|
|
||||||
{step === 3 && (
|
|
||||||
<div className="row text-black mb-3">
|
|
||||||
<div className="col-12 mb-3"></div>
|
|
||||||
<div className="text-start mb-2">
|
|
||||||
<div className="text-muted">{Organization.name}</div>
|
|
||||||
</div>
|
|
||||||
{/* Row 1 */}
|
|
||||||
<div className="col-md-6 mb-3">
|
|
||||||
<div className="d-flex">
|
|
||||||
<label
|
|
||||||
className="form-label me-2 mb-0 fw-semibold text-start"
|
|
||||||
style={{ minWidth: "130px" }}
|
|
||||||
>
|
|
||||||
Constact Person :
|
|
||||||
</label>
|
|
||||||
<div className="text-muted">{Organization.name}</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="col-md-6 mb-3">
|
|
||||||
<div className="d-flex">
|
|
||||||
<label
|
|
||||||
className="form-label me-2 mb-0 fw-semibold text-start"
|
|
||||||
style={{ minWidth: "130px" }}
|
|
||||||
>
|
|
||||||
Contact Number :
|
|
||||||
</label>
|
|
||||||
<div className="text-muted">{Organization.contactNumber}</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="col-md-6 mb-3">
|
|
||||||
<div className="d-flex">
|
|
||||||
<label
|
|
||||||
className="form-label me-2 mb-0 fw-semibold text-start"
|
|
||||||
style={{ minWidth: "130px" }}
|
|
||||||
>
|
|
||||||
Email Address :
|
|
||||||
</label>
|
|
||||||
<div className="text-muted">{Organization.email}</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="col-12 mb-3">
|
|
||||||
<div className="d-flex">
|
|
||||||
<label
|
|
||||||
className="form-label me-2 mb-0 fw-semibold text-start text-wrap"
|
|
||||||
style={{ maxWidth: "130px" }}
|
|
||||||
>
|
|
||||||
Service provider Id (SPRID) :
|
|
||||||
</label>
|
|
||||||
<div className="text-muted">{Organization.sprid}</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="col-12 mb-3">
|
|
||||||
<div className="d-flex">
|
|
||||||
<label
|
|
||||||
className="form-label me-1 mb-0 fw-semibold text-start"
|
|
||||||
style={{ minWidth: "130px" }}
|
|
||||||
>
|
|
||||||
Address :
|
|
||||||
</label>
|
|
||||||
<div className="text-muted text-start">
|
|
||||||
{Organization.address}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="text-black text-start">
|
|
||||||
<div className="mb-2">
|
|
||||||
<Label className="fs-6">Add Services</Label>
|
|
||||||
<ul className="list-group list-group-flush">
|
|
||||||
{masterService.data &&
|
|
||||||
masterService.data?.map((serv) => (
|
|
||||||
<li className="list-group-item py-1">
|
|
||||||
<input
|
|
||||||
type="checkbox"
|
|
||||||
className="form-check-input me-2"
|
|
||||||
/>
|
|
||||||
{serv.name}
|
|
||||||
</li>
|
|
||||||
))}
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="d-flex justify-content-between mt-3">
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
className="btn btn-xs btn-outline-secondary"
|
|
||||||
onClick={() => setStep(1)}
|
|
||||||
>
|
|
||||||
<i className="bx bx-left-arrow-alt"></i> Back
|
|
||||||
</button>
|
|
||||||
<button type="button" className="btn btn-sm btn-primary">
|
|
||||||
Add
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{/* ---------- STEP 3: Add New Organization ---------- */}
|
|
||||||
{step === 4 && (
|
|
||||||
<FormProvider {...method}>
|
|
||||||
<form className="form" onSubmit={handleSubmit(onSubmit)}>
|
|
||||||
<div className="mb-1 text-start">
|
|
||||||
<Label htmlFor="name" required>
|
|
||||||
Organization Name
|
|
||||||
</Label>
|
|
||||||
<input
|
|
||||||
className="form-control form-control-sm"
|
|
||||||
{...register("name")}
|
|
||||||
/>
|
|
||||||
{errors.name && (
|
|
||||||
<span className="danger-text">{errors.name.message}</span>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="mb-1 text-start">
|
|
||||||
<Label htmlFor="contactPerson" required>
|
|
||||||
Contact Person
|
|
||||||
</Label>
|
|
||||||
<input
|
|
||||||
className="form-control form-control-sm"
|
|
||||||
{...register("contactPerson")}
|
|
||||||
/>
|
|
||||||
{errors.contactPerson && (
|
|
||||||
<span className="danger-text">
|
|
||||||
{errors.contactPerson.message}
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="mb-1 text-start">
|
|
||||||
<Label htmlFor="contactNumber" required>
|
|
||||||
Contact Number
|
|
||||||
</Label>
|
|
||||||
<input
|
|
||||||
className="form-control form-control-sm"
|
|
||||||
{...register("contactNumber")}
|
|
||||||
/>
|
|
||||||
{errors.contactNumber && (
|
|
||||||
<span className="danger-text">
|
|
||||||
{errors.contactNumber.message}
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="mb-1 text-start">
|
|
||||||
<Label htmlFor="email" required>
|
|
||||||
Email Address
|
|
||||||
</Label>
|
|
||||||
<input
|
|
||||||
className="form-control form-control-sm"
|
|
||||||
{...register("email")}
|
|
||||||
/>
|
|
||||||
{errors.email && (
|
|
||||||
<span className="danger-text">{errors.email.message}</span>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="mb-1 text-start">
|
|
||||||
<SelectMultiple
|
|
||||||
name="serviceIds"
|
|
||||||
label="Services"
|
|
||||||
required
|
|
||||||
valueKey="id"
|
|
||||||
options={services?.data || []}
|
|
||||||
/>
|
|
||||||
{errors.serviceIds && (
|
|
||||||
<span className="danger-text">{errors.serviceIds.message}</span>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="mb-1 text-start">
|
|
||||||
<Label htmlFor="address" required>
|
|
||||||
Address
|
|
||||||
</Label>
|
|
||||||
<textarea
|
|
||||||
className="form-control form-control-sm"
|
|
||||||
{...register("address")}
|
|
||||||
rows={2}
|
|
||||||
/>
|
|
||||||
{errors.address && (
|
|
||||||
<span className="danger-text">{errors.address.message}</span>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="d-flex justify-content-between gap-2 my-2">
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
className="btn btn-sm btn-outline-secondary"
|
|
||||||
onClick={() => setStep(1)}
|
|
||||||
>
|
|
||||||
← Back
|
|
||||||
</button>
|
|
||||||
<div>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
className="btn btn-sm btn-secondary me-2"
|
|
||||||
onClick={orgModal.onClose}
|
|
||||||
disabled={isPending || isLoading}
|
|
||||||
>
|
|
||||||
Cancel
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
type="submit"
|
|
||||||
className="btn btn-sm btn-primary"
|
|
||||||
disabled={isPending || isLoading}
|
|
||||||
>
|
|
||||||
{isPending ? "Please Wait..." : "Submit"}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</FormProvider>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Modal
|
|
||||||
isOpen={orgModal.isOpen}
|
|
||||||
onClose={orgModal.onClose}
|
|
||||||
title={RenderTitle}
|
|
||||||
body={contentBody}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default ManageOrganization;
|
|
||||||
@ -1,193 +0,0 @@
|
|||||||
const ManageOrganization1 = ({
|
|
||||||
projectOrganizations = [],
|
|
||||||
organizationId = null,
|
|
||||||
}) => {
|
|
||||||
const [step, setStep] = useState(1); // default = scenario decision
|
|
||||||
const orgModal = useOrganizationModal();
|
|
||||||
const { data: services, isLoading } = useServices();
|
|
||||||
|
|
||||||
const method = useForm({
|
|
||||||
resolver: zodResolver(organizationSchema),
|
|
||||||
defaultValues: defaultOrganizationValues,
|
|
||||||
});
|
|
||||||
|
|
||||||
const {
|
|
||||||
handleSubmit,
|
|
||||||
register,
|
|
||||||
reset,
|
|
||||||
formState: { errors },
|
|
||||||
} = method;
|
|
||||||
|
|
||||||
const { mutate: CreateOrganization, isPending } = useCreateOrganization(
|
|
||||||
() => {
|
|
||||||
reset(defaultOrganizationValues);
|
|
||||||
orgModal.onClose();
|
|
||||||
setStep(1); // reset to first step
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
// 🔹 Decide first step when modal opens
|
|
||||||
useEffect(() => {
|
|
||||||
if (orgModal.isOpen) {
|
|
||||||
if (organizationId) {
|
|
||||||
setStep(3); // update flow → show org details directly
|
|
||||||
} else if (projectOrganizations && projectOrganizations.length > 0) {
|
|
||||||
setStep(1); // Scenario 1 → from current tenant list
|
|
||||||
} else {
|
|
||||||
setStep(2); // Scenario 2 → search with SPRID
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, [orgModal.isOpen, organizationId, projectOrganizations]);
|
|
||||||
|
|
||||||
const onSubmit = (OrgPayload) => {
|
|
||||||
CreateOrganization(OrgPayload);
|
|
||||||
};
|
|
||||||
|
|
||||||
const RenderTitle = useMemo(() => {
|
|
||||||
if (organizationId) return "Update Organization";
|
|
||||||
if (step === 1) return "Add Organization"; // current tenant
|
|
||||||
if (step === 2) return "Find Organization"; // search with SPRID
|
|
||||||
if (step === 3) return "Organization Details";
|
|
||||||
if (step === 4) return "Create Organization";
|
|
||||||
return "Manage Organization";
|
|
||||||
}, [step, organizationId]);
|
|
||||||
|
|
||||||
const contentBody = (
|
|
||||||
<div>
|
|
||||||
{/* ---------- STEP 1: From Current Tenant Organizations ---------- */}
|
|
||||||
{step === 1 && (
|
|
||||||
<div className="d-block">
|
|
||||||
<div className="list-group mt-3">
|
|
||||||
{projectOrganizations.map((org, idx) => (
|
|
||||||
<div
|
|
||||||
key={idx}
|
|
||||||
className="list-group-item list-group-item-action cursor-pointer"
|
|
||||||
onClick={() => setStep(3)}
|
|
||||||
>
|
|
||||||
<i className="bx bx-building-house me-2"></i>
|
|
||||||
{org}
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="d-flex justify-content-between text-secondary mt-3">
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
className="btn btn-xs btn-outline-secondary"
|
|
||||||
onClick={() => setStep(2)} // jump to SPRID search
|
|
||||||
>
|
|
||||||
<i className="bx bx-search-alt"></i> Find with SPRID
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
className="btn btn-xs btn-secondary"
|
|
||||||
onClick={() => setStep(4)}
|
|
||||||
>
|
|
||||||
<i className="bx bx-plus-circle me-2"></i>
|
|
||||||
Add New Organization
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{/* ---------- STEP 2: Search by Service Provider ID ---------- */}
|
|
||||||
{step === 2 && (
|
|
||||||
<div className="d-block">
|
|
||||||
<div className="text-start mb-1">
|
|
||||||
<Label className="text-secondary">Enter Service Provider ID</Label>
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
className="form-control form-control-sm w-auto"
|
|
||||||
placeholder="SPR - ID"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Example SPR results */}
|
|
||||||
<div className="list-group mt-3">
|
|
||||||
<div
|
|
||||||
className="list-group-item list-group-item-action cursor-pointer"
|
|
||||||
onClick={() => setStep(3)}
|
|
||||||
>
|
|
||||||
<i className="bx bx-building-house me-2"></i>
|
|
||||||
Sample Organization (SPRID)
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="d-flex justify-content-between gap-2 mt-3">
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
className="btn btn-xs btn-outline-secondary"
|
|
||||||
onClick={() => setStep(1)}
|
|
||||||
>
|
|
||||||
<i className="bx bx-left-arrow-alt"></i> Back
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
className="btn btn-xs btn-secondary"
|
|
||||||
onClick={() => setStep(4)}
|
|
||||||
>
|
|
||||||
<i className="bx bx-plus-circle me-2"></i>
|
|
||||||
Add New Organization
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{/* ---------- STEP 3: Organization Details ---------- */}
|
|
||||||
{step === 3 && (
|
|
||||||
<div>
|
|
||||||
<p className="text-muted small">
|
|
||||||
Show organization details here (from SPR or tenant list). User
|
|
||||||
selects services and clicks Add.
|
|
||||||
</p>
|
|
||||||
<div className="mb-2">
|
|
||||||
<Label>Services Offered</Label>
|
|
||||||
<ul className="list-group">
|
|
||||||
<li className="list-group-item">
|
|
||||||
<input type="checkbox" className="form-check-input me-2" />
|
|
||||||
Service 1
|
|
||||||
</li>
|
|
||||||
<li className="list-group-item">
|
|
||||||
<input type="checkbox" className="form-check-input me-2" />
|
|
||||||
Service 2
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<div className="d-flex justify-content-between mt-3">
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
className="btn btn-sm btn-outline-secondary"
|
|
||||||
onClick={() => setStep(1)}
|
|
||||||
>
|
|
||||||
← Back
|
|
||||||
</button>
|
|
||||||
<button type="button" className="btn btn-sm btn-primary">
|
|
||||||
Add
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{/* ---------- STEP 4: Create New Organization ---------- */}
|
|
||||||
{step === 4 && (
|
|
||||||
<FormProvider {...method}>
|
|
||||||
<form className="form" onSubmit={handleSubmit(onSubmit)}>
|
|
||||||
{/* same form as your code, unchanged */}
|
|
||||||
{/* ... */}
|
|
||||||
</form>
|
|
||||||
</FormProvider>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Modal
|
|
||||||
isOpen={orgModal.isOpen}
|
|
||||||
onClose={orgModal.onClose}
|
|
||||||
title={RenderTitle}
|
|
||||||
body={contentBody}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default ManageOrganization;
|
|
||||||
24
src/components/Organization/OrgPicker.css
Normal file
24
src/components/Organization/OrgPicker.css
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
/* Default: hide scrollbar */
|
||||||
|
.scrollable-tbody {
|
||||||
|
max-height: 350px;
|
||||||
|
overflow-y: auto;
|
||||||
|
scrollbar-width: none; /* Firefox */
|
||||||
|
}
|
||||||
|
.scrollable-tbody::-webkit-scrollbar {
|
||||||
|
width: 0; /* Chrome, Safari */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* On hover: show scrollbar */
|
||||||
|
.scrollable-tbody:hover {
|
||||||
|
scrollbar-width: thin; /* Firefox */
|
||||||
|
}
|
||||||
|
.scrollable-tbody:hover::-webkit-scrollbar {
|
||||||
|
width: 6px; /* Adjust width */
|
||||||
|
}
|
||||||
|
.scrollable-tbody:hover::-webkit-scrollbar-thumb {
|
||||||
|
background-color: rgba(0, 0, 0, 0.3);
|
||||||
|
border-radius: 10px;
|
||||||
|
}
|
||||||
|
.scrollable-tbody:hover::-webkit-scrollbar-track {
|
||||||
|
background: transparent;
|
||||||
|
}
|
||||||
157
src/components/Organization/OrgPickerFromSPId.jsx
Normal file
157
src/components/Organization/OrgPickerFromSPId.jsx
Normal file
@ -0,0 +1,157 @@
|
|||||||
|
import { useState } from "react";
|
||||||
|
import {
|
||||||
|
useAssignOrgToTenant,
|
||||||
|
useOrganizationBySPRID,
|
||||||
|
useOrganizationModal,
|
||||||
|
} from "../../hooks/useOrganization";
|
||||||
|
import Label from "../common/Label";
|
||||||
|
import { useDebounce } from "../../utils/appUtils";
|
||||||
|
import { useForm } from "react-hook-form";
|
||||||
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
|
import { spridSchema } from "./OrganizationSchema";
|
||||||
|
import { OrgCardSkeleton } from "./OrganizationSkeleton";
|
||||||
|
import { useQueryClient } from "@tanstack/react-query";
|
||||||
|
|
||||||
|
|
||||||
|
// Zod schema: only allow exactly 4 digits
|
||||||
|
|
||||||
|
const OrgPickerFromSPId = ({ title, placeholder }) => {
|
||||||
|
const { onClose, startStep, flowType, onOpen, prevStep,orgData } =
|
||||||
|
useOrganizationModal();
|
||||||
|
const clientQuery = useQueryClient()
|
||||||
|
const {
|
||||||
|
register,
|
||||||
|
handleSubmit,
|
||||||
|
formState: { errors },
|
||||||
|
watch,
|
||||||
|
} = useForm({
|
||||||
|
resolver: zodResolver(spridSchema),
|
||||||
|
defaultValues: { spridSearchText: "" },
|
||||||
|
});
|
||||||
|
|
||||||
|
const [SPRID, setSPRID] = useState("");
|
||||||
|
|
||||||
|
const { data, isLoading, isError, error, refetch } =
|
||||||
|
useOrganizationBySPRID(SPRID);
|
||||||
|
|
||||||
|
const onSubmit = (formdata) => {
|
||||||
|
setSPRID(formdata.spridSearchText);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleCrateOrg = () => {
|
||||||
|
clientQuery.removeQueries({queryKey:["organization"]})
|
||||||
|
onOpen({ startStep: 4,orgData:null })
|
||||||
|
};
|
||||||
|
const SP = watch("spridSearchText");
|
||||||
|
return (
|
||||||
|
<div className="d-block">
|
||||||
|
<form
|
||||||
|
className="d-flex flex-row gap-6 text-start align-items-center"
|
||||||
|
onSubmit={handleSubmit(onSubmit)}
|
||||||
|
>
|
||||||
|
<div className="d-flex flex-row align-items-center gap-2">
|
||||||
|
<Label className="text-secondary">Search by SPRID</Label>
|
||||||
|
<input
|
||||||
|
type="search"
|
||||||
|
{...register("spridSearchText")}
|
||||||
|
className="form-control form-control-sm w-auto"
|
||||||
|
placeholder="Enter SPRID"
|
||||||
|
maxLength={4}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button type="submit" className="btn btn-sm btn-primary">
|
||||||
|
<i className="bx bx-sm bx-search-alt-2"></i> Search
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
<div className="text-start danger-text">
|
||||||
|
{" "}
|
||||||
|
{errors.spridSearchText && (
|
||||||
|
<p className="text-danger small mt-1">
|
||||||
|
{errors.spridSearchText.message}
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* ---- Organization list ---- */}
|
||||||
|
{isLoading ? (
|
||||||
|
<OrgCardSkeleton />
|
||||||
|
) : data && data?.data.length > 0 ? (
|
||||||
|
<div className="py-2 text-tiny text-center">
|
||||||
|
<div className="d-flex flex-column gap-2 border-0 bg-none">
|
||||||
|
{data.data.map((org) => (
|
||||||
|
<div className="d-flex flex-row gap-2 text-start text-black ">
|
||||||
|
<div className="mt-1">
|
||||||
|
<img
|
||||||
|
src="/public/assets/img/orgLogo.png"
|
||||||
|
alt="logo"
|
||||||
|
width={50}
|
||||||
|
height={50}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="d-flex flex-column p-0 m-0 cursor-pointer">
|
||||||
|
<span className="fs-6 fw-semibold">{org.name}</span>
|
||||||
|
<div className="d-flex gap-2">
|
||||||
|
<small
|
||||||
|
className=" fw-semibold text-uppercase"
|
||||||
|
style={{ letterSpacing: "1px" }}
|
||||||
|
>
|
||||||
|
SPRID :{" "}
|
||||||
|
</small>
|
||||||
|
<small className="fs-6">{org.sprid}</small>
|
||||||
|
</div>
|
||||||
|
<div className="d-flex flex-row gap-2">
|
||||||
|
<small className="text-small fw-semibold">Address:</small>
|
||||||
|
<div className="d-flex text-wrap">{org.address}</div>
|
||||||
|
</div>
|
||||||
|
<div className="m-0 p-0">
|
||||||
|
{" "}
|
||||||
|
<button
|
||||||
|
type="submit"
|
||||||
|
className="btn btn-sm btn-primary"
|
||||||
|
onClick={() => onOpen({ startStep: 3, orgData: org })}
|
||||||
|
>
|
||||||
|
Select
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
) : SPRID ? (
|
||||||
|
<div className="py-3 text-center text-secondary">
|
||||||
|
No organization found for "{SPRID}"
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
|
<div className="py-12 text-center text-tiny text-black">
|
||||||
|
<small className="d-block text-secondary">
|
||||||
|
Do not have SPRID or could not find organization ?
|
||||||
|
</small>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="btn btn-sm btn-primary mt-3"
|
||||||
|
onClick={handleCrateOrg}
|
||||||
|
>
|
||||||
|
<i className="bx bx-plus-circle me-2"></i>
|
||||||
|
Create New Organization
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* ---- Footer buttons ---- */}
|
||||||
|
<div className={`d-flex text-secondary mt-3`}>
|
||||||
|
{flowType !== "default" && (
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="btn btn-xs btn-outline-secondary"
|
||||||
|
onClick={() => onOpen({ startStep: prevStep })}
|
||||||
|
>
|
||||||
|
<i className="bx bx-chevron-left"></i> Back
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default OrgPickerFromSPId;
|
||||||
182
src/components/Organization/OrgPickerfromTenant.jsx
Normal file
182
src/components/Organization/OrgPickerfromTenant.jsx
Normal file
@ -0,0 +1,182 @@
|
|||||||
|
import { useState } from "react";
|
||||||
|
import {
|
||||||
|
useOrganizationModal,
|
||||||
|
useOrganizationsList,
|
||||||
|
} from "../../hooks/useOrganization";
|
||||||
|
import { ITEMS_PER_PAGE } from "../../utils/constants";
|
||||||
|
import Label from "../common/Label";
|
||||||
|
import Pagination from "../common/Pagination";
|
||||||
|
import "./OrgPicker.css"
|
||||||
|
|
||||||
|
const OrgPickerfromTenant = ({ title }) => {
|
||||||
|
const [searchText, setSearchText] = useState("");
|
||||||
|
const [currentPage, setCurrentPage] = useState(1);
|
||||||
|
const { data, isLoading } = useOrganizationsList(
|
||||||
|
ITEMS_PER_PAGE - 10,
|
||||||
|
1,
|
||||||
|
true,
|
||||||
|
null,
|
||||||
|
searchText
|
||||||
|
);
|
||||||
|
|
||||||
|
const paginate = (page) => {
|
||||||
|
if (page >= 1 && page <= (data?.totalPages ?? 1)) {
|
||||||
|
setCurrentPage(page);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const { isOpen, orgData, startStep, onOpen, flowType, prevStep } =
|
||||||
|
useOrganizationModal();
|
||||||
|
|
||||||
|
const handleBack = () => {
|
||||||
|
if (prevStep == 1 && flowType == "assign") {
|
||||||
|
onOpen({ startStep: prevStep });
|
||||||
|
} else if (prevStep == 1 && flowType == "assign") {
|
||||||
|
onOpen({ startStep: 1 });
|
||||||
|
} else {
|
||||||
|
onOpen({ startStep: 2 });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const contactList = [
|
||||||
|
{
|
||||||
|
key: "name",
|
||||||
|
label: "Name",
|
||||||
|
getValue: (org) => (
|
||||||
|
<div className="d-flex gap-2 py-1 ">
|
||||||
|
<i class="bx bx-buildings"></i>
|
||||||
|
<span
|
||||||
|
className="text-truncate d-inline-block "
|
||||||
|
style={{ maxWidth: "150px" }}
|
||||||
|
>
|
||||||
|
{org?.name || "N/A"}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
align: "text-start",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "sprid",
|
||||||
|
label: "SPRID",
|
||||||
|
getValue: (org) => (
|
||||||
|
<span
|
||||||
|
className="text-truncate d-inline-block"
|
||||||
|
style={{ maxWidth: "200px" }}
|
||||||
|
>
|
||||||
|
{org?.sprid || "N/A"}
|
||||||
|
</span>
|
||||||
|
),
|
||||||
|
align: "text-center",
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="d-block">
|
||||||
|
<div className="d-flex align-items-center gap-2 mb-1">
|
||||||
|
<Label className="mb-0">{title}</Label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
value={searchText}
|
||||||
|
onChange={(e) => setSearchText?.(e.target.value)}
|
||||||
|
className="form-control form-control-sm w-auto"
|
||||||
|
placeholder="Enter Organization Name"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
{/* ---- Organization list ---- */}
|
||||||
|
{isLoading ? (
|
||||||
|
<div>Loading....</div>
|
||||||
|
) : data && data?.data?.length > 0 ? (
|
||||||
|
<div className="dataTables_wrapper no-footer pb-5">
|
||||||
|
<table className="table dataTable text-nowrap">
|
||||||
|
<thead>
|
||||||
|
<tr className="table_header_border">
|
||||||
|
{contactList.map((col) => (
|
||||||
|
<th key={col.key} className={col.align}>
|
||||||
|
{col.label}
|
||||||
|
</th>
|
||||||
|
))}
|
||||||
|
<th className="sticky-action-column bg-white text-center">
|
||||||
|
Action
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<div
|
||||||
|
className="scrollable-tbody overflow-y-auto"
|
||||||
|
style={{ maxHeight: "350px" }}
|
||||||
|
>
|
||||||
|
<table className="table dataTable text-nowrap mb-0">
|
||||||
|
<tbody>
|
||||||
|
{Array.isArray(data.data) && data.data.length > 0
|
||||||
|
? data.data.map((row, i) => (
|
||||||
|
<tr key={i}>
|
||||||
|
{contactList.map((col) => (
|
||||||
|
<td key={col.key} className={col.align}>
|
||||||
|
{col.getValue(row)}
|
||||||
|
</td>
|
||||||
|
))}
|
||||||
|
<td className="sticky-action-column p-0 bg-white">
|
||||||
|
<div className="p-1">
|
||||||
|
<span
|
||||||
|
type="submit"
|
||||||
|
className="btn btn-sm"
|
||||||
|
onClick={() =>
|
||||||
|
onOpen({ startStep: 3, orgData: row })
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<i class='bx bx-right-arrow-circle text-primary'></i>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
))
|
||||||
|
: null}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
|
<div className="d-flex flex-column align-items-center text-center text-wrap text-black gap-2">
|
||||||
|
<small className="mb-1">
|
||||||
|
Could not find organization in your database? Please search within the
|
||||||
|
global database.
|
||||||
|
</small>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="btn btn-sm btn-primary w-auto"
|
||||||
|
onClick={() => onOpen({ startStep: 2 })}
|
||||||
|
>
|
||||||
|
Search Using SPRID
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
{/* ---- Footer buttons ---- */}
|
||||||
|
<div
|
||||||
|
className={`d-flex justify-content-end
|
||||||
|
text-secondary mt-3`}
|
||||||
|
>
|
||||||
|
{flowType == "default" && (
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="btn btn-sm btn-outline-secondary"
|
||||||
|
onClick={handleBack}
|
||||||
|
>
|
||||||
|
<i className="bx bx-left-arrow-alt"></i> Back
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* <button
|
||||||
|
type="button"
|
||||||
|
className="btn btn-sm btn-secondary"
|
||||||
|
onClick={() => onOpen({ startStep: 4 })}
|
||||||
|
>
|
||||||
|
<i className="bx bx-plus-circle me-2"></i>
|
||||||
|
Add New Organization
|
||||||
|
</button> */}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default OrgPickerfromTenant;
|
||||||
117
src/components/Organization/OrganizationModal.jsx
Normal file
117
src/components/Organization/OrganizationModal.jsx
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
|
import React, { useMemo, useState } from "react";
|
||||||
|
import { FormProvider, useForm } from "react-hook-form";
|
||||||
|
import {
|
||||||
|
defaultOrganizationValues,
|
||||||
|
organizationSchema,
|
||||||
|
} from "./OrganizationSchema";
|
||||||
|
import Modal from "../common/Modal";
|
||||||
|
import {
|
||||||
|
useCreateOrganization,
|
||||||
|
useOrganizationBySPRID,
|
||||||
|
useOrganizationModal,
|
||||||
|
useOrganizationsList,
|
||||||
|
} from "../../hooks/useOrganization";
|
||||||
|
import Label from "../common/Label";
|
||||||
|
import SelectMultiple from "../common/SelectMultiple";
|
||||||
|
import { useServices } from "../../hooks/masterHook/useMaster";
|
||||||
|
import AssignOrg from "./AssignOrg";
|
||||||
|
import ManagOrg from "./ManagOrg";
|
||||||
|
import OrgPickerFromSPId from "./OrgPickerFromSPId";
|
||||||
|
import OrgPickerfromTenant from "./OrgPickerfromTenant";
|
||||||
|
import ViewOrganization from "./ViewOrganization";
|
||||||
|
|
||||||
|
const OrganizationModal = () => {
|
||||||
|
const { isOpen, orgData, startStep, onOpen, onClose, onToggle } =
|
||||||
|
useOrganizationModal();
|
||||||
|
const { data: masterService, isLoading } = useServices();
|
||||||
|
const [searchText, setSearchText] = useState();
|
||||||
|
const [SPRID, setSPRID] = useState("");
|
||||||
|
|
||||||
|
const [Organization, setOrganization] = useState({});
|
||||||
|
|
||||||
|
const method = useForm({
|
||||||
|
resolver: zodResolver(organizationSchema),
|
||||||
|
defaultValues: defaultOrganizationValues,
|
||||||
|
});
|
||||||
|
|
||||||
|
const {
|
||||||
|
handleSubmit,
|
||||||
|
register,
|
||||||
|
reset,
|
||||||
|
formState: { errors },
|
||||||
|
} = method;
|
||||||
|
|
||||||
|
const { mutate: CreateOrganization, isPending } = useCreateOrganization(
|
||||||
|
() => {
|
||||||
|
reset(defaultOrganizationValues);
|
||||||
|
onClose();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
const onSubmit = (OrgPayload) => {
|
||||||
|
CreateOrganization(OrgPayload);
|
||||||
|
};
|
||||||
|
|
||||||
|
const RenderTitle = useMemo(() => {
|
||||||
|
if (orgData && startStep === 3 ) {
|
||||||
|
return "Assign Organization";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (startStep === 1) {
|
||||||
|
return orgData && orgData !== null
|
||||||
|
? "Add Organization"
|
||||||
|
: "Choose Organization";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (startStep === 2) {
|
||||||
|
return "Add Organization";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (startStep === 3) {
|
||||||
|
return "Assign Organization";
|
||||||
|
}
|
||||||
|
if(startStep === 5){
|
||||||
|
return "Organization Details"
|
||||||
|
}
|
||||||
|
|
||||||
|
return `${orgData ? "Update":"Create"} Organization`;
|
||||||
|
}, [startStep, orgData]);
|
||||||
|
|
||||||
|
const contentBody = (
|
||||||
|
<div>
|
||||||
|
{/* ---------- STEP 1: Service Provider- Form Own Tenant list ---------- */}
|
||||||
|
{startStep === 1 && <OrgPickerfromTenant title="Find Organization" />}
|
||||||
|
|
||||||
|
{startStep === 2 && (
|
||||||
|
<OrgPickerFromSPId
|
||||||
|
title="Find Organization"
|
||||||
|
placeholder="Enter Service Provider Id"
|
||||||
|
projectOrganizations={orgData}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* ---------- STEP 2: Existing Organization Details ---------- */}
|
||||||
|
{startStep === 3 && Organization && (
|
||||||
|
<AssignOrg Organization={Organization} />
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* ---------- STEP 3: Add New Organization ---------- */}
|
||||||
|
{startStep === 4 && <ManagOrg />}
|
||||||
|
|
||||||
|
{/* ---------- STEP 3: View Organization ---------- */}
|
||||||
|
{startStep === 5 && <ViewOrganization orgId={orgData}/>}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Modal
|
||||||
|
isOpen={isOpen}
|
||||||
|
onClose={onClose}
|
||||||
|
title={RenderTitle}
|
||||||
|
body={contentBody}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default OrganizationModal;
|
||||||
@ -7,19 +7,19 @@ export const organizationSchema = z.object({
|
|||||||
contactNumber: z
|
contactNumber: z
|
||||||
.string()
|
.string()
|
||||||
.trim()
|
.trim()
|
||||||
.min(7, { message: "Contact number must be at least 7 digits" })
|
.min(7, { message: "Contact number must be at least 7 digits" })
|
||||||
.max(20, { message: "Contact number cannot exceed 12 digits" })
|
.max(20, { message: "Contact number cannot exceed 12 digits" })
|
||||||
|
|
||||||
.regex(phoneRegex, { message: "Invalid phone number" }),
|
.regex(phoneRegex, { message: "Invalid phone number" }),
|
||||||
contactPerson: z.string().min(1, { message: "Person name required" }),
|
contactPerson: z.string().min(1, { message: "Person name required" }),
|
||||||
address: z.string().min(1, { message: "Address is required!" }),
|
address: z.string().min(1, { message: "Address is required!" }),
|
||||||
email: z
|
email: z
|
||||||
.string()
|
.string().trim()
|
||||||
.min(1, { message: "Email is required" })
|
.min(1, { message: "Email is required" })
|
||||||
.email("Invalid email address"),
|
.email("Invalid email address"),
|
||||||
serviceIds: z
|
serviceIds: z
|
||||||
.array(z.string())
|
.array(z.string())
|
||||||
.min(1, { message: "Please insert service id" }),
|
.min(1, { message: "Service isrequired" }),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const defaultOrganizationValues = {
|
export const defaultOrganizationValues = {
|
||||||
@ -30,3 +30,28 @@ export const defaultOrganizationValues = {
|
|||||||
email: "",
|
email: "",
|
||||||
serviceIds: [],
|
serviceIds: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const assignedOrgToProject = z.object({
|
||||||
|
// projectId: z.string().uuid({ message: "Invalid projectId format" }),
|
||||||
|
// organizationId: z.string().string({ message: "Invalid organizationId format" }),
|
||||||
|
// parentOrganizationId: z
|
||||||
|
// .string()
|
||||||
|
// .nullable()
|
||||||
|
// .optional(),
|
||||||
|
serviceIds: z.preprocess(
|
||||||
|
(val) => (Array.isArray(val) ? val : []),
|
||||||
|
z
|
||||||
|
.array(z.string().uuid({ message: "Invalid serviceId format" }))
|
||||||
|
.nonempty({ message: "At least one service must be selected" })
|
||||||
|
),
|
||||||
|
|
||||||
|
organizationTypeId: z
|
||||||
|
.string()
|
||||||
|
.min(1, { message: "Organization is required" }),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const spridSchema = z.object({
|
||||||
|
spridSearchText: z
|
||||||
|
.string()
|
||||||
|
.regex(/^\d{4}$/, { message: "SPRID must be exactly 4 digits" }),
|
||||||
|
});
|
||||||
|
|||||||
123
src/components/Organization/OrganizationSkeleton.jsx
Normal file
123
src/components/Organization/OrganizationSkeleton.jsx
Normal file
@ -0,0 +1,123 @@
|
|||||||
|
const SkeletonLine = ({ height = 20, width = "100%", className = "" }) => (
|
||||||
|
<div
|
||||||
|
className={`skeleton mb-2 ${className}`}
|
||||||
|
style={{
|
||||||
|
height,
|
||||||
|
width,
|
||||||
|
}}
|
||||||
|
></div>
|
||||||
|
);
|
||||||
|
export const OrgCardSkeleton = () => {
|
||||||
|
return (
|
||||||
|
<div className="row p-3">
|
||||||
|
{[...Array(1)].map((_, idx) => (
|
||||||
|
<div
|
||||||
|
key={idx}
|
||||||
|
className="list-group-item d-flex flex-row gap-2 align-items-start border-0 shadow-sm rounded mb-3 p-3"
|
||||||
|
>
|
||||||
|
{/* Left: Logo/avatar placeholder */}
|
||||||
|
<div className="mt-1">
|
||||||
|
<SkeletonLine height={50} width={50} className="rounded-circle" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Right: Info section */}
|
||||||
|
<div className="d-flex flex-column flex-grow-1 text-start">
|
||||||
|
{/* Org name */}
|
||||||
|
<SkeletonLine height={18} width="160px" className="mb-2" />
|
||||||
|
|
||||||
|
{/* SPRID */}
|
||||||
|
<div className="d-flex gap-2 mb-2">
|
||||||
|
<SkeletonLine height={14} width="60px" />
|
||||||
|
<SkeletonLine height={14} width="100px" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Address */}
|
||||||
|
<div className="d-flex gap-2">
|
||||||
|
<SkeletonLine height={14} width="70px" />
|
||||||
|
<SkeletonLine height={14} width="100%" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
export const OrgDetailsSkeleton = () => {
|
||||||
|
return (
|
||||||
|
<div className="row text-start p-3">
|
||||||
|
{/* Header */}
|
||||||
|
<div className="col-12 mb-3">
|
||||||
|
<div className="d-flex justify-content-between align-items-center">
|
||||||
|
{/* Logo + Name */}
|
||||||
|
<div className="d-flex flex-row gap-2 align-items-center">
|
||||||
|
<SkeletonLine height={40} width={40} className="rounded-circle" />
|
||||||
|
<SkeletonLine height={18} width="180px" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Status Badge */}
|
||||||
|
<SkeletonLine height={20} width="70px" className="rounded-pill" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Section Title */}
|
||||||
|
<div className="d-flex text-secondary mb-2">
|
||||||
|
<SkeletonLine height={16} width="140px" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Contact Person */}
|
||||||
|
<div className="col-md-6 mb-3">
|
||||||
|
<div className="d-flex">
|
||||||
|
<SkeletonLine height={16} width="130px" className="me-2" />
|
||||||
|
<SkeletonLine height={16} width="140px" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Contact Number */}
|
||||||
|
<div className="col-md-6 mb-3">
|
||||||
|
<div className="d-flex">
|
||||||
|
<SkeletonLine height={16} width="130px" className="me-2" />
|
||||||
|
<SkeletonLine height={16} width="140px" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Email */}
|
||||||
|
<div className="col-md-12 mb-3">
|
||||||
|
<div className="d-flex">
|
||||||
|
<SkeletonLine height={16} width="130px" className="me-2" />
|
||||||
|
<SkeletonLine height={16} width="220px" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* SPRID */}
|
||||||
|
<div className="col-6 mb-3">
|
||||||
|
<div className="d-flex">
|
||||||
|
<SkeletonLine height={16} width="130px" className="me-2" />
|
||||||
|
<SkeletonLine height={16} width="160px" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Employees */}
|
||||||
|
<div className="col-6 mb-3">
|
||||||
|
<div className="d-flex">
|
||||||
|
<SkeletonLine height={16} width="130px" className="me-2" />
|
||||||
|
<SkeletonLine height={16} width="60px" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Address */}
|
||||||
|
<div className="col-12 mb-3">
|
||||||
|
<div className="d-flex">
|
||||||
|
<SkeletonLine height={16} width="130px" className="me-2" />
|
||||||
|
<SkeletonLine height={16} width="100%" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Section Title 2 */}
|
||||||
|
<div className="d-flex text-secondary mb-2">
|
||||||
|
<SkeletonLine height={16} width="200px" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
@ -1,10 +1,12 @@
|
|||||||
import React from "react";
|
import React, { useState } from "react";
|
||||||
import { useOrganizationsList } from "../../hooks/useOrganization";
|
import { useOrganizationModal, useOrganizationsList } from "../../hooks/useOrganization";
|
||||||
import { ITEMS_PER_PAGE } from "../../utils/constants";
|
import { ITEMS_PER_PAGE } from "../../utils/constants";
|
||||||
import Avatar from "../common/Avatar";
|
import Avatar from "../common/Avatar";
|
||||||
import { useDebounce } from "../../utils/appUtils";
|
import { useDebounce } from "../../utils/appUtils";
|
||||||
|
import Pagination from "../common/Pagination";
|
||||||
|
|
||||||
const OrganizationsList = ({searchText}) => {
|
const OrganizationsList = ({searchText}) => {
|
||||||
|
const [currentPage, setCurrentPage] = useState(1);
|
||||||
const searchString = useDebounce(searchText,500)
|
const searchString = useDebounce(searchText,500)
|
||||||
const {
|
const {
|
||||||
data = [],
|
data = [],
|
||||||
@ -13,6 +15,7 @@ const OrganizationsList = ({searchText}) => {
|
|||||||
isError,
|
isError,
|
||||||
error,
|
error,
|
||||||
} = useOrganizationsList(ITEMS_PER_PAGE, 1, true,null,searchString);
|
} = useOrganizationsList(ITEMS_PER_PAGE, 1, true,null,searchString);
|
||||||
|
const {onClose, startStep, flowType, onOpen,orgData } = useOrganizationModal();
|
||||||
|
|
||||||
const organizationsColumns = [
|
const organizationsColumns = [
|
||||||
{
|
{
|
||||||
@ -20,7 +23,7 @@ const OrganizationsList = ({searchText}) => {
|
|||||||
label: "Organization Name",
|
label: "Organization Name",
|
||||||
getValue: (org) => (
|
getValue: (org) => (
|
||||||
<div className="d-flex gap-2 py-1 ">
|
<div className="d-flex gap-2 py-1 ">
|
||||||
<i class="bx bx-buildings"></i>
|
<i className="bx bx-buildings"></i>
|
||||||
<span
|
<span
|
||||||
className="text-truncate d-inline-block "
|
className="text-truncate d-inline-block "
|
||||||
style={{ maxWidth: "150px" }}
|
style={{ maxWidth: "150px" }}
|
||||||
@ -81,11 +84,16 @@ const OrganizationsList = ({searchText}) => {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const paginate = (page) => {
|
||||||
|
if (page >= 1 && page <= (data?.totalPages ?? 1)) {
|
||||||
|
setCurrentPage(page);
|
||||||
|
}
|
||||||
|
};
|
||||||
if (isFetching && !isFetching) return <div>Loading...</div>;
|
if (isFetching && !isFetching) return <div>Loading...</div>;
|
||||||
if (isError) return <div>{error?.message || "Something went wrong"}</div>;
|
if (isError) return <div>{error?.message || "Something went wrong"}</div>;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="card px-0 px-sm-4">
|
<div className="card px-0 px-sm-4 pb-12 pt-5">
|
||||||
<div className="card-datatable table-responsive" id="horizontal-example">
|
<div className="card-datatable table-responsive" id="horizontal-example">
|
||||||
<div className="dataTables_wrapper no-footer px-2">
|
<div className="dataTables_wrapper no-footer px-2">
|
||||||
<table className="table border-top dataTable text-nowrap">
|
<table className="table border-top dataTable text-nowrap">
|
||||||
@ -106,8 +114,8 @@ const OrganizationsList = ({searchText}) => {
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{data.length > 0 ? (
|
{data?.data?.length > 0 ? (
|
||||||
data.map((org) => (
|
data?.data?.map((org) => (
|
||||||
<tr key={org.id}>
|
<tr key={org.id}>
|
||||||
{organizationsColumns.map((col) => (
|
{organizationsColumns.map((col) => (
|
||||||
<td
|
<td
|
||||||
@ -120,9 +128,9 @@ const OrganizationsList = ({searchText}) => {
|
|||||||
</td>
|
</td>
|
||||||
))}
|
))}
|
||||||
<td className="sticky-action-column ">
|
<td className="sticky-action-column ">
|
||||||
<div className="d-flex justify-content-center gap-2 ">
|
<div className="d-flex justify-content-center gap-2">
|
||||||
<i className="bx bx-show text-primary cursor-pointer"></i>
|
<i className="bx bx-show text-primary cursor-pointer" onClick={()=>onOpen({startStep:5,orgData:org.id,flowType:"view"})}></i>
|
||||||
<i className="bx bx-edit text-secondary cursor-pointer"></i>
|
<i className="bx bx-edit text-secondary cursor-pointer" onClick={()=>onOpen({startStep:4,orgData:org,flowType:"edit"})}></i>
|
||||||
<i className="bx bx-trash text-danger cursor-pointer"></i>
|
<i className="bx bx-trash text-danger cursor-pointer"></i>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
@ -134,12 +142,19 @@ const OrganizationsList = ({searchText}) => {
|
|||||||
colSpan={organizationsColumns.length + 1}
|
colSpan={organizationsColumns.length + 1}
|
||||||
className="text-center"
|
className="text-center"
|
||||||
>
|
>
|
||||||
<p className="fw-semibold">Not Found</p>
|
<p className="fw-semibold">{isLoading ? "Loading....":"Not Found Organization"}</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
)}
|
)}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
{data?.data?.length > 0 && (
|
||||||
|
<Pagination
|
||||||
|
currentPage={currentPage}
|
||||||
|
totalPages={data.totalPages}
|
||||||
|
onPageChange={paginate}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
116
src/components/Organization/ViewOrganization.jsx
Normal file
116
src/components/Organization/ViewOrganization.jsx
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
import React from "react";
|
||||||
|
import { useOrganization } from "../../hooks/useOrganization";
|
||||||
|
import { OrgDetailsSkeleton } from "./OrganizationSkeleton";
|
||||||
|
|
||||||
|
const VieworgDataanization = ({ orgId }) => {
|
||||||
|
const { data, isLoading, isError, error } = useOrganization(orgId);
|
||||||
|
if (isLoading) return <OrgDetailsSkeleton />;
|
||||||
|
if (isError) return <div>{error.message}</div>;
|
||||||
|
return (
|
||||||
|
<div className="row text-black text-black text-start ">
|
||||||
|
{/* Header */}
|
||||||
|
<div className="col-12 mb-3">
|
||||||
|
<div className="d-flex justify-content-between align-items-center text-start mb-1">
|
||||||
|
<div className="d-flex flex-row gap-2 align-items-center text-wrap">
|
||||||
|
<img
|
||||||
|
src="/public/assets/img/orgLogo.png"
|
||||||
|
alt="logo"
|
||||||
|
width={40}
|
||||||
|
height={40}
|
||||||
|
/>{" "}
|
||||||
|
<p className="fw-semibold fs-6 m-0">{data?.name}</p>
|
||||||
|
</div>
|
||||||
|
<div className="text-end">
|
||||||
|
<span
|
||||||
|
className={`badge bg-label-${
|
||||||
|
data?.isActive ? "primary" : "secondary"
|
||||||
|
} `}
|
||||||
|
>
|
||||||
|
{data?.isActive ? "Active" : "In-Active"}{" "}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="d-flex text-secondary mb-2">
|
||||||
|
{" "}
|
||||||
|
<i className="bx bx-sm bx-info-circle me-1" /> Organization Info
|
||||||
|
</div>
|
||||||
|
{/* Contact Info */}
|
||||||
|
<div className="col-md-6 mb-3">
|
||||||
|
<div className="d-flex">
|
||||||
|
<label
|
||||||
|
className="form-label me-2 mb-0 fw-semibold"
|
||||||
|
style={{ minWidth: "130px" }}
|
||||||
|
>
|
||||||
|
<i className="bx bx-sm bx-user me-1" /> Contact Person :
|
||||||
|
</label>
|
||||||
|
<div className="text-muted">{data?.contactPerson}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="col-md-6 mb-3">
|
||||||
|
<div className="d-flex">
|
||||||
|
<label
|
||||||
|
className="form-label me-2 mb-0 fw-semibold"
|
||||||
|
style={{ minWidth: "130px" }}
|
||||||
|
>
|
||||||
|
<i className="bx bx-sm me-1 bx-phone"></i> Contact Number :
|
||||||
|
</label>
|
||||||
|
<div className="text-muted">{data?.contactNumber}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="col-md-12 mb-3">
|
||||||
|
<div className="d-flex">
|
||||||
|
<label
|
||||||
|
className="form-label me-2 mb-0 fw-semibold"
|
||||||
|
style={{ minWidth: "130px" }}
|
||||||
|
>
|
||||||
|
<i className="bx bx-sm me-1 bx-envelope"></i> Email Address :
|
||||||
|
</label>
|
||||||
|
<div className="text-muted">{data?.email}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="col-6 mb-3">
|
||||||
|
<div className="d-flex">
|
||||||
|
<label
|
||||||
|
className="form-label me-2 mb-0 fw-semibold"
|
||||||
|
style={{ maxWidth: "130px" }}
|
||||||
|
>
|
||||||
|
<i className="bx bx-sm me-1 bx-barcode"></i>
|
||||||
|
Service Provider Id (SPRID) :
|
||||||
|
</label>
|
||||||
|
<div className="text-muted">{data?.sprid}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="col-6 mb-3">
|
||||||
|
<div className="d-flex">
|
||||||
|
<label
|
||||||
|
className="form-label me-2 mb-0 fw-semibold"
|
||||||
|
style={{ maxWidth: "130px" }}
|
||||||
|
>
|
||||||
|
<i className="bx bx-sm me-1 bx-group"></i>
|
||||||
|
Employees :
|
||||||
|
</label>
|
||||||
|
<div className="text-muted">{data?.activeEmployeeCount}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="col-12 mb-3">
|
||||||
|
<div className="d-flex">
|
||||||
|
<label
|
||||||
|
className="form-label me-1 mb-0 fw-semibold"
|
||||||
|
style={{ minWidth: "130px" }}
|
||||||
|
>
|
||||||
|
<i className="bx bx-sm me-1 bx-map"></i> Address :
|
||||||
|
</label>
|
||||||
|
<div className="text-muted text-start">{data?.address}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="d-flex text-secondary mb-2">
|
||||||
|
{" "}
|
||||||
|
<i className="bx bx-sm bx-briefcase me-1" /> Projects And Services
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default VieworgDataanization;
|
||||||
1
src/components/Organization/tempCodeRunnerFile.jsx
Normal file
1
src/components/Organization/tempCodeRunnerFile.jsx
Normal file
@ -0,0 +1 @@
|
|||||||
|
useAssignOrgToTenant
|
||||||
@ -42,7 +42,7 @@ const AboutProject = () => {
|
|||||||
{IsOpenModal && (
|
{IsOpenModal && (
|
||||||
<GlobalModel isOpen={IsOpenModal} closeModal={() => setIsOpenModal(false)}>
|
<GlobalModel isOpen={IsOpenModal} closeModal={() => setIsOpenModal(false)}>
|
||||||
<ManageProjectInfo
|
<ManageProjectInfo
|
||||||
project={projects_Details}
|
project={projects_Details?.id}
|
||||||
handleSubmitForm={handleFormSubmit}
|
handleSubmitForm={handleFormSubmit}
|
||||||
onClose={() => setIsOpenModal(false)}
|
onClose={() => setIsOpenModal(false)}
|
||||||
isPending={isPending}
|
isPending={isPending}
|
||||||
|
|||||||
@ -1,24 +1,26 @@
|
|||||||
import React, { useState, useEffect, useRef, useCallback } from "react";
|
import React, { useState, useEffect, useRef, useCallback } from "react";
|
||||||
import { useDispatch, useSelector } from "react-redux";
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
import { changeMaster } from "../../slices/localVariablesSlice";
|
import { changeMaster } from "../../slices/localVariablesSlice";
|
||||||
import useMaster from "../../hooks/masterHook/useMaster";
|
import useMaster, { useServices } from "../../hooks/masterHook/useMaster";
|
||||||
import { useForm, Controller } from "react-hook-form";
|
import { useForm, Controller } from "react-hook-form";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
import { clearCacheKey, getCachedData } from "../../slices/apiDataManager";
|
import { useSelectedProject } from "../../slices/apiDataManager";
|
||||||
import { useEmployeesAllOrByProjectId } from "../../hooks/useEmployees";
|
import { useEmployeesAllOrByProjectId } from "../../hooks/useEmployees";
|
||||||
import { TasksRepository } from "../../repositories/ProjectRepository";
|
import { TasksRepository } from "../../repositories/ProjectRepository";
|
||||||
import showToast from "../../services/toastService";
|
import showToast from "../../services/toastService";
|
||||||
import { useProjectDetails } from "../../hooks/useProjects";
|
import {
|
||||||
|
useEmployeeForTaskAssign,
|
||||||
|
useProjectAssignedOrganizationsName,
|
||||||
|
useProjectAssignedServices,
|
||||||
|
useProjectDetails,
|
||||||
|
} from "../../hooks/useProjects";
|
||||||
import eventBus from "../../services/eventBus";
|
import eventBus from "../../services/eventBus";
|
||||||
import { useCreateTask } from "../../hooks/useTasks";
|
import { useCreateTask } from "../../hooks/useTasks";
|
||||||
import Label from "../common/Label";
|
import Label from "../common/Label";
|
||||||
|
|
||||||
const AssignTask = ({ assignData, onClose, setAssigned }) => {
|
const TaskSchema = (maxPlanned) => {
|
||||||
const maxPlanned =
|
return z.object({
|
||||||
assignData?.workItem?.plannedWork - assignData?.workItem?.completedWork;
|
|
||||||
|
|
||||||
const schema = z.object({
|
|
||||||
selectedEmployees: z
|
selectedEmployees: z
|
||||||
.array(z.string())
|
.array(z.string())
|
||||||
.min(1, { message: "At least one employee must be selected" }),
|
.min(1, { message: "At least one employee must be selected" }),
|
||||||
@ -37,20 +39,26 @@ const AssignTask = ({ assignData, onClose, setAssigned }) => {
|
|||||||
})
|
})
|
||||||
),
|
),
|
||||||
});
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const AssignTask = ({ assignData, onClose, setAssigned }) => {
|
||||||
|
const planned = assignData?.workItem?.plannedWork || 0;
|
||||||
|
const completed = assignData?.workItem?.completedWork || 0;
|
||||||
|
const maxPlanned = planned - completed;
|
||||||
|
|
||||||
const [isHelpVisibleTarget, setIsHelpVisibleTarget] = useState(false);
|
const [isHelpVisibleTarget, setIsHelpVisibleTarget] = useState(false);
|
||||||
const helpPopupRefTarget = useRef(null);
|
const helpPopupRefTarget = useRef(null);
|
||||||
const [isHelpVisible, setIsHelpVisible] = useState(false);
|
const [isHelpVisible, setIsHelpVisible] = useState(false);
|
||||||
|
const [selectedService, setSelectedService] = useState(null);
|
||||||
|
const [selectedOrganization, setSelectedOrganization] = useState(null);
|
||||||
|
|
||||||
const { mutate: assignTask, isPending: isSubmitting } = useCreateTask({
|
const { mutate: assignTask, isPending: isSubmitting } = useCreateTask({
|
||||||
onSuccessCallback: () => {
|
onSuccessCallback: closedModel,
|
||||||
closedModel();
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const dropdownRef = useRef(null);
|
const dropdownRef = useRef(null);
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
|
|
||||||
// Close dropdown on outside click
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const handleClickOutside = (event) => {
|
const handleClickOutside = (event) => {
|
||||||
if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
|
if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
|
||||||
@ -63,48 +71,47 @@ const AssignTask = ({ assignData, onClose, setAssigned }) => {
|
|||||||
|
|
||||||
const infoRef = useRef(null);
|
const infoRef = useRef(null);
|
||||||
const infoRef1 = useRef(null);
|
const infoRef1 = useRef(null);
|
||||||
|
|
||||||
// State for search term
|
|
||||||
const [searchTerm, setSearchTerm] = useState("");
|
const [searchTerm, setSearchTerm] = useState("");
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (typeof bootstrap !== "undefined") {
|
if (typeof bootstrap !== "undefined") {
|
||||||
if (infoRef.current) {
|
infoRef.current &&
|
||||||
new bootstrap.Popover(infoRef.current, {
|
new bootstrap.Popover(infoRef.current, {
|
||||||
trigger: "focus",
|
trigger: "focus",
|
||||||
placement: "right",
|
placement: "right",
|
||||||
html: true,
|
html: true,
|
||||||
content: `<div>Total Pending tasks of the Activity</div>`,
|
content: `<div>Total Pending tasks of the Activity</div>`,
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
if (infoRef1.current) {
|
infoRef1.current &&
|
||||||
new bootstrap.Popover(infoRef1.current, {
|
new bootstrap.Popover(infoRef1.current, {
|
||||||
trigger: "focus",
|
trigger: "focus",
|
||||||
placement: "right",
|
placement: "right",
|
||||||
html: true,
|
html: true,
|
||||||
content: `<div>Target task for today</div>`,
|
content: `<div>Target task for today</div>`,
|
||||||
});
|
});
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
console.warn("Bootstrap is not available. Popovers might not function.");
|
console.warn("Bootstrap is not available. Popovers might not function.");
|
||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
const selectedProject = useSelector(
|
|
||||||
(store) => store.localVariables.projectId
|
|
||||||
);
|
|
||||||
const {
|
|
||||||
employees,
|
|
||||||
loading: employeeLoading,
|
|
||||||
recallEmployeeData,
|
|
||||||
} = useEmployeesAllOrByProjectId(false, selectedProject, false);
|
|
||||||
const dispatch = useDispatch();
|
|
||||||
const { loading } = useMaster();
|
|
||||||
const { data: jobRoleData } = useMaster();
|
|
||||||
|
|
||||||
// Changed to an array to hold multiple selected roles
|
const selectedProject = useSelectedProject();
|
||||||
|
const { data: serviceList, isLoading: isServiceLoading } = useProjectAssignedServices(selectedProject);
|
||||||
|
const { data: organizationList, isLoading: isOrgLoading } =
|
||||||
|
useProjectAssignedOrganizationsName(selectedProject);
|
||||||
|
const { data: employees, isLoading: isEmployeeLoading } =
|
||||||
|
useEmployeeForTaskAssign(
|
||||||
|
selectedProject,
|
||||||
|
selectedService,
|
||||||
|
selectedOrganization
|
||||||
|
);
|
||||||
|
|
||||||
|
const dispatch = useDispatch();
|
||||||
|
const { loading, data: jobRoleData } = useMaster();
|
||||||
|
|
||||||
const [selectedRoles, setSelectedRoles] = useState(["all"]);
|
const [selectedRoles, setSelectedRoles] = useState(["all"]);
|
||||||
const [displayedSelection, setDisplayedSelection] = useState("");
|
const [displayedSelection, setDisplayedSelection] = useState("");
|
||||||
|
|
||||||
const {
|
const {
|
||||||
handleSubmit,
|
handleSubmit,
|
||||||
control,
|
control,
|
||||||
@ -114,133 +121,98 @@ const AssignTask = ({ assignData, onClose, setAssigned }) => {
|
|||||||
reset,
|
reset,
|
||||||
trigger,
|
trigger,
|
||||||
} = useForm({
|
} = useForm({
|
||||||
defaultValues: {
|
defaultValues: { selectedEmployees: [], description: "", plannedTask: "" },
|
||||||
selectedEmployees: [],
|
resolver: zodResolver(TaskSchema(maxPlanned)),
|
||||||
description: "",
|
|
||||||
plannedTask: "",
|
|
||||||
},
|
|
||||||
resolver: zodResolver(schema),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const handleCheckboxChange = (event, user) => {
|
const handleCheckboxChange = (event, user) => {
|
||||||
const isChecked = event.target.checked;
|
const updatedSelectedEmployees = event.target.checked
|
||||||
let updatedSelectedEmployees = watch("selectedEmployees") || [];
|
? [...(watch("selectedEmployees") || []), user.id].filter(
|
||||||
|
(v, i, a) => a.indexOf(v) === i
|
||||||
|
)
|
||||||
|
: (watch("selectedEmployees") || []).filter((id) => id !== user.id);
|
||||||
|
|
||||||
if (isChecked) {
|
|
||||||
if (!updatedSelectedEmployees.includes(user.id)) {
|
|
||||||
updatedSelectedEmployees = [...updatedSelectedEmployees, user.id];
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
updatedSelectedEmployees = updatedSelectedEmployees?.filter(
|
|
||||||
(id) => id !== user.id
|
|
||||||
);
|
|
||||||
}
|
|
||||||
setValue("selectedEmployees", updatedSelectedEmployees);
|
setValue("selectedEmployees", updatedSelectedEmployees);
|
||||||
trigger("selectedEmployees");
|
trigger("selectedEmployees");
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
dispatch(changeMaster("Job Role"));
|
dispatch(changeMaster("Job Role"));
|
||||||
// Initial state should reflect "All Roles" selected
|
|
||||||
setSelectedRoles(["all"]);
|
setSelectedRoles(["all"]);
|
||||||
}, [dispatch]);
|
}, [dispatch]);
|
||||||
|
|
||||||
// Modified handleRoleChange to handle multiple selections
|
|
||||||
const handleRoleChange = (event, roleId) => {
|
const handleRoleChange = (event, roleId) => {
|
||||||
// If 'all' is selected, clear other selections
|
setSelectedRoles((prev) => {
|
||||||
if (roleId === "all") {
|
if (roleId === "all") return ["all"];
|
||||||
setSelectedRoles(["all"]);
|
const newRoles = prev.filter((r) => r !== "all");
|
||||||
} else {
|
return newRoles.includes(roleId)
|
||||||
setSelectedRoles((prevSelectedRoles) => {
|
? newRoles.filter((r) => r !== roleId)
|
||||||
// If "all" was previously selected, remove it
|
: [...newRoles, roleId];
|
||||||
const newRoles = prevSelectedRoles.filter((role) => role !== "all");
|
});
|
||||||
if (newRoles.includes(roleId)) {
|
|
||||||
// If role is already selected, unselect it
|
|
||||||
return newRoles.filter((id) => id !== roleId);
|
|
||||||
} else {
|
|
||||||
// If role is not selected, add it
|
|
||||||
return [...newRoles, roleId];
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// Update displayedSelection based on selectedRoles
|
|
||||||
if (selectedRoles.includes("all")) {
|
if (selectedRoles.includes("all")) {
|
||||||
setDisplayedSelection("All Roles");
|
setDisplayedSelection("All Roles");
|
||||||
} else if (selectedRoles.length > 0) {
|
} else if (selectedRoles.length > 0) {
|
||||||
const selectedRoleNames = selectedRoles.map(roleId => {
|
setDisplayedSelection(
|
||||||
const role = jobRoleData?.find(r => String(r.id) === roleId);
|
selectedRoles
|
||||||
return role ? role.name : '';
|
.map((id) => jobRoleData?.find((r) => String(r.id) === id)?.name)
|
||||||
}).filter(Boolean); // Filter out empty strings for roles not found
|
.filter(Boolean)
|
||||||
setDisplayedSelection(selectedRoleNames.join(', '));
|
.join(", ")
|
||||||
} else {
|
);
|
||||||
setDisplayedSelection("Select Roles");
|
} else setDisplayedSelection("Select Roles");
|
||||||
}
|
|
||||||
}, [selectedRoles, jobRoleData]);
|
}, [selectedRoles, jobRoleData]);
|
||||||
|
|
||||||
|
const handleSearchChange = (e) => setSearchTerm(e.target.value);
|
||||||
|
|
||||||
const handleSearchChange = (event) => {
|
const filteredEmployees = employees?.data?.filter((emp) => {
|
||||||
setSearchTerm(event.target.value);
|
|
||||||
};
|
|
||||||
|
|
||||||
// Filter employees first by role, then by search term AND job role name
|
|
||||||
const filteredEmployees = employees?.filter((emp) => {
|
|
||||||
const matchesRole =
|
const matchesRole =
|
||||||
selectedRoles.includes("all") || selectedRoles.includes(String(emp.jobRoleId));
|
selectedRoles.includes("all") ||
|
||||||
// Convert both first and last names and job role name to lowercase for case-insensitive matching
|
selectedRoles.includes(String(emp.jobRoleId));
|
||||||
const fullName = `${emp.firstName} ${emp.lastName}`.toLowerCase();
|
|
||||||
|
|
||||||
const jobRoleName = jobRoleData?.find((role) => role.id === emp.jobRoleId)?.name?.toLowerCase() || "";
|
|
||||||
|
|
||||||
const searchLower = searchTerm.toLowerCase();
|
const searchLower = searchTerm.toLowerCase();
|
||||||
// Check if the full name OR job role name includes the search term
|
const fullName = `${emp.firstName} ${emp.lastName}`.toLowerCase();
|
||||||
const matchesSearch = fullName.includes(searchLower) || jobRoleName.includes(searchLower);
|
const jobRoleName =
|
||||||
return matchesRole && matchesSearch;
|
jobRoleData
|
||||||
|
?.find((role) => role.id === emp.jobRoleId)
|
||||||
|
?.name?.toLowerCase() || "";
|
||||||
|
return (
|
||||||
|
matchesRole &&
|
||||||
|
(fullName.includes(searchLower) || jobRoleName.includes(searchLower))
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Determine unique job role IDs from the filtered employees (for dropdown options)
|
const jobRolesForDropdown = jobRoleData?.filter((role) =>
|
||||||
const uniqueJobRoleIdsInFilteredEmployees = new Set(
|
new Set(employees?.data?.map((emp) => emp.jobRoleId).filter(Boolean)).has(
|
||||||
employees?.map(emp => emp.jobRoleId).filter(Boolean)
|
role.id
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Filter jobRoleData to only include roles present in the uniqueJobRoleIdsInFilteredEmployees
|
|
||||||
const jobRolesForDropdown = jobRoleData?.filter(role =>
|
|
||||||
uniqueJobRoleIdsInFilteredEmployees.has(role.id)
|
|
||||||
);
|
|
||||||
|
|
||||||
// Calculate the count of selected roles for display
|
|
||||||
const selectedRolesCount = selectedRoles.includes("all")
|
const selectedRolesCount = selectedRoles.includes("all")
|
||||||
? 0 // "All Roles" doesn't contribute to a specific count
|
? 0
|
||||||
: selectedRoles.length;
|
: selectedRoles.length;
|
||||||
|
|
||||||
const onSubmit = (data) => {
|
const onSubmit = (data) => {
|
||||||
const selectedEmployeeIds = data.selectedEmployees;
|
|
||||||
|
|
||||||
const taskTeamWithDetails = selectedEmployeeIds
|
|
||||||
?.map((empId) => empId)
|
|
||||||
?.filter(Boolean);
|
|
||||||
const formattedData = {
|
|
||||||
taskTeam: taskTeamWithDetails,
|
|
||||||
plannedTask: data.plannedTask,
|
|
||||||
description: data.description,
|
|
||||||
assignmentDate: new Date().toISOString(),
|
|
||||||
workItemId: assignData?.workItem.id,
|
|
||||||
};
|
|
||||||
assignTask({
|
assignTask({
|
||||||
payload: formattedData,
|
payload: {
|
||||||
|
taskTeam: data.selectedEmployees.filter(Boolean),
|
||||||
|
plannedTask: data.plannedTask,
|
||||||
|
description: data.description,
|
||||||
|
assignmentDate: new Date().toISOString(),
|
||||||
|
workItemId: assignData?.workItem.id,
|
||||||
|
},
|
||||||
workAreaId: assignData?.workArea?.id,
|
workAreaId: assignData?.workArea?.id,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const closedModel = () => {
|
function closedModel() {
|
||||||
reset();
|
reset();
|
||||||
onClose();
|
onClose();
|
||||||
};
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="fs-5 text-dark text-center d-flex align-items-center justify-content-center flex-wrap">
|
<div className="fs-5 text-dark text-center d-flex align-items-center justify-content-center flex-wrap">
|
||||||
<p className="align-items-center flex-wrap m-0 ">Assign Task</p>
|
<p className="align-items-center flex-wrap m-0">Assign Task</p>
|
||||||
<div className="container my-3">
|
<div className="container my-3">
|
||||||
<div className="mb-1">
|
<div className="mb-1">
|
||||||
<p className="mb-0">
|
<p className="mb-0">
|
||||||
@ -252,7 +224,7 @@ const AssignTask = ({ assignData, onClose, setAssigned }) => {
|
|||||||
assignData?.workArea?.areaName,
|
assignData?.workArea?.areaName,
|
||||||
assignData?.workItem?.activityMaster?.activityName,
|
assignData?.workItem?.activityMaster?.activityName,
|
||||||
]
|
]
|
||||||
.filter(Boolean) // Filter out any undefined/null values
|
.filter(Boolean)
|
||||||
.map((item, index, array) => (
|
.map((item, index, array) => (
|
||||||
<span key={index} className="d-flex align-items-center">
|
<span key={index} className="d-flex align-items-center">
|
||||||
{item}
|
{item}
|
||||||
@ -268,20 +240,64 @@ const AssignTask = ({ assignData, onClose, setAssigned }) => {
|
|||||||
<div className="form-label text-start">
|
<div className="form-label text-start">
|
||||||
<div className="row mb-1">
|
<div className="row mb-1">
|
||||||
<div className="col-12">
|
<div className="col-12">
|
||||||
<div className="form-text text-start">
|
<div className="row text-start">
|
||||||
|
<div className="col-12 col-md-8 d-flex flex-row gap-3 align-items-center">
|
||||||
|
<div>
|
||||||
|
<select
|
||||||
|
className="form-select form-select-sm"
|
||||||
|
value={selectedOrganization || ""}
|
||||||
|
onChange={(e) =>
|
||||||
|
setSelectedOrganization(e.target.value)
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{isServiceLoading ? (
|
||||||
|
<option>Loading...</option>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<option value="">--Select Organization--</option>
|
||||||
|
{organizationList?.map((org,index) => (
|
||||||
|
<option key={`${org.id}-${index}`} value={org.id}>
|
||||||
|
{org.name}
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<select
|
||||||
|
className="form-select form-select-sm"
|
||||||
|
value={selectedService || ""}
|
||||||
|
onChange={(e) => setSelectedService(e.target.value)}
|
||||||
|
>
|
||||||
|
{isOrgLoading ? (
|
||||||
|
<option>Loading...</option>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<option value="">--Select Service--</option>
|
||||||
|
{serviceList?.map((service,index) => (
|
||||||
|
<option key={`${service.id}-${index}`} value={service.id}>
|
||||||
|
{service.name}
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div
|
<div
|
||||||
className="d-flex align-items-center form-text fs-7"
|
className="col-12 col-md-4 d-flex flex-row gap-3 align-items-center justify-content-end"
|
||||||
ref={dropdownRef}
|
ref={dropdownRef}
|
||||||
>
|
>
|
||||||
<span className="text-dark">Select Team</span>
|
|
||||||
|
|
||||||
{/* Dropdown */}
|
{/* Dropdown */}
|
||||||
<div className="dropdown position-relative d-inline-block">
|
<div className="dropdown position-relative d-inline-block">
|
||||||
<a
|
<a
|
||||||
className={`dropdown-toggle hide-arrow cursor-pointer ${selectedRoles.includes("all") || selectedRoles.length === 0
|
className={`dropdown-toggle hide-arrow cursor-pointer ${
|
||||||
|
selectedRoles.includes("all") ||
|
||||||
|
selectedRoles.length === 0
|
||||||
? "text-secondary"
|
? "text-secondary"
|
||||||
: "text-primary"
|
: "text-primary"
|
||||||
}`}
|
}`}
|
||||||
onClick={() => setOpen(!open)}
|
onClick={() => setOpen(!open)}
|
||||||
>
|
>
|
||||||
<i className="bx bx-slider-alt ms-2"></i>
|
<i className="bx bx-slider-alt ms-2"></i>
|
||||||
@ -290,7 +306,7 @@ const AssignTask = ({ assignData, onClose, setAssigned }) => {
|
|||||||
{/* Badge */}
|
{/* Badge */}
|
||||||
{selectedRolesCount > 0 && (
|
{selectedRolesCount > 0 && (
|
||||||
<span
|
<span
|
||||||
className="position-absolute top-0 start-100 translate-middle badge rounded-circle bg-warning text-white"
|
className="position-absolute top-0 start-100 translate-middle badge rounded-circle bg-warning text-white text-tiny"
|
||||||
style={{
|
style={{
|
||||||
fontSize: "0.65rem",
|
fontSize: "0.65rem",
|
||||||
minWidth: "18px",
|
minWidth: "18px",
|
||||||
@ -320,7 +336,9 @@ const AssignTask = ({ assignData, onClose, setAssigned }) => {
|
|||||||
id="checkboxAllRoles"
|
id="checkboxAllRoles"
|
||||||
value="all"
|
value="all"
|
||||||
checked={selectedRoles.includes("all")}
|
checked={selectedRoles.includes("all")}
|
||||||
onChange={(e) => handleRoleChange(e, e.target.value)}
|
onChange={(e) =>
|
||||||
|
handleRoleChange(e, e.target.value)
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
<label
|
<label
|
||||||
className="form-check-label ms-2"
|
className="form-check-label ms-2"
|
||||||
@ -340,8 +358,12 @@ const AssignTask = ({ assignData, onClose, setAssigned }) => {
|
|||||||
type="checkbox"
|
type="checkbox"
|
||||||
id={`checkboxRole-${role.id}`}
|
id={`checkboxRole-${role.id}`}
|
||||||
value={role.id}
|
value={role.id}
|
||||||
checked={selectedRoles.includes(String(role.id))}
|
checked={selectedRoles.includes(
|
||||||
onChange={(e) => handleRoleChange(e, e.target.value)}
|
String(role.id)
|
||||||
|
)}
|
||||||
|
onChange={(e) =>
|
||||||
|
handleRoleChange(e, e.target.value)
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
<label
|
<label
|
||||||
className="form-check-label ms-2"
|
className="form-check-label ms-2"
|
||||||
@ -357,14 +379,15 @@ const AssignTask = ({ assignData, onClose, setAssigned }) => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Search Box */}
|
{/* Search Box */}
|
||||||
<input
|
<div>
|
||||||
type="text"
|
<input
|
||||||
className="form-control form-control-sm ms-auto mb-2 mt-2"
|
type="text"
|
||||||
placeholder="Search employees or roles..."
|
className="form-control form-control-sm ms-auto mb-2 mt-2"
|
||||||
value={searchTerm}
|
placeholder="Search employees or roles..."
|
||||||
onChange={handleSearchChange}
|
value={searchTerm}
|
||||||
style={{ maxWidth: "200px" }}
|
onChange={handleSearchChange}
|
||||||
/>
|
/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -381,19 +404,19 @@ const AssignTask = ({ assignData, onClose, setAssigned }) => {
|
|||||||
>
|
>
|
||||||
{selectedRoles?.length > 0 && (
|
{selectedRoles?.length > 0 && (
|
||||||
<div className="row">
|
<div className="row">
|
||||||
{employeeLoading ? (
|
{isEmployeeLoading ? (
|
||||||
<div className="col-12">
|
<div className="col-12">
|
||||||
<p className="text-center">Loading employees...</p>
|
<p className="text-center">Loading employees...</p>
|
||||||
</div>
|
</div>
|
||||||
) : filteredEmployees?.length > 0 ? (
|
) : filteredEmployees?.length > 0 ? (
|
||||||
filteredEmployees.map((emp) => {
|
filteredEmployees.map((emp,index) => {
|
||||||
const jobRole = jobRoleData?.find(
|
const jobRole = jobRoleData?.find(
|
||||||
(role) => role?.id === emp?.jobRoleId
|
(role) => role?.id === emp?.jobRoleId
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
key={emp.id}
|
key={`${emp.index}-${index}`}
|
||||||
className="col-6 col-md-4 col-lg-3 mb-3"
|
className="col-6 col-md-4 col-lg-3 mb-3"
|
||||||
>
|
>
|
||||||
<div className="form-check d-flex align-items-start">
|
<div className="form-check d-flex align-items-start">
|
||||||
@ -441,7 +464,7 @@ const AssignTask = ({ assignData, onClose, setAssigned }) => {
|
|||||||
) : (
|
) : (
|
||||||
<div className="col-12">
|
<div className="col-12">
|
||||||
<p className="text-center">
|
<p className="text-center">
|
||||||
No employees found for the selected role.
|
No employees found for the selected filter.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
@ -456,12 +479,14 @@ const AssignTask = ({ assignData, onClose, setAssigned }) => {
|
|||||||
{watch("selectedEmployees")?.length > 0 && (
|
{watch("selectedEmployees")?.length > 0 && (
|
||||||
<div className="mt-1">
|
<div className="mt-1">
|
||||||
<div className="text-start px-2">
|
<div className="text-start px-2">
|
||||||
{watch("selectedEmployees")?.map((empId) => {
|
{watch("selectedEmployees")?.map((empId,ind) => {
|
||||||
const emp = employees.find((emp) => emp.id === empId);
|
const emp = employees?.data?.find(
|
||||||
|
(emp) => emp.id === empId
|
||||||
|
);
|
||||||
return (
|
return (
|
||||||
emp && (
|
emp && (
|
||||||
<span
|
<span
|
||||||
key={empId}
|
key={`${empId}-${ind}`}
|
||||||
className="badge rounded-pill bg-label-primary d-inline-flex align-items-center me-1 mb-1"
|
className="badge rounded-pill bg-label-primary d-inline-flex align-items-center me-1 mb-1"
|
||||||
>
|
>
|
||||||
{emp.firstName} {emp.lastName}
|
{emp.firstName} {emp.lastName}
|
||||||
@ -506,7 +531,12 @@ const AssignTask = ({ assignData, onClose, setAssigned }) => {
|
|||||||
{assignData?.workItem?.plannedWork -
|
{assignData?.workItem?.plannedWork -
|
||||||
assignData?.workItem?.completedWork}
|
assignData?.workItem?.completedWork}
|
||||||
</strong>{" "}
|
</strong>{" "}
|
||||||
<u>{assignData?.workItem?.activityMaster?.unitOfMeasurement}</u>
|
<u>
|
||||||
|
{
|
||||||
|
assignData?.workItem?.activityMaster
|
||||||
|
?.unitOfMeasurement
|
||||||
|
}
|
||||||
|
</u>
|
||||||
</label>
|
</label>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
@ -537,8 +567,15 @@ const AssignTask = ({ assignData, onClose, setAssigned }) => {
|
|||||||
className="form-control form-control-sm"
|
className="form-control form-control-sm"
|
||||||
{...field}
|
{...field}
|
||||||
/>
|
/>
|
||||||
<span style={{ paddingLeft: "6px", whiteSpace: "nowrap" }}>
|
<span
|
||||||
<u>{assignData?.workItem?.activityMaster?.unitOfMeasurement}</u>
|
style={{ paddingLeft: "6px", whiteSpace: "nowrap" }}
|
||||||
|
>
|
||||||
|
<u>
|
||||||
|
{
|
||||||
|
assignData?.workItem?.activityMaster
|
||||||
|
?.unitOfMeasurement
|
||||||
|
}
|
||||||
|
</u>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
@ -546,19 +583,17 @@ const AssignTask = ({ assignData, onClose, setAssigned }) => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{errors.plannedTask && (
|
{errors.plannedTask && (
|
||||||
<div className="danger-text mt-1">{errors.plannedTask.message}</div>
|
<div className="danger-text mt-1">
|
||||||
|
{errors.plannedTask.message}
|
||||||
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
<Label
|
||||||
{/* <label
|
|
||||||
className="form-text fs-7 m-1 text-lg text-dark"
|
className="form-text fs-7 m-1 text-lg text-dark"
|
||||||
htmlFor="descriptionTextarea" // Changed htmlFor for better accessibility
|
htmlFor="descriptionTextarea"
|
||||||
|
required
|
||||||
>
|
>
|
||||||
Description
|
Description
|
||||||
</label> */}
|
|
||||||
<Label className="form-text fs-7 m-1 text-lg text-dark"
|
|
||||||
htmlFor="descriptionTextarea" required>
|
|
||||||
Description
|
|
||||||
</Label>
|
</Label>
|
||||||
<Controller
|
<Controller
|
||||||
name="description"
|
name="description"
|
||||||
@ -592,7 +627,6 @@ const AssignTask = ({ assignData, onClose, setAssigned }) => {
|
|||||||
{isSubmitting ? "Please Wait" : "Submit"}
|
{isSubmitting ? "Please Wait" : "Submit"}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -32,8 +32,7 @@ const EditActivityModal = ({
|
|||||||
building,
|
building,
|
||||||
floor,
|
floor,
|
||||||
onClose,
|
onClose,
|
||||||
} ) =>
|
}) => {
|
||||||
{
|
|
||||||
|
|
||||||
const { activities, loading: loadingActivities } = useActivitiesMaster();
|
const { activities, loading: loadingActivities } = useActivitiesMaster();
|
||||||
const { categories, loading: loadingCategories } = useWorkCategoriesMaster();
|
const { categories, loading: loadingCategories } = useWorkCategoriesMaster();
|
||||||
@ -57,13 +56,12 @@ const EditActivityModal = ({
|
|||||||
comment: "",
|
comment: "",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const { mutate: UpdateTask, isPending } = useManageTask({
|
const { mutate: UpdateTask, isPending } = useManageTask({
|
||||||
onSuccessCallback: (response) =>
|
onSuccessCallback: (response) => {
|
||||||
{
|
showToast(response?.message, "success")
|
||||||
showToast( response?.message, "success" )
|
onClose()
|
||||||
onClose()
|
}
|
||||||
}
|
});
|
||||||
} );
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -82,34 +80,33 @@ const { mutate: UpdateTask, isPending } = useManageTask({
|
|||||||
[categories]
|
[categories]
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!workItem) return;
|
if (!workItem) return;
|
||||||
console.log(workItem)
|
console.log(workItem)
|
||||||
reset({
|
reset({
|
||||||
activityID: String(
|
activityID: String(
|
||||||
workItem?.workItem?.activityId || workItem?.activityMaster?.id
|
workItem?.workItem?.activityId || workItem?.activityMaster?.id
|
||||||
),
|
),
|
||||||
workCategoryId: String(
|
workCategoryId: String(
|
||||||
workItem?.workItem?.workCategoryId || workItem?.workCategoryMaster?.id
|
workItem?.workItem?.workCategoryId || workItem?.workCategoryMaster?.id
|
||||||
),
|
),
|
||||||
plannedWork:
|
plannedWork:
|
||||||
workItem?.workItem?.plannedWork || workItem?.plannedWork || 0,
|
workItem?.workItem?.plannedWork || workItem?.plannedWork || 0,
|
||||||
completedWork:
|
completedWork:
|
||||||
workItem?.workItem?.completedWork || workItem?.completedWork || 0,
|
workItem?.workItem?.completedWork || workItem?.completedWork || 0,
|
||||||
comment: workItem?.workItem?.description || workItem?.description || "",
|
comment: workItem?.workItem?.description || workItem?.description || "",
|
||||||
});
|
});
|
||||||
}, [workItem?.id,selectedActivity]);
|
}, [workItem?.id, selectedActivity]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const selected = activities?.find((a) => a.id === activityID);
|
const selected = activities?.find((a) => a.id === activityID);
|
||||||
setSelectedActivity( selected || null );
|
setSelectedActivity(selected || null);
|
||||||
}, [activityID, activities]);
|
}, [activityID, activities]);
|
||||||
|
|
||||||
const onSubmitForm = (data) =>
|
const onSubmitForm = (data) => {
|
||||||
{
|
const payload = {
|
||||||
const payload = {
|
|
||||||
...data,
|
...data,
|
||||||
id: workItem?.workItem?.id ?? workItem?.id,
|
id: workItem?.workItem?.id ?? workItem?.id,
|
||||||
buildingID: building?.id,
|
buildingID: building?.id,
|
||||||
@ -125,9 +122,9 @@ useEffect(() => {
|
|||||||
buildingId: building?.id,
|
buildingId: building?.id,
|
||||||
floorId: floor?.id,
|
floorId: floor?.id,
|
||||||
workAreaId: workArea?.id,
|
workAreaId: workArea?.id,
|
||||||
previousCompletedWork:completedTask
|
previousCompletedWork: completedTask
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<form className="row g-2 p-2 p-md-1" onSubmit={handleSubmit(onSubmitForm)}>
|
<form className="row g-2 p-2 p-md-1" onSubmit={handleSubmit(onSubmitForm)}>
|
||||||
<div className="text-center mb-1">
|
<div className="text-center mb-1">
|
||||||
@ -162,14 +159,26 @@ useEffect(() => {
|
|||||||
disabled
|
disabled
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
<div className="col-12 text-start">
|
||||||
|
<label className="form-label">Select Service</label>
|
||||||
|
<input
|
||||||
|
className="form-control form-control-sm"
|
||||||
|
value={
|
||||||
|
workItem?.activityMaster?.activityGroupMaster?.service?.name || ""
|
||||||
|
}
|
||||||
|
disabled
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div className="col-12 text-start">
|
<div className="col-12 text-start">
|
||||||
<label className="form-label">Select Activity</label>
|
<label className="form-label">Select Activity</label>
|
||||||
<select
|
<select
|
||||||
{...register("activityID")}
|
{...register("activityID")}
|
||||||
className="form-select form-select-sm"
|
className="form-select form-select-sm"
|
||||||
|
disabled
|
||||||
>
|
>
|
||||||
<option disabled>Select Activity</option>
|
<option >Select Activity</option>
|
||||||
{loadingActivities ? (
|
{loadingActivities ? (
|
||||||
<option>Loading...</option>
|
<option>Loading...</option>
|
||||||
) : (
|
) : (
|
||||||
|
|||||||
@ -11,7 +11,7 @@ import {
|
|||||||
getCachedData,
|
getCachedData,
|
||||||
} from "../../../slices/apiDataManager";
|
} from "../../../slices/apiDataManager";
|
||||||
|
|
||||||
const InfraTable = ({ buildings, projectId}) => {
|
const InfraTable = ({ buildings, projectId }) => {
|
||||||
const [projectBuilding, setProjectBuilding] = useState([]);
|
const [projectBuilding, setProjectBuilding] = useState([]);
|
||||||
const [expandedBuildings, setExpandedBuildings] = useState([]);
|
const [expandedBuildings, setExpandedBuildings] = useState([]);
|
||||||
const [showFloorModal, setShowFloorModal] = useState(false);
|
const [showFloorModal, setShowFloorModal] = useState(false);
|
||||||
@ -143,7 +143,7 @@ const InfraTable = ({ buildings, projectId}) => {
|
|||||||
// }, [handler]);
|
// }, [handler]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div className="px-6">
|
||||||
{projectBuilding && projectBuilding.length > 0 && (
|
{projectBuilding && projectBuilding.length > 0 && (
|
||||||
<table className="table table-bordered">
|
<table className="table table-bordered">
|
||||||
<tbody>
|
<tbody>
|
||||||
|
|||||||
@ -3,10 +3,12 @@ import { useForm } from "react-hook-form";
|
|||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
import {
|
import {
|
||||||
|
useActivitiesByGroups,
|
||||||
useActivitiesMaster,
|
useActivitiesMaster,
|
||||||
|
useGroups,
|
||||||
useWorkCategoriesMaster,
|
useWorkCategoriesMaster,
|
||||||
} from "../../../hooks/masterHook/useMaster";
|
} from "../../../hooks/masterHook/useMaster";
|
||||||
import { useManageTask, useProjectAssignedServices } from "../../../hooks/useProjects";
|
import { useManageTask, useProjectAssignedOrganizationsName, useProjectAssignedServices } from "../../../hooks/useProjects";
|
||||||
import showToast from "../../../services/toastService";
|
import showToast from "../../../services/toastService";
|
||||||
import Label from "../../common/Label";
|
import Label from "../../common/Label";
|
||||||
import { useSelectedProject } from "../../../slices/apiDataManager";
|
import { useSelectedProject } from "../../../slices/apiDataManager";
|
||||||
@ -15,6 +17,8 @@ const taskSchema = z.object({
|
|||||||
buildingID: z.string().min(1, "Building is required"),
|
buildingID: z.string().min(1, "Building is required"),
|
||||||
floorId: z.string().min(1, "Floor is required"),
|
floorId: z.string().min(1, "Floor is required"),
|
||||||
workAreaId: z.string().min(1, "Work Area is required"),
|
workAreaId: z.string().min(1, "Work Area is required"),
|
||||||
|
serviceId: z.string().min(1, "Service is required"),
|
||||||
|
activityGroupId: z.string().min(1, "Activity Group is required"),
|
||||||
activityID: z.string().min(1, "Activity is required"),
|
activityID: z.string().min(1, "Activity is required"),
|
||||||
workCategoryId: z.string().min(1, "Work Category is required"),
|
workCategoryId: z.string().min(1, "Work Category is required"),
|
||||||
plannedWork: z.number().min(1, "Planned Work must be greater than 0"),
|
plannedWork: z.number().min(1, "Planned Work must be greater than 0"),
|
||||||
@ -27,6 +31,8 @@ const defaultModel = {
|
|||||||
buildingID: "",
|
buildingID: "",
|
||||||
floorId: "",
|
floorId: "",
|
||||||
workAreaId: "",
|
workAreaId: "",
|
||||||
|
serviceId: "",
|
||||||
|
activityGroupId: "",
|
||||||
activityID: "",
|
activityID: "",
|
||||||
workCategoryId: "",
|
workCategoryId: "",
|
||||||
plannedWork: 0,
|
plannedWork: 0,
|
||||||
@ -35,18 +41,42 @@ const defaultModel = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const TaskModel = ({ project, onSubmit, onClose }) => {
|
const TaskModel = ({ project, onSubmit, onClose }) => {
|
||||||
const { activities, loading: activityLoading } = useActivitiesMaster();
|
// const { activities, loading: activityLoading } = useActivitiesMaster();
|
||||||
const { categories, categoryLoading } = useWorkCategoriesMaster();
|
const { categories, categoryLoading } = useWorkCategoriesMaster();
|
||||||
|
|
||||||
const projectId = useSelectedProject();
|
const projectId = useSelectedProject();
|
||||||
|
|
||||||
const { data: assignedServices, isLoading: servicesLoading } = useProjectAssignedServices(projectId);
|
const { data: assignedServices, isLoading: servicesLoading } = useProjectAssignedServices(projectId);
|
||||||
|
const { data: assignedOrganizations, isLoading: orgLoading } = useProjectAssignedOrganizationsName(projectId);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const [selectedService, setSelectedService] = useState("");
|
const [selectedService, setSelectedService] = useState("");
|
||||||
|
const [selectedGroup, setSelectedGroup] = useState("");
|
||||||
|
const { data: groupsResponse, isLoading: groupsLoading } = useGroups(selectedService);
|
||||||
|
const groups = groupsResponse?.data ?? [];
|
||||||
|
|
||||||
|
const { data: activitiesResponse, isLoading: activitiesLoading } = useActivitiesByGroups(selectedGroup);
|
||||||
|
const activities = activitiesResponse?.data ?? [];
|
||||||
|
// Fetch Assigned Organizations (Activity Groups)
|
||||||
|
|
||||||
|
const [selectedOrg, setSelectedOrg] = useState("");
|
||||||
const handleServiceChange = (e) => {
|
const handleServiceChange = (e) => {
|
||||||
setSelectedService(e.target.value);
|
const value = e.target.value;
|
||||||
|
setSelectedService(value);
|
||||||
|
setSelectedGroup("");
|
||||||
|
setValue("activityGroupId", "");
|
||||||
|
setValue("activityID", "");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleGroupChange = (e) => {
|
||||||
|
const value = e.target.value;
|
||||||
|
setSelectedGroup(value);
|
||||||
|
setValue("activityGroupId", value);
|
||||||
|
setValue("activityID", "");
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
register,
|
register,
|
||||||
handleSubmit,
|
handleSubmit,
|
||||||
@ -82,7 +112,10 @@ const TaskModel = ({ project, onSubmit, onClose }) => {
|
|||||||
const { mutate: CreateTask, isPending } = useManageTask({
|
const { mutate: CreateTask, isPending } = useManageTask({
|
||||||
onSuccessCallback: (response) => {
|
onSuccessCallback: (response) => {
|
||||||
showToast(response?.message, "success");
|
showToast(response?.message, "success");
|
||||||
onClose?.();
|
setValue("activityID",""),
|
||||||
|
setValue("plannedWork",0),
|
||||||
|
setValue("completedWork",0)
|
||||||
|
setValue("comment","")
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -188,15 +221,18 @@ const TaskModel = ({ project, onSubmit, onClose }) => {
|
|||||||
{/* Services Selection */}
|
{/* Services Selection */}
|
||||||
{selectedWorkArea && (
|
{selectedWorkArea && (
|
||||||
<div className="col-12 text-start">
|
<div className="col-12 text-start">
|
||||||
<Label className="form-label">Select Services</Label>
|
<Label className="form-label" required>Select Service</Label>
|
||||||
<select
|
<select
|
||||||
name="DataTables_Table_0_length"
|
|
||||||
aria-controls="DataTables_Table_0"
|
|
||||||
className="form-select form-select-sm"
|
className="form-select form-select-sm"
|
||||||
aria-label="Select Service"
|
{...register("serviceId")}
|
||||||
value={selectedService}
|
value={selectedService}
|
||||||
onChange={handleServiceChange}
|
// onChange={handleServiceChange}
|
||||||
|
onChange={(e) => {
|
||||||
|
handleServiceChange(e);
|
||||||
|
setValue("serviceId", e.target.value);
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
|
<option value="">Select Service</option>
|
||||||
{servicesLoading && <option>Loading...</option>}
|
{servicesLoading && <option>Loading...</option>}
|
||||||
{assignedServices?.map((service) => (
|
{assignedServices?.map((service) => (
|
||||||
<option key={service.id} value={service.id}>
|
<option key={service.id} value={service.id}>
|
||||||
@ -204,35 +240,46 @@ const TaskModel = ({ project, onSubmit, onClose }) => {
|
|||||||
</option>
|
</option>
|
||||||
))}
|
))}
|
||||||
</select>
|
</select>
|
||||||
{errors.buildingID && (
|
|
||||||
<p className="danger-text">{errors.buildingID.message}</p>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* Activity Selection */}
|
{/* Activity Group (Organization) Selection */}
|
||||||
{selectedWorkArea && (
|
{selectedService && (
|
||||||
<div className="col-12 text-start">
|
<div className="col-12 text-start">
|
||||||
<Label className="form-label" required>Select Activity</Label>
|
<Label className="form-label" required>Select Activity Group</Label>
|
||||||
<select
|
<select
|
||||||
className="form-select form-select-sm"
|
className="form-select form-select-sm"
|
||||||
{...register("activityID")}
|
{...register("activityGroupId")}
|
||||||
|
value={selectedGroup}
|
||||||
|
onChange={handleGroupChange}
|
||||||
>
|
>
|
||||||
<option value="">Select Activity</option>
|
<option value="">Select Group</option>
|
||||||
{activityData.map((a) => (
|
{groupsLoading && <option>Loading...</option>}
|
||||||
<option key={a.id} value={a.id}>
|
{groups?.map((g) => (
|
||||||
{a.activityName}
|
<option key={g.id} value={g.id}>{g.name}</option>
|
||||||
</option>
|
|
||||||
))}
|
))}
|
||||||
</select>
|
</select>
|
||||||
{errors.activityID && (
|
{errors.activityGroupId && <p className="danger-text">{errors.activityGroupId.message}</p>}
|
||||||
<p className="danger-text">{errors.activityID.message}</p>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|
||||||
{selectedWorkArea && (
|
{/* Activity Selection */}
|
||||||
|
{selectedGroup && (
|
||||||
|
<div className="col-12 text-start">
|
||||||
|
<Label className="form-label" required>Select Activity</Label>
|
||||||
|
<select className="form-select form-select-sm" {...register("activityID")}>
|
||||||
|
<option value="">Select Activity</option>
|
||||||
|
{activitiesLoading && <option>Loading...</option>}
|
||||||
|
{activities?.map((a) => (
|
||||||
|
<option key={a.id} value={a.id}>{a.activityName}</option>
|
||||||
|
))}
|
||||||
|
</select>
|
||||||
|
{errors.activityID && <p className="danger-text">{errors.activityID.message}</p>}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{watchActivityId && (
|
||||||
<div className="col-12 text-start">
|
<div className="col-12 text-start">
|
||||||
<label className="form-label">Select Work Category</label>
|
<label className="form-label">Select Work Category</label>
|
||||||
<select
|
<select
|
||||||
@ -312,9 +359,10 @@ const TaskModel = ({ project, onSubmit, onClose }) => {
|
|||||||
<button
|
<button
|
||||||
type="submit"
|
type="submit"
|
||||||
className="btn btn-sm btn-primary"
|
className="btn btn-sm btn-primary"
|
||||||
disabled={isSubmitting}
|
// disabled={isSubmitting}
|
||||||
|
disabled={isPending}
|
||||||
>
|
>
|
||||||
{isSubmitting ? "Please Wait..." : "Add Task"}
|
{isPending ? "Please Wait..." : "Add Task"}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import WorkItem from "./WorkItem";
|
import WorkItem from "./WorkItem";
|
||||||
import { useProjectDetails, useProjectTasks } from "../../../hooks/useProjects";
|
import { useCurrentService, useProjectDetails, useProjectTasks } from "../../../hooks/useProjects";
|
||||||
import { cacheData } from "../../../slices/apiDataManager";
|
import { cacheData, useSelectedProject } from "../../../slices/apiDataManager";
|
||||||
import { useDispatch, useSelector } from "react-redux";
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
import { refreshData } from "../../../slices/localVariablesSlice";
|
import { refreshData } from "../../../slices/localVariablesSlice";
|
||||||
import ProjectRepository from "../../../repositories/ProjectRepository";
|
import ProjectRepository from "../../../repositories/ProjectRepository";
|
||||||
@ -14,20 +14,20 @@ import {
|
|||||||
} from "../../../utils/constants";
|
} from "../../../utils/constants";
|
||||||
import { useParams } from "react-router-dom";
|
import { useParams } from "react-router-dom";
|
||||||
import ProgressBar from "../../common/ProgressBar";
|
import ProgressBar from "../../common/ProgressBar";
|
||||||
import {formatNumber} from "../../../utils/dateUtils";
|
import { formatNumber } from "../../../utils/dateUtils";
|
||||||
|
import { useServices } from "../../../hooks/masterHook/useMaster";
|
||||||
|
|
||||||
const WorkArea = ({ workArea, floor, forBuilding }) => {
|
const WorkArea = ({ workArea, floor, forBuilding }) => {
|
||||||
const selectedProject = useSelector((store) => store.localVariables.projectId);
|
const selectedProject = useSelectedProject()
|
||||||
|
const selectedService = useCurrentService()
|
||||||
const { projects_Details, loading } = useProjectDetails(selectedProject);
|
const { projects_Details, loading } = useProjectDetails(selectedProject);
|
||||||
const [IsExpandedArea, setIsExpandedArea] = useState(false);
|
const [IsExpandedArea, setIsExpandedArea] = useState(false);
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const [Project, setProject] = useState();
|
const [Project, setProject] = useState();
|
||||||
// const { projectId } = useParams();
|
|
||||||
|
|
||||||
const ManageInfra = useHasUserPermission(MANAGE_PROJECT_INFRA);
|
const ManageInfra = useHasUserPermission(MANAGE_PROJECT_INFRA);
|
||||||
const ManageAndAssignTak = useHasUserPermission(ASSIGN_REPORT_TASK);
|
const ManageAndAssignTak = useHasUserPermission(ASSIGN_REPORT_TASK);
|
||||||
|
const { ProjectTaskList, isLoading } = useProjectTasks(workArea.id, selectedService, IsExpandedArea);
|
||||||
const { ProjectTaskList, isLoading } = useProjectTasks(workArea.id, IsExpandedArea);
|
|
||||||
|
|
||||||
const [workAreaStatus, setWorkAreaStatus] = useState({
|
const [workAreaStatus, setWorkAreaStatus] = useState({
|
||||||
completed: 0,
|
completed: 0,
|
||||||
@ -82,9 +82,8 @@ const WorkArea = ({ workArea, floor, forBuilding }) => {
|
|||||||
aria-controls={`collapse-${workArea.id}`}
|
aria-controls={`collapse-${workArea.id}`}
|
||||||
>
|
>
|
||||||
<i
|
<i
|
||||||
className={`bx me-2 toggle-icon ${
|
className={`bx me-2 toggle-icon ${IsExpandedArea ? "bx-minus-circle" : "bx-plus-circle"
|
||||||
IsExpandedArea ? "bx-minus-circle" : "bx-plus-circle"
|
}`}
|
||||||
}`}
|
|
||||||
style={{
|
style={{
|
||||||
fontSize: "1.2rem",
|
fontSize: "1.2rem",
|
||||||
color: "black",
|
color: "black",
|
||||||
@ -105,13 +104,13 @@ const WorkArea = ({ workArea, floor, forBuilding }) => {
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="col-2">
|
<div className="col-2">
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
completedWork={formatNumber(workArea?.completedWork)}
|
completedWork={formatNumber(workArea?.completedWork)}
|
||||||
plannedWork={formatNumber(workArea?.plannedWork)}
|
plannedWork={formatNumber(workArea?.plannedWork)}
|
||||||
className="m-0 text-info"
|
className="m-0 my-2 " height="6px"rounded showLabel={true}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</button>
|
</button>
|
||||||
</p>
|
</p>
|
||||||
@ -121,16 +120,17 @@ const WorkArea = ({ workArea, floor, forBuilding }) => {
|
|||||||
className="accordion-collapse collapse"
|
className="accordion-collapse collapse"
|
||||||
aria-labelledby={`heading-${workArea.id}`}
|
aria-labelledby={`heading-${workArea.id}`}
|
||||||
>
|
>
|
||||||
<div className="accordion-body px-1">
|
<div className="accordion-body px-6">
|
||||||
{isLoading || ProjectTaskList === undefined ? (
|
{isLoading || ProjectTaskList === undefined ? (
|
||||||
<div className="text-center py-2 text-muted">Loading activities...</div>
|
<div className="text-center py-2 text-muted">Loading activities...</div>
|
||||||
) : ProjectTaskList?.length === 0 ? (
|
) : ProjectTaskList?.length === 0 ? (
|
||||||
<div className="text-center py-2 text-muted">No activities available for this work area.</div>
|
<div className="text-center py-2 text-muted">No activities available for this work area.</div>
|
||||||
):ProjectTaskList?.length > 0 ? (
|
) : ProjectTaskList?.length > 0 ? (
|
||||||
<table className="table table-sm mx-1">
|
<table className="table table-sm mx-1">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th className="infra-activity-table-header-first">Activity</th>
|
<th className="infra-activity-table-header-first">Activity</th>
|
||||||
|
<th className="infra-activity-table-header-second">Service</th>
|
||||||
<th className="infra-activity-table-header d-sm-table-cell d-md-none">
|
<th className="infra-activity-table-header d-sm-table-cell d-md-none">
|
||||||
Status
|
Status
|
||||||
</th>
|
</th>
|
||||||
@ -152,9 +152,9 @@ const WorkArea = ({ workArea, floor, forBuilding }) => {
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody className="table-border-bottom-0">
|
<tbody className="table-border-bottom-0">
|
||||||
{ProjectTaskList.map((workItem,index) => (
|
{ProjectTaskList.map((workItem, index) => (
|
||||||
<WorkItem
|
<WorkItem
|
||||||
key={workItem.workItemId || `fallback-${index}`}
|
key={workItem.workItemId || `fallback-${index}`}
|
||||||
workItem={workItem}
|
workItem={workItem}
|
||||||
forBuilding={forBuilding}
|
forBuilding={forBuilding}
|
||||||
forFloor={floor}
|
forFloor={floor}
|
||||||
|
|||||||
@ -50,8 +50,8 @@ const WorkAreaModel = ({ project, onSubmit, onClose }) => {
|
|||||||
: "Work Area created Successfully",
|
: "Work Area created Successfully",
|
||||||
"success"
|
"success"
|
||||||
);
|
);
|
||||||
reset({ id: "0", buildingId: "0", areaName: "", floorId: "0" });
|
setValue("id", "0");
|
||||||
// onClose?.();
|
setValue("areaName", "");
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -157,7 +157,17 @@ const WorkItem = ({
|
|||||||
: "NA"}
|
: "NA"}
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
|
<td className="text-center d-sm-table-cell ">
|
||||||
|
{hasWorkItem
|
||||||
|
? NewWorkItem?.workItem?.activityMaster?.activityGroupMaster?.service?.name ??
|
||||||
|
workItem?.activityMaster?.activityGroupMaster?.service?.name ??
|
||||||
|
"NA"
|
||||||
|
: "NA"}
|
||||||
|
{" "}
|
||||||
|
{hasWorkItem
|
||||||
|
? NewWorkItem?.workItem?.activityMaster?.activityGroupMaster?.service?.name
|
||||||
|
: "NA"}
|
||||||
|
</td>
|
||||||
{/* Status - visible only on small screens */}
|
{/* Status - visible only on small screens */}
|
||||||
<td className="text-center d-sm-table-cell d-md-none">
|
<td className="text-center d-sm-table-cell d-md-none">
|
||||||
{hasWorkItem
|
{hasWorkItem
|
||||||
|
|||||||
@ -77,13 +77,7 @@ const ManageProject = () => {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{isProjectCreated && (
|
|
||||||
<div>
|
|
||||||
<h3>Additional Content</h3>
|
|
||||||
<p>Now that the project is created, you can access this content.</p>
|
|
||||||
{/* Add more content here */}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,11 +1,24 @@
|
|||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
|
import { projectSchema, projectDefault } from "./ProjectSchema";
|
||||||
import { useForm, Controller } from "react-hook-form";
|
import { useForm, Controller } from "react-hook-form";
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
import { z } from "zod";
|
|
||||||
import Label from "../common/Label";
|
import Label from "../common/Label";
|
||||||
import DatePicker from "../common/DatePicker";
|
import DatePicker from "../common/DatePicker";
|
||||||
|
import { useCreateProject, useProjectDetails, useUpdateProject } from "../../hooks/useProjects";
|
||||||
|
|
||||||
const currentDate = new Date().toLocaleDateString('en-CA');
|
import {
|
||||||
|
DEFAULT_EMPTY_STATUS_ID,
|
||||||
|
ITEMS_PER_PAGE,
|
||||||
|
PROJECT_STATUS,
|
||||||
|
} from "../../utils/constants";
|
||||||
|
import {
|
||||||
|
useOrganizationModal,
|
||||||
|
useOrganizationsList,
|
||||||
|
} from "../../hooks/useOrganization";
|
||||||
|
import { localToUtc } from "../../utils/appUtils";
|
||||||
|
|
||||||
|
const currentDate = new Date().toLocaleDateString("en-CA");
|
||||||
const formatDate = (date) => {
|
const formatDate = (date) => {
|
||||||
if (!date) {
|
if (!date) {
|
||||||
return currentDate;
|
return currentDate;
|
||||||
@ -14,54 +27,23 @@ const formatDate = (date) => {
|
|||||||
if (isNaN(d.getTime())) {
|
if (isNaN(d.getTime())) {
|
||||||
return currentDate;
|
return currentDate;
|
||||||
}
|
}
|
||||||
return d.toLocaleDateString('en-CA');
|
return d.toLocaleDateString("en-CA");
|
||||||
};
|
};
|
||||||
const ManageProjectInfo = ({ project, handleSubmitForm, onClose, isPending }) => {
|
const ManageProjectInfo = ({ project, onClose }) => {
|
||||||
const [CurrentProject, setCurrentProject] = useState();
|
|
||||||
const [addressLength, setAddressLength] = useState(0);
|
const [addressLength, setAddressLength] = useState(0);
|
||||||
const maxAddressLength = 500;
|
const maxAddressLength = 500;
|
||||||
|
const { onOpen, startStep, flowType } = useOrganizationModal();
|
||||||
|
|
||||||
const ACTIVE_STATUS_ID = "b74da4c2-d07e-46f2-9919-e75e49b12731";
|
const ACTIVE_STATUS_ID = "b74da4c2-d07e-46f2-9919-e75e49b12731";
|
||||||
const DEFAULT_EMPTY_STATUS_ID = "00000000-0000-0000-0000-000000000000";
|
|
||||||
|
|
||||||
const projectSchema = z
|
const { projects_Details, loading } = useProjectDetails(project);
|
||||||
.object({
|
const { data, isLoading, isError, error } = useOrganizationsList(
|
||||||
...(project?.id ? { id: z.string().optional() } : {}),
|
ITEMS_PER_PAGE,
|
||||||
name: z.string().min(1, { message: "Project Name is required" }),
|
1,
|
||||||
shortName: z.string().optional(),
|
true
|
||||||
contactPerson: z
|
);
|
||||||
.string()
|
const { mutate: UpdateProject, isPending } = useUpdateProject(() => {onClose?.()});
|
||||||
.min(1, { message: "Contact Person Name is required" })
|
const {mutate:CeateProject,isPending:isCreating} = useCreateProject(()=>{onClose?.()})
|
||||||
.regex(/^[A-Za-z\s]+$/, {
|
|
||||||
message: "Contact Person must contain only letters",
|
|
||||||
}),
|
|
||||||
projectAddress: z
|
|
||||||
.string()
|
|
||||||
.min(1, { message: "Address is required" })
|
|
||||||
.max(500, "Address must not exceed 150 characters"),
|
|
||||||
startDate: z
|
|
||||||
.string()
|
|
||||||
.min(1, { message: "Start Date is required" })
|
|
||||||
.default(currentDate),
|
|
||||||
endDate: z
|
|
||||||
.string()
|
|
||||||
.min(1, { message: "End Date is required" })
|
|
||||||
.default(currentDate),
|
|
||||||
projectStatusId: z
|
|
||||||
.string()
|
|
||||||
.min(1, { message: "Status is required" })
|
|
||||||
})
|
|
||||||
.refine(
|
|
||||||
(data) => {
|
|
||||||
const start = new Date(data.startDate);
|
|
||||||
const end = new Date(data.endDate);
|
|
||||||
return end >= start;
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: ["endDate"], // attaches the error to the endDate field
|
|
||||||
message: "End Date must be greater than Start Date",
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
register,
|
register,
|
||||||
@ -72,80 +54,66 @@ const ManageProjectInfo = ({ project, handleSubmitForm, onClose, isPending }) =>
|
|||||||
getValues,
|
getValues,
|
||||||
} = useForm({
|
} = useForm({
|
||||||
resolver: zodResolver(projectSchema),
|
resolver: zodResolver(projectSchema),
|
||||||
defaultValues: {
|
defaultValues: projectDefault,
|
||||||
id: project?.id || "",
|
|
||||||
name: project?.name || "",
|
|
||||||
shortName: project?.shortName || "",
|
|
||||||
contactPerson: project?.contactPerson || "",
|
|
||||||
projectAddress: project?.projectAddress || "",
|
|
||||||
startDate: formatDate(project?.startDate) || currentDate,
|
|
||||||
endDate: formatDate(project?.endDate) || currentDate,
|
|
||||||
// projectStatusId: String(project?.projectStatusId || "00000000-0000-0000-0000-000000000000"),
|
|
||||||
projectStatusId: project?.projectStatusId && project.projectStatusId !== DEFAULT_EMPTY_STATUS_ID
|
|
||||||
|
|
||||||
? String(project.projectStatusId)
|
|
||||||
|
|
||||||
: ACTIVE_STATUS_ID,
|
|
||||||
},
|
|
||||||
mode: "onChange",
|
mode: "onChange",
|
||||||
});
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setCurrentProject(project);
|
if (project && projects_Details)
|
||||||
reset(
|
reset({
|
||||||
project
|
name: projects_Details?.name || "",
|
||||||
? {
|
shortName: projects_Details?.shortName || "",
|
||||||
id: project?.id || "",
|
contactPerson: projects_Details?.contactPerson || "",
|
||||||
name: project?.name || "",
|
projectAddress: projects_Details?.projectAddress || "",
|
||||||
shortName: project?.shortName || "",
|
startDate: formatDate(projects_Details?.startDate) || "",
|
||||||
contactPerson: project?.contactPerson || "",
|
endDate: formatDate(projects_Details?.endDate) || "",
|
||||||
projectAddress: project?.projectAddress || "",
|
projectStatusId:
|
||||||
startDate: formatDate(project?.startDate) || "",
|
String(projects_Details?.projectStatus?.id) ||
|
||||||
endDate: formatDate(project?.endDate) || "",
|
DEFAULT_EMPTY_STATUS_IDF,
|
||||||
projectStatusId: String(project?.projectStatus?.id) || "00000000-0000-0000-0000-000000000000",
|
promoterId: projects_Details?.promoter?.id || "",
|
||||||
}
|
pmcId: projects_Details?.pmc?.id || "",
|
||||||
: {}
|
});
|
||||||
);
|
setAddressLength(projects_Details?.projectAddress?.length || 0);
|
||||||
setAddressLength(project?.projectAddress?.length || 0);
|
}, [project, projects_Details, reset,data]);
|
||||||
}, [project, reset]);
|
|
||||||
|
|
||||||
/**
|
const onSubmitForm = (formData) => {
|
||||||
|
if (project) {
|
||||||
* Handles the form submission.
|
let payload = {
|
||||||
|
...formData,
|
||||||
* @param {object} updatedProject - The project data from the form.
|
startDate: localToUtc(formData.startDate),
|
||||||
|
endDate: localToUtc(formData.endDate),
|
||||||
*/
|
id: project,
|
||||||
|
};
|
||||||
const onSubmitForm = (updatedProject) => {
|
UpdateProject({ projectId: project, payload: payload });
|
||||||
|
}else{
|
||||||
handleSubmitForm(updatedProject);
|
let payload = {
|
||||||
|
...formData,
|
||||||
|
startDate: localToUtc(formData.startDate),
|
||||||
|
endDate: localToUtc(formData.endDate),
|
||||||
|
};
|
||||||
|
CeateProject(payload)
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleCancel = () => {
|
const handleCancel = () => {
|
||||||
reset({
|
reset(projectDefault);
|
||||||
id: project?.id || "",
|
|
||||||
name: project?.name || "",
|
|
||||||
shortName: project?.shortName || "",
|
|
||||||
contactPerson: project?.contactPerson || "",
|
|
||||||
projectAddress: project?.projectAddress || "",
|
|
||||||
startDate: formatDate(project?.startDate) || currentDate,
|
|
||||||
endDate: formatDate(project?.endDate) || currentDate,
|
|
||||||
projectStatusId: String(project?.projectStatus?.id || "00000000-0000-0000-0000-000000000000"),
|
|
||||||
});
|
|
||||||
onClose();
|
onClose();
|
||||||
};
|
};
|
||||||
|
const handleOrganizaioFinder = () => {
|
||||||
|
onClose();
|
||||||
|
onOpen({ startStep: 2, flowType: "default" });
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
||||||
<div className="p-sm-2 p-2">
|
<div className="p-sm-2 p-2">
|
||||||
|
|
||||||
<div className="text-center mb-2">
|
<div className="text-center mb-2">
|
||||||
<h5 className="mb-2">
|
<h5 className="mb-2">{project ? "Edit Project" : "Create Project"}</h5>
|
||||||
{project?.id ? "Edit Project" : "Create Project"}
|
|
||||||
</h5>
|
|
||||||
</div>
|
</div>
|
||||||
<form className="row g-2 text-start" onSubmit={handleSubmit(onSubmitForm)}>
|
<form
|
||||||
|
className="row g-2 text-start"
|
||||||
|
onSubmit={handleSubmit(onSubmitForm)}
|
||||||
|
>
|
||||||
<div className="col-12 col-md-12">
|
<div className="col-12 col-md-12">
|
||||||
<Label htmlFor="name" required>
|
<Label htmlFor="name" required>
|
||||||
Project Name
|
Project Name
|
||||||
@ -225,7 +193,10 @@ const ManageProjectInfo = ({ project, handleSubmitForm, onClose, isPending }) =>
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
{errors.startDate && (
|
{errors.startDate && (
|
||||||
<div className="danger-text text-start" style={{ fontSize: "12px" }}>
|
<div
|
||||||
|
className="danger-text text-start"
|
||||||
|
style={{ fontSize: "12px" }}
|
||||||
|
>
|
||||||
{errors.startDate.message}
|
{errors.startDate.message}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
@ -240,18 +211,21 @@ const ManageProjectInfo = ({ project, handleSubmitForm, onClose, isPending }) =>
|
|||||||
name="endDate"
|
name="endDate"
|
||||||
control={control}
|
control={control}
|
||||||
placeholder="DD-MM-YYYY"
|
placeholder="DD-MM-YYYY"
|
||||||
minDate={getValues("startDate")} // optional: restrict future dates
|
minDate={getValues("startDate")} // optional: restrict future dates
|
||||||
className="w-100"
|
className="w-100"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{errors.endDate && (
|
{errors.endDate && (
|
||||||
<div className="danger-text text-start" style={{ fontSize: "12px" }}>
|
<div
|
||||||
|
className="danger-text text-start"
|
||||||
|
style={{ fontSize: "12px" }}
|
||||||
|
>
|
||||||
{errors.endDate.message}
|
{errors.endDate.message}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="col-12 col-md-6">
|
<div className="col-12 ">
|
||||||
<label className="form-label" htmlFor="modalEditUserStatus">
|
<label className="form-label" htmlFor="modalEditUserStatus">
|
||||||
Status
|
Status
|
||||||
</label>
|
</label>
|
||||||
@ -265,15 +239,11 @@ const ManageProjectInfo = ({ project, handleSubmitForm, onClose, isPending }) =>
|
|||||||
valueAsNumber: false,
|
valueAsNumber: false,
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
{/* <option disabled>Status</option>
|
{PROJECT_STATUS.map((status) => (
|
||||||
<option value="b74da4c2-d07e-46f2-9919-e75e49b12731">Active</option> */}
|
<option key={status.id} value={status.id}>
|
||||||
<option value={ACTIVE_STATUS_ID}>Active</option>
|
{status.label}
|
||||||
<option value="603e994b-a27f-4e5d-a251-f3d69b0498ba">On Hold</option>
|
</option>
|
||||||
|
))}
|
||||||
<option value="cdad86aa-8a56-4ff4-b633-9c629057dfef">In Progress</option>
|
|
||||||
<option value="ef1c356e-0fe0-42df-a5d3-8daee355492d">Inactive</option>
|
|
||||||
|
|
||||||
<option value="33deaef9-9af1-4f2a-b443-681ea0d04f81">Completed</option>
|
|
||||||
</select>
|
</select>
|
||||||
{errors.projectStatusId && (
|
{errors.projectStatusId && (
|
||||||
<div
|
<div
|
||||||
@ -284,6 +254,83 @@ const ManageProjectInfo = ({ project, handleSubmitForm, onClose, isPending }) =>
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
<div className="col-12 ">
|
||||||
|
<label className="form-label" htmlFor="modalEditUserStatus">
|
||||||
|
Promoter
|
||||||
|
</label>
|
||||||
|
<select
|
||||||
|
className="select2 form-select form-select-sm"
|
||||||
|
aria-label="Default select example"
|
||||||
|
{...register("promoterId", {
|
||||||
|
required: "Promoter is required",
|
||||||
|
valueAsNumber: false,
|
||||||
|
})}
|
||||||
|
>
|
||||||
|
{isLoading ? (
|
||||||
|
<option>Loading...</option>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<option value="">Select Promoter</option>
|
||||||
|
{data?.data?.map((org) => (
|
||||||
|
<option key={org.id} value={org.id}>
|
||||||
|
{org.name}
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</select>
|
||||||
|
{errors.promoterId && (
|
||||||
|
<div
|
||||||
|
className="danger-text text-start"
|
||||||
|
style={{ fontSize: "12px" }}
|
||||||
|
>
|
||||||
|
{errors.promoterId.message}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<div className="col-12 ">
|
||||||
|
<label className="form-label" htmlFor="modalEditUserStatus">
|
||||||
|
PMC
|
||||||
|
</label>
|
||||||
|
<select
|
||||||
|
className="select2 form-select form-select-sm"
|
||||||
|
aria-label="Default select example"
|
||||||
|
{...register("pmcId", {
|
||||||
|
required: "Promoter is required",
|
||||||
|
valueAsNumber: false,
|
||||||
|
})}
|
||||||
|
>
|
||||||
|
{isLoading ? (
|
||||||
|
<option>Loading...</option>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<option value="">Select PMC</option>
|
||||||
|
{data?.data?.map((org) => (
|
||||||
|
<option key={org.id} value={org.id}>
|
||||||
|
{org.name}
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</select>
|
||||||
|
{errors.pmcId && (
|
||||||
|
<div
|
||||||
|
className="danger-text text-start"
|
||||||
|
style={{ fontSize: "12px" }}
|
||||||
|
>
|
||||||
|
{errors.pmcId.message}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<div className="d-flex justify-content-between text-secondary text-tiny text-wrap">
|
||||||
|
<span>
|
||||||
|
<i className="bx bx-sm bx-info-circle"></i> Not found PMC and
|
||||||
|
Pomoter, find through SPRID or create new
|
||||||
|
</span>
|
||||||
|
<small className="cursor-pointer" onClick={handleOrganizaioFinder} >
|
||||||
|
<i className="bx bx-plus-circle text-primary"></i>
|
||||||
|
</small>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div className="col-12 col-md-12">
|
<div className="col-12 col-md-12">
|
||||||
<Label htmlFor="projectAddress" required>
|
<Label htmlFor="projectAddress" required>
|
||||||
@ -301,6 +348,7 @@ const ManageProjectInfo = ({ project, handleSubmitForm, onClose, isPending }) =>
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="text-end" style={{ fontSize: "12px" }}>
|
<div className="text-end" style={{ fontSize: "12px" }}>
|
||||||
{maxAddressLength - addressLength} characters left
|
{maxAddressLength - addressLength} characters left
|
||||||
</div>
|
</div>
|
||||||
@ -319,19 +367,18 @@ const ManageProjectInfo = ({ project, handleSubmitForm, onClose, isPending }) =>
|
|||||||
className="btn btn-label-secondary btn-sm me-2"
|
className="btn btn-label-secondary btn-sm me-2"
|
||||||
onClick={handleCancel}
|
onClick={handleCancel}
|
||||||
aria-label="Close"
|
aria-label="Close"
|
||||||
disabled={isPending}
|
disabled={isPending || isCreating || loading}
|
||||||
>
|
>
|
||||||
Cancel
|
Cancel
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
type="submit"
|
type="submit"
|
||||||
className="btn btn-primary btn-sm"
|
className="btn btn-primary btn-sm"
|
||||||
disabled={isPending}
|
disabled={isPending || isCreating || loading}
|
||||||
>
|
>
|
||||||
{isPending ? "Please Wait..." : project?.id ? "Update" : "Submit"}
|
{isPending||isCreating ? "Please Wait..." : project ? "Update" : "Submit"}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -1,211 +0,0 @@
|
|||||||
import React, { useState, useEffect } from "react";
|
|
||||||
import EmployeeRepository from "../../repositories/EmployeeRepository";
|
|
||||||
import { useAllEmployees } from "../../hooks/useEmployees";
|
|
||||||
import useSearch from "../../hooks/useSearch";
|
|
||||||
import AssignEmployeeTable from "./AssignEmployeeTable";
|
|
||||||
import showToast from "../../services/toastService";
|
|
||||||
import "./MapUser.css";
|
|
||||||
|
|
||||||
const MapUsers = ({
|
|
||||||
projectId,
|
|
||||||
onClose,
|
|
||||||
empJobRoles,
|
|
||||||
onSubmit,
|
|
||||||
allocation,
|
|
||||||
assignedLoading,
|
|
||||||
setAssignedLoading,
|
|
||||||
}) => {
|
|
||||||
const {
|
|
||||||
employeesList,
|
|
||||||
loading: employeeLoading,
|
|
||||||
error,
|
|
||||||
} = useAllEmployees(false);
|
|
||||||
const [selectedEmployees, setSelectedEmployees] = useState([]);
|
|
||||||
const [searchText, setSearchText] = useState("");
|
|
||||||
|
|
||||||
const handleAllocationData = Array.isArray(allocation) ? allocation : [];
|
|
||||||
|
|
||||||
const allocationEmployees = employeesList.map((employee) => {
|
|
||||||
const allocationItem = handleAllocationData.find(
|
|
||||||
(alloc) => alloc.employeeId === employee.id
|
|
||||||
);
|
|
||||||
return {
|
|
||||||
...employee,
|
|
||||||
isActive: allocationItem ? allocationItem.isActive : false,
|
|
||||||
jobRoleId: allocationItem ? allocationItem.jobRoleId : employee.jobRoleId,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
function parseDate(dateStr) {
|
|
||||||
return new Date(dateStr.split(".")[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
const latestAllocations = handleAllocationData.reduce((acc, alloc) => {
|
|
||||||
const existingAlloc = acc[alloc.employeeId];
|
|
||||||
|
|
||||||
if (!existingAlloc) {
|
|
||||||
acc[alloc.employeeId] = alloc;
|
|
||||||
} else {
|
|
||||||
const existingDate = parseDate(
|
|
||||||
existingAlloc.reAllocationDate || existingAlloc.allocationDate
|
|
||||||
);
|
|
||||||
const newDate = parseDate(alloc.reAllocationDate || alloc.allocationDate);
|
|
||||||
|
|
||||||
if (newDate > existingDate) {
|
|
||||||
acc[alloc.employeeId] = alloc;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return acc;
|
|
||||||
}, {});
|
|
||||||
|
|
||||||
const allocationEmployeesData = employeesList
|
|
||||||
.map((employee) => {
|
|
||||||
const allocationItem = latestAllocations[employee.id];
|
|
||||||
return {
|
|
||||||
...employee,
|
|
||||||
isActive: allocationItem ? allocationItem.isActive : false,
|
|
||||||
};
|
|
||||||
})
|
|
||||||
.filter((employee) => employee.isActive === false);
|
|
||||||
|
|
||||||
const { filteredData, setSearchQuery } = useSearch(
|
|
||||||
allocationEmployeesData,
|
|
||||||
searchText
|
|
||||||
);
|
|
||||||
|
|
||||||
const handleRoleChange = (employeeId, newRoleId) => {
|
|
||||||
setSelectedEmployees((prevSelectedEmployees) =>
|
|
||||||
prevSelectedEmployees.map((emp) =>
|
|
||||||
emp.id === employeeId ? { ...emp, jobRoleId: newRoleId } : emp
|
|
||||||
)
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleCheckboxChange = (employeeId) => {
|
|
||||||
setSelectedEmployees((prevSelectedEmployees) => {
|
|
||||||
const updatedEmployees = [...prevSelectedEmployees];
|
|
||||||
const employeeIndex = updatedEmployees.findIndex(
|
|
||||||
(emp) => emp.id === employeeId
|
|
||||||
);
|
|
||||||
|
|
||||||
if (employeeIndex !== -1) {
|
|
||||||
const isSelected = !updatedEmployees[employeeIndex].isSelected;
|
|
||||||
updatedEmployees[employeeIndex].isSelected = isSelected;
|
|
||||||
} else {
|
|
||||||
updatedEmployees.push({
|
|
||||||
id: employeeId,
|
|
||||||
isSelected: true,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return updatedEmployees;
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleSubmit = () => {
|
|
||||||
setAssignedLoading(true);
|
|
||||||
const selected = selectedEmployees
|
|
||||||
.filter((emp) => emp.isSelected)
|
|
||||||
.map((emp) => ({ empID: emp.id, jobRoleId: emp.jobRoleId }));
|
|
||||||
if (selected.length > 0) {
|
|
||||||
onSubmit(selected);
|
|
||||||
setSelectedEmployees([]);
|
|
||||||
} else {
|
|
||||||
showToast("Please select Employee", "error");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<div className="modal-dialog modal-dialog-scrollable mx-sm-auto mx-1 modal-lg modal-simple modal-edit-user">
|
|
||||||
<div className="modal-content">
|
|
||||||
<div className="modal-header text-center">
|
|
||||||
<button type="button" className="btn-close" data-bs-dismiss="modal" aria-label="Close">
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
<p className="m-0 fw-semibold fs-5">Assign Employee</p>
|
|
||||||
|
|
||||||
<div className="px-4 mt-4 col-md-4 text-start">
|
|
||||||
{(filteredData.length > 0 ||
|
|
||||||
allocationEmployeesData.length > 0) && (
|
|
||||||
<div className="input-group input-group-sm mb-2">
|
|
||||||
<input
|
|
||||||
type="search"
|
|
||||||
className="form-control"
|
|
||||||
placeholder="Search employees..."
|
|
||||||
onChange={(e) => setSearchQuery(e.target.value)}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<p className="mb-0 small text-muted fw-semibold">Select Employee</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="modal-body p-sm-4 p-0">
|
|
||||||
<table
|
|
||||||
className="datatables-users table border-top dataTable no-footer dtr-column "
|
|
||||||
id="DataTables_Table_0"
|
|
||||||
aria-describedby="DataTables_Table_0_info"
|
|
||||||
style={{ width: "100%" }}
|
|
||||||
>
|
|
||||||
<tbody>
|
|
||||||
{employeeLoading && allocationEmployeesData.length === 0 && (
|
|
||||||
<tr>
|
|
||||||
<td>Loading..</td>
|
|
||||||
</tr>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{!employeeLoading &&
|
|
||||||
allocationEmployeesData.length === 0 &&
|
|
||||||
filteredData.length === 0 && (
|
|
||||||
<tr>
|
|
||||||
<td>All employee assigned to Project.</td>
|
|
||||||
</tr>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{!employeeLoading &&
|
|
||||||
allocationEmployeesData.length > 0 &&
|
|
||||||
filteredData.length === 0 && (
|
|
||||||
<tr>
|
|
||||||
<td>No matching employees found.</td>
|
|
||||||
</tr>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{(filteredData.length > 0 ||
|
|
||||||
allocationEmployeesData.length > 0) &&
|
|
||||||
filteredData.map((emp) => (
|
|
||||||
<AssignEmployeeTable
|
|
||||||
key={emp.id}
|
|
||||||
employee={emp}
|
|
||||||
jobRoles={empJobRoles}
|
|
||||||
isChecked={emp.isSelected}
|
|
||||||
onRoleChange={handleRoleChange}
|
|
||||||
onCheckboxChange={handleCheckboxChange}
|
|
||||||
/>
|
|
||||||
))}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
<div className="modal-footer mt-5 d-flex justify-content-end gap-0">
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
className="btn btn-sm btn-label-secondary"
|
|
||||||
data-dismiss="modal"
|
|
||||||
aria-label="Close"
|
|
||||||
onClick={onClose}
|
|
||||||
>
|
|
||||||
Cancel
|
|
||||||
</button>
|
|
||||||
|
|
||||||
{(filteredData.length > 0 || allocationEmployeesData.length > 0) && (
|
|
||||||
<button className="btn btn-sm btn-primary" onClick={handleSubmit}>
|
|
||||||
{assignedLoading ? "Please Wait..." : "Assign to Project"}
|
|
||||||
</button>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default MapUsers;
|
|
||||||
@ -14,41 +14,15 @@ import {
|
|||||||
getProjectStatusName,
|
getProjectStatusName,
|
||||||
} from "../../utils/projectStatus";
|
} from "../../utils/projectStatus";
|
||||||
import GlobalModel from "../common/GlobalModel";
|
import GlobalModel from "../common/GlobalModel";
|
||||||
import { useDispatch } from "react-redux";
|
import { useDispatch } from "react-redux";
|
||||||
import { setProjectId } from "../../slices/localVariablesSlice";
|
import { setProjectId } from "../../slices/localVariablesSlice";
|
||||||
|
import { useProjectContext } from "../../pages/project/ProjectPage";
|
||||||
|
|
||||||
const ProjectCard = ({ projectData, recall }) => {
|
const ProjectCard = ({ project }) => {
|
||||||
const [ projectInfo, setProjectInfo ] = useState( projectData );
|
const dispatch = useDispatch();
|
||||||
const { projects_Details, loading, error, refetch } = useProjectDetails(
|
|
||||||
projectInfo?.id,false
|
|
||||||
);
|
|
||||||
const [showModal, setShowModal] = useState(false);
|
|
||||||
const dispatch = useDispatch()
|
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const ManageProject = useHasUserPermission(MANAGE_PROJECT);
|
const ManageProject = useHasUserPermission(MANAGE_PROJECT);
|
||||||
const {
|
const { setMangeProject } = useProjectContext();
|
||||||
mutate: updateProject,
|
|
||||||
isPending,
|
|
||||||
isSuccess,
|
|
||||||
isError,
|
|
||||||
} = useUpdateProject({
|
|
||||||
onSuccessCallback: () => {
|
|
||||||
setShowModal(false);
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
useEffect(()=>{
|
|
||||||
setProjectInfo(projectData);
|
|
||||||
}, [ projectData ] )
|
|
||||||
|
|
||||||
const handleShow = async () => {
|
|
||||||
try {
|
|
||||||
const { data } = await refetch();
|
|
||||||
setShowModal(true);
|
|
||||||
} catch (err) {
|
|
||||||
showToast("Failed to load project details", "error");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const getProgress = (planned, completed) => {
|
const getProgress = (planned, completed) => {
|
||||||
return (completed * 100) / planned + "%";
|
return (completed * 100) / planned + "%";
|
||||||
@ -60,35 +34,17 @@ const ProjectCard = ({ projectData, recall }) => {
|
|||||||
const handleClose = () => setShowModal(false);
|
const handleClose = () => setShowModal(false);
|
||||||
|
|
||||||
const handleViewProject = () => {
|
const handleViewProject = () => {
|
||||||
dispatch(setProjectId(projectInfo.id))
|
dispatch(setProjectId(project.id));
|
||||||
navigate(`/projects/details`);
|
navigate(`/projects/details`);
|
||||||
};
|
};
|
||||||
|
const handleViewActivities = () => {
|
||||||
const handleFormSubmit = (updatedProject) => {
|
dispatch(setProjectId(project.id));
|
||||||
if (projectInfo?.id) {
|
navigate(`/activities/records?project=${project.id}`);
|
||||||
updateProject({
|
};
|
||||||
projectId: projectInfo.id,
|
|
||||||
updatedData: updatedProject,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|
||||||
{showModal && projects_Details && (
|
|
||||||
<GlobalModel isOpen={showModal} closeModal={handleClose}>
|
|
||||||
<ManageProjectInfo
|
|
||||||
project={projects_Details}
|
|
||||||
handleSubmitForm={handleFormSubmit}
|
|
||||||
onClose={handleClose}
|
|
||||||
isPending={isPending}
|
|
||||||
/>
|
|
||||||
</GlobalModel>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<div className="col-md-6 col-lg-4 col-xl-4 order-0 mb-4">
|
<div className="col-md-6 col-lg-4 col-xl-4 order-0 mb-4">
|
||||||
<div className={`card cursor-pointer ${isPending ? "bg-light opacity-50 pointer-events-none" : ""}`}>
|
<div className={`card cursor-pointer`}>
|
||||||
<div className="card-header pb-4">
|
<div className="card-header pb-4">
|
||||||
<div className="d-flex align-items-start">
|
<div className="d-flex align-items-start">
|
||||||
<div className="d-flex align-items-center">
|
<div className="d-flex align-items-center">
|
||||||
@ -103,12 +59,10 @@ const ProjectCard = ({ projectData, recall }) => {
|
|||||||
className="mb-0 stretched-link text-heading text-start"
|
className="mb-0 stretched-link text-heading text-start"
|
||||||
onClick={handleViewProject}
|
onClick={handleViewProject}
|
||||||
>
|
>
|
||||||
{projectInfo.shortName
|
{project?.shortName ? project?.shortName : project?.name}
|
||||||
? projectInfo.shortName
|
|
||||||
: projectInfo.name}
|
|
||||||
</h5>
|
</h5>
|
||||||
<div className="client-info text-body">
|
<div className="client-info text-body">
|
||||||
<span>{projectInfo.shortName ? projectInfo.name : ""}</span>
|
<span>{project?.shortName ? project?.name : ""}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -120,23 +74,14 @@ const ProjectCard = ({ projectData, recall }) => {
|
|||||||
data-bs-toggle="dropdown"
|
data-bs-toggle="dropdown"
|
||||||
aria-expanded="false"
|
aria-expanded="false"
|
||||||
>
|
>
|
||||||
{loading ? (
|
<i
|
||||||
<div
|
className="bx bx-dots-vertical-rounded bx-sm text-muted"
|
||||||
className="spinner-border spinner-border-sm text-secondary"
|
data-bs-toggle="tooltip"
|
||||||
role="status"
|
data-bs-offset="0,8"
|
||||||
>
|
data-bs-placement="top"
|
||||||
<span className="visually-hidden">Loading...</span>
|
data-bs-custom-class="tooltip-dark"
|
||||||
</div>
|
title="More Action"
|
||||||
) : (
|
></i>
|
||||||
<i
|
|
||||||
className="bx bx-dots-vertical-rounded bx-sm text-muted"
|
|
||||||
data-bs-toggle="tooltip"
|
|
||||||
data-bs-offset="0,8"
|
|
||||||
data-bs-placement="top"
|
|
||||||
data-bs-custom-class="tooltip-dark"
|
|
||||||
title="More Action"
|
|
||||||
></i>
|
|
||||||
)}
|
|
||||||
</button>
|
</button>
|
||||||
<ul className="dropdown-menu dropdown-menu-end">
|
<ul className="dropdown-menu dropdown-menu-end">
|
||||||
<li>
|
<li>
|
||||||
@ -150,19 +95,18 @@ const ProjectCard = ({ projectData, recall }) => {
|
|||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li onClick={handleShow}>
|
<li>
|
||||||
<a className="dropdown-item">
|
<a className="dropdown-item" onClick={() =>
|
||||||
|
setMangeProject({
|
||||||
|
isOpen: true,
|
||||||
|
Project: project.id,
|
||||||
|
})
|
||||||
|
}>
|
||||||
<i className="bx bx-pencil me-2"></i>
|
<i className="bx bx-pencil me-2"></i>
|
||||||
<span className="align-left">Modify</span>
|
<span className="align-left">Modify</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li
|
<li onClick={handleViewActivities}>
|
||||||
onClick={() =>
|
|
||||||
navigate(
|
|
||||||
`/activities/records?project=${projectInfo.id}`
|
|
||||||
)
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<a className="dropdown-item">
|
<a className="dropdown-item">
|
||||||
<i className="bx bx-task me-2"></i>
|
<i className="bx bx-task me-2"></i>
|
||||||
<span className="align-left">Activities</span>
|
<span className="align-left">Activities</span>
|
||||||
@ -180,22 +124,22 @@ const ProjectCard = ({ projectData, recall }) => {
|
|||||||
<span className="text-heading fw-medium">
|
<span className="text-heading fw-medium">
|
||||||
Contact Person:{" "}
|
Contact Person:{" "}
|
||||||
</span>
|
</span>
|
||||||
{projectInfo.contactPerson ? projectInfo.contactPerson : "NA"}
|
{project?.contactPerson ? project.contactPerson : "NA"}
|
||||||
</p>
|
</p>
|
||||||
<p className="mb-1">
|
<p className="mb-1">
|
||||||
<span className="text-heading fw-medium">Start Date: </span>
|
<span className="text-heading fw-medium">Start Date: </span>
|
||||||
{projectInfo.startDate
|
{project.startDate
|
||||||
? moment(projectInfo.startDate).format("DD-MMM-YYYY")
|
? moment(project?.startDate).format("DD-MMM-YYYY")
|
||||||
: "NA"}
|
: "NA"}
|
||||||
</p>
|
</p>
|
||||||
<p className="mb-1">
|
<p className="mb-1">
|
||||||
<span className="text-heading fw-medium">Deadline: </span>
|
<span className="text-heading fw-medium">Deadline: </span>
|
||||||
|
|
||||||
{projectInfo.endDate
|
{project?.endDate
|
||||||
? moment(projectInfo.endDate).format("DD-MMM-YYYY")
|
? moment(project?.endDate).format("DD-MMM-YYYY")
|
||||||
: "NA"}
|
: "NA"}
|
||||||
</p>
|
</p>
|
||||||
<p className="mb-0">{projectInfo.projectAddress}</p>
|
<p className="mb-0">{project?.projectAddress}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -205,36 +149,37 @@ const ProjectCard = ({ projectData, recall }) => {
|
|||||||
<span
|
<span
|
||||||
className={
|
className={
|
||||||
`badge rounded-pill ` +
|
`badge rounded-pill ` +
|
||||||
getProjectStatusColor(projectInfo.projectStatusId)
|
getProjectStatusColor(project?.projectStatusId)
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{getProjectStatusName(projectInfo.projectStatusId)}
|
{getProjectStatusName(project?.projectStatusId)}
|
||||||
</span>
|
</span>
|
||||||
</p>{" "}
|
</p>{" "}
|
||||||
{getDateDifferenceInDays(projectInfo.endDate, Date()) >= 0 && (
|
{getDateDifferenceInDays(project?.endDate,new Date() ) >= 0 && (
|
||||||
<span className="badge bg-label-success ms-auto">
|
<span className="badge bg-label-success ms-auto">
|
||||||
{projectInfo.endDate &&
|
{project?.endDate &&
|
||||||
getDateDifferenceInDays(projectInfo.endDate, Date())}{" "}
|
getDateDifferenceInDays(project?.endDate, new Date())}{" "}
|
||||||
Days left
|
Days left
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
{getDateDifferenceInDays(projectInfo.endDate, Date()) < 0 && (
|
{getDateDifferenceInDays(project?.endDate, new Date()) < 0 && (
|
||||||
<span className="badge bg-label-danger ms-auto">
|
<span className="badge bg-label-danger ms-auto">
|
||||||
{projectInfo.endDate &&
|
{project?.endDate &&
|
||||||
getDateDifferenceInDays(projectInfo.endDate, Date())}{" "}
|
getDateDifferenceInDays(project?.endDate, new Date())}{" "}
|
||||||
Days overdue
|
Days overdue
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="d-flex justify-content-between align-items-center mb-2">
|
<div className="d-flex justify-content-between align-items-center mb-2">
|
||||||
<small className="text-body">
|
<small className="text-body">
|
||||||
Task: {formatNumber(projectInfo.completedWork)} / {formatNumber(projectInfo.plannedWork)}
|
Task: {formatNumber(project?.completedWork)} /{" "}
|
||||||
|
{formatNumber(project?.plannedWork)}
|
||||||
</small>
|
</small>
|
||||||
<small className="text-body">
|
<small className="text-body">
|
||||||
{Math.floor(
|
{Math.floor(
|
||||||
getProgressInNumber(
|
getProgressInNumber(
|
||||||
projectInfo.plannedWork,
|
project?.plannedWork,
|
||||||
projectInfo.completedWork
|
project?.completedWork
|
||||||
)
|
)
|
||||||
) || 0}{" "}
|
) || 0}{" "}
|
||||||
% Completed
|
% Completed
|
||||||
@ -246,22 +191,20 @@ const ProjectCard = ({ projectData, recall }) => {
|
|||||||
role="progressbar"
|
role="progressbar"
|
||||||
style={{
|
style={{
|
||||||
width: getProgress(
|
width: getProgress(
|
||||||
projectInfo.plannedWork,
|
project?.plannedWork,
|
||||||
projectInfo.completedWork
|
project?.completedWork
|
||||||
),
|
),
|
||||||
}}
|
}}
|
||||||
aria-valuenow={projectInfo.completedWork}
|
aria-valuenow={project?.completedWork}
|
||||||
aria-valuemin="0"
|
aria-valuemin="0"
|
||||||
aria-valuemax={projectInfo.plannedWork}
|
aria-valuemax={project?.plannedWork}
|
||||||
></div>
|
></div>
|
||||||
</div>
|
</div>
|
||||||
<div className="d-flex align-items-center justify-content-between">
|
<div className="d-flex align-items-center justify-content-between">
|
||||||
{/* <div className="d-flex align-items-center ">
|
|
||||||
</div> */}
|
|
||||||
<div>
|
<div>
|
||||||
<a className="text-muted d-flex " alt="Active team size">
|
<a className="text-muted d-flex " alt="Active team size">
|
||||||
<i className="bx bx-group bx-sm me-1_5"></i>
|
<i className="bx bx-group bx-sm me-1_5"></i>
|
||||||
{projectInfo?.teamSize} Members
|
{project?.teamSize} Members
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
70
src/components/Project/ProjectCardView.jsx
Normal file
70
src/components/Project/ProjectCardView.jsx
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
import React from 'react'
|
||||||
|
import { useProjects } from '../../hooks/useProjects'
|
||||||
|
import Loader from '../common/Loader'
|
||||||
|
import ProjectCard from './ProjectCard'
|
||||||
|
|
||||||
|
const ProjectCardView = ({currentItems,setCurrentPage,totalPages }) => {
|
||||||
|
|
||||||
|
|
||||||
|
return (
|
||||||
|
|
||||||
|
<div className="row page-min-h">
|
||||||
|
|
||||||
|
{ currentItems.length === 0 && (
|
||||||
|
<p className="text-center text-muted">No projects found.</p>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{currentItems.map((project) => (
|
||||||
|
<ProjectCard
|
||||||
|
key={project.id}
|
||||||
|
project={project}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
|
||||||
|
|
||||||
|
{ totalPages > 1 && (
|
||||||
|
<nav>
|
||||||
|
<ul className="pagination pagination-sm justify-content-end py-2">
|
||||||
|
<li className={`page-item ${currentPage === 1 && "disabled"}`}>
|
||||||
|
<button
|
||||||
|
className="page-link"
|
||||||
|
onClick={() => setCurrentPage((p) => Math.max(1, p - 1))}
|
||||||
|
>
|
||||||
|
«
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
{[...Array(totalPages)].map((_, i) => (
|
||||||
|
<li
|
||||||
|
key={i}
|
||||||
|
className={`page-item ${currentPage === i + 1 && "active"}`}
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
className="page-link"
|
||||||
|
onClick={() => setCurrentPage(i + 1)}
|
||||||
|
>
|
||||||
|
{i + 1}
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
))}
|
||||||
|
<li
|
||||||
|
className={`page-item ${currentPage === totalPages && "disabled"
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
className="page-link"
|
||||||
|
onClick={() =>
|
||||||
|
setCurrentPage((p) => Math.min(totalPages, p + 1))
|
||||||
|
}
|
||||||
|
>
|
||||||
|
»
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default ProjectCardView
|
||||||
@ -17,113 +17,173 @@ import {
|
|||||||
getCachedData,
|
getCachedData,
|
||||||
useSelectedProject,
|
useSelectedProject,
|
||||||
} from "../../slices/apiDataManager";
|
} from "../../slices/apiDataManager";
|
||||||
import { useProjectDetails, useProjectInfra } from "../../hooks/useProjects";
|
import {
|
||||||
|
useCurrentService,
|
||||||
|
useProjectAssignedServices,
|
||||||
|
useProjectDetails,
|
||||||
|
useProjectInfra,
|
||||||
|
} from "../../hooks/useProjects";
|
||||||
import { useDispatch, useSelector } from "react-redux";
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
import { refreshData } from "../../slices/localVariablesSlice";
|
import { refreshData } from "../../slices/localVariablesSlice";
|
||||||
import eventBus from "../../services/eventBus";
|
import eventBus from "../../services/eventBus";
|
||||||
import {useParams} from "react-router-dom";
|
import { useParams } from "react-router-dom";
|
||||||
import GlobalModel from "../common/GlobalModel";
|
import GlobalModel from "../common/GlobalModel";
|
||||||
|
import { setService } from "../../slices/globalVariablesSlice";
|
||||||
|
|
||||||
const ProjectInfra = ( {data, onDataChange, eachSiteEngineer} ) =>
|
const ProjectInfra = ({ data, onDataChange, eachSiteEngineer }) => {
|
||||||
{
|
|
||||||
// const projectId = useSelector((store)=>store.localVariables.projectId)
|
|
||||||
const projectId = useSelectedProject();
|
const projectId = useSelectedProject();
|
||||||
|
const selectedService = useCurrentService();
|
||||||
const reloadedData = useSelector((store) => store.localVariables.reload);
|
const reloadedData = useSelector((store) => store.localVariables.reload);
|
||||||
const [ expandedBuildings, setExpandedBuildings ] = useState( [] );
|
const [expandedBuildings, setExpandedBuildings] = useState([]);
|
||||||
const {projectInfra,isLoading,error} = useProjectInfra(projectId)
|
const { projectInfra, isLoading, error } = useProjectInfra(
|
||||||
|
projectId,
|
||||||
|
selectedService
|
||||||
|
);
|
||||||
const { projects_Details, refetch, loading } = useProjectDetails(data?.id);
|
const { projects_Details, refetch, loading } = useProjectDetails(data?.id);
|
||||||
const [ project, setProject ] = useState( projects_Details );
|
const [project, setProject] = useState(projects_Details);
|
||||||
const ManageInfra = useHasUserPermission(MANAGE_PROJECT_INFRA);
|
const ManageInfra = useHasUserPermission(MANAGE_PROJECT_INFRA);
|
||||||
const ManageTask = useHasUserPermission(MANAGE_TASK)
|
const ManageTask = useHasUserPermission(MANAGE_TASK);
|
||||||
const [showModalFloor, setshowModalFloor] = useState(false);
|
const [showModalFloor, setshowModalFloor] = useState(false);
|
||||||
const [showModalWorkArea, setshowModalWorkArea] = useState(false);
|
const [showModalWorkArea, setshowModalWorkArea] = useState(false);
|
||||||
const [showModalTask, setshowModalTask] = useState(false);
|
const [showModalTask, setshowModalTask] = useState(false);
|
||||||
const [showModalBuilding, setshowModalBuilding] = useState(false);
|
const [showModalBuilding, setshowModalBuilding] = useState(false);
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
|
const { data: assignedServices, isLoading: servicesLoading } =
|
||||||
|
useProjectAssignedServices(projectId);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setProject(projectInfra);
|
setProject(projectInfra);
|
||||||
}, [data, projects_Details]);
|
}, [data, projects_Details]);
|
||||||
|
|
||||||
// useEffect(() => {
|
|
||||||
// if (reloadedData) {
|
|
||||||
// refetch();
|
|
||||||
// dispatch(refreshData(false));
|
|
||||||
// }
|
|
||||||
// }, [reloadedData]);
|
|
||||||
|
|
||||||
const signalRHandler = (response) => {
|
const signalRHandler = (response) => {
|
||||||
setProject(response);
|
setProject(response);
|
||||||
}
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{showModalBuilding && <GlobalModel isOpen={showModalBuilding} size="md" closeModal={() => setshowModalBuilding( false )}>
|
{showModalBuilding && (
|
||||||
<BuildingModel
|
<GlobalModel
|
||||||
project={projectInfra}
|
isOpen={showModalBuilding}
|
||||||
onClose={() => setshowModalBuilding( false )}
|
size="md"
|
||||||
/>
|
closeModal={() => setshowModalBuilding(false)}
|
||||||
</GlobalModel>}
|
>
|
||||||
{showModalFloor && <GlobalModel isOpen={showModalFloor} size="md" closeModal={()=>setshowModalFloor(false)}>
|
<BuildingModel
|
||||||
<FloorModel
|
|
||||||
project={projectInfra}
|
project={projectInfra}
|
||||||
onClose={()=>setshowModalFloor(false)}
|
onClose={() => setshowModalBuilding(false)}
|
||||||
/>
|
/>
|
||||||
</GlobalModel>}
|
</GlobalModel>
|
||||||
{showModalWorkArea && <GlobalModel isOpen={showModalWorkArea} size="lg" closeModal={()=>setshowModalWorkArea(false)} >
|
)}
|
||||||
|
{showModalFloor && (
|
||||||
|
<GlobalModel
|
||||||
|
isOpen={showModalFloor}
|
||||||
|
size="md"
|
||||||
|
closeModal={() => setshowModalFloor(false)}
|
||||||
|
>
|
||||||
|
<FloorModel
|
||||||
|
project={projectInfra}
|
||||||
|
onClose={() => setshowModalFloor(false)}
|
||||||
|
/>
|
||||||
|
</GlobalModel>
|
||||||
|
)}
|
||||||
|
{showModalWorkArea && (
|
||||||
|
<GlobalModel
|
||||||
|
isOpen={showModalWorkArea}
|
||||||
|
size="lg"
|
||||||
|
closeModal={() => setshowModalWorkArea(false)}
|
||||||
|
>
|
||||||
<WorkAreaModel
|
<WorkAreaModel
|
||||||
project={projectInfra}
|
project={projectInfra}
|
||||||
onClose={()=>setshowModalWorkArea(false)}
|
onClose={() => setshowModalWorkArea(false)}
|
||||||
/>
|
/>
|
||||||
</GlobalModel>}
|
</GlobalModel>
|
||||||
{showModalTask && ( <GlobalModel isOpen={showModalTask} size="lg" closeModal={()=>setshowModalTask(false)}>
|
)}
|
||||||
<TaskModel
|
{showModalTask && (
|
||||||
|
<GlobalModel
|
||||||
|
isOpen={showModalTask}
|
||||||
|
size="lg"
|
||||||
|
closeModal={() => setshowModalTask(false)}
|
||||||
|
>
|
||||||
|
<TaskModel
|
||||||
project={projectInfra}
|
project={projectInfra}
|
||||||
onClose={()=>setshowModalTask(false)}
|
onClose={() => setshowModalTask(false)}
|
||||||
/>
|
/>
|
||||||
</GlobalModel>)}
|
</GlobalModel>
|
||||||
|
)}
|
||||||
<div className="col-md-12 col-lg-12 col-xl-12 order-0 mb-4">
|
<div className="col-md-12 col-lg-12 col-xl-12 order-0 mb-4">
|
||||||
<div className="card">
|
<div className="card">
|
||||||
<div className="card-body" style={{ padding: "0.5rem" }}>
|
<div className="card-body" style={{ padding: "0.5rem" }}>
|
||||||
<div className="align-items-center">
|
<div className="align-items-center">
|
||||||
<div className="row ">
|
<div className="row ">
|
||||||
<div
|
<div
|
||||||
className={`col-12 text-end mb-1 `}
|
className="dataTables_length text-start py-2 px-6 col-md-4 col-12"
|
||||||
|
id="DataTables_Table_0_length"
|
||||||
>
|
>
|
||||||
{ManageInfra && (<>
|
{!servicesLoading &&
|
||||||
<button
|
assignedServices?.length > 0 &&
|
||||||
type="button"
|
(assignedServices.length > 1 ? (
|
||||||
className="link-button btn btn-xs rounded-md link-button-sm m-1 btn-primary"
|
<label>
|
||||||
onClick={()=>setshowModalBuilding(true)}
|
<select
|
||||||
>
|
name="DataTables_Table_0_length"
|
||||||
<i className="bx bx-plus-circle me-2"></i>
|
aria-controls="DataTables_Table_0"
|
||||||
Manage Building
|
className="form-select form-select-sm"
|
||||||
</button>
|
aria-label="Select Service"
|
||||||
<button
|
value={selectedService}
|
||||||
type="button"
|
onChange={(e) => dispatch(setService(e.target.value))}
|
||||||
className="link-button btn btn-xs rounded-md m-1 btn-primary"
|
>
|
||||||
onClick={()=>setshowModalFloor(true)}
|
<option value="">All Services</option>
|
||||||
>
|
{assignedServices.map((service) => (
|
||||||
<i className="bx bx-plus-circle me-2"></i>
|
<option key={service.id} value={service.id}>
|
||||||
Manage Floors
|
{service.name}
|
||||||
</button>
|
</option>
|
||||||
<button
|
))}
|
||||||
type="button"
|
</select>
|
||||||
className="link-button btn btn-xs rounded-md m-1 btn-primary"
|
</label>
|
||||||
onClick={() => setshowModalWorkArea(true)}
|
) : (
|
||||||
>
|
<h5>{assignedServices[0].name}</h5>
|
||||||
<i className="bx bx-plus-circle me-2"></i>
|
))}
|
||||||
Manage Work Areas
|
</div>
|
||||||
</button></>)}
|
|
||||||
|
|
||||||
{(ManageTask || ManageInfra) && (<button
|
{/* Buttons Section (aligned to right) */}
|
||||||
type="button"
|
<div className="col-md-8 col-12 text-end mb-1">
|
||||||
className="link-button btn btn-xs rounded-md m-1 btn-primary"
|
{ManageInfra && (
|
||||||
onClick={()=>setshowModalTask(true)}
|
<>
|
||||||
>
|
<button
|
||||||
<i className="bx bx-plus-circle me-2"></i>
|
type="button"
|
||||||
Create Tasks
|
className="link-button btn btn-xs rounded-md link-button-sm m-1 btn-primary"
|
||||||
</button>)}
|
onClick={() => setshowModalBuilding(true)}
|
||||||
|
>
|
||||||
|
<i className="bx bx-plus-circle me-2"></i>
|
||||||
|
Manage Building
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="link-button btn btn-xs rounded-md m-1 btn-primary"
|
||||||
|
onClick={() => setshowModalFloor(true)}
|
||||||
|
>
|
||||||
|
<i className="bx bx-plus-circle me-2"></i>
|
||||||
|
Manage Floors
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="link-button btn btn-xs rounded-md m-1 btn-primary"
|
||||||
|
onClick={() => setshowModalWorkArea(true)}
|
||||||
|
>
|
||||||
|
<i className="bx bx-plus-circle me-2"></i>
|
||||||
|
Manage Work Areas
|
||||||
|
</button>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{(ManageTask || ManageInfra) && (
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="link-button btn btn-xs rounded-md m-1 btn-primary"
|
||||||
|
onClick={() => setshowModalTask(true)}
|
||||||
|
>
|
||||||
|
<i className="bx bx-plus-circle me-2"></i>
|
||||||
|
Create Tasks
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="row ">
|
<div className="row ">
|
||||||
@ -132,11 +192,14 @@ const ProjectInfra = ( {data, onDataChange, eachSiteEngineer} ) =>
|
|||||||
<InfraTable
|
<InfraTable
|
||||||
buildings={projectInfra}
|
buildings={projectInfra}
|
||||||
projectId={projectId}
|
projectId={projectId}
|
||||||
// handleFloor={submitData}
|
serviceId={selectedService}
|
||||||
// signalRHandler ={signalRHandler}
|
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{!isLoading && projectInfra?.length == 0 && <div className="mt-5"><p>No Infra Avaiable</p></div>}
|
{!isLoading && projectInfra?.length == 0 && (
|
||||||
|
<div className="mt-5">
|
||||||
|
<p>No Infra Avaiable</p>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
285
src/components/Project/ProjectListView.jsx
Normal file
285
src/components/Project/ProjectListView.jsx
Normal file
@ -0,0 +1,285 @@
|
|||||||
|
import React, { useState } from "react";
|
||||||
|
import { MANAGE_PROJECT, PROJECT_STATUS } from "../../utils/constants";
|
||||||
|
import { useProjects } from "../../hooks/useProjects";
|
||||||
|
import { formatNumber, formatUTCToLocalTime } from "../../utils/dateUtils";
|
||||||
|
import ProgressBar from "../common/ProgressBar";
|
||||||
|
import {
|
||||||
|
getProjectStatusColor,
|
||||||
|
getProjectStatusName,
|
||||||
|
} from "../../utils/projectStatus";
|
||||||
|
import { useDispatch } from "react-redux";
|
||||||
|
import { setProjectId } from "../../slices/localVariablesSlice";
|
||||||
|
import { useNavigate } from "react-router-dom";
|
||||||
|
import { useHasUserPermission } from "../../hooks/useHasUserPermission";
|
||||||
|
import { useProjectContext } from "../../pages/project/ProjectPage";
|
||||||
|
import usePagination from "../../hooks/usePagination";
|
||||||
|
|
||||||
|
const ProjectListView = ({
|
||||||
|
currentItems,
|
||||||
|
selectedStatuses,
|
||||||
|
handleStatusChange,
|
||||||
|
setCurrentPage,
|
||||||
|
totalPages,
|
||||||
|
isLoading,
|
||||||
|
}) => {
|
||||||
|
const dispatch = useDispatch();
|
||||||
|
const navigate = useNavigate();
|
||||||
|
const { setMangeProject } = useProjectContext();
|
||||||
|
// const { data, isLoading, isError, error } = useProjects();
|
||||||
|
|
||||||
|
// check Permissions
|
||||||
|
const canManageProject = useHasUserPermission(MANAGE_PROJECT);
|
||||||
|
|
||||||
|
const projectColumns = [
|
||||||
|
{
|
||||||
|
key: "projectName",
|
||||||
|
label: "Project Name",
|
||||||
|
className: "text-start py-3",
|
||||||
|
getValue: (p) => (
|
||||||
|
<div
|
||||||
|
className="text-primary cursor-pointer fw-bold py-3"
|
||||||
|
onClick={() => {
|
||||||
|
dispatch(setProjectId(p.id));
|
||||||
|
navigate(`/projects/details`);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{p.shortName ? `${p.name} (${p.shortName})` : p.name}
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "contactPerson",
|
||||||
|
label: "Contact Person",
|
||||||
|
className: "text-start small",
|
||||||
|
getValue: (p) => `${p?.contactPerson ?? ""}`.trim() || "N/A",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "startDate",
|
||||||
|
label: "Start Date",
|
||||||
|
className: "text-center small",
|
||||||
|
getValue: (p) => formatUTCToLocalTime(p?.startDate) || "N/A",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "deadline",
|
||||||
|
label: "Deadline",
|
||||||
|
className: "text-center small",
|
||||||
|
getValue: (p) => formatUTCToLocalTime(p?.endDate) || "N/A",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "task",
|
||||||
|
label: "Task",
|
||||||
|
colSpan: 2,
|
||||||
|
className: "text-center small",
|
||||||
|
getValue: (p) => formatNumber(p?.plannedWork) || "0",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "progress",
|
||||||
|
label: "Progress",
|
||||||
|
className: "text-start small",
|
||||||
|
|
||||||
|
getValue: (p) => (
|
||||||
|
<ProgressBar
|
||||||
|
plannedWork={p.plannedWork}
|
||||||
|
completedWork={p.completedWork}
|
||||||
|
className="mb-0"
|
||||||
|
height="6px"
|
||||||
|
/>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "status",
|
||||||
|
label: "Status",
|
||||||
|
className: "text-center small",
|
||||||
|
isFilter: true,
|
||||||
|
customRender: (_, selectedStatuses, handleStatusChange) => (
|
||||||
|
<div className="dropdown">
|
||||||
|
<a
|
||||||
|
className="dropdown-toggle hide-arrow cursor-pointer"
|
||||||
|
data-bs-toggle="dropdown"
|
||||||
|
aria-expanded="false"
|
||||||
|
>
|
||||||
|
Status <i className="bx bx-filter bx-sm"></i>
|
||||||
|
</a>
|
||||||
|
<ul className="dropdown-menu p-2 text-capitalize">
|
||||||
|
{PROJECT_STATUS.map(({ id, label }) => (
|
||||||
|
<li key={id}>
|
||||||
|
<div className="form-check">
|
||||||
|
<input
|
||||||
|
className="form-check-input"
|
||||||
|
type="checkbox"
|
||||||
|
checked={selectedStatuses.includes(id)}
|
||||||
|
onChange={() => handleStatusChange(id)}
|
||||||
|
/>
|
||||||
|
<label className="form-check-label">{label}</label>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
getValue: (p) => (
|
||||||
|
<span className={`badge ${getProjectStatusColor(p.projectStatusId)}`}>
|
||||||
|
{getProjectStatusName(p.projectStatusId)}
|
||||||
|
</span>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
const handleViewActivities = (project) => {
|
||||||
|
dispatch(setProjectId(project));
|
||||||
|
navigate(`/activities/records?project=${project}`);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="card page-min-h py-4 px-6 shadow-sm">
|
||||||
|
|
||||||
|
<div
|
||||||
|
className="table-responsive text-nowrap page-min-h"
|
||||||
|
>
|
||||||
|
<table className="table table-hover align-middle m-0">
|
||||||
|
<thead className="border-bottom ">
|
||||||
|
<tr>
|
||||||
|
{projectColumns.map((col) => (
|
||||||
|
<th key={col.key} colSpan={col.colSpan} className={`${col.className} table_header_border`}>
|
||||||
|
{col.label}
|
||||||
|
</th>
|
||||||
|
))}
|
||||||
|
<th className="text-center py-3">Action</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{currentItems?.map((project) => (
|
||||||
|
<tr key={project.id}>
|
||||||
|
{projectColumns.map((col) => (
|
||||||
|
<td
|
||||||
|
key={col.key}
|
||||||
|
colSpan={col.colSpan}
|
||||||
|
className={`${col.className} py-5`}
|
||||||
|
style={{ paddingTop: "20px", paddingBottom: "20px" }}
|
||||||
|
>
|
||||||
|
{col.getValue
|
||||||
|
? col.getValue(project)
|
||||||
|
: project[col.key] || "N/A"}
|
||||||
|
</td>
|
||||||
|
))}
|
||||||
|
<td
|
||||||
|
className={`mx-2 ${
|
||||||
|
canManageProject ? "d-sm-table-cell" : "d-none"
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
<div className="dropdown z-2">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="btn btn-icon btn-text-secondary rounded-pill dropdown-toggle hide-arrow p-0"
|
||||||
|
data-bs-toggle="dropdown"
|
||||||
|
aria-expanded="false"
|
||||||
|
>
|
||||||
|
<i
|
||||||
|
className="bx bx-dots-vertical-rounded bx-sm text-muted"
|
||||||
|
data-bs-toggle="tooltip"
|
||||||
|
data-bs-offset="0,8"
|
||||||
|
data-bs-placement="top"
|
||||||
|
data-bs-custom-class="tooltip-dark"
|
||||||
|
title="More Action"
|
||||||
|
></i>
|
||||||
|
</button>
|
||||||
|
<ul className="dropdown-menu dropdown-menu-end">
|
||||||
|
<li>
|
||||||
|
<a
|
||||||
|
aria-label="click to View details"
|
||||||
|
className="dropdown-item cursor-pointer"
|
||||||
|
>
|
||||||
|
<i className="bx bx-detail me-2"></i>
|
||||||
|
<span className="align-left">View details</span>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<li>
|
||||||
|
<a
|
||||||
|
className="dropdown-item cursor-pointer"
|
||||||
|
onClick={() =>
|
||||||
|
setMangeProject({
|
||||||
|
isOpen: true,
|
||||||
|
Project: project.id,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<i className="bx bx-pencil me-2"></i>
|
||||||
|
<span className="align-left">Modify</span>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li onClick={() => handleViewActivities(project.id)}>
|
||||||
|
<a className="dropdown-item cursor-pointer">
|
||||||
|
<i className="bx bx-task me-2"></i>
|
||||||
|
<span className="align-left">Activities</span>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
))}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{isLoading && (
|
||||||
|
<div className="py-4">
|
||||||
|
{" "}
|
||||||
|
{isLoading && <p className="text-center">Loading...</p>}
|
||||||
|
{!isLoading && filteredProjects.length === 0 && (
|
||||||
|
<p className="text-center text-muted">No projects found.</p>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{!isLoading && currentItems.length === 0 && (
|
||||||
|
<div className="py-6">
|
||||||
|
<p className="text-center text-muted">No projects found.</p>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{!isLoading && totalPages > 1 && (
|
||||||
|
<nav>
|
||||||
|
<ul className="pagination pagination-sm justify-content-end py-2">
|
||||||
|
<li className={`page-item ${currentPage === 1 && "disabled"}`}>
|
||||||
|
<button
|
||||||
|
className="page-link"
|
||||||
|
onClick={() => setCurrentPage((p) => Math.max(1, p - 1))}
|
||||||
|
>
|
||||||
|
«
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
{[...Array(totalPages)].map((_, i) => (
|
||||||
|
<li
|
||||||
|
key={i}
|
||||||
|
className={`page-item ${currentPage === i + 1 && "active"}`}
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
className="page-link"
|
||||||
|
onClick={() => setCurrentPage(i + 1)}
|
||||||
|
>
|
||||||
|
{i + 1}
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
))}
|
||||||
|
<li
|
||||||
|
className={`page-item ${
|
||||||
|
currentPage === totalPages && "disabled"
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
className="page-link"
|
||||||
|
onClick={() =>
|
||||||
|
setCurrentPage((p) => Math.min(totalPages, p + 1))
|
||||||
|
}
|
||||||
|
>
|
||||||
|
»
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ProjectListView;
|
||||||
@ -1,36 +1,35 @@
|
|||||||
import React from 'react'
|
import React from "react";
|
||||||
import AssignRole from './AssignTask'
|
import AssignRole from "./AssignTask";
|
||||||
|
|
||||||
const ProjectModal = ({modalConfig,closeModal}) => {
|
|
||||||
|
|
||||||
|
const ProjectModal = ({ modalConfig, closeModal }) => {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className="modal fade"
|
className="modal fade"
|
||||||
id="project-modal"
|
id="project-modal"
|
||||||
tabindex="-1"
|
tabindex="-1"
|
||||||
aria-hidden="true"
|
aria-hidden="true"
|
||||||
role="dialog"
|
role="dialog"
|
||||||
>
|
>
|
||||||
<div className="modal-dialog modal-lg modal-simple">
|
<div className="modal-dialog modal-lg modal-simple">
|
||||||
<div className="modal-content">
|
<div className="modal-content">
|
||||||
<div className="modal-body">
|
<div className="modal-body">
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className="btn-close"
|
className="btn-close"
|
||||||
data-bs-dismiss="modal"
|
data-bs-dismiss="modal"
|
||||||
aria-label="Close"
|
aria-label="Close"
|
||||||
onClick={closeModal}
|
onClick={closeModal}
|
||||||
></button>
|
></button>
|
||||||
<div className="text-center mb-2"></div>
|
<div className="text-center mb-2"></div>
|
||||||
|
|
||||||
|
{modalConfig?.type === "assignRole" && (
|
||||||
|
<AssignRole assignData={modalConfig?.data} onClose={closeModal} />
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
{modalConfig?.type === "assignRole" && <AssignRole assignData={modalConfig?.data} onClose={closeModal} />}
|
export default ProjectModal;
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default ProjectModal
|
|
||||||
|
|||||||
@ -1,6 +1,4 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { hasUserPermission } from "../../utils/authUtils";
|
|
||||||
import { useHasUserPermission } from "../../hooks/useHasUserPermission";
|
|
||||||
import {
|
import {
|
||||||
DIRECTORY_ADMIN,
|
DIRECTORY_ADMIN,
|
||||||
DIRECTORY_MANAGER,
|
DIRECTORY_MANAGER,
|
||||||
@ -13,6 +11,7 @@ import {
|
|||||||
VIEW_DOCUMENT,
|
VIEW_DOCUMENT,
|
||||||
VIEW_PROJECT_INFRA,
|
VIEW_PROJECT_INFRA,
|
||||||
} from "../../utils/constants";
|
} from "../../utils/constants";
|
||||||
|
import { useHasUserPermission } from "../../hooks/useHasUserPermission";
|
||||||
|
|
||||||
const ProjectNav = ({ onPillClick, activePill }) => {
|
const ProjectNav = ({ onPillClick, activePill }) => {
|
||||||
const HasViewInfraStructure = useHasUserPermission(VIEW_PROJECT_INFRA);
|
const HasViewInfraStructure = useHasUserPermission(VIEW_PROJECT_INFRA);
|
||||||
@ -22,7 +21,7 @@ const ProjectNav = ({ onPillClick, activePill }) => {
|
|||||||
const DireManager = useHasUserPermission(DIRECTORY_MANAGER);
|
const DireManager = useHasUserPermission(DIRECTORY_MANAGER);
|
||||||
const DirUser = useHasUserPermission(DIRECTORY_USER);
|
const DirUser = useHasUserPermission(DIRECTORY_USER);
|
||||||
const isManageTeam = useHasUserPermission(MANAGE_TEAM)
|
const isManageTeam = useHasUserPermission(MANAGE_TEAM)
|
||||||
const isViewDocuments = hasUserPermission(VIEW_DOCUMENT);
|
const isViewDocuments = useHasUserPermission(VIEW_DOCUMENT);
|
||||||
const isUploadDocument = useHasUserPermission(UPLOAD_DOCUMENT)
|
const isUploadDocument = useHasUserPermission(UPLOAD_DOCUMENT)
|
||||||
const isModifyDocument = useHasUserPermission(MODIFY_DOCUMENT)
|
const isModifyDocument = useHasUserPermission(MODIFY_DOCUMENT)
|
||||||
|
|
||||||
@ -42,8 +41,8 @@ const ProjectNav = ({ onPillClick, activePill }) => {
|
|||||||
hidden: !(DirAdmin || DireManager || DirUser),
|
hidden: !(DirAdmin || DireManager || DirUser),
|
||||||
},
|
},
|
||||||
{ key: "documents", icon: "bx bx-folder-open", label: "Documents",hidden:!(isViewDocuments || isModifyDocument || isUploadDocument) },
|
{ key: "documents", icon: "bx bx-folder-open", label: "Documents",hidden:!(isViewDocuments || isModifyDocument || isUploadDocument) },
|
||||||
|
{ key: "organization", icon: "bx bx-buildings", label: "Organization"},
|
||||||
{ key: "setting", icon: "bx bxs-cog", label: "Setting",hidden:!isManageTeam },
|
{ key: "setting", icon: "bx bxs-cog", label: "Setting",hidden:!isManageTeam },
|
||||||
{ key: "organization", icon: "bx bx-buildings", label: "Organization"},
|
|
||||||
];
|
];
|
||||||
return (
|
return (
|
||||||
<div className="nav-align-top">
|
<div className="nav-align-top">
|
||||||
|
|||||||
@ -0,0 +1,125 @@
|
|||||||
|
import React from "react";
|
||||||
|
import { useProjectAssignedOrganizations } from "../../../hooks/useProjects";
|
||||||
|
import { useSelectedProject } from "../../../slices/apiDataManager";
|
||||||
|
import { formatUTCToLocalTime } from "../../../utils/dateUtils";
|
||||||
|
|
||||||
|
const ProjectAssignedOrgs = () => {
|
||||||
|
const selectedProject = useSelectedProject();
|
||||||
|
const { data, isLoading, isError, error } =
|
||||||
|
useProjectAssignedOrganizations(selectedProject);
|
||||||
|
|
||||||
|
const orgList = [
|
||||||
|
{
|
||||||
|
key: "name",
|
||||||
|
label: "Organization Name",
|
||||||
|
getValue: (org) => (
|
||||||
|
<div className="d-flex gap-2 py-1 ">
|
||||||
|
<i class="bx bx-buildings"></i>
|
||||||
|
<span
|
||||||
|
className="text-truncate d-inline-block "
|
||||||
|
style={{ maxWidth: "150px" }}
|
||||||
|
>
|
||||||
|
{org?.name || "N/A"}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
align: "text-start",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "service",
|
||||||
|
label: "Service Name",
|
||||||
|
getValue: (org) => (
|
||||||
|
<div className="d-flex gap-2 py-1 ">
|
||||||
|
{org?.service?.name}
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
align: "text-start",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "sprid",
|
||||||
|
label: "Service Provider Id",
|
||||||
|
getValue: (org) => (
|
||||||
|
<span
|
||||||
|
className="text-truncate d-inline-block"
|
||||||
|
style={{ maxWidth: "200px" }}
|
||||||
|
>
|
||||||
|
{org?.sprid || "N/A"}
|
||||||
|
</span>
|
||||||
|
),
|
||||||
|
align: "text-center",
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
key: "organizationType",
|
||||||
|
label: "Organization Type",
|
||||||
|
getValue: (org) => (
|
||||||
|
<span
|
||||||
|
className="text-truncate d-inline-block"
|
||||||
|
style={{ maxWidth: "200px" }}
|
||||||
|
>
|
||||||
|
{org?.organizationType || "N/A"}
|
||||||
|
</span>
|
||||||
|
),
|
||||||
|
align: "text-center",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "assignedDate",
|
||||||
|
label: "Assigned Date",
|
||||||
|
getValue: (org) => (
|
||||||
|
<span
|
||||||
|
className="text-truncate d-inline-block"
|
||||||
|
style={{ maxWidth: "200px" }}
|
||||||
|
>
|
||||||
|
{/* {org?.assignedDate || "N/A"} */}
|
||||||
|
{formatUTCToLocalTime(org?.assignedDate)}
|
||||||
|
</span>
|
||||||
|
),
|
||||||
|
align: "text-center",
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
if (isLoading) return <div>Loading...</div>;
|
||||||
|
if (isError) return <div>{error.message}</div>;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<div className="dataTables_wrapper no-footer mx-5 pb-2 page">
|
||||||
|
<table className="table dataTable text-nowrap">
|
||||||
|
<thead>
|
||||||
|
<tr className="table_header_border">
|
||||||
|
{orgList.map((col) => (
|
||||||
|
<th key={col.key} className={col.align}>
|
||||||
|
{col.label}
|
||||||
|
</th>
|
||||||
|
))}
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{Array.isArray(data) && data.length > 0 ? (
|
||||||
|
data.map((row, i) => (
|
||||||
|
<tr key={i}>
|
||||||
|
{orgList.map((col) => (
|
||||||
|
<td key={col.key} className={col.align}>
|
||||||
|
{col.getValue(row)}
|
||||||
|
</td>
|
||||||
|
))}
|
||||||
|
</tr>
|
||||||
|
))
|
||||||
|
) : (
|
||||||
|
<tr style={{ height: "200px" }}>
|
||||||
|
<td
|
||||||
|
colSpan={orgList.length}
|
||||||
|
className="text-center align-middle"
|
||||||
|
>
|
||||||
|
Not Assigned yet
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
)}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ProjectAssignedOrgs;
|
||||||
@ -0,0 +1,11 @@
|
|||||||
|
import React from 'react'
|
||||||
|
|
||||||
|
const ProjectServices = () => {
|
||||||
|
return (
|
||||||
|
<div className='row'>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default ProjectServices
|
||||||
@ -1,29 +1,28 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { useOrganizationModal } from "../../hooks/useOrganization";
|
import { useOrganizationModal } from "../../hooks/useOrganization";
|
||||||
import { useSelectedProject } from "../../slices/apiDataManager";
|
import { useSelectedProject } from "../../slices/apiDataManager";
|
||||||
|
import ProjectAssignedOrgs from "./ProjectOrganization/ProjectAssignedOrgs";
|
||||||
|
|
||||||
const ProjectOrganizations = () => {
|
const ProjectOrganizations = () => {
|
||||||
const orgModal = useOrganizationModal();
|
const { onOpen, startStep, flowType } = useOrganizationModal();
|
||||||
const selectedProject = useSelectedProject()
|
const selectedProject = useSelectedProject();
|
||||||
return (
|
return (
|
||||||
<div className="card">
|
<div className="card pb-10" >
|
||||||
<div className="card-header">
|
<div className="card-header">
|
||||||
<div className="d-flex justify-content-end px-2">
|
<div className="d-flex justify-content-end px-2">
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className="link-button btn btn-xs rounded-md link-button-sm m-1 btn-primary"
|
className="link-button btn btn-sm rounded-md link-button-sm m-1 btn-primary"
|
||||||
onClick={() => orgModal.onOpen(selectedProject)}
|
onClick={() => onOpen({ startStep: 1, flowType: "assign" })}
|
||||||
>
|
>
|
||||||
<i className="bx bx-plus-circle me-2"></i>
|
<i className="bx bx-plus-circle me-2"></i>
|
||||||
Add Organization
|
Add Organization
|
||||||
</button>
|
</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="card-body">
|
<div className="row">
|
||||||
<p className="text-secondary">
|
<ProjectAssignedOrgs />
|
||||||
Not found Organization connected with current Project
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -10,9 +10,9 @@ import ReactApexChart from "react-apexcharts";
|
|||||||
import Chart from "react-apexcharts";
|
import Chart from "react-apexcharts";
|
||||||
|
|
||||||
const ProjectOverview = ({ project }) => {
|
const ProjectOverview = ({ project }) => {
|
||||||
const { projects } = useProjects();
|
const { data } = useProjects();
|
||||||
const [current_project, setCurrentProject] = useState(
|
const [current_project, setCurrentProject] = useState(
|
||||||
projects.find((pro) => pro.id == project)
|
data?.find((pro) => pro.id == project)
|
||||||
);
|
);
|
||||||
|
|
||||||
const selectedProject = useSelector(
|
const selectedProject = useSelector(
|
||||||
@ -154,7 +154,7 @@ const ProjectOverview = ({ project }) => {
|
|||||||
}, [current_project]);
|
}, [current_project]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setCurrentProject(projects.find((pro) => pro.id == selectedProject));
|
setCurrentProject(data?.find((pro) => pro.id == selectedProject));
|
||||||
if (current_project) {
|
if (current_project) {
|
||||||
let val = getProgressInPercentage(
|
let val = getProgressInPercentage(
|
||||||
current_project.plannedWork,
|
current_project.plannedWork,
|
||||||
|
|||||||
59
src/components/Project/ProjectSchema.jsx
Normal file
59
src/components/Project/ProjectSchema.jsx
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
import { z } from "zod";
|
||||||
|
import { DEFAULT_EMPTY_STATUS_ID } from "../../utils/constants";
|
||||||
|
const currentDate = new Date()
|
||||||
|
|
||||||
|
|
||||||
|
export const projectDefault = {
|
||||||
|
name: "",
|
||||||
|
shortName: "",
|
||||||
|
contactPerson: "",
|
||||||
|
projectAddress: "",
|
||||||
|
startDate: currentDate.toISOString().split("T")[0],
|
||||||
|
endDate: currentDate.toISOString().split("T")[0],
|
||||||
|
projectStatusId: DEFAULT_EMPTY_STATUS_ID,
|
||||||
|
promoterId: "",
|
||||||
|
pmcId: "",
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
export const projectSchema = z
|
||||||
|
.object({
|
||||||
|
name: z.string().min(1, { message: "Project Name is required" }),
|
||||||
|
shortName: z.string().optional(),
|
||||||
|
contactPerson: z
|
||||||
|
.string()
|
||||||
|
.min(1, { message: "Contact Person Name is required" })
|
||||||
|
.regex(/^[A-Za-z\s]+$/, {
|
||||||
|
message: "Contact Person must contain only letters",
|
||||||
|
}),
|
||||||
|
projectAddress: z
|
||||||
|
.string()
|
||||||
|
.min(1, { message: "Address is required" })
|
||||||
|
.max(500, "Address must not exceed 150 characters"),
|
||||||
|
startDate: z
|
||||||
|
.string()
|
||||||
|
.min(1, { message: "Start Date is required" })
|
||||||
|
.default(projectDefault),
|
||||||
|
endDate: z
|
||||||
|
.string()
|
||||||
|
.min(1, { message: "End Date is required" })
|
||||||
|
.default(projectDefault),
|
||||||
|
projectStatusId: z.string().min(1, { message: "Status is required" }),
|
||||||
|
promoterId: z.string().min(1, { message: "Promoter is required" }),
|
||||||
|
pmcId: z.string().min(1, { message: "PMC is required" }),
|
||||||
|
})
|
||||||
|
.refine(
|
||||||
|
(data) => {
|
||||||
|
const start = new Date(data.startDate);
|
||||||
|
const end = new Date(data.endDate);
|
||||||
|
return end >= start;
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: ["endDate"],
|
||||||
|
message: "End Date must be greater than Start Date",
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
80
src/components/Project/Team/TeamAssignToProject.jsx
Normal file
80
src/components/Project/Team/TeamAssignToProject.jsx
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
import React, { useState } from "react";
|
||||||
|
import TeamEmployeeList from "./TeamEmployeeList";
|
||||||
|
import { useOrganization } from "../../../hooks/useDirectory";
|
||||||
|
import { useOrganizationsList } from "../../../hooks/useOrganization";
|
||||||
|
import { useProjectAssignedOrganizationsName } from "../../../hooks/useProjects";
|
||||||
|
import { useSelectedProject } from "../../../slices/apiDataManager";
|
||||||
|
|
||||||
|
const TeamAssignToProject = ({ closeModal }) => {
|
||||||
|
const [searchText, setSearchText] = useState("");
|
||||||
|
const [selectedOrg, setSelectedOrg] = useState(null);
|
||||||
|
const project = useSelectedProject();
|
||||||
|
const { data, isLoading, isError, error } =
|
||||||
|
useProjectAssignedOrganizationsName(project);
|
||||||
|
return (
|
||||||
|
<div className="container">
|
||||||
|
<p className="fs-5 fs-seminbod ">Assign Employee To Project </p>
|
||||||
|
|
||||||
|
<div className="row align-items-center gx-5">
|
||||||
|
<div className="col">
|
||||||
|
<div className="d-flex flex-grow-1 align-items-center gap-2">
|
||||||
|
{isLoading ? (
|
||||||
|
<select className="form-select form-select-sm w-100" disabled>
|
||||||
|
<option value="">Loading...</option>
|
||||||
|
</select>
|
||||||
|
) : data?.length === 0 ? (
|
||||||
|
<p className="mb-0 badge bg-label-secondary">No organizations found</p>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<label
|
||||||
|
htmlFor="organization"
|
||||||
|
className="form-label mb-0 text-nowrap"
|
||||||
|
>
|
||||||
|
Select Organization
|
||||||
|
</label>
|
||||||
|
<select
|
||||||
|
id="organization"
|
||||||
|
className="form-select form-select-sm w-100"
|
||||||
|
value={selectedOrg || ""}
|
||||||
|
onChange={(e) => setSelectedOrg(e.target.value)}
|
||||||
|
>
|
||||||
|
<option value="">Select</option>
|
||||||
|
{data.map((org) => (
|
||||||
|
<option key={org.id} value={org.id}>
|
||||||
|
{org.name}
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
|
</select>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="col">
|
||||||
|
<div className="d-flex flex-grow-1 align-items-center gap-2">
|
||||||
|
<label htmlFor="search" className="form-label mb-0 text-nowrap">
|
||||||
|
Search Employee
|
||||||
|
</label>
|
||||||
|
<input
|
||||||
|
id="search"
|
||||||
|
type="search"
|
||||||
|
className="form-control form-control-sm w-100"
|
||||||
|
placeholder="Search..."
|
||||||
|
value={searchText}
|
||||||
|
onChange={(e) => setSearchText(e.target.value)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div >
|
||||||
|
<TeamEmployeeList
|
||||||
|
organizationId={selectedOrg}
|
||||||
|
searchTerm={searchText}
|
||||||
|
closeModal={closeModal}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default TeamAssignToProject;
|
||||||
251
src/components/Project/Team/TeamEmployeeList.jsx
Normal file
251
src/components/Project/Team/TeamEmployeeList.jsx
Normal file
@ -0,0 +1,251 @@
|
|||||||
|
import React, { useState, useEffect } from "react";
|
||||||
|
import Avatar from "../../common/Avatar";
|
||||||
|
import { useDebounce } from "../../../utils/appUtils";
|
||||||
|
import { useSelectedProject } from "../../../slices/apiDataManager";
|
||||||
|
import {
|
||||||
|
useEmployeesByProjectAllocated,
|
||||||
|
useManageProjectAllocation,
|
||||||
|
useProjectAssignedServices,
|
||||||
|
} from "../../../hooks/useProjects";
|
||||||
|
import useMaster, { useServices } from "../../../hooks/masterHook/useMaster";
|
||||||
|
import showToast from "../../../services/toastService";
|
||||||
|
import { useOrganizationEmployees } from "../../../hooks/useOrganization";
|
||||||
|
|
||||||
|
const TeamEmployeeList = ({ organizationId, searchTerm, closeModal }) => {
|
||||||
|
const selectedProject = useSelectedProject();
|
||||||
|
const debounceSearchTerm = useDebounce(searchTerm, 500);
|
||||||
|
|
||||||
|
const {
|
||||||
|
data: employeesData = [],
|
||||||
|
isLoading,
|
||||||
|
isError,
|
||||||
|
error,
|
||||||
|
} = useOrganizationEmployees(
|
||||||
|
selectedProject,
|
||||||
|
organizationId,
|
||||||
|
debounceSearchTerm
|
||||||
|
);
|
||||||
|
|
||||||
|
const { projectEmployees, loading: employeeLodaing } =
|
||||||
|
useEmployeesByProjectAllocated(selectedProject, null);
|
||||||
|
|
||||||
|
const { data: jobRoles } = useMaster();
|
||||||
|
const { data: services } = useProjectAssignedServices(selectedProject);
|
||||||
|
|
||||||
|
const [employees, setEmployees] = useState([]);
|
||||||
|
|
||||||
|
const { mutate: handleAssignEmployee, isPending } =
|
||||||
|
useManageProjectAllocation({
|
||||||
|
onSuccessCallback: () => {
|
||||||
|
closeModal();
|
||||||
|
},
|
||||||
|
onErrorCallback: () => {
|
||||||
|
closeModal();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (employeesData?.data?.length > 0) {
|
||||||
|
const available = employeesData.data.filter((emp) => {
|
||||||
|
const projEmp = projectEmployees.find((pe) => pe.employeeId === emp.id);
|
||||||
|
return !projEmp || projEmp.isActive === false;
|
||||||
|
});
|
||||||
|
|
||||||
|
setEmployees(
|
||||||
|
available.map((emp) => ({
|
||||||
|
...emp,
|
||||||
|
isChecked: false,
|
||||||
|
jobRole: emp?.jobRoleId || null,
|
||||||
|
serviceId: "",
|
||||||
|
errors: {},
|
||||||
|
}))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}, [employeesData, projectEmployees, organizationId]);
|
||||||
|
|
||||||
|
const handleCheckboxChange = (index) => {
|
||||||
|
setEmployees((prev) => {
|
||||||
|
const newArr = [...prev];
|
||||||
|
newArr[index].isChecked = !newArr[index].isChecked;
|
||||||
|
newArr[index].errors = {};
|
||||||
|
return newArr;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleSelectChange = (index, field, value) => {
|
||||||
|
setEmployees((prev) => {
|
||||||
|
const newArr = [...prev];
|
||||||
|
newArr[index][field] = value;
|
||||||
|
newArr[index].errors[field] = "";
|
||||||
|
return newArr;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const onSubmit = () => {
|
||||||
|
const checkedEmployees = employees.filter((emp) => emp.isChecked);
|
||||||
|
|
||||||
|
setEmployees((prev) => prev.map((emp) => ({ ...emp, errors: {} })));
|
||||||
|
|
||||||
|
if (checkedEmployees.length === 0) {
|
||||||
|
showToast("Select at least one employee", "info");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let hasError = false;
|
||||||
|
const newEmployees = employees.map((emp) => {
|
||||||
|
const empErrors = {};
|
||||||
|
if (emp.isChecked) {
|
||||||
|
if (!emp.jobRole) {
|
||||||
|
empErrors.jobRole = "Job role is required";
|
||||||
|
hasError = true;
|
||||||
|
}
|
||||||
|
if (!emp.serviceId) {
|
||||||
|
empErrors.serviceId = "Service is required";
|
||||||
|
hasError = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return { ...emp, errors: empErrors };
|
||||||
|
});
|
||||||
|
|
||||||
|
setEmployees(newEmployees);
|
||||||
|
|
||||||
|
if (hasError) return; // stop submit if validation fails
|
||||||
|
|
||||||
|
const payload = checkedEmployees.map((emp) => ({
|
||||||
|
employeeId: emp.id,
|
||||||
|
jobRoleId: emp.jobRole,
|
||||||
|
serviceId: emp.serviceId,
|
||||||
|
projectId: selectedProject,
|
||||||
|
status: true,
|
||||||
|
}));
|
||||||
|
|
||||||
|
handleAssignEmployee({ payload,actionType:"assign"} );
|
||||||
|
|
||||||
|
setEmployees((prev) =>
|
||||||
|
prev.map((emp) => ({
|
||||||
|
...emp,
|
||||||
|
isChecked: false,
|
||||||
|
jobRole: "",
|
||||||
|
serviceId: "",
|
||||||
|
errors: {},
|
||||||
|
}))
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
if (isLoading) {
|
||||||
|
return ( <div className="page-min-h d-flex justify-content-center align-items-center "><p className="text-muted">Loading employees...</p></div>) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isError) {
|
||||||
|
return (
|
||||||
|
<div className="page-min-h d-flex justify-content-center align-items-center ">
|
||||||
|
{error?.status === 400 ? (
|
||||||
|
<p className="m-0">Enter employee you want to find.</p>
|
||||||
|
) : (
|
||||||
|
<p className="m-0 dange-text">Something went wrong. Please try again later.</p>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (employees.length === 0) {
|
||||||
|
return(<div className="page-min-h d-flex justify-content-center align-items-center "><p className="text-muted">No available employees to assign.</p></div>) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className=" position-relative">
|
||||||
|
<table className="table" style={{ maxHeight: "80px", overflowY: "auto" }}>
|
||||||
|
<thead className=" position-sticky top-0">
|
||||||
|
<tr>
|
||||||
|
<th>Employee</th>
|
||||||
|
<th>Service</th>
|
||||||
|
<th>Job Role</th>
|
||||||
|
<th>Select</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{employees.map((emp, index) => (
|
||||||
|
<tr key={emp.id}>
|
||||||
|
<td>
|
||||||
|
<div className="d-flex align-items-center">
|
||||||
|
<Avatar firstName={emp.firstName} lastName={emp.lastName} />
|
||||||
|
<span className="ms-2 fw-semibold">
|
||||||
|
{emp.firstName} {emp.lastName}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<select
|
||||||
|
value={emp.serviceId}
|
||||||
|
disabled={!emp.isChecked}
|
||||||
|
onChange={(e) =>
|
||||||
|
handleSelectChange(index, "serviceId", e.target.value)
|
||||||
|
}
|
||||||
|
className={`form-select form-select-sm w-auto border-none rounded-0 py-1 px-auto ${
|
||||||
|
emp.errors.serviceId ? "is-invalid" : ""
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
<option value="">Select Service</option>
|
||||||
|
{services?.map((s) => (
|
||||||
|
<option key={s.id} value={s.id}>
|
||||||
|
{s.name}
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
|
</select>
|
||||||
|
{emp.errors.serviceId && (
|
||||||
|
<div className="danger-text">{emp.errors.serviceId}</div>
|
||||||
|
)}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<select
|
||||||
|
value={emp.jobRole}
|
||||||
|
disabled={!emp.isChecked}
|
||||||
|
onChange={(e) =>
|
||||||
|
handleSelectChange(index, "jobRole", e.target.value)
|
||||||
|
}
|
||||||
|
className={`form-select form-select-sm w-auto border-none rounded-0 py-1 px-auto ${
|
||||||
|
emp.errors.jobRole ? "is-invalid" : ""
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
<option value="">Select Job Role</option>
|
||||||
|
{jobRoles?.map((r) => (
|
||||||
|
<option key={r.id} value={r.id}>
|
||||||
|
{r.name}
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
|
</select>
|
||||||
|
{emp.errors.jobRole && (
|
||||||
|
<div className="danger-text">{emp.errors.jobRole}</div>
|
||||||
|
)}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
className="form-check-input"
|
||||||
|
checked={emp.isChecked}
|
||||||
|
onChange={() => handleCheckboxChange(index)}
|
||||||
|
/>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
))}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<div className="position-sticky bottom-0 bg-white d-flex justify-content-end gap-3 z-25 ">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="btn btn-sm btn-label-secondary"
|
||||||
|
onClick={() => closeModal()}
|
||||||
|
>
|
||||||
|
Cancel
|
||||||
|
</button>
|
||||||
|
<button onClick={onSubmit} className="btn btn-primary">
|
||||||
|
{isPending ? "Please Wait..." : "Assign to Project"}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default TeamEmployeeList;
|
||||||
339
src/components/Project/Team/Teams.jsx
Normal file
339
src/components/Project/Team/Teams.jsx
Normal file
@ -0,0 +1,339 @@
|
|||||||
|
import React, { useState, useEffect, useCallback, useMemo } from "react";
|
||||||
|
import { Link, NavLink, useNavigate, useParams } from "react-router-dom";
|
||||||
|
|
||||||
|
import showToast from "../../../services/toastService";
|
||||||
|
import Avatar from "../../common/Avatar";
|
||||||
|
import moment from "moment";
|
||||||
|
|
||||||
|
import ProjectRepository from "../../../repositories/ProjectRepository";
|
||||||
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
|
import { changeMaster } from "../../../slices/localVariablesSlice";
|
||||||
|
import useMaster from "../../../hooks/masterHook/useMaster";
|
||||||
|
import { useHasUserPermission } from "../../../hooks/useHasUserPermission";
|
||||||
|
import { ASSIGN_TO_PROJECT } from "../../../utils/constants";
|
||||||
|
import ConfirmModal from "../../common/ConfirmModal";
|
||||||
|
import eventBus from "../../../services/eventBus";
|
||||||
|
import {
|
||||||
|
useEmployeesByProjectAllocated,
|
||||||
|
useManageProjectAllocation,
|
||||||
|
useProjectAssignedServices,
|
||||||
|
} from "../../../hooks/useProjects";
|
||||||
|
import { useSelectedProject } from "../../../slices/apiDataManager";
|
||||||
|
import GlobalModel from "../../common/GlobalModel";
|
||||||
|
import TeamAssignToProject from "./TeamAssignToProject";
|
||||||
|
|
||||||
|
const Teams = () => {
|
||||||
|
const selectedProject = useSelectedProject();
|
||||||
|
const dispatch = useDispatch();
|
||||||
|
const [AssigTeam, setAssignTeam] = useState(false);
|
||||||
|
const [employees, setEmployees] = useState([]);
|
||||||
|
const [selectedEmployee, setSelectedEmployee] = useState(null);
|
||||||
|
const [deleteEmployee, setDeleteEmplyee] = useState(null);
|
||||||
|
const [searchTerm, setSearchTerm] = useState(""); // State for search term
|
||||||
|
const [selectedService, setSelectedService] = useState(null);
|
||||||
|
const [activeEmployee, setActiveEmployee] = useState(false);
|
||||||
|
|
||||||
|
const { data: assignedServices, isLoading: servicesLoading } =
|
||||||
|
useProjectAssignedServices(selectedProject);
|
||||||
|
const { data: empJobRoles, loading } = useMaster();
|
||||||
|
const handleToggleActive = (e) => setActiveEmployee(e.target.checked);
|
||||||
|
|
||||||
|
const handleServiceChange = (e) => {
|
||||||
|
setSelectedService(e.target.value);
|
||||||
|
};
|
||||||
|
|
||||||
|
const navigate = useNavigate();
|
||||||
|
|
||||||
|
const HasAssignUserPermission = useHasUserPermission(ASSIGN_TO_PROJECT);
|
||||||
|
const [IsDeleteModal, setIsDeleteModal] = useState(false);
|
||||||
|
const {
|
||||||
|
projectEmployees,
|
||||||
|
loading: employeeLodaing,
|
||||||
|
refetch,
|
||||||
|
} = useEmployeesByProjectAllocated(
|
||||||
|
selectedProject,
|
||||||
|
selectedService,
|
||||||
|
null,
|
||||||
|
activeEmployee
|
||||||
|
);
|
||||||
|
const {
|
||||||
|
mutate: submitAllocations,
|
||||||
|
isPending,
|
||||||
|
isSuccess,
|
||||||
|
isError,
|
||||||
|
} = useManageProjectAllocation({
|
||||||
|
onSuccessCallback: () => {
|
||||||
|
setSelectedEmployee(null);
|
||||||
|
},
|
||||||
|
onErrorCallback: () => {
|
||||||
|
setSelectedEmployee(null);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const handleDelete = (employee) => {
|
||||||
|
let payload = [
|
||||||
|
{
|
||||||
|
employeeId: employee?.employeeId,
|
||||||
|
jobRoleId: employee?.jobRoleId,
|
||||||
|
projectId: selectedProject,
|
||||||
|
serviceId: employee?.serviceId,
|
||||||
|
status: false,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
submitAllocations({ payload: payload, actionType: "remove" });
|
||||||
|
};
|
||||||
|
const getJobRole = (jobRoleId) => {
|
||||||
|
if (loading) return "Loading...";
|
||||||
|
if (!Array.isArray(empJobRoles)) return "Unassigned";
|
||||||
|
if (!jobRoleId) return "Unassigned";
|
||||||
|
|
||||||
|
const role = empJobRoles.find((b) => b.id == jobRoleId);
|
||||||
|
return role ? role.name : "Unassigned";
|
||||||
|
};
|
||||||
|
|
||||||
|
const filteredEmployees = useMemo(() => {
|
||||||
|
if (!projectEmployees) return [];
|
||||||
|
|
||||||
|
let filtered = projectEmployees;
|
||||||
|
|
||||||
|
if (activeEmployee) {
|
||||||
|
filtered = projectEmployees.filter((emp) => !emp.isActive);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply search filter if present
|
||||||
|
if (searchTerm?.trim()) {
|
||||||
|
const lower = searchTerm.toLowerCase();
|
||||||
|
filtered = filtered.filter((emp) => {
|
||||||
|
const fullName = `${emp.firstName ?? ""} ${emp.lastName ?? ""}`.toLowerCase();
|
||||||
|
const jobRole = getJobRole(emp?.jobRoleId)?.toLowerCase();
|
||||||
|
return fullName.includes(lower) || jobRole.includes(lower);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return filtered;
|
||||||
|
}, [projectEmployees, searchTerm, activeEmployee]);
|
||||||
|
const handleSearch = (e) => setSearchTerm(e.target.value);
|
||||||
|
const employeeHandler = useCallback(
|
||||||
|
(msg) => {
|
||||||
|
if (filteredEmployees.some((emp) => emp.employeeId == msg.employeeId)) {
|
||||||
|
refetch();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[filteredEmployees, refetch]
|
||||||
|
);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
eventBus.on("employee", employeeHandler);
|
||||||
|
return () => eventBus.off("employee", employeeHandler);
|
||||||
|
}, [employeeHandler]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{AssigTeam && (
|
||||||
|
<GlobalModel
|
||||||
|
size="lg"
|
||||||
|
isOpen={AssigTeam}
|
||||||
|
closeModal={() => setAssignTeam(false)}
|
||||||
|
>
|
||||||
|
<TeamAssignToProject closeModal={() => setAssignTeam(false)} />
|
||||||
|
</GlobalModel>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<ConfirmModal
|
||||||
|
type="delete"
|
||||||
|
header={"Remove Employee"}
|
||||||
|
message={"Are you sure you want to remove?"}
|
||||||
|
isOpen={!!selectedEmployee}
|
||||||
|
loading={isPending}
|
||||||
|
onSubmit={() => handleDelete(selectedEmployee)}
|
||||||
|
onClose={() => setSelectedEmployee(null)}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<div className="card card-action mb-6">
|
||||||
|
<div className="card-body">
|
||||||
|
<div className="row align-items-center justify-content-between mb-4 g-3">
|
||||||
|
<div className="col-md-6 col-12 algin-items-center">
|
||||||
|
<div className="d-flex flex-wrap align-items-center gap-3">
|
||||||
|
<div>
|
||||||
|
{!servicesLoading && (
|
||||||
|
<>
|
||||||
|
{(!assignedServices || assignedServices.length === 0) && (
|
||||||
|
<span className="badge bg-label-secondary">
|
||||||
|
Not Service Assigned
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{assignedServices?.length === 1 && (
|
||||||
|
<span className="badge bg-label-secondary">
|
||||||
|
{assignedServices[0].name}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{assignedServices?.length > 1 && (
|
||||||
|
<select
|
||||||
|
className="form-select form-select-sm"
|
||||||
|
aria-label="Select Service"
|
||||||
|
value={selectedService}
|
||||||
|
onChange={handleServiceChange}
|
||||||
|
>
|
||||||
|
<option value="">All Services</option>
|
||||||
|
{assignedServices.map((service) => (
|
||||||
|
<option key={service.id} value={service.id}>
|
||||||
|
{service.name}
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
|
</select>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="form-check form-switch d-flex align-items-center text-nowrap">
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
className="form-check-input"
|
||||||
|
id="activeEmployeeSwitch"
|
||||||
|
checked={activeEmployee}
|
||||||
|
onChange={handleToggleActive}
|
||||||
|
/>
|
||||||
|
<label
|
||||||
|
className="form-check-label ms-2"
|
||||||
|
htmlFor="activeEmployeeSwitch"
|
||||||
|
>
|
||||||
|
{activeEmployee ? "Active Employees" : "Include Inactive Employees"}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="col-md-6 col-12 d-flex justify-content-md-end align-items-center justify-content-start gap-3">
|
||||||
|
<input
|
||||||
|
type="search"
|
||||||
|
className="form-control form-control-sm"
|
||||||
|
placeholder="Search by Name or Role"
|
||||||
|
aria-controls="DataTables_Table_0"
|
||||||
|
style={{ maxWidth: "200px" }}
|
||||||
|
value={searchTerm}
|
||||||
|
onChange={handleSearch}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{HasAssignUserPermission && (
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="btn btn-primary btn-sm text-nowrap"
|
||||||
|
onClick={() => setAssignTeam(true)}
|
||||||
|
>
|
||||||
|
<i className="bx bx-plus-circle me-1"></i>
|
||||||
|
Assign Employee
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="table-responsive text-nowrap modal-min-h">
|
||||||
|
{employeeLodaing && <p>Loading..</p>}
|
||||||
|
{projectEmployees && projectEmployees.length > 0 && (
|
||||||
|
<table className="table ">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>
|
||||||
|
<div className="text-start ms-5">Name</div>
|
||||||
|
</th>
|
||||||
|
<th>Services</th>
|
||||||
|
<th>Organization</th>
|
||||||
|
<th>Assigned Date</th>
|
||||||
|
{activeEmployee && <th>Release Date</th>}
|
||||||
|
<th>Project Role</th>
|
||||||
|
<th>Actions</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody className="table-border-bottom-0">
|
||||||
|
{filteredEmployees &&
|
||||||
|
filteredEmployees
|
||||||
|
.sort((a, b) =>
|
||||||
|
(a.firstName || "").localeCompare(b.firstName || "")
|
||||||
|
)
|
||||||
|
.map((emp) => (
|
||||||
|
<tr key={emp.id}>
|
||||||
|
<td>
|
||||||
|
<div className="d-flex justify-content-start align-items-center">
|
||||||
|
<Avatar
|
||||||
|
firstName={emp.firstName}
|
||||||
|
lastName={emp.lastName}
|
||||||
|
/>
|
||||||
|
<div className="d-flex flex-column">
|
||||||
|
<a
|
||||||
|
onClick={() =>
|
||||||
|
navigate(
|
||||||
|
`/employee/${emp.employeeId}?for=attendance`
|
||||||
|
)
|
||||||
|
}
|
||||||
|
className="text-heading text-truncate cursor-pointer"
|
||||||
|
>
|
||||||
|
<span className="fw-normal">
|
||||||
|
{emp.firstName}{" "}
|
||||||
|
{emp.lastName}
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
|
||||||
|
<td>{emp.serviceName || "N/A"}</td>
|
||||||
|
<td>{emp.organizationName || "N/A"}</td>
|
||||||
|
|
||||||
|
<td>
|
||||||
|
{moment(emp.allocationDate).format("DD-MMM-YYYY")}
|
||||||
|
</td>
|
||||||
|
{activeEmployee && (
|
||||||
|
<td>
|
||||||
|
{emp.reAllocationDate
|
||||||
|
? moment(emp.reAllocationDate).format(
|
||||||
|
"DD-MMM-YYYY"
|
||||||
|
)
|
||||||
|
: "Present"}
|
||||||
|
</td>
|
||||||
|
)}
|
||||||
|
<td>
|
||||||
|
<span className="badge bg-label-primary me-1">
|
||||||
|
{getJobRole(emp.jobRoleId)}
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{emp.isActive ? (
|
||||||
|
<button
|
||||||
|
aria-label="Delete"
|
||||||
|
type="button"
|
||||||
|
title="Remove from project"
|
||||||
|
className="btn p-0 dropdown-toggle hide-arrow"
|
||||||
|
onClick={() => setSelectedEmployee(emp)}
|
||||||
|
>
|
||||||
|
<i className="bx bx-trash me-1 text-danger"></i>
|
||||||
|
</button>
|
||||||
|
) : (
|
||||||
|
<span>Not in project</span>
|
||||||
|
)}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
))}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
)}
|
||||||
|
{!employeeLodaing && filteredEmployees.length === 0 && (
|
||||||
|
<div className="text-center text-muted py-3 d-flex justify-content-center align-items-center py-12">
|
||||||
|
<p>
|
||||||
|
{activeEmployee
|
||||||
|
? "No active employees assigned to the project"
|
||||||
|
: "No inactive employees assigned to the project"}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Teams;
|
||||||
@ -1,420 +0,0 @@
|
|||||||
import React, { useState, useEffect, useCallback } from "react";
|
|
||||||
import MapUsers from "./MapUsers";
|
|
||||||
import { Link, NavLink, useNavigate, useParams } from "react-router-dom";
|
|
||||||
|
|
||||||
import showToast from "../../services/toastService";
|
|
||||||
import Avatar from "../common/Avatar";
|
|
||||||
import moment from "moment";
|
|
||||||
|
|
||||||
import ProjectRepository from "../../repositories/ProjectRepository";
|
|
||||||
import { useDispatch, useSelector } from "react-redux";
|
|
||||||
import { changeMaster } from "../../slices/localVariablesSlice";
|
|
||||||
import useMaster from "../../hooks/masterHook/useMaster";
|
|
||||||
import { useHasUserPermission } from "../../hooks/useHasUserPermission";
|
|
||||||
import { ASSIGN_TO_PROJECT } from "../../utils/constants";
|
|
||||||
import ConfirmModal from "../common/ConfirmModal";
|
|
||||||
import eventBus from "../../services/eventBus";
|
|
||||||
import {
|
|
||||||
useEmployeesByProjectAllocated,
|
|
||||||
useManageProjectAllocation,
|
|
||||||
} from "../../hooks/useProjects";
|
|
||||||
import { useSelectedProject } from "../../slices/apiDataManager";
|
|
||||||
|
|
||||||
const Teams = () => {
|
|
||||||
// const {projectId} = useParams()
|
|
||||||
// const projectId = useSelector((store)=>store.localVariables.projectId)
|
|
||||||
const projectId = useSelectedProject();
|
|
||||||
const dispatch = useDispatch();
|
|
||||||
|
|
||||||
const { data, loading } = useMaster();
|
|
||||||
const [isModalOpen, setIsModelOpen] = useState(false);
|
|
||||||
const [error, setError] = useState("");
|
|
||||||
const [empJobRoles, setEmpJobRoles] = useState(null);
|
|
||||||
const [employees, setEmployees] = useState([]);
|
|
||||||
const [filteredEmployees, setFilteredEmployees] = useState([]);
|
|
||||||
const [removingEmployeeId, setRemovingEmployeeId] = useState(null);
|
|
||||||
const [assignedLoading, setAssignedLoading] = useState(false);
|
|
||||||
const [activeEmployee, setActiveEmployee] = useState(true);
|
|
||||||
const [deleteEmployee, setDeleteEmplyee] = useState(null);
|
|
||||||
const [searchTerm, setSearchTerm] = useState(""); // State for search term
|
|
||||||
|
|
||||||
const navigate = useNavigate();
|
|
||||||
|
|
||||||
const HasAssignUserPermission = useHasUserPermission(ASSIGN_TO_PROJECT);
|
|
||||||
const [IsDeleteModal, setIsDeleteModal] = useState(false);
|
|
||||||
const {
|
|
||||||
projectEmployees,
|
|
||||||
loading: employeeLodaing,
|
|
||||||
refetch,
|
|
||||||
} = useEmployeesByProjectAllocated(projectId);
|
|
||||||
const {
|
|
||||||
mutate: submitAllocations,
|
|
||||||
isPending,
|
|
||||||
isSuccess,
|
|
||||||
isError,
|
|
||||||
} = useManageProjectAllocation({
|
|
||||||
onSuccessCallback: () => {
|
|
||||||
setRemovingEmployeeId(null);
|
|
||||||
setAssignedLoading(false);
|
|
||||||
setDeleteEmplyee(null);
|
|
||||||
closeDeleteModal();
|
|
||||||
},
|
|
||||||
onErrorCallback: () => {
|
|
||||||
closeDeleteModal();
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const removeAllocation = (item) => {
|
|
||||||
setRemovingEmployeeId(item.id);
|
|
||||||
|
|
||||||
submitAllocations({
|
|
||||||
items: [
|
|
||||||
{
|
|
||||||
empID: item.employeeId,
|
|
||||||
jobRoleId: item.jobRoleId,
|
|
||||||
projectId: projectId,
|
|
||||||
status: false,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
added: false,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleEmpAlicationFormSubmit = (allocaionObj) => {
|
|
||||||
let items = allocaionObj.map((item) => {
|
|
||||||
return {
|
|
||||||
empID: item.empID,
|
|
||||||
jobRoleId: item.jobRoleId,
|
|
||||||
projectId: projectId,
|
|
||||||
status: true,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
submitAllocations({ items, added: true });
|
|
||||||
|
|
||||||
setActiveEmployee(true);
|
|
||||||
setFilteredEmployees(employees.filter((emp) => emp.isActive));
|
|
||||||
|
|
||||||
const dropdown = document.querySelector(
|
|
||||||
'select[name="DataTables_Table_0_length"]'
|
|
||||||
);
|
|
||||||
if (dropdown) dropdown.value = "true";
|
|
||||||
};
|
|
||||||
|
|
||||||
const getRole = (jobRoleId) => {
|
|
||||||
if (loading) return "Loading...";
|
|
||||||
if (!Array.isArray(empJobRoles)) return "Unassigned";
|
|
||||||
if (!jobRoleId) return "Unassigned";
|
|
||||||
|
|
||||||
const role = empJobRoles.find((b) => b.id == jobRoleId);
|
|
||||||
return role ? role.name : "Unassigned";
|
|
||||||
};
|
|
||||||
const openModel = () => {
|
|
||||||
setIsModelOpen(true);
|
|
||||||
};
|
|
||||||
|
|
||||||
const onModelClose = () => {
|
|
||||||
setIsModelOpen(false);
|
|
||||||
const modalElement = document.getElementById("user-model");
|
|
||||||
if (modalElement) {
|
|
||||||
modalElement.classList.remove("show");
|
|
||||||
modalElement.style.display = "none";
|
|
||||||
document.body.classList.remove("modal-open");
|
|
||||||
document.querySelector(".modal-backdrop").remove();
|
|
||||||
}
|
|
||||||
const modalBackdropElement = document.querySelector(".modal-backdrop");
|
|
||||||
if (modalBackdropElement) {
|
|
||||||
modalBackdropElement.remove();
|
|
||||||
}
|
|
||||||
document.body.style.overflow = "auto";
|
|
||||||
};
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
dispatch(changeMaster("Job Role"));
|
|
||||||
}, [dispatch]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (projectEmployees) {
|
|
||||||
setEmployees(projectEmployees);
|
|
||||||
//setFilteredEmployees(projectEmployees?.filter((emp) => emp.isActive));
|
|
||||||
const filtered = projectEmployees.filter((emp) => emp.isActive);
|
|
||||||
setFilteredEmployees(filtered);
|
|
||||||
}
|
|
||||||
}, [projectEmployees, employeeLodaing]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (data) {
|
|
||||||
setEmpJobRoles(data);
|
|
||||||
}
|
|
||||||
}, [data]);
|
|
||||||
|
|
||||||
const filterAndSearchEmployees = useCallback(() => {
|
|
||||||
const statusFiltered = employees.filter((emp) =>
|
|
||||||
activeEmployee ? emp.isActive : !emp.isActive
|
|
||||||
);
|
|
||||||
|
|
||||||
if (searchTerm === "") {
|
|
||||||
setFilteredEmployees(statusFiltered);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const lowercasedSearchTerm = searchTerm.toLowerCase();
|
|
||||||
const searchedAndFiltered = statusFiltered.filter((item) => {
|
|
||||||
const fullName =
|
|
||||||
`${item.firstName} ${item.middleName} ${item.lastName}`.toLowerCase();
|
|
||||||
const roleName = getRole(item.jobRoleId).toLowerCase();
|
|
||||||
|
|
||||||
return (
|
|
||||||
fullName.includes(lowercasedSearchTerm) ||
|
|
||||||
roleName.includes(lowercasedSearchTerm)
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
setFilteredEmployees(searchedAndFiltered);
|
|
||||||
}, [employees, activeEmployee, searchTerm, getRole]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
filterAndSearchEmployees();
|
|
||||||
}, [employees, activeEmployee, searchTerm, filterAndSearchEmployees]);
|
|
||||||
|
|
||||||
const handleFilterEmployee = (e) => {
|
|
||||||
const filterValue = e.target.value;
|
|
||||||
// if (filterValue === "true") {
|
|
||||||
// setActiveEmployee(true);
|
|
||||||
// setFilteredEmployees(employees.filter((emp) => emp.isActive));
|
|
||||||
// } else {
|
|
||||||
// setFilteredEmployees(employees.filter((emp) => !emp.isActive));
|
|
||||||
// setActiveEmployee(false);
|
|
||||||
// }
|
|
||||||
setActiveEmployee(filterValue === "true");
|
|
||||||
setSearchTerm("");
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleSearch = (e) => {
|
|
||||||
setSearchTerm(e.target.value);
|
|
||||||
};
|
|
||||||
|
|
||||||
const deleteModalOpen = (item) => {
|
|
||||||
setDeleteEmplyee(item);
|
|
||||||
setIsDeleteModal(true);
|
|
||||||
};
|
|
||||||
const closeDeleteModal = () => setIsDeleteModal(false);
|
|
||||||
|
|
||||||
const handler = useCallback(
|
|
||||||
(msg) => {
|
|
||||||
if (msg.projectIds.some((item) => item === projectId)) {
|
|
||||||
refetch();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
[projectId, refetch]
|
|
||||||
);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
eventBus.on("assign_project_all", handler);
|
|
||||||
return () => eventBus.off("assign_project_all", handler);
|
|
||||||
}, [handler]);
|
|
||||||
|
|
||||||
const employeeHandler = useCallback(
|
|
||||||
(msg) => {
|
|
||||||
if (filteredEmployees.some((item) => item.employeeId == msg.employeeId)) {
|
|
||||||
refetch();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
[filteredEmployees, refetch]
|
|
||||||
);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
eventBus.on("employee", employeeHandler);
|
|
||||||
return () => eventBus.off("employee", employeeHandler);
|
|
||||||
}, [employeeHandler]);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<div
|
|
||||||
className="modal fade"
|
|
||||||
id="user-model"
|
|
||||||
tabIndex="-1"
|
|
||||||
aria-labelledby="userModalLabel"
|
|
||||||
aria-hidden="true"
|
|
||||||
>
|
|
||||||
<MapUsers
|
|
||||||
projectId={projectId}
|
|
||||||
onClose={onModelClose}
|
|
||||||
empJobRoles={empJobRoles}
|
|
||||||
onSubmit={handleEmpAlicationFormSubmit}
|
|
||||||
allocation={employees}
|
|
||||||
assignedLoading={assignedLoading}
|
|
||||||
setAssignedLoading={setAssignedLoading}
|
|
||||||
></MapUsers>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{IsDeleteModal && (
|
|
||||||
<ConfirmModal
|
|
||||||
isOpen={IsDeleteModal}
|
|
||||||
type="delete"
|
|
||||||
header="Removed Employee"
|
|
||||||
message="Are you sure you want delete?"
|
|
||||||
onSubmit={() => removeAllocation(deleteEmployee)}
|
|
||||||
onClose={closeDeleteModal}
|
|
||||||
loading={isPending}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<div className="card card-action mb-6">
|
|
||||||
<div className="card-body">
|
|
||||||
<div className="row d-flex justify-content-between mb-4">
|
|
||||||
<div className="col-md-6 col-12 d-flex align-items-center">
|
|
||||||
<div className="dataTables_filter d-inline-flex align-items-center ms-2">
|
|
||||||
<input
|
|
||||||
type="search"
|
|
||||||
className="form-control form-control-sm me-4"
|
|
||||||
placeholder="Search by Name or Role"
|
|
||||||
aria-controls="DataTables_Table_0"
|
|
||||||
value={searchTerm}
|
|
||||||
onChange={handleSearch}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="col-md-6 col-12 d-flex justify-content-end align-items-center">
|
|
||||||
<div
|
|
||||||
className="dataTables_length text-start py-2 px-2"
|
|
||||||
id="DataTables_Table_0_length"
|
|
||||||
>
|
|
||||||
<label>
|
|
||||||
<select
|
|
||||||
name="DataTables_Table_0_length"
|
|
||||||
aria-controls="DataTables_Table_0"
|
|
||||||
className="form-select form-select-sm"
|
|
||||||
onChange={handleFilterEmployee}
|
|
||||||
// value={false}
|
|
||||||
aria-label=""
|
|
||||||
defaultValue="true"
|
|
||||||
>
|
|
||||||
<option value="true">Active Employee</option>
|
|
||||||
<option value="false">In-Active Employee</option>
|
|
||||||
</select>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
className={`link-button btn-primary btn-sm ${
|
|
||||||
HasAssignUserPermission ? "" : "d-none"
|
|
||||||
}`}
|
|
||||||
data-bs-toggle="modal"
|
|
||||||
data-bs-target="#user-model"
|
|
||||||
>
|
|
||||||
<i className="bx bx-plus-circle me-2"></i>
|
|
||||||
Assign Employee
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="table-responsive text-nowrap">
|
|
||||||
{employeeLodaing && <p>Loading..</p>}
|
|
||||||
{!employeeLodaing &&
|
|
||||||
filteredEmployees &&
|
|
||||||
filteredEmployees.length > 0 && (
|
|
||||||
<table className="table ">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>
|
|
||||||
<div className="text-start ms-5">Name</div>
|
|
||||||
</th>
|
|
||||||
<th>Assigned Date</th>
|
|
||||||
{!activeEmployee && <th>Release Date</th>}
|
|
||||||
<th>Project Role</th>
|
|
||||||
<th>Actions</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody className="table-border-bottom-0">
|
|
||||||
{filteredEmployees &&
|
|
||||||
filteredEmployees.map((item) => (
|
|
||||||
<tr key={item.id}>
|
|
||||||
<td>
|
|
||||||
<div className="d-flex justify-content-start align-items-center">
|
|
||||||
<Avatar
|
|
||||||
firstName={item.firstName}
|
|
||||||
lastName={item.lastName}
|
|
||||||
></Avatar>
|
|
||||||
<div className="d-flex flex-column">
|
|
||||||
<a
|
|
||||||
onClick={() =>
|
|
||||||
navigate(
|
|
||||||
`/employee/${item.employeeId}?for=attendance`
|
|
||||||
)
|
|
||||||
}
|
|
||||||
className="text-heading text-truncate cursor-pointer"
|
|
||||||
>
|
|
||||||
<span className="fw-normal">
|
|
||||||
{item.firstName} {item.middleName}{" "}
|
|
||||||
{item.lastName}
|
|
||||||
</span>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
{" "}
|
|
||||||
{moment(item.allocationDate).format(
|
|
||||||
"DD-MMM-YYYY"
|
|
||||||
)}{" "}
|
|
||||||
</td>
|
|
||||||
{!activeEmployee && (
|
|
||||||
<td>
|
|
||||||
{item.reAllocationDate
|
|
||||||
? moment(item.reAllocationDate).format(
|
|
||||||
"DD-MMM-YYYY"
|
|
||||||
)
|
|
||||||
: "Present"}
|
|
||||||
</td>
|
|
||||||
)}
|
|
||||||
<td>
|
|
||||||
<span className="badge bg-label-primary me-1">
|
|
||||||
{getRole(item.jobRoleId)}
|
|
||||||
</span>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
{item.isActive && (
|
|
||||||
<button
|
|
||||||
aria-label="Delete"
|
|
||||||
type="button"
|
|
||||||
title="Remove from project"
|
|
||||||
className="btn p-0 dropdown-toggle hide-arrow"
|
|
||||||
onClick={() => deleteModalOpen(item)}
|
|
||||||
>
|
|
||||||
{" "}
|
|
||||||
{removingEmployeeId === item.id ? (
|
|
||||||
<div
|
|
||||||
className="spinner-border spinner-border-sm text-primary"
|
|
||||||
role="status"
|
|
||||||
>
|
|
||||||
<span className="visually-hidden">
|
|
||||||
Loading...
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
<i className="bx bx-trash me-1 text-danger"></i>
|
|
||||||
)}
|
|
||||||
</button>
|
|
||||||
)}
|
|
||||||
{!item.isActive && <span>Not in project</span>}
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
))}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
)}
|
|
||||||
{!employeeLodaing && filteredEmployees.length === 0 && (
|
|
||||||
<div className="text-center text-muted py-3">
|
|
||||||
{activeEmployee
|
|
||||||
? "No active employees assigned to the project"
|
|
||||||
: "No inactive employees assigned to the project"}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default Teams;
|
|
||||||
@ -72,15 +72,15 @@ const EditProfile = ({ TenantId, onClose }) => {
|
|||||||
return (
|
return (
|
||||||
<FormProvider {...methods}>
|
<FormProvider {...methods}>
|
||||||
<form className="row g-6" onSubmit={handleSubmit(onSubmit)}>
|
<form className="row g-6" onSubmit={handleSubmit(onSubmit)}>
|
||||||
<h6>Edit Tenant</h6>
|
<h5>Edit Tenant</h5>
|
||||||
|
|
||||||
<div className="col-sm-6 mt-1">
|
<div className="col-sm-6 mt-1 text-start">
|
||||||
<Label htmlFor="firstName" required>First Name</Label>
|
<Label htmlFor="firstName" required>First Name</Label>
|
||||||
<input id="firstName" type="text" className="form-control form-control-sm" {...register("firstName")} inputMode='text' />
|
<input id="firstName" type="text" className="form-control form-control-sm" {...register("firstName")} inputMode='text' />
|
||||||
{errors.firstName && <div className="danger-text">{errors.firstName.message}</div>}
|
{errors.firstName && <div className="danger-text">{errors.firstName.message}</div>}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="col-sm-6 mt-1">
|
<div className="col-sm-6 mt-1 text-start">
|
||||||
<Label htmlFor="lastName" required>Last Name</Label>
|
<Label htmlFor="lastName" required>Last Name</Label>
|
||||||
<input id="lastName" type="text" className="form-control form-control-sm" {...register("lastName")} />
|
<input id="lastName" type="text" className="form-control form-control-sm" {...register("lastName")} />
|
||||||
{errors.lastName && <div className="danger-text">{errors.lastName.message}</div>}
|
{errors.lastName && <div className="danger-text">{errors.lastName.message}</div>}
|
||||||
@ -88,32 +88,32 @@ const EditProfile = ({ TenantId, onClose }) => {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div className="col-sm-6 mt-1">
|
<div className="col-sm-6 mt-1 text-start">
|
||||||
<Label htmlFor="contactNumber" required>Contact Number</Label>
|
<Label htmlFor="contactNumber" required>Contact Number</Label>
|
||||||
<input id="contactNumber" type="text" className="form-control form-control-sm" {...register("contactNumber")} inputMode="tel"
|
<input id="contactNumber" type="text" className="form-control form-control-sm" {...register("contactNumber")} inputMode="tel"
|
||||||
placeholder="+91 9876543210" />
|
placeholder="+91 9876543210" />
|
||||||
{errors.contactNumber && <div className="danger-text">{errors.contactNumber.message}</div>}
|
{errors.contactNumber && <div className="danger-text">{errors.contactNumber.message}</div>}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="col-sm-6 mt-1">
|
<div className="col-sm-6 mt-1 text-start">
|
||||||
<Label htmlFor="domainName" >Domain Name</Label>
|
<Label htmlFor="domainName" >Domain Name</Label>
|
||||||
<input id="domainName" type="text" className="form-control form-control-sm" {...register("domainName")} />
|
<input id="domainName" type="text" className="form-control form-control-sm" {...register("domainName")} />
|
||||||
{errors.domainName && <div className="danger-text">{errors.domainName.message}</div>}
|
{errors.domainName && <div className="danger-text">{errors.domainName.message}</div>}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="col-sm-6 mt-1">
|
<div className="col-sm-6 mt-1 text-start">
|
||||||
<Label htmlFor="taxId" >Tax ID</Label>
|
<Label htmlFor="taxId" >Tax ID</Label>
|
||||||
<input id="taxId" type="text" className="form-control form-control-sm" {...register("taxId")} />
|
<input id="taxId" type="text" className="form-control form-control-sm" {...register("taxId")} />
|
||||||
{errors.taxId && <div className="danger-text">{errors.taxId.message}</div>}
|
{errors.taxId && <div className="danger-text">{errors.taxId.message}</div>}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="col-sm-6 mt-1">
|
<div className="col-sm-6 mt-1 text-start">
|
||||||
<Label htmlFor="officeNumber" >Office Number</Label>
|
<Label htmlFor="officeNumber" >Office Number</Label>
|
||||||
<input id="officeNumber" type="text" className="form-control form-control-sm" {...register("officeNumber")} />
|
<input id="officeNumber" type="text" className="form-control form-control-sm" {...register("officeNumber")} />
|
||||||
{errors.officeNumber && <div className="danger-text">{errors.officeNumber.message}</div>}
|
{errors.officeNumber && <div className="danger-text">{errors.officeNumber.message}</div>}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="col-sm-6 mt-1">
|
<div className="col-sm-6 mt-1 text-start">
|
||||||
<Label htmlFor="industryId" required>Industry</Label>
|
<Label htmlFor="industryId" required>Industry</Label>
|
||||||
<select className="form-select form-select-sm" {...register("industryId")}>
|
<select className="form-select form-select-sm" {...register("industryId")}>
|
||||||
{industryLoading ? <option value="">Loading...</option> :
|
{industryLoading ? <option value="">Loading...</option> :
|
||||||
@ -125,7 +125,7 @@ const EditProfile = ({ TenantId, onClose }) => {
|
|||||||
{errors.industryId && <div className="danger-text">{errors.industryId.message}</div>}
|
{errors.industryId && <div className="danger-text">{errors.industryId.message}</div>}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="col-sm-6 mt-1">
|
<div className="col-sm-6 mt-1 text-start">
|
||||||
<Label htmlFor="reference">Reference</Label>
|
<Label htmlFor="reference">Reference</Label>
|
||||||
<select className="form-select form-select-sm" {...register("reference")}>
|
<select className="form-select form-select-sm" {...register("reference")}>
|
||||||
{reference.map((org) => (
|
{reference.map((org) => (
|
||||||
@ -134,7 +134,7 @@ const EditProfile = ({ TenantId, onClose }) => {
|
|||||||
</select>
|
</select>
|
||||||
{errors.reference && <div className="danger-text">{errors.reference.message}</div>}
|
{errors.reference && <div className="danger-text">{errors.reference.message}</div>}
|
||||||
</div>
|
</div>
|
||||||
<div className="col-sm-6">
|
<div className="col-sm-6 text-start">
|
||||||
<Label htmlFor="organizationSize" required>
|
<Label htmlFor="organizationSize" required>
|
||||||
Organization Size
|
Organization Size
|
||||||
</Label>
|
</Label>
|
||||||
@ -154,19 +154,19 @@ const EditProfile = ({ TenantId, onClose }) => {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="col-12 mt-1">
|
<div className="col-12 mt-1 text-start">
|
||||||
<Label htmlFor="billingAddress" required>Billing Address</Label>
|
<Label htmlFor="billingAddress" required>Billing Address</Label>
|
||||||
<textarea id="billingAddress" className="form-control" {...register("billingAddress")} rows={2} />
|
<textarea id="billingAddress" className="form-control" {...register("billingAddress")} rows={2} />
|
||||||
{errors.billingAddress && <div className="danger-text">{errors.billingAddress.message}</div>}
|
{errors.billingAddress && <div className="danger-text">{errors.billingAddress.message}</div>}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="col-12 mt-1">
|
<div className="col-12 mt-1 text-start">
|
||||||
<Label htmlFor="description">Description</Label>
|
<Label htmlFor="description">Description</Label>
|
||||||
<textarea id="description" className="form-control" {...register("description")} rows={2} />
|
<textarea id="description" className="form-control" {...register("description")} rows={2} />
|
||||||
{errors.description && <div className="danger-text">{errors.description.message}</div>}
|
{errors.description && <div className="danger-text">{errors.description.message}</div>}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="col-sm-12">
|
<div className="col-sm-12 text-start">
|
||||||
<Label htmlFor="logImage">Logo Image</Label>
|
<Label htmlFor="logImage">Logo Image</Label>
|
||||||
<LogoUpload
|
<LogoUpload
|
||||||
preview={logoPreview}
|
preview={logoPreview}
|
||||||
@ -176,9 +176,9 @@ const EditProfile = ({ TenantId, onClose }) => {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="d-flex justify-content-center gap-2 mt-3">
|
<div className="d-flex justify-content-end gap-2 mt-3">
|
||||||
|
<button type="button" disabled={isPending} className="btn btn-sm btn-label-secondary" onClick={onClose}>Cancel</button>
|
||||||
<button type="submit" disabled={isPending} className="btn btn-sm btn-primary">{isPending ? "Please Wait..." : "Submit"}</button>
|
<button type="submit" disabled={isPending} className="btn btn-sm btn-primary">{isPending ? "Please Wait..." : "Submit"}</button>
|
||||||
<button type="button" disabled={isPending} className="btn btn-sm btn-secondary" onClick={onClose}>Cancel</button>
|
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</FormProvider>
|
</FormProvider>
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import React from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import { useFormContext } from "react-hook-form";
|
import { useFormContext } from "react-hook-form";
|
||||||
|
|
||||||
const toBase64 = (file) =>
|
const toBase64 = (file) =>
|
||||||
@ -10,11 +10,15 @@ const toBase64 = (file) =>
|
|||||||
});
|
});
|
||||||
|
|
||||||
export const LogoUpload = ({ preview, setPreview, fileName, setFileName }) => {
|
export const LogoUpload = ({ preview, setPreview, fileName, setFileName }) => {
|
||||||
const {
|
const { register, setValue, watch, formState: { errors } } = useFormContext();
|
||||||
register,
|
const logoImage = watch("logoImage");
|
||||||
setValue,
|
|
||||||
formState: { errors },
|
// Sync preview when the form value changes
|
||||||
} = useFormContext();
|
useEffect(() => {
|
||||||
|
if (logoImage && !preview) {
|
||||||
|
setPreview(logoImage); // Use base64 as preview
|
||||||
|
}
|
||||||
|
}, [logoImage, preview, setPreview]);
|
||||||
|
|
||||||
const handleUpload = async (e) => {
|
const handleUpload = async (e) => {
|
||||||
const file = e.target.files?.[0];
|
const file = e.target.files?.[0];
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import React, { useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import { useFormContext, Controller } from "react-hook-form";
|
import { useFormContext, Controller } from "react-hook-form";
|
||||||
import Label from "../common/Label";
|
import Label from "../common/Label";
|
||||||
import DatePicker from "../common/DatePicker";
|
import DatePicker from "../common/DatePicker";
|
||||||
@ -6,11 +6,14 @@ import { useCreateTenant, useIndustries } from "../../hooks/useTenant";
|
|||||||
import { LogoUpload } from "./LogoUpload";
|
import { LogoUpload } from "./LogoUpload";
|
||||||
import { orgSize, reference } from "../../utils/constants";
|
import { orgSize, reference } from "../../utils/constants";
|
||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
|
import { useGlobalServices } from "../../hooks/masterHook/useMaster";
|
||||||
|
import SelectMultiple from "../common/SelectMultiple";
|
||||||
|
|
||||||
const OrganizationInfo = ({ onNext, onPrev, onSubmitTenant }) => {
|
const OrganizationInfo = ({ onNext, onPrev, onSubmitTenant }) => {
|
||||||
const { data, isError, isLoading: industryLoading } = useIndustries();
|
const { data, isError, isLoading: industryLoading } = useIndustries();
|
||||||
const [logoPreview, setLogoPreview] = useState(null);
|
const [logoPreview, setLogoPreview] = useState(null);
|
||||||
const [logoName, setLogoName] = useState("");
|
const [logoName, setLogoName] = useState("");
|
||||||
|
const { data: services, isLoading: serviceLoading } = useGlobalServices();
|
||||||
const {
|
const {
|
||||||
register,
|
register,
|
||||||
control,
|
control,
|
||||||
@ -42,6 +45,7 @@ const OrganizationInfo = ({ onNext, onPrev, onSubmitTenant }) => {
|
|||||||
"industryId",
|
"industryId",
|
||||||
"reference",
|
"reference",
|
||||||
"logoImage",
|
"logoImage",
|
||||||
|
"serviceIds",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (valid) {
|
if (valid) {
|
||||||
@ -53,6 +57,13 @@ const OrganizationInfo = ({ onNext, onPrev, onSubmitTenant }) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const logoImage = getValues("logoImage");
|
||||||
|
if (logoImage) {
|
||||||
|
setLogoPreview(logoImage);
|
||||||
|
setLogoName("Uploaded Logo");
|
||||||
|
}
|
||||||
|
}, [getValues]);
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -181,7 +192,7 @@ const OrganizationInfo = ({ onNext, onPrev, onSubmitTenant }) => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="col-sm-6">
|
<div className="col-sm-6">
|
||||||
<Label htmlFor="reference">Reference</Label>
|
<Label htmlFor="reference" required>Reference</Label>
|
||||||
<select
|
<select
|
||||||
id="reference"
|
id="reference"
|
||||||
className="form-select shadow-none border py-1 px-2 small"
|
className="form-select shadow-none border py-1 px-2 small"
|
||||||
@ -198,6 +209,20 @@ const OrganizationInfo = ({ onNext, onPrev, onSubmitTenant }) => {
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div className="col-sm-6">
|
||||||
|
<SelectMultiple
|
||||||
|
name="serviceIds"
|
||||||
|
label="Services"
|
||||||
|
options={services?.data}
|
||||||
|
isLoading={serviceLoading}
|
||||||
|
labelKey="name"
|
||||||
|
valueKey="id"
|
||||||
|
/>
|
||||||
|
{errors.serviceIds && (
|
||||||
|
<div className="danger-text">{errors.serviceIds.message}</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div className="col-sm-12">
|
<div className="col-sm-12">
|
||||||
<Label htmlFor="description">Description</Label>
|
<Label htmlFor="description">Description</Label>
|
||||||
|
|||||||
@ -5,12 +5,12 @@ import GlobalModel from "../common/GlobalModel";
|
|||||||
import { useTenantContext } from "../../pages/Tenant/TenantPage";
|
import { useTenantContext } from "../../pages/Tenant/TenantPage";
|
||||||
import { useTenantDetailsContext } from "../../pages/Tenant/TenantDetails";
|
import { useTenantDetailsContext } from "../../pages/Tenant/TenantDetails";
|
||||||
import IconButton from "../common/IconButton";
|
import IconButton from "../common/IconButton";
|
||||||
import { hasUserPermission } from "../../utils/authUtils";
|
|
||||||
import { MANAGE_TENANTS } from "../../utils/constants";
|
import { MANAGE_TENANTS } from "../../utils/constants";
|
||||||
|
import { useHasUserPermission } from "../../hooks/useHasUserPermission";
|
||||||
|
|
||||||
const Profile = ({ data }) => {
|
const Profile = ({ data }) => {
|
||||||
const {setEditTenant} = useTenantDetailsContext()
|
const {setEditTenant} = useTenantDetailsContext()
|
||||||
const canUpdateTenant = hasUserPermission(MANAGE_TENANTS)
|
const canUpdateTenant = useHasUserPermission(MANAGE_TENANTS)
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="container-fuid">
|
<div className="container-fuid">
|
||||||
|
|||||||
@ -224,7 +224,7 @@ const SubScription = ({ onSubmitSubScription, onNext }) => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{Object.keys(errors).length > 0 && (
|
{Object.keys(errors).length > 0 && (
|
||||||
<div class="alert alert-danger" role="alert">
|
<div role="alert">
|
||||||
{Object.entries(errors).map(([key, error]) => (
|
{Object.entries(errors).map(([key, error]) => (
|
||||||
<div key={key} className="danger-text">
|
<div key={key} className="danger-text">
|
||||||
{error?.message}
|
{error?.message}
|
||||||
|
|||||||
@ -14,7 +14,7 @@ const SkeletonCell = ({ width = "100%", height = 20, style = {} }) => (
|
|||||||
|
|
||||||
export const TenantTableSkeleton = ({ columns, rows = 5 }) => {
|
export const TenantTableSkeleton = ({ columns, rows = 5 }) => {
|
||||||
return (
|
return (
|
||||||
<div className="card p-2 mt-3">
|
<div className="p-2 mt-3">
|
||||||
<div className="card-datatable text-nowrap table-responsive">
|
<div className="card-datatable text-nowrap table-responsive">
|
||||||
<table className="table border-top dataTable text-nowrap">
|
<table className="table border-top dataTable text-nowrap">
|
||||||
<thead>
|
<thead>
|
||||||
|
|||||||
@ -38,7 +38,7 @@ const TenantFilterPanel = ({ onApply }) => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
// ✅ Close popup when navigating to another component
|
// Close popup when navigating to another component
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
handleClosePanel();
|
handleClosePanel();
|
||||||
@ -106,13 +106,13 @@ const TenantFilterPanel = ({ onApply }) => {
|
|||||||
<div className="d-flex justify-content-end py-3 gap-2">
|
<div className="d-flex justify-content-end py-3 gap-2">
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className="btn btn-label-secondary btn-xs"
|
className="btn btn-label-secondary btn-sm"
|
||||||
onClick={onClear}
|
onClick={onClear}
|
||||||
|
|
||||||
>
|
>
|
||||||
Clear
|
Clear
|
||||||
</button>
|
</button>
|
||||||
<button type="submit" className="btn btn-primary btn-xs" >
|
<button type="submit" className="btn btn-primary btn-sm" >
|
||||||
Apply
|
Apply
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -33,6 +33,7 @@ export const newTenantSchema = z.object({
|
|||||||
organizationSize: z.string().nonempty("Organization size is required"),
|
organizationSize: z.string().nonempty("Organization size is required"),
|
||||||
industryId: z.string().uuid("Invalid industry ID"),
|
industryId: z.string().uuid("Invalid industry ID"),
|
||||||
reference: z.string().nonempty("Reference is required"),
|
reference: z.string().nonempty("Reference is required"),
|
||||||
|
serviceIds: z.array(z.string()).optional(),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const tenantDefaultValues = {
|
export const tenantDefaultValues = {
|
||||||
@ -51,13 +52,14 @@ export const tenantDefaultValues = {
|
|||||||
organizationSize: "",
|
organizationSize: "",
|
||||||
industryId: "", // should be a valid UUID if pre-filled
|
industryId: "", // should be a valid UUID if pre-filled
|
||||||
reference: "",
|
reference: "",
|
||||||
|
serviceIds:[]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export const getSubscriptionSchema = (minUsers) =>
|
export const getSubscriptionSchema = (minUsers) =>
|
||||||
z.object({
|
z.object({
|
||||||
planId: z.string().min(1, { message: "Please select Plan" }),
|
planId: z.string().min(1, { message: "Please select a plan to continue" }),
|
||||||
currencyId: z.string().uuid("Invalid currency"),
|
currencyId: z.string().uuid("Invalid currency"),
|
||||||
maxUsers: z
|
maxUsers: z
|
||||||
.number({ invalid_type_error: "Must be a number" })
|
.number({ invalid_type_error: "Must be a number" })
|
||||||
|
|||||||
@ -137,7 +137,7 @@ const TenantsList = ({
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="p-2 mt-3">
|
<div className="p-2 mt-3">
|
||||||
<div className="card-datatable text-nowrap table-responsive">
|
<div className=" text-nowrap table-responsive">
|
||||||
<table className="table border-top dataTable text-nowrap">
|
<table className="table border-top dataTable text-nowrap">
|
||||||
<thead>
|
<thead>
|
||||||
<tr className="shadow-sm">
|
<tr className="shadow-sm">
|
||||||
|
|||||||
266
src/components/collections/AddPayment.jsx
Normal file
266
src/components/collections/AddPayment.jsx
Normal file
@ -0,0 +1,266 @@
|
|||||||
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
|
import React, { useState } from "react";
|
||||||
|
import { FormProvider, useForm } from "react-hook-form";
|
||||||
|
import { defaultPayment, paymentSchema } from "./collectionSchema";
|
||||||
|
import Label from "../common/Label";
|
||||||
|
import DatePicker from "../common/DatePicker";
|
||||||
|
import { formatDate } from "date-fns";
|
||||||
|
import { useCollectionContext } from "../../pages/collections/CollectionPage";
|
||||||
|
import { useAddPayment, useCollection } from "../../hooks/useCollections";
|
||||||
|
import { formatFigure, localToUtc } from "../../utils/appUtils";
|
||||||
|
import { formatUTCToLocalTime } from "../../utils/dateUtils";
|
||||||
|
import Avatar from "../common/Avatar";
|
||||||
|
import { PaymentHistorySkeleton } from "./CollectionSkeleton";
|
||||||
|
import { usePaymentAjustmentHead } from "../../hooks/masterHook/useMaster";
|
||||||
|
|
||||||
|
const AddPayment = ({ onClose }) => {
|
||||||
|
const { addPayment } = useCollectionContext();
|
||||||
|
const { data, isLoading, isError, error } = useCollection(
|
||||||
|
addPayment?.invoiceId
|
||||||
|
);
|
||||||
|
const {
|
||||||
|
data: paymentTypes,
|
||||||
|
isLoading: isPaymentTypeLoading,
|
||||||
|
isError: isPaymentTypeError,
|
||||||
|
error: paymentError,
|
||||||
|
} = usePaymentAjustmentHead(true);
|
||||||
|
const methods = useForm({
|
||||||
|
resolver: zodResolver(paymentSchema),
|
||||||
|
defaultValues: defaultPayment,
|
||||||
|
});
|
||||||
|
const {
|
||||||
|
control,
|
||||||
|
register,
|
||||||
|
handleSubmit,
|
||||||
|
reset,
|
||||||
|
formState: { errors },
|
||||||
|
} = methods;
|
||||||
|
const { mutate: AddPayment, isPending } = useAddPayment(() => {
|
||||||
|
handleClose();
|
||||||
|
});
|
||||||
|
const onSubmit = (formData) => {
|
||||||
|
const payload = {
|
||||||
|
...formData,
|
||||||
|
paymentReceivedDate: localToUtc(formData.paymentReceivedDate),
|
||||||
|
invoiceId: addPayment.invoiceId,
|
||||||
|
};
|
||||||
|
AddPayment(payload);
|
||||||
|
};
|
||||||
|
const handleClose = (formData) => {
|
||||||
|
reset(defaultPayment);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="container pb-3">
|
||||||
|
<div className="text-black fs-5 mb-2">Add Payment</div>
|
||||||
|
<FormProvider {...methods}>
|
||||||
|
<form onSubmit={handleSubmit(onSubmit)} className="p-0 text-start">
|
||||||
|
<div className="row px-md-1 px-0">
|
||||||
|
<div className="col-12 col-md-6 mb-2">
|
||||||
|
<Label required>TransanctionId</Label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
className="form-control form-control-sm"
|
||||||
|
{...register("transactionId")}
|
||||||
|
/>
|
||||||
|
{errors.transactionId && (
|
||||||
|
<small className="danger-text">
|
||||||
|
{errors.transactionId.message}
|
||||||
|
</small>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="col-12 col-md-6 mb-2">
|
||||||
|
<Label required>Transaction Date </Label>
|
||||||
|
<DatePicker
|
||||||
|
name="paymentReceivedDate"
|
||||||
|
control={control}
|
||||||
|
minDate={
|
||||||
|
data?.clientSubmitedDate
|
||||||
|
? new Date(
|
||||||
|
new Date(data?.clientSubmitedDate).setDate(
|
||||||
|
new Date(data?.clientSubmitedDate).getDate() + 1
|
||||||
|
)
|
||||||
|
)
|
||||||
|
: null
|
||||||
|
}
|
||||||
|
maxDate={new Date()}
|
||||||
|
/>
|
||||||
|
{errors.paymentReceivedDate && (
|
||||||
|
<small className="danger-text">
|
||||||
|
{errors.paymentReceivedDate.message}
|
||||||
|
</small>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="col-12 col-md-6 mb-2">
|
||||||
|
<Label
|
||||||
|
htmlFor="paymentAdjustmentHeadId"
|
||||||
|
className="form-label"
|
||||||
|
required
|
||||||
|
>
|
||||||
|
Payment Adjustment Head
|
||||||
|
</Label>
|
||||||
|
<select
|
||||||
|
className="form-select form-select-sm "
|
||||||
|
{...register("paymentAdjustmentHeadId")}
|
||||||
|
>
|
||||||
|
{isPaymentTypeLoading ? (
|
||||||
|
<option>Loading..</option>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<option value="">Select Payment Head</option>
|
||||||
|
{paymentTypes?.data
|
||||||
|
?.sort((a, b) => a.name.localeCompare(b.name))
|
||||||
|
?.map((type) => (
|
||||||
|
<option key={type.id} value={type.id}>
|
||||||
|
{type.name}
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</select>
|
||||||
|
{errors.paymentAdjustmentHeadId && (
|
||||||
|
<small className="danger-text">
|
||||||
|
{errors.paymentAdjustmentHeadId.message}
|
||||||
|
</small>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="col-12 col-md-6 mb-2">
|
||||||
|
<Label htmlFor="amount" className="form-label" required>
|
||||||
|
Amount
|
||||||
|
</Label>
|
||||||
|
<input
|
||||||
|
type="number"
|
||||||
|
id="amount"
|
||||||
|
className="form-control form-control-sm"
|
||||||
|
min="1"
|
||||||
|
step="0.01"
|
||||||
|
inputMode="decimal"
|
||||||
|
{...register("amount", { valueAsNumber: true })}
|
||||||
|
/>
|
||||||
|
{errors.amount && (
|
||||||
|
<small className="danger-text">{errors.amount.message}</small>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<div className="col-12 mb-2">
|
||||||
|
<Label htmlFor="comment" className="form-label" required>
|
||||||
|
Comment
|
||||||
|
</Label>
|
||||||
|
<textarea
|
||||||
|
id="comment"
|
||||||
|
className="form-control form-control-sm"
|
||||||
|
{...register("comment")}
|
||||||
|
/>
|
||||||
|
{errors.comment && (
|
||||||
|
<small className="danger-text">{errors.comment.message}</small>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="d-flex justify-content-end gap-3">
|
||||||
|
{" "}
|
||||||
|
<button
|
||||||
|
type="reset"
|
||||||
|
className="btn btn-label-secondary btn-sm mt-3"
|
||||||
|
onClick={() => {
|
||||||
|
handleClose();
|
||||||
|
onClose();
|
||||||
|
}}
|
||||||
|
disabled={isPending}
|
||||||
|
>
|
||||||
|
Cancel
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="submit"
|
||||||
|
className="btn btn-primary btn-sm mt-3"
|
||||||
|
disabled={isPending}
|
||||||
|
>
|
||||||
|
{isPending ? "Please Wait..." : "Submit"}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</FormProvider>
|
||||||
|
|
||||||
|
{isLoading ? (
|
||||||
|
<PaymentHistorySkeleton />
|
||||||
|
) : (
|
||||||
|
data?.receivedInvoicePayments?.length > 0 && (
|
||||||
|
<div className="mt-1 text-start">
|
||||||
|
<div className="mb-2 text-secondry fs-6">
|
||||||
|
<i className="bx bx-history bx-sm me-1"></i>History
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="row text-start mx-2">
|
||||||
|
{data.receivedInvoicePayments
|
||||||
|
.sort((a, b) => new Date(b.createdAt) - new Date(a.createdAt))
|
||||||
|
.map((payment, index) => (
|
||||||
|
<div className="col-12 mb-2" key={payment.id}>
|
||||||
|
<div className=" p-2 border-start border-warning">
|
||||||
|
<div className="row">
|
||||||
|
<div className="col-12 col-md-6 d-flex justify-content-between align-items-center ">
|
||||||
|
<div>
|
||||||
|
<small className="fw-semibold me-1">
|
||||||
|
Transaction Date:
|
||||||
|
</small>{" "}
|
||||||
|
{formatUTCToLocalTime(payment.paymentReceivedDate)}
|
||||||
|
</div>
|
||||||
|
<span className="fs-semibold d-block d-md-none">
|
||||||
|
{formatFigure(payment.amount, {
|
||||||
|
type: "currency",
|
||||||
|
currency: "INR",
|
||||||
|
})}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="col-12 col-md-6 mb-0 d-flex align-items-center m-0">
|
||||||
|
<small className="fw-semibold me-2">
|
||||||
|
Updated By:
|
||||||
|
</small>{" "}
|
||||||
|
<Avatar
|
||||||
|
size="xs"
|
||||||
|
firstName={payment?.createdBy?.firstName}
|
||||||
|
lastName={payment?.createdBy?.lastName}
|
||||||
|
/>{" "}
|
||||||
|
{payment?.createdBy?.firstName}{" "}
|
||||||
|
{payment.createdBy?.lastName}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="row">
|
||||||
|
<div className="col-12 col-md-6">
|
||||||
|
<p className="mb-1">
|
||||||
|
<small className="fw-semibold">
|
||||||
|
Transaction ID:
|
||||||
|
</small>{" "}
|
||||||
|
{payment.transactionId}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div className="col-12 ">
|
||||||
|
<div className="d-flex justify-content-between">
|
||||||
|
<span>{payment?.paymentAdjustmentHead?.name}</span>
|
||||||
|
<span className="fs-semibold d-none d-md-block">
|
||||||
|
{formatFigure(payment.amount, {
|
||||||
|
type: "currency",
|
||||||
|
currency: "INR",
|
||||||
|
})}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<p className="text-tiny m-0 mt-1">
|
||||||
|
{payment?.comment}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default AddPayment;
|
||||||
296
src/components/collections/CollectionList.jsx
Normal file
296
src/components/collections/CollectionList.jsx
Normal file
@ -0,0 +1,296 @@
|
|||||||
|
import React, { useState } from "react";
|
||||||
|
import { useCollections } from "../../hooks/useCollections";
|
||||||
|
import {
|
||||||
|
ADDPAYMENT_COLLECTION,
|
||||||
|
ADMIN_COLLECTION,
|
||||||
|
CREATE_COLLECTION,
|
||||||
|
EDIT_COLLECTION,
|
||||||
|
ITEMS_PER_PAGE,
|
||||||
|
VIEW_COLLECTION,
|
||||||
|
} from "../../utils/constants";
|
||||||
|
import { formatFigure, localToUtc, useDebounce } from "../../utils/appUtils";
|
||||||
|
import { formatUTCToLocalTime } from "../../utils/dateUtils";
|
||||||
|
import Pagination from "../common/Pagination";
|
||||||
|
import { useCollectionContext } from "../../pages/collections/CollectionPage";
|
||||||
|
import { CollectionTableSkeleton } from "./CollectionSkeleton";
|
||||||
|
import { useSelectedProject } from "../../slices/apiDataManager";
|
||||||
|
import { useHasUserPermission } from "../../hooks/useHasUserPermission";
|
||||||
|
|
||||||
|
const CollectionList = ({ fromDate, toDate, isPending, searchString }) => {
|
||||||
|
const [currentPage, setCurrentPage] = useState(1);
|
||||||
|
|
||||||
|
const isAdmin = useHasUserPermission(ADMIN_COLLECTION);
|
||||||
|
const canAddPayment = useHasUserPermission(ADDPAYMENT_COLLECTION);
|
||||||
|
const canViewCollection = useHasUserPermission(VIEW_COLLECTION);
|
||||||
|
const canEditCollection = useHasUserPermission(EDIT_COLLECTION);
|
||||||
|
const canCreate = useHasUserPermission(CREATE_COLLECTION);
|
||||||
|
|
||||||
|
const selectedProject = useSelectedProject();
|
||||||
|
const searchDebounce = useDebounce(searchString, 500);
|
||||||
|
|
||||||
|
const { data, isLoading, isError, error } = useCollections(
|
||||||
|
ITEMS_PER_PAGE,
|
||||||
|
currentPage,
|
||||||
|
localToUtc(fromDate),
|
||||||
|
localToUtc(toDate),
|
||||||
|
isPending,
|
||||||
|
true,
|
||||||
|
selectedProject,
|
||||||
|
searchDebounce
|
||||||
|
);
|
||||||
|
const { setProcessedPayment, setAddPayment, setViewCollection } =
|
||||||
|
useCollectionContext();
|
||||||
|
|
||||||
|
const paginate = (page) => {
|
||||||
|
if (page >= 1 && page <= (data?.totalPages ?? 1)) {
|
||||||
|
setCurrentPage(page);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const collectionColumns = [
|
||||||
|
{
|
||||||
|
key: "invoiceDate",
|
||||||
|
label: "Invoice Date",
|
||||||
|
getValue: (col) => (
|
||||||
|
<span
|
||||||
|
className="text-truncate d-inline-block"
|
||||||
|
style={{ maxWidth: "200px" }}
|
||||||
|
>
|
||||||
|
{formatUTCToLocalTime(col.invoiceDate)}
|
||||||
|
</span>
|
||||||
|
),
|
||||||
|
align: "text-start",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "invoiceId",
|
||||||
|
label: "Invoice No",
|
||||||
|
getValue: (col) => (
|
||||||
|
<span
|
||||||
|
className="text-truncate d-inline-block"
|
||||||
|
style={{ maxWidth: "200px" }}
|
||||||
|
>
|
||||||
|
{col?.invoiceNumber ?? "-"}
|
||||||
|
</span>
|
||||||
|
),
|
||||||
|
align: "text-start",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "project",
|
||||||
|
label: "Project",
|
||||||
|
getValue: (col) => (
|
||||||
|
<span
|
||||||
|
className="text-truncate d-inline-block"
|
||||||
|
style={{ maxWidth: "200px" }}
|
||||||
|
>
|
||||||
|
{col?.project?.name ?? "-"}
|
||||||
|
</span>
|
||||||
|
),
|
||||||
|
align: "text-start",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "submittedDate",
|
||||||
|
label: "Submission Date",
|
||||||
|
getValue: (col) => (
|
||||||
|
<span
|
||||||
|
className="text-truncate d-inline-block"
|
||||||
|
style={{ maxWidth: "200px" }}
|
||||||
|
>
|
||||||
|
{formatUTCToLocalTime(col.createdAt)}
|
||||||
|
</span>
|
||||||
|
),
|
||||||
|
align: "text-center",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "expectedSubmittedDate",
|
||||||
|
label: "Expected Payment Date",
|
||||||
|
getValue: (col) => (
|
||||||
|
<span
|
||||||
|
className="text-truncate d-inline-block"
|
||||||
|
style={{ maxWidth: "200px" }}
|
||||||
|
>
|
||||||
|
{formatUTCToLocalTime(col.exceptedPaymentDate) ?? "-"}
|
||||||
|
</span>
|
||||||
|
),
|
||||||
|
align: "text-center",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "amount",
|
||||||
|
label: "Total Amount",
|
||||||
|
getValue: (col) => (
|
||||||
|
<span
|
||||||
|
className="text-truncate d-inline-block"
|
||||||
|
style={{ maxWidth: "200px" }}
|
||||||
|
>
|
||||||
|
{formatFigure(col?.basicAmount + col?.taxAmount, {
|
||||||
|
type: "currency",
|
||||||
|
currency: "INR",
|
||||||
|
}) ?? 0}
|
||||||
|
</span>
|
||||||
|
),
|
||||||
|
align: "text-end",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "balance",
|
||||||
|
label: "Balance",
|
||||||
|
getValue: (col) => (
|
||||||
|
<span
|
||||||
|
className="text-truncate d-inline-block py-3"
|
||||||
|
style={{ maxWidth: "200px" }}
|
||||||
|
>
|
||||||
|
{formatFigure(col?.balanceAmount, {
|
||||||
|
type: "currency",
|
||||||
|
currency: "INR",
|
||||||
|
}) ?? 0}
|
||||||
|
</span>
|
||||||
|
),
|
||||||
|
align: "text-end",
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
if (isLoading) return <CollectionTableSkeleton />;
|
||||||
|
if (isError) return <p>{error.message}</p>;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="card ">
|
||||||
|
<div
|
||||||
|
className="card-datatable table-responsive page-min-h"
|
||||||
|
id="horizontal-example"
|
||||||
|
>
|
||||||
|
<div className="dataTables_wrapper no-footer mx-5 pb-2">
|
||||||
|
<table className="table dataTable text-nowrap">
|
||||||
|
<thead>
|
||||||
|
<tr className="table_header_border">
|
||||||
|
{collectionColumns.map((col) => (
|
||||||
|
<th key={col.key} className={col.align}>
|
||||||
|
{col.label}
|
||||||
|
</th>
|
||||||
|
))}
|
||||||
|
{(isAdmin ||
|
||||||
|
canAddPayment ||
|
||||||
|
canViewCollection ||
|
||||||
|
canEditCollection ||
|
||||||
|
canCreate) && <th>Action</th>}
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{Array.isArray(data?.data) && data.data.length > 0 ? (
|
||||||
|
data.data.map((row, i) => (
|
||||||
|
<tr key={i}>
|
||||||
|
{collectionColumns.map((col) => (
|
||||||
|
<td key={col.key} className={col.align}>
|
||||||
|
{col.getValue(row)}
|
||||||
|
</td>
|
||||||
|
))}
|
||||||
|
{(isAdmin ||
|
||||||
|
canAddPayment ||
|
||||||
|
canViewCollection ||
|
||||||
|
canEditCollection ||
|
||||||
|
canCreate) && (
|
||||||
|
<td
|
||||||
|
className="sticky-action-column text-center"
|
||||||
|
style={{ padding: "12px 8px" }}
|
||||||
|
>
|
||||||
|
<div className="dropdown z-2">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="btn btn-icon btn-text-secondary rounded-pill dropdown-toggle hide-arrow p-0"
|
||||||
|
data-bs-toggle="dropdown"
|
||||||
|
aria-expanded="false"
|
||||||
|
>
|
||||||
|
<i
|
||||||
|
className="bx bx-dots-vertical-rounded bx-sm text-muted"
|
||||||
|
data-bs-toggle="tooltip"
|
||||||
|
data-bs-offset="0,8"
|
||||||
|
data-bs-placement="top"
|
||||||
|
data-bs-custom-class="tooltip-dark"
|
||||||
|
title="More Action"
|
||||||
|
></i>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<ul className="dropdown-menu dropdown-menu-end">
|
||||||
|
{/* View */}
|
||||||
|
|
||||||
|
<li>
|
||||||
|
<a
|
||||||
|
className="dropdown-item cursor-pointer"
|
||||||
|
onClick={() => setViewCollection(row.id)}
|
||||||
|
>
|
||||||
|
<i className="bx bx-show me-2 text-primary"></i>
|
||||||
|
<span>View</span>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
{/* Only if not completed */}
|
||||||
|
{!row?.markAsCompleted && (
|
||||||
|
<>
|
||||||
|
{/* Add Payment */}
|
||||||
|
{(isAdmin || canAddPayment) && (
|
||||||
|
<li>
|
||||||
|
<a
|
||||||
|
className="dropdown-item cursor-pointer"
|
||||||
|
onClick={() =>
|
||||||
|
setAddPayment({
|
||||||
|
isOpen: true,
|
||||||
|
invoiceId: row.id,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<i className="bx bx-wallet me-2 text-warning"></i>
|
||||||
|
<span>Add Payment</span>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* Mark Payment */}
|
||||||
|
{isAdmin && (
|
||||||
|
<li>
|
||||||
|
<a
|
||||||
|
className="dropdown-item cursor-pointer"
|
||||||
|
onClick={() =>
|
||||||
|
setProcessedPayment({
|
||||||
|
isOpen: true,
|
||||||
|
invoiceId: row.id,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<i className="bx bx-check-circle me-2 text-success"></i>
|
||||||
|
<span>Mark Payment</span>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
)}
|
||||||
|
</tr>
|
||||||
|
))
|
||||||
|
) : (
|
||||||
|
<tr style={{ height: "200px" }}>
|
||||||
|
<td
|
||||||
|
colSpan={collectionColumns.length + 1}
|
||||||
|
className="text-center border-0 align-middle"
|
||||||
|
>
|
||||||
|
No Collections Found
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
)}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
{data?.data?.length > 0 && (
|
||||||
|
<div className="d-flex justify-content-start mt-2">
|
||||||
|
<Pagination
|
||||||
|
currentPage={currentPage}
|
||||||
|
totalPages={data?.totalPages}
|
||||||
|
onPageChange={paginate}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default CollectionList;
|
||||||
211
src/components/collections/CollectionSkeleton.jsx
Normal file
211
src/components/collections/CollectionSkeleton.jsx
Normal file
@ -0,0 +1,211 @@
|
|||||||
|
import React from "react";
|
||||||
|
|
||||||
|
const SkeletonLine = ({ height = 20, width = "100%", className = "" }) => (
|
||||||
|
<div
|
||||||
|
className={`skeleton mb-2 ${className}`}
|
||||||
|
style={{
|
||||||
|
height,
|
||||||
|
width,
|
||||||
|
}}
|
||||||
|
></div>
|
||||||
|
);
|
||||||
|
|
||||||
|
export const PaymentHistorySkeleton = ({ count = 2 }) => {
|
||||||
|
return (
|
||||||
|
<div className="row text-start">
|
||||||
|
{[...Array(count)].map((_, idx) => (
|
||||||
|
<div className="col-12 mb-2" key={idx}>
|
||||||
|
<div className="p-2 border-start border-warning">
|
||||||
|
{/* Top Row: Date + Amount */}
|
||||||
|
<div className="d-flex justify-content-between align-items-center">
|
||||||
|
<SkeletonLine width="150px" height={18} /> {/* Date */}
|
||||||
|
<SkeletonLine width="100px" height={18} /> {/* Amount */}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="row mt-1">
|
||||||
|
{/* Transaction ID */}
|
||||||
|
<div className="col-12 col-md-6">
|
||||||
|
<SkeletonLine width="80%" height={16} />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Received By (Avatar + Name) */}
|
||||||
|
<div className="col-12 col-md-6 d-flex align-items-center gap-2">
|
||||||
|
<SkeletonLine
|
||||||
|
width="30px"
|
||||||
|
height={30}
|
||||||
|
className="rounded-circle"
|
||||||
|
/>{" "}
|
||||||
|
{/* Avatar */}
|
||||||
|
<SkeletonLine width="120px" height={16} /> {/* Name */}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const CollectionDetailsSkeleton = () => {
|
||||||
|
return (
|
||||||
|
<div className="container p-3">
|
||||||
|
{/* Title */}
|
||||||
|
<SkeletonLine height={24} width="200px" className="mx-auto" />
|
||||||
|
|
||||||
|
{/* Header Row */}
|
||||||
|
<div className="row mb-3 px-1">
|
||||||
|
<div className="col-10">
|
||||||
|
<SkeletonLine height={20} />
|
||||||
|
</div>
|
||||||
|
<div className="col-2 d-flex justify-content-end">
|
||||||
|
<SkeletonLine height={20} width="60px" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Project */}
|
||||||
|
<div className="row mb-3">
|
||||||
|
<div className="col-md-6">
|
||||||
|
<SkeletonLine width="60%" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Invoice & E-Invoice */}
|
||||||
|
<div className="row mb-3">
|
||||||
|
<div className="col-md-6">
|
||||||
|
<SkeletonLine />
|
||||||
|
</div>
|
||||||
|
<div className="col-md-6">
|
||||||
|
<SkeletonLine />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Invoice Date & Client Submitted */}
|
||||||
|
<div className="row mb-3">
|
||||||
|
<div className="col-md-6">
|
||||||
|
<SkeletonLine />
|
||||||
|
</div>
|
||||||
|
<div className="col-md-6">
|
||||||
|
<SkeletonLine />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Expected Payment & Mark as Completed */}
|
||||||
|
<div className="row mb-3">
|
||||||
|
<div className="col-md-6">
|
||||||
|
<SkeletonLine />
|
||||||
|
</div>
|
||||||
|
<div className="col-md-6">
|
||||||
|
<SkeletonLine width="40%" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Basic & Tax Amount */}
|
||||||
|
<div className="row mb-3">
|
||||||
|
<div className="col-md-6">
|
||||||
|
<SkeletonLine />
|
||||||
|
</div>
|
||||||
|
<div className="col-md-6">
|
||||||
|
<SkeletonLine />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Balance & Created At */}
|
||||||
|
<div className="row mb-3">
|
||||||
|
<div className="col-md-6">
|
||||||
|
<SkeletonLine />
|
||||||
|
</div>
|
||||||
|
<div className="col-md-6">
|
||||||
|
<SkeletonLine />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Created By */}
|
||||||
|
<div className="row mb-3">
|
||||||
|
<div className="col-md-6 d-flex align-items-center">
|
||||||
|
<SkeletonLine
|
||||||
|
width="40px"
|
||||||
|
height={40}
|
||||||
|
className="me-2 rounded-circle"
|
||||||
|
/>
|
||||||
|
<SkeletonLine width="100px" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Description */}
|
||||||
|
<div className="row mb-3">
|
||||||
|
<div className="col-12">
|
||||||
|
<SkeletonLine height={50} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Attachments */}
|
||||||
|
<div className="row mb-3">
|
||||||
|
<div className="col-12 d-flex gap-2 flex-wrap">
|
||||||
|
{[...Array(3)].map((_, idx) => (
|
||||||
|
<SkeletonLine key={idx} height={60} width="80px" />
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Tabs */}
|
||||||
|
<div className="row mb-2">
|
||||||
|
<div className="col-12 d-flex gap-2">
|
||||||
|
<SkeletonLine height={35} width="120px" />
|
||||||
|
<SkeletonLine height={35} width="150px" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Tab Content (Comments / Payments) */}
|
||||||
|
<SkeletonLine height={200} />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const CollectionTableSkeleton = () => {
|
||||||
|
const columnCount = 8;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="card ">
|
||||||
|
<div
|
||||||
|
className="card-datatable table-responsive page-min-h"
|
||||||
|
id="horizontal-example"
|
||||||
|
>
|
||||||
|
<div className="dataTables_wrapper no-footer mx-5 pb-2">
|
||||||
|
<table className="table dataTable text-nowrap">
|
||||||
|
<thead>
|
||||||
|
<tr >
|
||||||
|
{[...Array(columnCount - 1)].map((_, i) => (
|
||||||
|
<th key={i}>
|
||||||
|
<SkeletonLine height={15} width="80px" />
|
||||||
|
</th>
|
||||||
|
))}
|
||||||
|
<th className="d-flex justify-content-center">
|
||||||
|
<SkeletonLine height={16} width="40px" />
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{[...Array(8)].map((_, rowIdx) => (
|
||||||
|
<tr key={rowIdx}>
|
||||||
|
{[...Array(columnCount - 1)].map((_, colIdx) => (
|
||||||
|
<td key={colIdx}>
|
||||||
|
<SkeletonLine height={33} />
|
||||||
|
</td>
|
||||||
|
))}
|
||||||
|
<td className="d-flex justify-content-center">
|
||||||
|
<SkeletonLine height={16} width="20px" />
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
))}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
{/* Pagination Skeleton */}
|
||||||
|
<div className="d-flex justify-content-end mt-2">
|
||||||
|
<SkeletonLine height={30} width="200px" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
85
src/components/collections/Comment.jsx
Normal file
85
src/components/collections/Comment.jsx
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
|
import React from "react";
|
||||||
|
import { useForm } from "react-hook-form";
|
||||||
|
import { CommentSchema } from "./collectionSchema";
|
||||||
|
import { useAddComment } from "../../hooks/useCollections";
|
||||||
|
import Avatar from "../common/Avatar";
|
||||||
|
import { formatUTCToLocalTime } from "../../utils/dateUtils";
|
||||||
|
import moment from "moment";
|
||||||
|
|
||||||
|
const Comment = ({ invoice }) => {
|
||||||
|
const {
|
||||||
|
register,
|
||||||
|
reset,
|
||||||
|
handleSubmit,
|
||||||
|
formState: { errors },
|
||||||
|
} = useForm({
|
||||||
|
resolver: zodResolver(CommentSchema),
|
||||||
|
defaultValues: { comment: "" },
|
||||||
|
});
|
||||||
|
|
||||||
|
const { mutate: AddComment, isPending } = useAddComment(() => {
|
||||||
|
reset();
|
||||||
|
});
|
||||||
|
|
||||||
|
const onSubmit = (formData) => {
|
||||||
|
const payload = { ...formData, invoiceId: invoice?.id };
|
||||||
|
AddComment(payload);
|
||||||
|
};
|
||||||
|
return (
|
||||||
|
<div className="row pt-1 px-2">
|
||||||
|
<form onSubmit={handleSubmit(onSubmit)}>
|
||||||
|
<div className="col-12">
|
||||||
|
<textarea
|
||||||
|
className="form-control "
|
||||||
|
rows={3}
|
||||||
|
{...register("comment")}
|
||||||
|
/>
|
||||||
|
{errors.comment && (
|
||||||
|
<small className="danger-text">{errors.comment.message}</small>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<div className="d-flex justify-content-end p-2">
|
||||||
|
<button
|
||||||
|
className="btn btn-sm btn-primary"
|
||||||
|
type="submit"
|
||||||
|
disabled={isPending}
|
||||||
|
>
|
||||||
|
{isPending ? "Please wait..." : "Submit"}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
{invoice?.comments?.length > 0 ? (
|
||||||
|
invoice.comments.map((comment, index) => (
|
||||||
|
<div
|
||||||
|
className="border-start border-primary ps-1 py-2 mb-3"
|
||||||
|
key={comment.id || index}
|
||||||
|
>
|
||||||
|
<div className="d-flex justify-content-between align-items-center mb-1">
|
||||||
|
<div className="d-flex align-items-center">
|
||||||
|
<Avatar
|
||||||
|
size="xs"
|
||||||
|
firstName={comment?.createdBy?.firstName}
|
||||||
|
lastName={comment?.createdBy?.lastName}
|
||||||
|
/>
|
||||||
|
<span className="ms-1 fw-semibold">
|
||||||
|
{comment?.createdBy?.firstName} {comment?.createdBy?.lastName}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<small className="text-secondary">
|
||||||
|
{moment.utc(comment?.createdAt).local().fromNow()}
|
||||||
|
</small>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="ms-9"> <p className="mb-1">{comment?.comment}</p></div>
|
||||||
|
</div>
|
||||||
|
))
|
||||||
|
) : (
|
||||||
|
<div className="text-center py-2"> <p className="text-muted">No comments yet.</p></div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Comment;
|
||||||
445
src/components/collections/ManageCollection.jsx
Normal file
445
src/components/collections/ManageCollection.jsx
Normal file
@ -0,0 +1,445 @@
|
|||||||
|
import React, { useEffect } from "react";
|
||||||
|
import { useModal } from "../../hooks/useAuth";
|
||||||
|
import Modal from "../common/Modal";
|
||||||
|
import { FormProvider, useForm } from "react-hook-form";
|
||||||
|
import Label from "../common/Label";
|
||||||
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
|
import { defaultCollection, newCollection } from "./collectionSchema";
|
||||||
|
import SelectMultiple from "../common/SelectMultiple";
|
||||||
|
import { useProjectName } from "../../hooks/useProjects";
|
||||||
|
import DatePicker from "../common/DatePicker";
|
||||||
|
import {
|
||||||
|
useCollection,
|
||||||
|
useCreateCollection,
|
||||||
|
useUpdateCollection,
|
||||||
|
} from "../../hooks/useCollections";
|
||||||
|
import { formatFileSize, localToUtc } from "../../utils/appUtils";
|
||||||
|
import { useCollectionContext } from "../../pages/collections/CollectionPage";
|
||||||
|
import { formatDate } from "../../utils/dateUtils";
|
||||||
|
|
||||||
|
const ManageCollection = ({ collectionId, onClose }) => {
|
||||||
|
const { data, isError, isLoading, error } = useCollection(collectionId);
|
||||||
|
const { projectNames, projectLoading } = useProjectName(true);
|
||||||
|
const methods = useForm({
|
||||||
|
resolver: zodResolver(newCollection),
|
||||||
|
defaultValues: defaultCollection,
|
||||||
|
});
|
||||||
|
const {
|
||||||
|
control,
|
||||||
|
watch,
|
||||||
|
register,
|
||||||
|
setValue,
|
||||||
|
handleSubmit,
|
||||||
|
reset,
|
||||||
|
formState: { errors },
|
||||||
|
} = methods;
|
||||||
|
|
||||||
|
const { mutate: createNewCollection, isPending } = useCreateCollection(() => {
|
||||||
|
handleClose();
|
||||||
|
});
|
||||||
|
const { mutate: UpdateCollection } = useUpdateCollection(() => {
|
||||||
|
handleClose();
|
||||||
|
});
|
||||||
|
|
||||||
|
const files = watch("attachments");
|
||||||
|
const onFileChange = async (e) => {
|
||||||
|
const newFiles = Array.from(e.target.files);
|
||||||
|
if (newFiles.length === 0) return;
|
||||||
|
|
||||||
|
const existingFiles = watch("attachments") || [];
|
||||||
|
|
||||||
|
const parsedFiles = await Promise.all(
|
||||||
|
newFiles.map(async (file) => {
|
||||||
|
const base64Data = await toBase64(file);
|
||||||
|
return {
|
||||||
|
fileName: file.name,
|
||||||
|
base64Data,
|
||||||
|
contentType: file.type,
|
||||||
|
fileSize: file.size,
|
||||||
|
description: "",
|
||||||
|
isActive: true,
|
||||||
|
};
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
const combinedFiles = [
|
||||||
|
...existingFiles,
|
||||||
|
...parsedFiles.filter(
|
||||||
|
(newFile) =>
|
||||||
|
!existingFiles.some(
|
||||||
|
(f) =>
|
||||||
|
f.fileName === newFile.fileName && f.fileSize === newFile.fileSize
|
||||||
|
)
|
||||||
|
),
|
||||||
|
];
|
||||||
|
|
||||||
|
setValue("attachments", combinedFiles, {
|
||||||
|
shouldDirty: true,
|
||||||
|
shouldValidate: true,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const toBase64 = (file) =>
|
||||||
|
new Promise((resolve, reject) => {
|
||||||
|
const reader = new FileReader();
|
||||||
|
reader.readAsDataURL(file);
|
||||||
|
reader.onload = () => resolve(reader.result.split(",")[1]);
|
||||||
|
reader.onerror = (error) => reject(error);
|
||||||
|
});
|
||||||
|
const removeFile = (index) => {
|
||||||
|
if (collectionId) {
|
||||||
|
const newFiles = files.map((file, i) => {
|
||||||
|
if (file.documentId !== index) return file;
|
||||||
|
return {
|
||||||
|
...file,
|
||||||
|
isActive: false,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
setValue("attachments", newFiles, { shouldValidate: true });
|
||||||
|
} else {
|
||||||
|
const newFiles = files.filter((_, i) => i !== index);
|
||||||
|
setValue("attachments", newFiles, { shouldValidate: true });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const onSubmit = (formData) => {
|
||||||
|
const payload = {
|
||||||
|
...formData,
|
||||||
|
clientSubmitedDate: localToUtc(formData.clientSubmitedDate),
|
||||||
|
invoiceDate: localToUtc(formData.invoiceDate),
|
||||||
|
exceptedPaymentDate: localToUtc(formData.exceptedPaymentDate),
|
||||||
|
};
|
||||||
|
|
||||||
|
if (collectionId) {
|
||||||
|
UpdateCollection({
|
||||||
|
collectionId,
|
||||||
|
payload: { ...payload, id: collectionId },
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
createNewCollection(payload);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleClose = () => {
|
||||||
|
reset(defaultCollection);
|
||||||
|
onClose();
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (data && collectionId) {
|
||||||
|
reset({
|
||||||
|
projectId: data?.project?.id,
|
||||||
|
invoiceNumber: data?.invoiceNumber,
|
||||||
|
eInvoiceNumber: data?.eInvoiceNumber,
|
||||||
|
title: data?.title,
|
||||||
|
clientSubmitedDate: formatDate(data?.clientSubmitedDate),
|
||||||
|
invoiceDate: formatDate(data?.invoiceDate),
|
||||||
|
exceptedPaymentDate: formatDate(data?.exceptedPaymentDate),
|
||||||
|
taxAmount: data?.taxAmount,
|
||||||
|
basicAmount: data?.basicAmount,
|
||||||
|
description: data?.description,
|
||||||
|
attachments: data.attachments
|
||||||
|
? data.attachments.map((doc) => ({
|
||||||
|
fileName: doc.fileName,
|
||||||
|
base64Data: null,
|
||||||
|
contentType: doc.contentType,
|
||||||
|
documentId: doc.documentId,
|
||||||
|
fileSize: 0,
|
||||||
|
description: "",
|
||||||
|
preSignedUrl: doc.preSignedUrl,
|
||||||
|
isActive: doc.isActive ?? true,
|
||||||
|
}))
|
||||||
|
: [],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, [data]);
|
||||||
|
if (isLoading) return <div>Loading....</div>;
|
||||||
|
if (isError) return <div>{error.message}</div>;
|
||||||
|
return (
|
||||||
|
<div className="container pb-3">
|
||||||
|
<div className="text-black fs-5 mb-2">
|
||||||
|
{collectionId ? "Update" : "New"} Collection
|
||||||
|
</div>
|
||||||
|
<FormProvider {...methods}>
|
||||||
|
<form onSubmit={handleSubmit(onSubmit)} className="p-0 text-start">
|
||||||
|
<div className="row px-md-1 px-0">
|
||||||
|
<div className="col-12 col-md-6 mb-2">
|
||||||
|
<Label className="form-label" required>
|
||||||
|
Select Project
|
||||||
|
</Label>
|
||||||
|
<select
|
||||||
|
className="form-select form-select-sm"
|
||||||
|
{...register("projectId")}
|
||||||
|
>
|
||||||
|
<option value="">Select Project</option>
|
||||||
|
{projectLoading ? (
|
||||||
|
<option>Loading...</option>
|
||||||
|
) : (
|
||||||
|
projectNames?.map((project) => (
|
||||||
|
<option key={project.id} value={project.id}>
|
||||||
|
{project.name}
|
||||||
|
</option>
|
||||||
|
))
|
||||||
|
)}
|
||||||
|
</select>
|
||||||
|
{errors.projectId && (
|
||||||
|
<small className="danger-text">
|
||||||
|
{errors.projectId.message}
|
||||||
|
</small>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<div className="col-12 col-md-6 mb-2">
|
||||||
|
<Label required>Title</Label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
className="form-control form-control-sm"
|
||||||
|
{...register("title")}
|
||||||
|
/>
|
||||||
|
{errors.title && (
|
||||||
|
<small className="danger-text">{errors.title.message}</small>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<div className="col-12 col-md-6 mb-2">
|
||||||
|
<Label required>Invoice Number</Label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
className="form-control form-control-sm"
|
||||||
|
{...register("invoiceNumber")}
|
||||||
|
/>
|
||||||
|
{errors.invoiceId && (
|
||||||
|
<small className="danger-text">
|
||||||
|
{errors.invoiceId.message}
|
||||||
|
</small>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<div className="col-12 col-md-6 mb-2">
|
||||||
|
<Label required>E-Invoice Number</Label>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
className="form-control form-control-sm"
|
||||||
|
{...register("eInvoiceNumber")}
|
||||||
|
/>
|
||||||
|
{errors.invoiceId && (
|
||||||
|
<small className="danger-text">
|
||||||
|
{errors.invoiceId.message}
|
||||||
|
</small>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<div className="col-12 col-md-6 mb-2">
|
||||||
|
<Label required>Invoice Date</Label>
|
||||||
|
<DatePicker
|
||||||
|
name="invoiceDate"
|
||||||
|
control={control}
|
||||||
|
maxDate={new Date()}
|
||||||
|
/>
|
||||||
|
{errors.invoiceDate && (
|
||||||
|
<small className="danger-text">
|
||||||
|
{errors.invoiceDate.message}
|
||||||
|
</small>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<div className="col-12 col-md-6 mb-2">
|
||||||
|
<Label required>Expected Payment Date</Label>
|
||||||
|
<DatePicker
|
||||||
|
name="exceptedPaymentDate"
|
||||||
|
control={control}
|
||||||
|
minDate={watch("invoiceDate")}
|
||||||
|
/>
|
||||||
|
{errors.exceptedPaymentDate && (
|
||||||
|
<small className="danger-text">
|
||||||
|
{errors.exceptedPaymentDate.message}
|
||||||
|
</small>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<div className="col-12 col-md-6 mb-2">
|
||||||
|
<Label required>Submission Date (Client)</Label>
|
||||||
|
<DatePicker
|
||||||
|
name="clientSubmitedDate"
|
||||||
|
control={control}
|
||||||
|
maxDate={new Date()}
|
||||||
|
/>
|
||||||
|
{errors.exceptedPaymentDate && (
|
||||||
|
<small className="danger-text">
|
||||||
|
{errors.exceptedPaymentDate.message}
|
||||||
|
</small>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="col-12 col-md-6 mb-2">
|
||||||
|
<Label htmlFor="basicAmount" className="form-label" required>
|
||||||
|
Basic Amount
|
||||||
|
</Label>
|
||||||
|
<input
|
||||||
|
type="number"
|
||||||
|
id="basicAmount"
|
||||||
|
className="form-control form-control-sm"
|
||||||
|
min="1"
|
||||||
|
step="0.01"
|
||||||
|
inputMode="decimal"
|
||||||
|
{...register("basicAmount", { valueAsNumber: true })}
|
||||||
|
/>
|
||||||
|
{errors.basicAmount && (
|
||||||
|
<small className="danger-text">
|
||||||
|
{errors.basicAmount.message}
|
||||||
|
</small>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<div className="col-12 col-md-6 mb-2">
|
||||||
|
<Label htmlFor="taxAmount" className="form-label" required>
|
||||||
|
Tax Amount
|
||||||
|
</Label>
|
||||||
|
<input
|
||||||
|
type="number"
|
||||||
|
id="taxAmount"
|
||||||
|
className="form-control form-control-sm"
|
||||||
|
min="1"
|
||||||
|
step="0.01"
|
||||||
|
inputMode="decimal"
|
||||||
|
{...register("taxAmount", { valueAsNumber: true })}
|
||||||
|
/>
|
||||||
|
{errors.taxAmount && (
|
||||||
|
<small className="danger-text">
|
||||||
|
{errors.taxAmount.message}
|
||||||
|
</small>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<div className="col-12 my-2 text-start mb-2">
|
||||||
|
<div className="col-md-12">
|
||||||
|
<Label htmlFor="description" className="form-label" required>
|
||||||
|
Description
|
||||||
|
</Label>
|
||||||
|
<textarea
|
||||||
|
id="description"
|
||||||
|
className="form-control form-control-sm"
|
||||||
|
{...register("description")}
|
||||||
|
rows="2"
|
||||||
|
></textarea>
|
||||||
|
{errors.description && (
|
||||||
|
<small className="danger-text">
|
||||||
|
{errors.description.message}
|
||||||
|
</small>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="col-12">
|
||||||
|
<Label className="form-label" required>
|
||||||
|
Upload Bill{" "}
|
||||||
|
</Label>
|
||||||
|
|
||||||
|
<div
|
||||||
|
className="border border-secondary border-dashed rounded p-4 text-center bg-textMuted position-relative text-black"
|
||||||
|
style={{ cursor: "pointer" }}
|
||||||
|
onClick={() => document.getElementById("attachments").click()}
|
||||||
|
>
|
||||||
|
<i className="bx bx-cloud-upload d-block bx-lg "> </i>
|
||||||
|
<span className="text-muted d-block">
|
||||||
|
Click to select or click here to browse
|
||||||
|
</span>
|
||||||
|
<small className="text-muted">
|
||||||
|
(PDF, JPG, PNG,Doc,docx,xls,xlsx max 5MB)
|
||||||
|
</small>
|
||||||
|
|
||||||
|
<input
|
||||||
|
type="file"
|
||||||
|
id="attachments"
|
||||||
|
accept="
|
||||||
|
.pdf,
|
||||||
|
.doc,
|
||||||
|
.docx,
|
||||||
|
.xls,
|
||||||
|
.xlsx,
|
||||||
|
.jpg,
|
||||||
|
.jpeg,
|
||||||
|
.png
|
||||||
|
"
|
||||||
|
multiple
|
||||||
|
style={{ display: "none" }}
|
||||||
|
{...register("attachments")}
|
||||||
|
onChange={(e) => {
|
||||||
|
onFileChange(e);
|
||||||
|
e.target.value = "";
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
{errors.attachments && (
|
||||||
|
<small className="danger-text">
|
||||||
|
{errors.attachments.message}
|
||||||
|
</small>
|
||||||
|
)}
|
||||||
|
{files.length > 0 && (
|
||||||
|
<div className="d-block">
|
||||||
|
{files
|
||||||
|
.filter((file) => {
|
||||||
|
if (collectionId) {
|
||||||
|
return file.isActive;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
})
|
||||||
|
.map((file, idx) => (
|
||||||
|
<a
|
||||||
|
key={idx}
|
||||||
|
className="d-flex justify-content-between text-start p-1"
|
||||||
|
href={file.preSignedUrl || "#"}
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
>
|
||||||
|
<div>
|
||||||
|
<span className="mb-0 text-secondary small d-block">
|
||||||
|
{file.fileName}
|
||||||
|
</span>
|
||||||
|
<span className="text-body-secondary small d-block">
|
||||||
|
{file.fileSize ? formatFileSize(file.fileSize) : ""}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<i
|
||||||
|
className="bx bx-trash bx-sm cursor-pointer text-danger"
|
||||||
|
onClick={(e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
removeFile(collectionId ? file.documentId : idx);
|
||||||
|
}}
|
||||||
|
></i>
|
||||||
|
</a>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{Array.isArray(errors.attachments) &&
|
||||||
|
errors.attachments.map((fileError, index) => (
|
||||||
|
<div key={index} className="danger-text small mt-1">
|
||||||
|
{
|
||||||
|
(fileError?.fileSize?.message ||
|
||||||
|
fileError?.contentType?.message ||
|
||||||
|
fileError?.base64Data?.message,
|
||||||
|
fileError?.documentId?.message)
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="d-flex justify-content-end gap-3">
|
||||||
|
{" "}
|
||||||
|
<button
|
||||||
|
type="reset"
|
||||||
|
className="btn btn-label-secondary btn-sm mt-3"
|
||||||
|
onClick={handleClose}
|
||||||
|
disabled={isPending}
|
||||||
|
>
|
||||||
|
Cancel
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="submit"
|
||||||
|
className="btn btn-primary btn-sm mt-3"
|
||||||
|
disabled={isPending}
|
||||||
|
>
|
||||||
|
{isPending ? "Please Wait..." : "Submit"}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</FormProvider>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ManageCollection;
|
||||||
53
src/components/collections/PaymentHistoryTable.jsx
Normal file
53
src/components/collections/PaymentHistoryTable.jsx
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
import React from 'react'
|
||||||
|
import { formatUTCToLocalTime } from '../../utils/dateUtils'
|
||||||
|
import { formatFigure } from '../../utils/appUtils'
|
||||||
|
import Avatar from '../common/Avatar'
|
||||||
|
|
||||||
|
const PaymentHistoryTable = ({data}) => {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
|
||||||
|
{data?.receivedInvoicePayments?.length > 0 ? (
|
||||||
|
<div className="pt-1 data-tabe table-responsive">
|
||||||
|
<table className="table table-bordered table-responsive mt-2">
|
||||||
|
<thead className="table-light">
|
||||||
|
<tr>
|
||||||
|
<th className="text-center">Sr.No</th>
|
||||||
|
<th className="text-center">Transaction ID</th>
|
||||||
|
<th className="text-center"> Received Date</th>
|
||||||
|
<th className="text-center"> Payment Adjustment-Head</th>
|
||||||
|
<th className="text-center">Amount</th>
|
||||||
|
<th className="text-center">Updated By</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{data.receivedInvoicePayments.map((payment, index) => (
|
||||||
|
<tr key={payment.id}>
|
||||||
|
<td className="text-center">{index + 1}</td>
|
||||||
|
<td ><span className="mx-2">{payment.transactionId}</span></td>
|
||||||
|
<td className="text-center">{formatUTCToLocalTime(payment.paymentReceivedDate)}</td>
|
||||||
|
<td className="text-start">{payment?.paymentAdjustmentHead?.name ?? "--"}</td>
|
||||||
|
<td className="text-end">
|
||||||
|
<span className="px-1">{formatFigure(payment.amount, {
|
||||||
|
type: "currency",
|
||||||
|
currency: "INR",
|
||||||
|
})}</span>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div className="d-flex align-items-center mx-2 py-1">
|
||||||
|
|
||||||
|
{payment.createdBy?.firstName}{" "}
|
||||||
|
{payment.createdBy?.lastName}
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
))}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
):(<div className='text-center py-2'><p>No History</p></div>)}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default PaymentHistoryTable
|
||||||
258
src/components/collections/ViewCollection.jsx
Normal file
258
src/components/collections/ViewCollection.jsx
Normal file
@ -0,0 +1,258 @@
|
|||||||
|
import React, { useState } from "react";
|
||||||
|
import { useCollectionContext } from "../../pages/collections/CollectionPage";
|
||||||
|
import { useCollection } from "../../hooks/useCollections";
|
||||||
|
import { formatUTCToLocalTime } from "../../utils/dateUtils";
|
||||||
|
import { formatFigure, getIconByFileType } from "../../utils/appUtils";
|
||||||
|
import Avatar from "../common/Avatar";
|
||||||
|
import PaymentHistoryTable from "./PaymentHistoryTable";
|
||||||
|
import Comment from "./Comment";
|
||||||
|
import { CollectionDetailsSkeleton } from "./CollectionSkeleton";
|
||||||
|
import { useHasUserPermission } from "../../hooks/useHasUserPermission";
|
||||||
|
import { ADMIN_COLLECTION, EDIT_COLLECTION } from "../../utils/constants";
|
||||||
|
|
||||||
|
const ViewCollection = ({ onClose }) => {
|
||||||
|
const [activeTab, setActiveTab] = useState("payments");
|
||||||
|
const isAdmin = useHasUserPermission(ADMIN_COLLECTION);
|
||||||
|
const canEditCollection = useHasUserPermission(EDIT_COLLECTION);
|
||||||
|
const { viewCollection, setCollection, setDocumentView } =
|
||||||
|
useCollectionContext();
|
||||||
|
const { data, isLoading, isError, error } = useCollection(viewCollection);
|
||||||
|
|
||||||
|
const handleEdit = () => {
|
||||||
|
setCollection({ isOpen: true, invoiceId: viewCollection });
|
||||||
|
onClose();
|
||||||
|
};
|
||||||
|
|
||||||
|
if (isLoading) return <CollectionDetailsSkeleton />;
|
||||||
|
if (isError) return <div>{error.message}</div>;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="container p-3">
|
||||||
|
<p className="fs-5 fw-semibold">Collection Details</p>
|
||||||
|
<div className="row text-start ">
|
||||||
|
<div className="col-12 mb-3 d-flex justify-content-between">
|
||||||
|
<div className="d-flex">
|
||||||
|
<label
|
||||||
|
className=" me-2 mb-0 fw-semibold"
|
||||||
|
style={{ minWidth: "130px" }}
|
||||||
|
>
|
||||||
|
Project :
|
||||||
|
</label>
|
||||||
|
<div className="text-muted">{data?.project?.name}</div>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
{" "}
|
||||||
|
<span
|
||||||
|
className={`badge bg-label-${
|
||||||
|
data?.isActive ? "primary" : "danger"
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
{data?.isActive ? "Active" : "Inactive"}
|
||||||
|
</span>
|
||||||
|
{(isAdmin || canEditCollection) &&
|
||||||
|
!data?.receivedInvoicePayments && (
|
||||||
|
<span onClick={handleEdit} className="ms-2 cursor-pointer">
|
||||||
|
<i className="bx bx-edit text-primary bx-sm"></i>
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="col-md-6">
|
||||||
|
<div className="row mb-2 text-wrap">
|
||||||
|
<div className="col-4 fw-semibold">Title :</div>
|
||||||
|
<div className="col-8 text-wrap">{data?.title}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="col-md-6">
|
||||||
|
<div className="row mb-4 align-items-end">
|
||||||
|
<div className="col-4 fw-semibold">Invoice Number:</div>
|
||||||
|
<div className="col-8">{data?.invoiceNumber}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/* Row 2: E-Invoice Number + Project */}
|
||||||
|
<div className="col-md-6">
|
||||||
|
<div className="row mb-4 align-items-end">
|
||||||
|
<div className="col-4 fw-semibold">E-Invoice Number:</div>
|
||||||
|
<div className="col-8">{data?.eInvoiceNumber}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Row 3: Invoice Date + Client Submitted Date */}
|
||||||
|
<div className="col-md-6">
|
||||||
|
<div className="row mb-4 align-items-end">
|
||||||
|
<div className="col-4 fw-semibold">Invoice Date:</div>
|
||||||
|
<div className="col-8">
|
||||||
|
{formatUTCToLocalTime(data?.invoiceDate)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="col-md-6">
|
||||||
|
<div className="row mb-4 align-items-end">
|
||||||
|
<div className="col-4 fw-semibold">Client Submission Date:</div>
|
||||||
|
<div className="col-8">
|
||||||
|
{formatUTCToLocalTime(data?.clientSubmitedDate)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/* Row 4: Expected Payment Date + Mark as Completed */}
|
||||||
|
<div className="col-md-6">
|
||||||
|
<div className="row mb-4 align-items-end">
|
||||||
|
<div className="col-4 fw-semibold">Expected Payment Date:</div>
|
||||||
|
<div className="col-8">
|
||||||
|
{formatUTCToLocalTime(data?.exceptedPaymentDate)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Row 5: Basic Amount + Tax Amount */}
|
||||||
|
<div className="col-md-6">
|
||||||
|
<div className="row mb-4 align-items-end">
|
||||||
|
<div className="col-4 fw-semibold">Basic Amount :</div>
|
||||||
|
<div className="col-8">
|
||||||
|
{formatFigure(data?.basicAmount, {
|
||||||
|
type: "currency",
|
||||||
|
currency: "INR",
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="col-md-6">
|
||||||
|
<div className="row mb-4 align-items-end">
|
||||||
|
<div className="col-4 fw-semibold">Tax Amount :</div>
|
||||||
|
<div className="col-8">
|
||||||
|
{formatFigure(data?.taxAmount, {
|
||||||
|
type: "currency",
|
||||||
|
currency: "INR",
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/* Row 6: Balance Amount + Created At */}
|
||||||
|
<div className="col-md-6">
|
||||||
|
<div className="row mb-4 align-items-end">
|
||||||
|
<div className="col-4 fw-semibold">Balance Amount :</div>
|
||||||
|
<div className="col-8">
|
||||||
|
{formatFigure(data?.balanceAmount, {
|
||||||
|
type: "currency",
|
||||||
|
currency: "INR",
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="col-md-6">
|
||||||
|
<div className="row mb-4 align-items-end">
|
||||||
|
<div className="col-4 fw-semibold">Created At :</div>
|
||||||
|
<div className="col-8">{formatUTCToLocalTime(data?.createdAt)}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/* Row 7: Created By */}
|
||||||
|
<div className="col-md-6">
|
||||||
|
<div className="row mb-4 align-items-center">
|
||||||
|
<div className="col-4 fw-semibold">Created By :</div>
|
||||||
|
<div className="col-8 d-flex align-items-center">
|
||||||
|
<Avatar
|
||||||
|
size="xs"
|
||||||
|
firstName={data.createdBy?.firstName}
|
||||||
|
lastName={data.createdBy?.lastName}
|
||||||
|
/>
|
||||||
|
<span className="ms-1 text-muted">
|
||||||
|
{data?.createdBy?.firstName} {data?.createdBy?.lastName}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/* Description */}
|
||||||
|
<div className="col-12 my-1 mb-2">
|
||||||
|
<div className=" me-2 mb-0 fw-semibold">Description :</div>
|
||||||
|
<div className="text-muted">{data?.description}</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="col-12 text-start">
|
||||||
|
<label className=" me-2 mb-2 fw-semibold">Attachment :</label>
|
||||||
|
|
||||||
|
<div className="d-flex flex-wrap gap-2">
|
||||||
|
{data?.attachments?.map((doc) => {
|
||||||
|
const isImage = doc.contentType?.includes("image");
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
key={doc.documentId}
|
||||||
|
className="border rounded hover-scale p-2 d-flex flex-column align-items-center"
|
||||||
|
style={{
|
||||||
|
width: "80px",
|
||||||
|
cursor: isImage ? "pointer" : "default",
|
||||||
|
}}
|
||||||
|
onClick={() => {
|
||||||
|
if (isImage) {
|
||||||
|
setDocumentView({
|
||||||
|
IsOpen: true,
|
||||||
|
Image: doc.preSignedUrl,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<i
|
||||||
|
className={`bx ${getIconByFileType(doc.contentType)}`}
|
||||||
|
style={{ fontSize: "30px" }}
|
||||||
|
></i>
|
||||||
|
<small
|
||||||
|
className="text-center text-tiny text-truncate w-100"
|
||||||
|
title={doc.fileName}
|
||||||
|
>
|
||||||
|
{doc.fileName}
|
||||||
|
</small>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}) ?? "No Attachment"}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="container px-1">
|
||||||
|
{/* Tabs Navigation */}
|
||||||
|
<ul className="nav nav-tabs" role="tablist">
|
||||||
|
<li className="nav-item">
|
||||||
|
<button
|
||||||
|
className={`nav-link ${
|
||||||
|
activeTab === "payments" ? "active" : ""
|
||||||
|
}`}
|
||||||
|
onClick={() => setActiveTab("payments")}
|
||||||
|
type="button"
|
||||||
|
>
|
||||||
|
<i className="bx bx-history bx-sm me-1"></i> Payments History
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
<li className="nav-item">
|
||||||
|
<button
|
||||||
|
className={`nav-link ${
|
||||||
|
activeTab === "details" ? "active" : ""
|
||||||
|
}`}
|
||||||
|
onClick={() => setActiveTab("details")}
|
||||||
|
type="button"
|
||||||
|
>
|
||||||
|
<i className="bx bx-message-dots bx-sm me-2"></i> Comments (
|
||||||
|
{data?.comments?.length ?? "0"})
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
{/* Tab Content */}
|
||||||
|
<div className="tab-content px-1 py-0 border-top-0">
|
||||||
|
{activeTab === "payments" && (
|
||||||
|
<div className="tab-pane fade show active">
|
||||||
|
<PaymentHistoryTable data={data} />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{activeTab === "details" && (
|
||||||
|
<div className="tab-pane fade show active">
|
||||||
|
<Comment invoice={data} />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ViewCollection;
|
||||||
101
src/components/collections/collectionSchema.jsx
Normal file
101
src/components/collections/collectionSchema.jsx
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
import { z } from "zod";
|
||||||
|
|
||||||
|
const MAX_FILE_SIZE = 5 * 1024 * 1024; // 5MB
|
||||||
|
const ALLOWED_TYPES = [
|
||||||
|
"application/pdf",
|
||||||
|
"application/doc",
|
||||||
|
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
||||||
|
"image/png",
|
||||||
|
"image/jpg",
|
||||||
|
"image/jpeg",
|
||||||
|
"application/vnd.ms-excel",
|
||||||
|
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
export const newCollection = z.object({
|
||||||
|
title: z.string().trim().min(1, { message: "Title is required" }),
|
||||||
|
projectId: z.string().trim().min(1, { message: "Project is required" }),
|
||||||
|
invoiceDate: z.string().min(1, { message: "Date is required" }),
|
||||||
|
description: z.string().trim().optional(),
|
||||||
|
clientSubmitedDate: z.string().min(1, { message: "Date is required" }),
|
||||||
|
exceptedPaymentDate: z.string().min(1, { message: "Date is required" }),
|
||||||
|
invoiceNumber: z
|
||||||
|
.string()
|
||||||
|
.trim()
|
||||||
|
.min(1, { message: "Invoice is required" })
|
||||||
|
.max(17, { message: "Invalid Number" }),
|
||||||
|
eInvoiceNumber: z
|
||||||
|
.string()
|
||||||
|
.trim()
|
||||||
|
.min(1, { message: "E-Invoice No is required" }),
|
||||||
|
taxAmount: z.coerce
|
||||||
|
.number({
|
||||||
|
invalid_type_error: "Amount is required and must be a number",
|
||||||
|
})
|
||||||
|
.min(1, "Amount must be Enter")
|
||||||
|
.refine((val) => /^\d+(\.\d{1,2})?$/.test(val.toString()), {
|
||||||
|
message: "Amount must have at most 2 decimal places",
|
||||||
|
}),
|
||||||
|
basicAmount: z.coerce
|
||||||
|
.number({
|
||||||
|
invalid_type_error: "Amount is required and must be a number",
|
||||||
|
})
|
||||||
|
.min(1, "Amount must be Enter")
|
||||||
|
.refine((val) => /^\d+(\.\d{1,2})?$/.test(val.toString()), {
|
||||||
|
message: "Amount must have at most 2 decimal places",
|
||||||
|
}),
|
||||||
|
attachments: z
|
||||||
|
.array(
|
||||||
|
z.object({
|
||||||
|
fileName: z.string().min(1, { message: "Filename is required" }),
|
||||||
|
base64Data: z.string().nullable(),
|
||||||
|
contentType: z.string().refine((val) => ALLOWED_TYPES.includes(val), {
|
||||||
|
message: "Only PDF, PNG, JPG, or JPEG files are allowed",
|
||||||
|
}),
|
||||||
|
documentId: z.string().optional(),
|
||||||
|
fileSize: z.number().max(MAX_FILE_SIZE, {
|
||||||
|
message: "File size must be less than or equal to 5MB",
|
||||||
|
}),
|
||||||
|
description: z.string().optional(),
|
||||||
|
isActive: z.boolean().default(true),
|
||||||
|
})
|
||||||
|
)
|
||||||
|
.nonempty({ message: "At least one file attachment is required" }),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const defaultCollection = {
|
||||||
|
projectId: "",
|
||||||
|
invoiceNumber: " ",
|
||||||
|
eInvoiceNumber: "",
|
||||||
|
title: "",
|
||||||
|
clientSubmitedDate: null,
|
||||||
|
invoiceDate: null,
|
||||||
|
exceptedPaymentDate: null,
|
||||||
|
taxAmount: "",
|
||||||
|
basicAmount: "",
|
||||||
|
description: "",
|
||||||
|
attachments: [],
|
||||||
|
};
|
||||||
|
|
||||||
|
export const paymentSchema = z.object({
|
||||||
|
paymentReceivedDate: z.string().min(1, { message: "Date is required" }),
|
||||||
|
transactionId: z.string().min(1, "Transaction ID is required"),
|
||||||
|
amount: z.number().min(1, "Amount must be greater than zero"),
|
||||||
|
comment:z.string().min(1,{message:"Comment required"}),
|
||||||
|
paymentAdjustmentHeadId:z.string().min(1,{message:"Payment Type required"})
|
||||||
|
});
|
||||||
|
|
||||||
|
// Default Value
|
||||||
|
export const defaultPayment = {
|
||||||
|
paymentReceivedDate: null,
|
||||||
|
transactionId: "",
|
||||||
|
amount: 0,
|
||||||
|
comment:"",
|
||||||
|
paymentAdjustmentHeadId:""
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
export const CommentSchema = z.object({
|
||||||
|
comment:z.string().min(1,{message:"Comment required"})
|
||||||
|
})
|
||||||
22
src/components/common/AccessDenied.jsx
Normal file
22
src/components/common/AccessDenied.jsx
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
import React from "react";
|
||||||
|
import Breadcrumb from "./Breadcrumb";
|
||||||
|
|
||||||
|
const AccessDenied = ({data}) => {
|
||||||
|
return (
|
||||||
|
<div className="container-fluid">
|
||||||
|
<Breadcrumb
|
||||||
|
data={data}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<div className="card text-center py-1">
|
||||||
|
<i className="fa-solid fa-triangle-exclamation fs-5" />
|
||||||
|
<p>
|
||||||
|
Access Denied: You don't have permission to perform this action !
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default AccessDenied;
|
||||||
@ -51,7 +51,7 @@ const Avatar = ({ firstName, lastName, size = "sm", classAvatar }) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="avatar-wrapper p-1">
|
<div className="avatar-wrapper p-1">
|
||||||
<div className={`avatar avatar-${size} me-2 ${classAvatar}`}>
|
<div className={`avatar avatar-${size} ${classAvatar}`}>
|
||||||
<span className={`avatar-initial rounded-circle ${bgClass}`}>
|
<span className={`avatar-initial rounded-circle ${bgClass}`}>
|
||||||
{generateAvatarText(firstName, lastName)}
|
{generateAvatarText(firstName, lastName)}
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
@ -13,19 +13,18 @@ const ConfirmModal = ({
|
|||||||
if (!isOpen) return null;
|
if (!isOpen) return null;
|
||||||
|
|
||||||
const TypeofIcon = () => {
|
const TypeofIcon = () => {
|
||||||
if (type === "delete") {
|
switch (type) {
|
||||||
return (
|
case "delete":
|
||||||
<i
|
return <i className="bx bx-x-circle text-danger" style={{ fontSize: "60px" }}></i>;
|
||||||
className="bx bx-x-circle text-danger"
|
case "success":
|
||||||
style={{ fontSize: "60px" }}
|
return <i className="bx bx-check-circle text-success" style={{ fontSize: "60px" }}></i>;
|
||||||
></i>
|
case "warning":
|
||||||
);
|
return <i className="bx bx-error-circle text-warning" style={{ fontSize: "60px" }}></i>;
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const modalSize = type === "delete" ? "sm" : "md";
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className="modal fade show"
|
className="modal fade show"
|
||||||
@ -33,22 +32,24 @@ const ConfirmModal = ({
|
|||||||
role="dialog"
|
role="dialog"
|
||||||
aria-modal="true"
|
aria-modal="true"
|
||||||
>
|
>
|
||||||
<div className={`modal-dialog modal-${modalSize} modal-dialog-top`}>
|
<div className="modal-dialog modal-sm modal-dialog-top">
|
||||||
<div className="modal-content">
|
<div className="modal-content">
|
||||||
<div className="modal-body py-1 px-2">
|
<div className="modal-body py-1 px-2">
|
||||||
<div className="d-flex justify-content-between mb-4 pt-2">
|
<div className="d-flex justify-content-between mb-4 pt-2">
|
||||||
{header && <strong className="mb-0">{header}</strong>}
|
{header && <strong className="mb-0">{header}</strong>}
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className="btn-close "
|
className="btn-close"
|
||||||
aria-label="Close"
|
aria-label="Close"
|
||||||
onClick={onClose}
|
onClick={onClose}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="row">
|
<div className="row">
|
||||||
<div className="col-4 col-sm-2">{TypeofIcon()}</div>
|
<div className="col-4 col-sm-3 d-flex justify-content-center align-items-start">
|
||||||
<div className="col-8 col-sm-10 py-sm-2 py-1 text-sm-start">
|
{TypeofIcon()}
|
||||||
|
</div>
|
||||||
|
<div className="col-8 col-sm-9 py-sm-2 py-1 text-sm-start">
|
||||||
<span className="fs-6">{message}</span>
|
<span className="fs-6">{message}</span>
|
||||||
<div className="d-flex justify-content-end mt-4">
|
<div className="d-flex justify-content-end mt-4">
|
||||||
<button
|
<button
|
||||||
@ -59,7 +60,7 @@ const ConfirmModal = ({
|
|||||||
{loading ? "Please Wait..." : "Yes"}
|
{loading ? "Please Wait..." : "Yes"}
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
className="btn btn-secondary ms-4 btn-sm"
|
className="btn btn-secondary ms-3 btn-sm"
|
||||||
onClick={onClose}
|
onClick={onClose}
|
||||||
disabled={loading}
|
disabled={loading}
|
||||||
>
|
>
|
||||||
@ -68,6 +69,7 @@ const ConfirmModal = ({
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user