From df574da9bdfdf3a600a59c888e3fa88abc534984 Mon Sep 17 00:00:00 2001 From: Uday Sagar Date: Sat, 9 Mar 2024 03:58:05 +0530 Subject: [PATCH 01/25] added new package --- package-lock.json | 97 ++++++++++++++++++++++++++++++++++++++++++++++- package.json | 3 +- 2 files changed, 98 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 497be83b96f..032a9820a5d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -60,7 +60,8 @@ "rehype-raw": "^6.1.1", "rescript-webapi": "^0.8.0", "use-keyboard-shortcut": "^1.1.6", - "uuid": "^9.0.1" + "uuid": "^9.0.1", + "xlsx": "^0.18.5" }, "devDependencies": { "@storybook/addon-essentials": "^7.6.16", @@ -7183,6 +7184,14 @@ "node": ">= 10.0.0" } }, + "node_modules/adler-32": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/adler-32/-/adler-32-1.3.1.tgz", + "integrity": "sha512-ynZ4w/nUUv5rrsR8UUGoe1VC9hZj6V5hU9Qw1HlMDJGEJw5S7TfTErWTjMys6M7vr0YWcPqs3qAr4ss0nDfP+A==", + "engines": { + "node": ">=0.8" + } + }, "node_modules/agent-base": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", @@ -8208,6 +8217,18 @@ "url": "https://github.com/sponsors/wooorm" } }, + "node_modules/cfb": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/cfb/-/cfb-1.2.2.tgz", + "integrity": "sha512-KfdUZsSOw19/ObEWasvBP/Ac4reZvAGauZhs6S/gqNhXhI7cKwvlH7ulj+dOEYnca4bm4SGo8C1bTAQvnTjgQA==", + "dependencies": { + "adler-32": "~1.3.0", + "crc-32": "~1.2.0" + }, + "engines": { + "node": ">=0.8" + } + }, "node_modules/chainsaw": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/chainsaw/-/chainsaw-0.1.0.tgz", @@ -8510,6 +8531,14 @@ "node": ">=6" } }, + "node_modules/codepage": { + "version": "1.15.0", + "resolved": "https://registry.npmjs.org/codepage/-/codepage-1.15.0.tgz", + "integrity": "sha512-3g6NUTPd/YtuuGrhMnOMRjFc+LJw/bnMp3+0r/Wcz3IXUuCosKRJvMphm5+Q+bvTVGcJJuRvVLuYba+WojaFaA==", + "engines": { + "node": ">=0.8" + } + }, "node_modules/color-convert": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", @@ -8792,6 +8821,17 @@ "js-yaml": "bin/js-yaml.js" } }, + "node_modules/crc-32": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/crc-32/-/crc-32-1.2.2.tgz", + "integrity": "sha512-ROmzCKrTnOwybPcJApAA6WBWij23HVfGVNKqqrZpuyZOHqK2CwHSvpGuyt/UNNvaIjEd8X5IFGp4Mh+Ie1IHJQ==", + "bin": { + "crc32": "bin/crc32.njs" + }, + "engines": { + "node": ">=0.8" + } + }, "node_modules/cross-env": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/cross-env/-/cross-env-7.0.3.tgz", @@ -12881,6 +12921,14 @@ "node": ">= 0.6" } }, + "node_modules/frac": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/frac/-/frac-1.1.2.tgz", + "integrity": "sha512-w/XBfkibaTl3YDqASwfDUqkna4Z2p9cFSr1aHDt0WoMTECnRfBOv2WArlZILlqgWlmdIlALXGpM2AOhEk5W3IA==", + "engines": { + "node": ">=0.8" + } + }, "node_modules/fraction.js": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/fraction.js/-/fraction.js-4.2.0.tgz", @@ -22165,6 +22213,17 @@ "integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==", "dev": true }, + "node_modules/ssf": { + "version": "0.11.2", + "resolved": "https://registry.npmjs.org/ssf/-/ssf-0.11.2.tgz", + "integrity": "sha512-+idbmIXoYET47hH+d7dfm2epdOMUDjqcB4648sTZ+t2JwoyBFL/insLfB/racrDmsKB3diwsDA696pZMieAC5g==", + "dependencies": { + "frac": "~1.1.2" + }, + "engines": { + "node": ">=0.8" + } + }, "node_modules/sshpk": { "version": "1.17.0", "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.17.0.tgz", @@ -25379,6 +25438,22 @@ "string-width": "^1.0.2 || 2 || 3 || 4" } }, + "node_modules/wmf": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wmf/-/wmf-1.0.2.tgz", + "integrity": "sha512-/p9K7bEh0Dj6WbXg4JG0xvLQmIadrner1bi45VMJTfnbVHsc7yIajZyoSoK60/dtVBs12Fm6WkUI5/3WAVsNMw==", + "engines": { + "node": ">=0.8" + } + }, + "node_modules/word": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/word/-/word-0.3.0.tgz", + "integrity": "sha512-OELeY0Q61OXpdUfTp+oweA/vtLVg5VDOXh+3he3PNzLGG/y0oylSOC1xRVj0+l4vQ3tj/bB1HVHv1ocXkQceFA==", + "engines": { + "node": ">=0.8" + } + }, "node_modules/wordwrap": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", @@ -25841,6 +25916,26 @@ } } }, + "node_modules/xlsx": { + "version": "0.18.5", + "resolved": "https://registry.npmjs.org/xlsx/-/xlsx-0.18.5.tgz", + "integrity": "sha512-dmg3LCjBPHZnQp5/F/+nnTa+miPJxUXB6vtk42YjBBKayDNagxGEeIdWApkYPOf3Z3pm3k62Knjzp7lMeTEtFQ==", + "dependencies": { + "adler-32": "~1.3.0", + "cfb": "~1.2.1", + "codepage": "~1.15.0", + "crc-32": "~1.2.1", + "ssf": "~0.11.2", + "wmf": "~1.0.1", + "word": "~0.3.0" + }, + "bin": { + "xlsx": "bin/xlsx.njs" + }, + "engines": { + "node": ">=0.8" + } + }, "node_modules/xtend": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", diff --git a/package.json b/package.json index 7c5ab561332..9efe1ba09c7 100644 --- a/package.json +++ b/package.json @@ -100,7 +100,8 @@ "rehype-raw": "^6.1.1", "rescript-webapi": "^0.8.0", "use-keyboard-shortcut": "^1.1.6", - "uuid": "^9.0.1" + "uuid": "^9.0.1", + "xlsx": "^0.18.5" }, "devDependencies": { "@storybook/addon-essentials": "^7.6.16", From dc13d217a13faffb56b254d02555c86976fba45f Mon Sep 17 00:00:00 2001 From: Uday Sagar Date: Sat, 9 Mar 2024 04:01:07 +0530 Subject: [PATCH 02/25] removed 2 packages --- package-lock.json | 274 ++++------------------------------------------ package.json | 2 - 2 files changed, 19 insertions(+), 257 deletions(-) diff --git a/package-lock.json b/package-lock.json index 032a9820a5d..cf12b803136 100644 --- a/package-lock.json +++ b/package-lock.json @@ -39,7 +39,6 @@ "raviger": "^4.1.2", "react": "18.2.0", "react-copy-to-clipboard": "^5.1.0", - "react-csv-reader": "^4.0.0", "react-dnd": "^16.0.1", "react-dnd-html5-backend": "^16.0.1", "react-dnd-scrolling": "^1.3.3", @@ -54,7 +53,6 @@ "react-redux": "^8.1.1", "react-transition-group": "^4.4.5", "react-webcam": "^7.1.1", - "read-excel-file": "^5.6.1", "redux": "^4.2.1", "redux-thunk": "^2.4.2", "rehype-raw": "^6.1.1", @@ -7061,14 +7059,6 @@ "node": ">=12" } }, - "node_modules/@xmldom/xmldom": { - "version": "0.8.10", - "resolved": "https://registry.npmjs.org/@xmldom/xmldom/-/xmldom-0.8.10.tgz", - "integrity": "sha512-2WALfTl4xo2SkGCYRt6rDTFfk9R1czmBvUQy12gK2KuRKIpWEhcbbzy8EZXtz/jkRqHX8bFEc6FC1HjX4TUWYw==", - "engines": { - "node": ">=10.0.0" - } - }, "node_modules/@yaireo/ui-range": { "version": "2.1.15", "resolved": "https://registry.npmjs.org/@yaireo/ui-range/-/ui-range-2.1.15.tgz", @@ -7833,22 +7823,11 @@ "version": "1.6.51", "resolved": "https://registry.npmjs.org/big-integer/-/big-integer-1.6.51.tgz", "integrity": "sha512-GPEid2Y9QU1Exl1rpO9B2IPJGHPSupF5GnVIP0blYvNOMer2bTvSWs1jGOUg04hTmu67nmLsQ9TBo1puaotBHg==", + "dev": true, "engines": { "node": ">=0.6" } }, - "node_modules/binary": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/binary/-/binary-0.3.0.tgz", - "integrity": "sha512-D4H1y5KYwpJgK8wk1Cue5LLPgmwHKYSChkbspQg5JtVuR5ulGckxfR62H3AE9UDkdMC8yyXlqYihuz3Aqg2XZg==", - "dependencies": { - "buffers": "~0.1.1", - "chainsaw": "~0.1.0" - }, - "engines": { - "node": "*" - } - }, "node_modules/binary-extensions": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", @@ -7957,6 +7936,7 @@ "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "devOptional": true, "dependencies": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -8076,22 +8056,6 @@ "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==" }, - "node_modules/buffer-indexof-polyfill": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/buffer-indexof-polyfill/-/buffer-indexof-polyfill-1.0.2.tgz", - "integrity": "sha512-I7wzHwA3t1/lwXQh+A5PbNvJxgfo5r3xulgpYDB5zckTu/Z9oUK9biouBKQUjEqzaz3HnAT6TYoovmE+GqSf7A==", - "engines": { - "node": ">=0.10" - } - }, - "node_modules/buffers": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/buffers/-/buffers-0.1.1.tgz", - "integrity": "sha512-9q/rDEGSb/Qsvv2qvzIzdluL5k7AaJOTrw23z9reQthrbF7is4CtlT0DXyO1oei2DCp4uojjzQ7igaSHp1kAEQ==", - "engines": { - "node": ">=0.2.0" - } - }, "node_modules/builtin-modules": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.3.0.tgz", @@ -8229,17 +8193,6 @@ "node": ">=0.8" } }, - "node_modules/chainsaw": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/chainsaw/-/chainsaw-0.1.0.tgz", - "integrity": "sha512-75kWfWt6MEKNC8xYXIdRpDehRYY/tNSgwKaJq+dbbDcxORuVrrQ+SEHoWsniVn9XPYfP4gmdWIeDk/4YNp1rNQ==", - "dependencies": { - "traverse": ">=0.3.0 <0.4" - }, - "engines": { - "node": "*" - } - }, "node_modules/chalk": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", @@ -8677,7 +8630,8 @@ "node_modules/concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==" + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", + "devOptional": true }, "node_modules/concat-stream": { "version": "2.0.0", @@ -8786,7 +8740,8 @@ "node_modules/core-util-is": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "integrity": "sha512-3lqz5YjWTYnW6dlDa5TLaTCcShfar1e40rmcJVwCBJC6mWlFuj0eCHIElmG1g5kyuJ/GD+8Wn4FFCcz4gJPfaQ==" + "integrity": "sha512-3lqz5YjWTYnW6dlDa5TLaTCcShfar1e40rmcJVwCBJC6mWlFuj0eCHIElmG1g5kyuJ/GD+8Wn4FFCcz4gJPfaQ==", + "dev": true }, "node_modules/cosmiconfig": { "version": "8.2.0", @@ -9665,46 +9620,6 @@ "node": ">=12" } }, - "node_modules/duplexer2": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.1.4.tgz", - "integrity": "sha512-asLFVfWWtJ90ZyOUHMqk7/S2w2guQKxUI2itj3d92ADHhxUSbCMGi1f1cBcJ7xM1To+pE/Khbwo1yuNbMEPKeA==", - "dependencies": { - "readable-stream": "^2.0.2" - } - }, - "node_modules/duplexer2/node_modules/isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==" - }, - "node_modules/duplexer2/node_modules/readable-stream": { - "version": "2.3.8", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.8.tgz", - "integrity": "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==", - "dependencies": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - }, - "node_modules/duplexer2/node_modules/safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" - }, - "node_modules/duplexer2/node_modules/string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "dependencies": { - "safe-buffer": "~5.1.0" - } - }, "node_modules/duplexify": { "version": "3.7.1", "resolved": "https://registry.npmjs.org/duplexify/-/duplexify-3.7.1.tgz", @@ -12475,11 +12390,6 @@ "integrity": "sha512-3yurQZ2hD9VISAhJJP9bpYFNQrHHBXE2JxxjY5aLEcDi46RmAzJE2OC9FAde0yis5ElW0jTTzs0zfg/Cca4XqQ==", "dev": true }, - "node_modules/fflate": { - "version": "0.7.4", - "resolved": "https://registry.npmjs.org/fflate/-/fflate-0.7.4.tgz", - "integrity": "sha512-5u2V/CDW15QM1XbbgS+0DfPxVB+jUKhWEKuuFuHncbk3tEEqzmoXL+2KyOFuKGqOnmdIy0/davWF1CkuwtibCw==" - }, "node_modules/figures": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/figures/-/figures-3.2.0.tgz", @@ -13004,7 +12914,8 @@ "node_modules/fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==" + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", + "devOptional": true }, "node_modules/fsevents": { "version": "2.3.3", @@ -13020,61 +12931,6 @@ "node": "^8.16.0 || ^10.6.0 || >=11.0.0" } }, - "node_modules/fstream": { - "version": "1.0.12", - "resolved": "https://registry.npmjs.org/fstream/-/fstream-1.0.12.tgz", - "integrity": "sha512-WvJ193OHa0GHPEL+AycEJgxvBEwyfRkN1vhjca23OaPVMCaLCXTd5qAu82AjTcgP1UJmytkOKb63Ypde7raDIg==", - "dependencies": { - "graceful-fs": "^4.1.2", - "inherits": "~2.0.0", - "mkdirp": ">=0.5 0", - "rimraf": "2" - }, - "engines": { - "node": ">=0.6" - } - }, - "node_modules/fstream/node_modules/glob": { - "version": "7.2.3", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", - "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", - "dependencies": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.1.1", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - }, - "engines": { - "node": "*" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/fstream/node_modules/mkdirp": { - "version": "0.5.6", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz", - "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", - "dependencies": { - "minimist": "^1.2.6" - }, - "bin": { - "mkdirp": "bin/cmd.js" - } - }, - "node_modules/fstream/node_modules/rimraf": { - "version": "2.7.1", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz", - "integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==", - "dependencies": { - "glob": "^7.1.3" - }, - "bin": { - "rimraf": "bin.js" - } - }, "node_modules/function-bind": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", @@ -13532,7 +13388,8 @@ "node_modules/graceful-fs": { "version": "4.2.11", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", - "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==" + "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==", + "dev": true }, "node_modules/graphemer": { "version": "1.4.0", @@ -14146,6 +14003,7 @@ "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", + "devOptional": true, "dependencies": { "once": "^1.3.0", "wrappy": "1" @@ -15575,11 +15433,6 @@ "url": "https://github.com/chalk/wrap-ansi?sponsor=1" } }, - "node_modules/listenercount": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/listenercount/-/listenercount-1.0.1.tgz", - "integrity": "sha512-3mk/Zag0+IJxeDrxSgaDPy4zZ3w05PRZeJNnlWhzFz5OkX49J4krc+A8X2d2M69vGMBEX0uyl8M+W+8gH+kBqQ==" - }, "node_modules/listr2": { "version": "3.14.0", "resolved": "https://registry.npmjs.org/listr2/-/listr2-3.14.0.tgz", @@ -17651,6 +17504,7 @@ "version": "3.1.2", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "devOptional": true, "dependencies": { "brace-expansion": "^1.1.7" }, @@ -17662,6 +17516,7 @@ "version": "1.2.8", "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz", "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==", + "dev": true, "funding": { "url": "https://github.com/sponsors/ljharb" } @@ -18322,6 +18177,7 @@ "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "devOptional": true, "dependencies": { "wrappy": "1" } @@ -18464,11 +18320,6 @@ "integrity": "sha512-NUcwaKxUxWrZLpDG+z/xZaCgQITkA/Dv4V/T6bw7VON6l1Xz/VnrBqrYjZQ12TamKHzITTfOEIYUj48y2KXImA==", "dev": true }, - "node_modules/papaparse": { - "version": "5.4.1", - "resolved": "https://registry.npmjs.org/papaparse/-/papaparse-5.4.1.tgz", - "integrity": "sha512-HipMsgJkZu8br23pW15uvo6sib6wne/4woLZPlFf3rpDyMe9ywEXUsuD7+6K9PRkJlVT51j/sCOYDKGGS3ZJrw==" - }, "node_modules/parent-module": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", @@ -18542,6 +18393,7 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", + "devOptional": true, "engines": { "node": ">=0.10.0" } @@ -19134,7 +18986,8 @@ "node_modules/process-nextick-args": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", - "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==" + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", + "dev": true }, "node_modules/progress": { "version": "2.0.3", @@ -19592,19 +19445,6 @@ "react": "^15.3.0 || 16 || 17 || 18" } }, - "node_modules/react-csv-reader": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/react-csv-reader/-/react-csv-reader-4.0.0.tgz", - "integrity": "sha512-NRo27kv1YWYAJAR3H5ZZ5KREEw35avUtdGr4DwYel87QN3rwJf2wdAw97swNDO3cTW2i3cuXSNjfPqVIJm5xOg==", - "dependencies": { - "papaparse": "^5.3.0" - }, - "peerDependencies": { - "prop-types": "^15.7.2", - "react": "^16.0.0 || ^17.0.0 || ^18.0.0", - "react-dom": "^16.0.0 || ^17.0.0 || ^18.0.0" - } - }, "node_modules/react-dnd": { "version": "16.0.1", "resolved": "https://registry.npmjs.org/react-dnd/-/react-dnd-16.0.1.tgz", @@ -20567,16 +20407,6 @@ "pify": "^2.3.0" } }, - "node_modules/read-excel-file": { - "version": "5.6.1", - "resolved": "https://registry.npmjs.org/read-excel-file/-/read-excel-file-5.6.1.tgz", - "integrity": "sha512-Gwms2Knx8OzAs8ggUIv9wvJJ6VGwtxkN/BmLczIzlA79ykjisAaKewdQFfrvinmyh3sfHN+ARw1R6y6szsto3g==", - "dependencies": { - "@xmldom/xmldom": "^0.8.2", - "fflate": "^0.7.3", - "unzipper": "^0.10.11" - } - }, "node_modules/read-package-json-fast": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/read-package-json-fast/-/read-package-json-fast-3.0.2.tgz", @@ -21901,11 +21731,6 @@ "node": ">= 0.4" } }, - "node_modules/setimmediate": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz", - "integrity": "sha512-MATJdZp8sLqDl/68LfQmbP8zKPLQNV6BIZoIgrscFDQ+RsvK/BxeDQOgyxKKoh0y/8h3BqVFnCqQ/gd+reiIXA==" - }, "node_modules/setprototypeof": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", @@ -23212,14 +23037,6 @@ "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", "devOptional": true }, - "node_modules/traverse": { - "version": "0.3.9", - "resolved": "https://registry.npmjs.org/traverse/-/traverse-0.3.9.tgz", - "integrity": "sha512-iawgk0hLP3SxGKDfnDJf8wTz4p2qImnyihM5Hh/sGvQ3K37dPi/w8sRhdNIxYA1TwFwc5mDhIJq+O0RsvXBKdQ==", - "engines": { - "node": "*" - } - }, "node_modules/trim-lines": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/trim-lines/-/trim-lines-3.0.1.tgz", @@ -24230,60 +24047,6 @@ "node": ">=8" } }, - "node_modules/unzipper": { - "version": "0.10.14", - "resolved": "https://registry.npmjs.org/unzipper/-/unzipper-0.10.14.tgz", - "integrity": "sha512-ti4wZj+0bQTiX2KmKWuwj7lhV+2n//uXEotUmGuQqrbVZSEGFMbI68+c6JCQ8aAmUWYvtHEz2A8K6wXvueR/6g==", - "dependencies": { - "big-integer": "^1.6.17", - "binary": "~0.3.0", - "bluebird": "~3.4.1", - "buffer-indexof-polyfill": "~1.0.0", - "duplexer2": "~0.1.4", - "fstream": "^1.0.12", - "graceful-fs": "^4.2.2", - "listenercount": "~1.0.1", - "readable-stream": "~2.3.6", - "setimmediate": "~1.0.4" - } - }, - "node_modules/unzipper/node_modules/bluebird": { - "version": "3.4.7", - "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.4.7.tgz", - "integrity": "sha512-iD3898SR7sWVRHbiQv+sHUtHnMvC1o3nW5rAcqnq3uOn07DSAppZYUkIGslDz6gXC7HfunPe7YVBgoEJASPcHA==" - }, - "node_modules/unzipper/node_modules/isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==" - }, - "node_modules/unzipper/node_modules/readable-stream": { - "version": "2.3.8", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.8.tgz", - "integrity": "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==", - "dependencies": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - }, - "node_modules/unzipper/node_modules/safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" - }, - "node_modules/unzipper/node_modules/string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "dependencies": { - "safe-buffer": "~5.1.0" - } - }, "node_modules/upath": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/upath/-/upath-1.2.0.tgz", @@ -25880,7 +25643,8 @@ "node_modules/wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==" + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", + "devOptional": true }, "node_modules/write-file-atomic": { "version": "4.0.2", diff --git a/package.json b/package.json index 9efe1ba09c7..7e54836df05 100644 --- a/package.json +++ b/package.json @@ -79,7 +79,6 @@ "raviger": "^4.1.2", "react": "18.2.0", "react-copy-to-clipboard": "^5.1.0", - "react-csv-reader": "^4.0.0", "react-dnd": "^16.0.1", "react-dnd-html5-backend": "^16.0.1", "react-dnd-scrolling": "^1.3.3", @@ -94,7 +93,6 @@ "react-redux": "^8.1.1", "react-transition-group": "^4.4.5", "react-webcam": "^7.1.1", - "read-excel-file": "^5.6.1", "redux": "^4.2.1", "redux-thunk": "^2.4.2", "rehype-raw": "^6.1.1", From 844a0b84a3fa31ba1c1bbf182a04de25551577c4 Mon Sep 17 00:00:00 2001 From: Uday Sagar Date: Sat, 9 Mar 2024 04:31:07 +0530 Subject: [PATCH 03/25] changed route for external result import modal --- src/Components/ExternalResult/ResultList.tsx | 10 +++++++++- src/Routers/routes/ExternalResultRoutes.tsx | 2 -- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Components/ExternalResult/ResultList.tsx b/src/Components/ExternalResult/ResultList.tsx index 88a385394aa..7e3c4fb5dc7 100644 --- a/src/Components/ExternalResult/ResultList.tsx +++ b/src/Components/ExternalResult/ResultList.tsx @@ -18,6 +18,7 @@ import useQuery from "../../Utils/request/useQuery"; import { parsePhoneNumber } from "../../Utils/utils"; import useAuthUser from "../../Common/hooks/useAuthUser"; import { NonReadOnlyUsers } from "../../Utils/AuthorizeFor"; +import ExternalResultUploadModal from "./ExternalResultUploadModal"; const Loading = lazy(() => import("../Common/Loading")); @@ -34,6 +35,7 @@ export default function ResultList() { limit: 14, cacheBlacklist: ["mobile_number", "name"], }); + const [importModalOpen, setImportModalOpen] = useState(false); const [showDialog, setShowDialog] = useState(false); const [selectedFacility, setSelectedFacility] = useState({ name: "", @@ -243,9 +245,9 @@ export default function ResultList() { ? [ { label: "Import Results", - action: () => navigate("/external_results/upload"), options: { icon: , + onClick: () => setImportModalOpen(true), }, }, ] @@ -266,6 +268,12 @@ export default function ResultList() { /> } > + {importModalOpen && ( + setImportModalOpen(false)} + /> + )}
, - "/external_results/upload": () => , "/external_results/:id": ({ id }: DetailRoute) => , "/external_results/:id/update": ({ id }: DetailRoute) => ( From b90d2ce231e6dd2e7578b83ec00179a3e1c2ce46 Mon Sep 17 00:00:00 2001 From: Uday Sagar Date: Sat, 9 Mar 2024 15:08:50 +0530 Subject: [PATCH 04/25] updated schemas --- src/Common/constants.tsx | 140 +++++++++++++++++++++++++-------------- 1 file changed, 89 insertions(+), 51 deletions(-) diff --git a/src/Common/constants.tsx b/src/Common/constants.tsx index e452ed5abb2..89fecbaf8b6 100644 --- a/src/Common/constants.tsx +++ b/src/Common/constants.tsx @@ -4,6 +4,7 @@ import { SortOption } from "../Components/Common/SortDropdown"; import { dateQueryString } from "../Utils/utils"; import { IconName } from "../CAREUI/icons/CareIcon"; import { PhoneNumberValidator } from "../Components/Form/FieldValidators"; +import { SchemaType } from "./schemaParser"; export const RESULTS_PER_PAGE_LIMIT = 14; export const PAGINATION_LIMIT = 36; @@ -894,23 +895,23 @@ export const BLACKLISTED_PATHS: RegExp[] = [ /\/facility\/([A-Za-z0-9]+(-[A-Za-z0-9]+)+)\/patient\/([A-Za-z0-9]+(-[A-Za-z0-9]+)+)\/consultation\/([A-Za-z0-9]+(-[A-Za-z0-9]+)+)\/dialysis+/i, ]; -export const XLSXAssetImportSchema = { - Name: { prop: "name", type: String }, +export const AssetImportSchema: SchemaType = { + Name: { prop: "name", type: "string" }, Type: { prop: "asset_type", - type: String, + type: "string", oneOf: ["INTERNAL", "EXTERNAL"], required: true, }, Class: { prop: "asset_class", - type: String, + type: "string", oneOf: ["HL7MONITOR", "ONVIF", "VENTILATOR", ""], }, - Description: { prop: "description", type: String }, + Description: { prop: "description", type: "string" }, "Working Status": { prop: "is_working", - type: Boolean, + type: "boolean", parse: (status: string) => { if (status === "WORKING") { return true; @@ -922,18 +923,15 @@ export const XLSXAssetImportSchema = { }, required: true, }, - "Not Working Reason": { - prop: "not_working_reason", - type: String, - }, - "Serial Number": { prop: "serial_number", type: String }, - "QR Code ID": { prop: "qr_code_id", type: String }, - Manufacturer: { prop: "manufacturer", type: String }, - "Vendor Name": { prop: "vendor_name", type: String }, - "Support Name": { prop: "support_name", type: String }, + "Not Working Reason": { prop: "not_working_reason", type: "string" }, + "Serial Number": { prop: "serial_number", type: "string" }, + "QR Code ID": { prop: "qr_code_id", type: "string" }, + Manufacturer: { prop: "manufacturer", type: "string" }, + "Vendor Name": { prop: "vendor_name", type: "string" }, + "Support Name": { prop: "support_name", type: "string" }, "Support Email": { prop: "support_email", - type: String, + type: "string", parse: (email: string) => { if (!email) return null; const isValid = /^[\w-.]+@([\w-]+\.)+[\w-]{2,4}$/.test(email); @@ -947,7 +945,7 @@ export const XLSXAssetImportSchema = { }, "Support Phone Number": { prop: "support_phone", - type: String, + type: "string", parse: (phone: number | string) => { phone = String(phone); if (phone.length === 10 && !phone.startsWith("1800")) { @@ -972,13 +970,10 @@ export const XLSXAssetImportSchema = { }, "Warranty End Date": { prop: "warranty_amc_end_of_validity", - type: String, + type: "string", parse: (date: string) => { if (!date) return null; - const parts = date.split("-"); - const reformattedDateStr = `${parts[2]}-${parts[1]}-${parts[0]}`; - const parsed = new Date(reformattedDateStr); - + const parsed = new Date(date); if (String(parsed) === "Invalid Date") { throw new Error("Invalid Warranty End Date:" + date); } @@ -988,12 +983,10 @@ export const XLSXAssetImportSchema = { }, "Last Service Date": { prop: "last_serviced_on", - type: String, + type: "string", parse: (date: string) => { if (!date) return null; - const parts = date.split("-"); - const reformattedDateStr = `${parts[2]}-${parts[1]}-${parts[0]}`; - const parsed = new Date(reformattedDateStr); + const parsed = new Date(date); if (String(parsed) === "Invalid Date") { throw new Error("Invalid Last Service Date:" + date); @@ -1002,33 +995,78 @@ export const XLSXAssetImportSchema = { return dateQueryString(parsed); }, }, - Notes: { prop: "notes", type: String }, - META: { - prop: "meta", - type: { - "Config - IP Address": { - prop: "local_ip_address", - type: String, - parse: (ip: string) => { - if (!ip) return null; - const isValid = - /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test( - ip - ); - - if (!isValid) { - throw new Error("Invalid Config IP Address: " + ip); - } - - return ip; - }, - }, - "Config - Camera Access Key": { - prop: "camera_access_key", - type: String, - }, + Notes: { prop: "notes", type: "string" }, + "Config - IP Address": { + parent: "meta", + prop: "local_ip_address", + type: "string", + parse: (ip: string) => { + if (!ip) return null; + const isValid = + /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test( + ip + ); + + if (!isValid) { + throw new Error("Invalid Config IP Address: " + ip); + } + + return ip; + }, + }, + "Config: Camera Access Key": { + parent: "meta", + prop: "camera_access_key", + type: "string", + }, +}; + +export const ExternalResultImportSchema: SchemaType = { + District: { prop: "district", type: "any" }, + "srf id": { prop: "srf_id", type: "string" }, + name: { prop: "name", type: "string" }, + age: { prop: "age", type: "number" }, + "age in": { prop: "age_in", type: "string" }, + gender: { prop: "gender", type: "string" }, + "mobile number": { prop: "mobile_number", type: "any" }, + address: { prop: "address", type: "string" }, + ward: { prop: "ward", type: "number" }, + "local body": { prop: "local_body", type: "string" }, + "local body type": { prop: "local_body_type", type: "string" }, + source: { prop: "source", type: "string" }, + "Sample Collection Date": { + prop: "sample_collection_date", + type: "string", + parse: (date: string) => { + if (!date) return null; + const parsed = new Date(date); + if (String(parsed) === "Invalid Date") { + throw new Error("Invalid Date:" + date); + } + + return dateQueryString(parsed); + }, + }, + "result date": { + prop: "result_date", + type: "string", + parse: (date: string) => { + if (!date) return null; + const parsed = new Date(date); + if (String(parsed) === "Invalid Date") { + throw new Error("Invalid Date:" + date); + } + + return dateQueryString(parsed); }, }, + "test type": { prop: "test_type", type: "string" }, + "lab name": { prop: "lab_name", type: "string" }, + "sample type": { prop: "sample_type", type: "string" }, + "patient status": { prop: "patient_status", type: "string" }, + "Is Repeat": { prop: "is_repeat", type: "string" }, + "patient category": { prop: "patient_category", type: "string" }, + result: { prop: "result", type: "string" }, }; export const USER_TYPES_MAP = { From e67c48fa75272433d2388185c1fcf2c8170b26e2 Mon Sep 17 00:00:00 2001 From: Uday Sagar Date: Sat, 9 Mar 2024 15:14:44 +0530 Subject: [PATCH 05/25] custom schema parser --- src/Common/schemaParser.ts | 144 +++++++++++++++++++++++++++++++++++++ src/Utils/utils.ts | 50 ------------- 2 files changed, 144 insertions(+), 50 deletions(-) create mode 100644 src/Common/schemaParser.ts diff --git a/src/Common/schemaParser.ts b/src/Common/schemaParser.ts new file mode 100644 index 00000000000..d4ed312eaf9 --- /dev/null +++ b/src/Common/schemaParser.ts @@ -0,0 +1,144 @@ +interface SingleKeySchema { + parent?: string; + prop: string; + type: string; + oneOf?: string[]; + required?: boolean; + parse?: (value: any) => any; +} + +export interface SchemaType { + [key: string]: SingleKeySchema; +} + +interface DataWithError { + [key: string]: { + value: any; + error?: string; + }; +} + +interface parseDataProps { + dataWithErrors: DataWithError[]; + parsedData: { [key: string]: any }[]; + errors: { index: number; key: string; error: string }[]; +} + +const validateAndParse = ( + key: string, + value: any, + schema: SingleKeySchema +): { [key: string]: { value: any; error?: string } } => { + try { + const parsedValue = schema?.parse?.(value) ?? value; + const expectedType = schema?.type; + + if ( + (parsedValue === undefined || parsedValue === null) && + !schema?.required + ) { + return { [key]: { value: parsedValue } }; + } + + if (typeof parsedValue !== expectedType && expectedType !== "any") { + return { + [key]: { + value: parsedValue, + error: `${key} should be of type ${expectedType}`, + }, + }; + } + + if (schema?.oneOf && !schema?.oneOf.includes(parsedValue)) { + return { + [key]: { + value: parsedValue, + error: `${key} should be one of the ${schema?.oneOf}`, + }, + }; + } + + if ( + schema?.required && + (parsedValue === undefined || parsedValue === null) + ) { + return { + [key]: { value: parsedValue, error: `${key} is required` }, + }; + } + + return { [key]: { value: parsedValue } }; + } catch (error) { + return { [key]: { value, error: error.message } }; + } +}; + +const parseDataWithSchema = ( + data: any[], + schema: SchemaType +): parseDataProps => { + const errors: { index: number; key: string; error: string }[] = []; + const parsedData: { [key: string]: any }[] = []; + const dataWithErrors: DataWithError[] = data.map((item, index) => { + return Object.keys(schema).reduce((acc, key) => { + const { + [key]: { value, error }, + } = validateAndParse(key, item[key], schema[key]); + const parsedRow = { [schema[key].prop]: value }; + if (error) { + errors.push({ index, key, error }); + } + const prop = schema[key].prop || key; + + if (schema[key].parent) { + const indexKey = schema[key].parent || key; + acc[indexKey] = acc[indexKey] || {}; + acc[indexKey][prop] = { value, error }; + + if (!parsedData[index]) { + parsedData[index] = {}; + } + + parsedData[index][indexKey] = { + ...(parsedData[index][indexKey] || {}), + [prop]: value, + }; + } else { + acc[prop] = { value, error }; + + if (!parsedData[index]) { + parsedData[index] = {}; + } + + parsedData[index] = { ...parsedData[index], ...parsedRow }; + } + + return acc; + }, {} as { [key: string]: any }); + }); + + return { dataWithErrors, parsedData, errors }; +}; + +const schemaParser = ( + dataArray: any[], + schema: SchemaType +): parseDataProps & { ParsedDataWithOutErrors: { [key: string]: any }[] } => { + const { dataWithErrors, parsedData, errors } = parseDataWithSchema( + dataArray, + schema + ); + + const ParsedDataWithOutErrors = parsedData.filter((item, index) => { + return !Object.values(dataWithErrors[index]).some((item) => item.error); + }); + + return { + dataWithErrors, + parsedData, + ParsedDataWithOutErrors, + errors, + }; +}; + +export default schemaParser; diff --git a/src/Utils/utils.ts b/src/Utils/utils.ts index 4e1d1626a59..a41da792457 100644 --- a/src/Utils/utils.ts +++ b/src/Utils/utils.ts @@ -164,56 +164,6 @@ export const classNames = (...classes: (string | boolean | undefined)[]) => { return classes.filter(Boolean).join(" "); }; -interface ISchema { - [key: string]: { - prop: string; - oneOf?: string[]; - parse?: (value: any) => any; - type?: any; - required?: boolean; - }; -} - -export const parseCsvFile = async ( - file: File, - schema: ISchema | undefined = undefined -) => { - const parseWithSchema: any = (schema: any, data: any) => - Object.keys(schema).reduce((acc, key) => { - if (schema[key]?.oneOf && !schema[key].oneOf.includes(data[key])) - throw new Error(`${key} should be one of the ${schema[key].oneOf}`); - - const value = - typeof schema[key]?.type === "object" - ? parseWithSchema(schema[key]?.type, data) - : schema[key]?.parse?.(data[key]) ?? data[key]; - - if (schema[key]?.required && (value === undefined || value === null)) - throw new Error(`${key} is required`); - - return value === undefined || value === null - ? acc - : { - ...acc, - [schema[key]?.prop]: value, - }; - }, {}); - - const csvData = (await file.text()) - .trim() - .split("\n") - .map((row: string) => row.split(",")); - - const parsed = csvData - .map((row: string[]) => - row.reduce((acc, val, i) => ({ ...acc, [csvData[0][i]]: val }), {}) - ) - .splice(1) - .map((csvMap: any) => (schema ? parseWithSchema(schema, csvMap) : csvMap)); - - return parsed; -}; - export const getPincodeDetails = async (pincode: string, apiKey: string) => { const response = await fetch( `https://api.data.gov.in/resource/6176ee09-3d56-4a3b-8115-21841576b2f6?api-key=${apiKey}&format=json&filters[pincode]=${pincode}&limit=1` From 96ad5399799e4a6eaf96dce51172210ada67fedf Mon Sep 17 00:00:00 2001 From: Uday Sagar Date: Sat, 9 Mar 2024 15:27:38 +0530 Subject: [PATCH 06/25] modified schema parser --- src/Common/schemaParser.ts | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/Common/schemaParser.ts b/src/Common/schemaParser.ts index d4ed312eaf9..7f16b1581aa 100644 --- a/src/Common/schemaParser.ts +++ b/src/Common/schemaParser.ts @@ -1,4 +1,4 @@ -interface SingleKeySchema { +export interface SingleKeySchema { parent?: string; prop: string; type: string; @@ -11,17 +11,27 @@ export interface SchemaType { [key: string]: SingleKeySchema; } -interface DataWithError { +export interface DataWithError { [key: string]: { value: any; error?: string; }; } +export interface ParsedData { + [key: string]: any; +} + +export interface ErrorData { + index: number; + key: string; + error: string; +} + interface parseDataProps { dataWithErrors: DataWithError[]; - parsedData: { [key: string]: any }[]; - errors: { index: number; key: string; error: string }[]; + parsedData: ParsedData[]; + errors: ErrorData[]; } const validateAndParse = ( @@ -77,8 +87,8 @@ const parseDataWithSchema = ( data: any[], schema: SchemaType ): parseDataProps => { - const errors: { index: number; key: string; error: string }[] = []; - const parsedData: { [key: string]: any }[] = []; + const errors: ErrorData[] = []; + const parsedData: ParsedData[] = []; const dataWithErrors: DataWithError[] = data.map((item, index) => { return Object.keys(schema).reduce((acc, key) => { const { @@ -114,7 +124,7 @@ const parseDataWithSchema = ( } return acc; - }, {} as { [key: string]: any }); + }, {} as ParsedData); }); return { dataWithErrors, parsedData, errors }; @@ -123,7 +133,7 @@ const parseDataWithSchema = ( const schemaParser = ( dataArray: any[], schema: SchemaType -): parseDataProps & { ParsedDataWithOutErrors: { [key: string]: any }[] } => { +): parseDataProps & { ParsedDataWithOutErrors: ParsedData[] } => { const { dataWithErrors, parsedData, errors } = parseDataWithSchema( dataArray, schema From 1f69649cd73e20359cefd061f89d3e8780917ffa Mon Sep 17 00:00:00 2001 From: Uday Sagar Date: Sat, 9 Mar 2024 15:37:22 +0530 Subject: [PATCH 07/25] added file drag and drop component --- .../Common/ExcelFIleDragAndDrop.tsx | 259 ++++++++++++++++++ 1 file changed, 259 insertions(+) create mode 100644 src/Components/Common/ExcelFIleDragAndDrop.tsx diff --git a/src/Components/Common/ExcelFIleDragAndDrop.tsx b/src/Components/Common/ExcelFIleDragAndDrop.tsx new file mode 100644 index 00000000000..ae6a77a6251 --- /dev/null +++ b/src/Components/Common/ExcelFIleDragAndDrop.tsx @@ -0,0 +1,259 @@ +import _ from "lodash-es"; +import { useEffect, useRef, useState } from "react"; +import * as Notification from "../../Utils/Notifications.js"; +import { useTranslation } from "react-i18next"; +import { Cancel, Submit } from "./components/ButtonV2.js"; +import CareIcon from "../../CAREUI/icons/CareIcon.js"; +import useDragAndDrop from "../../Utils/useDragAndDrop.js"; +import ExcelViewer from "./ExcelViewer.js"; +import * as XLSX from "xlsx"; +import schemaParser, { + SchemaType, + ErrorData, + ParsedData, +} from "../../Common/schemaParser.js"; + +interface Props { + handleSubmit: (data: any) => void; + loading: boolean; + sampleLink?: string; + schema: SchemaType; + onClose?: () => void; + setIsValid?: (value: boolean) => void; +} + +export default function ExcelFileDragAndDrop({ + handleSubmit, + loading = false, + sampleLink, + schema, + onClose, + setIsValid, +}: Props) { + const [fileData, setFileData] = useState([]); + const [errors, setErrors] = useState([]); + const [preview, setPreview] = useState(false); + const [selectedFile, setSelectedFile] = useState(); + const [validData, setValidData] = useState([]); + const [parsedData, setParsedData] = useState([]); + + const { t } = useTranslation(); + const fileInputRef = useRef(null); + + const closeModal = () => { + setSelectedFile(undefined); + setFileData([]); + onClose && onClose(); + }; + + const onSelectFile = (file: Blob) => { + setSelectedFile(file); + dragProps.setFileDropError(""); + try { + const reader = new FileReader(); + + reader.onload = (e) => { + const result = (e.target as FileReader).result; + const workbook = XLSX.read(result, { type: "binary" }); + const worksheetName = workbook.SheetNames[0]; + const worksheet = workbook.Sheets[worksheetName]; + const data = XLSX.utils.sheet_to_json(worksheet, { defval: "" }); + setFileData(data); + }; + reader.onerror = () => { + throw new Error("Error in reading file"); + }; + + reader.readAsBinaryString(file); + } catch (e: any) { + Notification.Error({ + msg: e.message, + }); + } + }; + + useEffect(() => { + if (fileData.length !== 0) { + const { errors, parsedData, ParsedDataWithOutErrors } = schemaParser( + fileData, + schema + ); + setErrors(errors); + setParsedData(parsedData); + setValidData(ParsedDataWithOutErrors); + if (ParsedDataWithOutErrors.length !== 0) { + setIsValid && setIsValid(true); + } + } + }, [fileData]); + + const dragProps = useDragAndDrop(); + const onDrop = (e) => { + e.preventDefault(); + dragProps.setDragOver(false); + + const droppedFiles = e?.dataTransfer?.files; + + if (!droppedFiles || droppedFiles.length === 0) { + return dragProps.setFileDropError("Please drop a file to upload!"); + } + + const droppedFile = droppedFiles[0]; + const fileTypes = [ + "vnd.ms-excel", + "text/csv", + "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", + ]; + + if (!fileTypes.includes(droppedFile?.type)) { + dragProps.setFileDropError("Please drop a Excel / CSV file to upload!"); + setSelectedFile(null); + return; + } + onSelectFile(droppedFile); + }; + + return ( +
+ {preview && ( + setPreview(false)} + selectedFile={selectedFile} + fileData={fileData} + errors={errors} + handleSubmit={handleSubmit} + parsedData={parsedData} + /> + )} +
!selectedFile && fileInputRef.current?.click()} + className={`mb-8 mt-5 flex flex-1 flex-col items-center justify-center rounded-lg border-[3px] border-dashed px-3 py-6 ${ + dragProps.dragOver ? "border-primary-500" : "border-gray-500" + } ${dragProps.fileDropError !== "" ? "border-red-500" : ""}`} + > + +

+ {dragProps.fileDropError !== "" && dragProps.fileDropError} + {!selectedFile && "Drag & drop xlsx/csv file to upload"} +

+ { + const files = e.target.files; + if (files && files.length > 0) { + onSelectFile(files[0]); + } + }} + className="hidden" + ref={fileInputRef} + /> + {selectedFile && ( +
+

+ {selectedFile.name} - {(selectedFile.size / 1024).toFixed(2)} KB +

+ { + setSelectedFile(undefined); + setFileData([]); + setErrors([]); + setValidData([]); + setIsValid && setIsValid(false); + dragProps.setDragOver(false); + dragProps.setFileDropError(""); + }} + > + cancel + +
+ )} + {selectedFile ? ( + <> + setPreview(true)} + > + + + ) : ( + e.stopPropagation()} + > + + )} +
+
+ +
+ { + closeModal(); + setErrors([]); + setValidData([]); + dragProps.setDragOver(false); + dragProps.setFileDropError(""); + }} + disabled={loading} + /> + handleSubmit(validData)} + disabled={loading || !selectedFile || validData.length === 0} + data-testid="asset-import-btn" + > + {loading ? ( + + ) : ( + + )} + + {loading + ? "Importing..." + : `Import ${validData.length} valid fields`} + + +
+
+ ); +} From 58154229f32355b506cdaedd80ad5a06600f4f11 Mon Sep 17 00:00:00 2001 From: Uday Sagar Date: Sat, 9 Mar 2024 15:38:44 +0530 Subject: [PATCH 08/25] modified assest import modal to use reusable component --- src/Components/Assets/AssetImportModal.tsx | 270 +++------------------ 1 file changed, 39 insertions(+), 231 deletions(-) diff --git a/src/Components/Assets/AssetImportModal.tsx b/src/Components/Assets/AssetImportModal.tsx index 7e743219c7e..c3f1ae216b3 100644 --- a/src/Components/Assets/AssetImportModal.tsx +++ b/src/Components/Assets/AssetImportModal.tsx @@ -1,23 +1,17 @@ -import { ChangeEventHandler, useEffect, useState } from "react"; -import useDragAndDrop from "../../Utils/useDragAndDrop"; +import { useState } from "react"; import { sleep } from "../../Utils/utils"; import { FacilityModel } from "../Facility/models"; import { AssetData } from "./AssetTypes"; import * as Notification from "../../Utils/Notifications.js"; -import { Cancel, Submit } from "../Common/components/ButtonV2"; +import { Cancel } from "../Common/components/ButtonV2"; import { Link } from "raviger"; -import readXlsxFile from "read-excel-file"; -import { - LocalStorageKeys, - XLSXAssetImportSchema, -} from "../../Common/constants"; -import { parseCsvFile } from "../../Utils/utils"; +import { LocalStorageKeys, AssetImportSchema } from "../../Common/constants"; import useConfig from "../../Common/hooks/useConfig"; import DialogModal from "../Common/Dialog"; import useQuery from "../../Utils/request/useQuery"; import routes from "../../Redux/api"; import { SelectFormField } from "../Form/FormFields/SelectFormField"; -import CareIcon from "../../CAREUI/icons/CareIcon"; +import ExcelFileDragAndDrop from "../Common/ExcelFIleDragAndDrop"; interface Props { open: boolean; @@ -28,18 +22,14 @@ interface Props { const AssetImportModal = ({ open, onClose, facility, onUpdate }: Props) => { const [isImporting, setIsImporting] = useState(false); - const [selectedFile, setSelectedFile] = useState(); - const [preview, setPreview] = - useState<(AssetData & { notes?: string; last_serviced_on?: string })[]>(); const [location, setLocation] = useState(""); + const [isValid, setIsValid] = useState(false); const [errors, setErrors] = useState({ location: "", }); const { sample_format_asset_import } = useConfig(); const closeModal = () => { - setPreview(undefined); - setSelectedFile(undefined); onClose && onClose(); }; const { data, loading } = useQuery(routes.listFacilityAssetLocation, { @@ -48,63 +38,10 @@ const AssetImportModal = ({ open, onClose, facility, onUpdate }: Props) => { const locations = data?.results || []; - useEffect(() => { - const readFile = async () => { - try { - if (selectedFile) { - switch (selectedFile.name.split(".").pop()) { - case "xlsx": { - const parsedData = await readXlsxFile(selectedFile, { - schema: XLSXAssetImportSchema, - }); - if (parsedData.errors.length) { - parsedData.errors.map((error) => { - Notification.Error({ - msg: `Please check the row ${error.row} of column ${error.column}`, - }); - }); - setSelectedFile(undefined); - } else { - setPreview(parsedData.rows as AssetData[]); - } - break; - } - case "csv": { - const parsedData = await parseCsvFile( - selectedFile, - XLSXAssetImportSchema - ); - setPreview(parsedData); - break; - } - default: { - const parsedData = JSON.parse(await selectedFile.text()); - setPreview(parsedData); - } - } - } - } catch (e: any) { - setPreview(undefined); - console.log(e); - Notification.Error({ - msg: "Invalid file: " + e.message, - }); - setSelectedFile(undefined); - } - }; - readFile(); - }, [selectedFile]); - - const onSelectFile: ChangeEventHandler = (e) => { - if (!e.target.files || e.target.files.length === 0) { - setSelectedFile(undefined); - return; - } - setSelectedFile(e.target.files[0]); - }; - - const handleUpload = async () => { - if (!selectedFile) { + const handleUpload = async ( + data: (AssetData & { notes?: string; last_serviced_on?: string })[] + ) => { + if (!data) { closeModal(); return; } @@ -119,7 +56,7 @@ const AssetImportModal = ({ open, onClose, facility, onUpdate }: Props) => { let error = false; Notification.Success({ msg: "Importing assets..." }); - for (const asset of preview || []) { + for (const asset of data || []) { const asset_data: any = { name: asset.name, asset_type: asset.asset_type, @@ -162,10 +99,6 @@ const AssetImportModal = ({ open, onClose, facility, onUpdate }: Props) => { "Error importing asset: " + asset.name + " " + JSON.stringify(data), }); error = true; - } else { - setPreview((preview) => { - return preview?.slice(1); - }); } } if (!error) { @@ -181,22 +114,6 @@ const AssetImportModal = ({ open, onClose, facility, onUpdate }: Props) => { } }; - const dragProps = useDragAndDrop(); - const onDrop = (e: React.DragEvent) => { - e.preventDefault(); - dragProps.setDragOver(false); - const dropedFile = e?.dataTransfer?.files[0]; - if ( - !["xlsx", "csv", "json"].includes( - dropedFile?.name?.split(".")?.pop() || "" - ) - ) - return dragProps.setFileDropError( - "Please drop a JSON / Excel file to upload!" - ); - setSelectedFile(dropedFile); - }; - return ( { ) : ( <> - {preview && preview?.length > 0 ? ( -
-

- {preview.length} assets {isImporting ? "are being" : "will be"}{" "} - imported -

-
- -
- ({ - title: location.name, - description: location.facility.name, - value: location.id, - }))} - optionLabel={(o) => o.title} - optionValue={(o) => o.value} - placeholder="Select a location" - value={location} - onChange={({ value }) => setLocation(value)} - error={errors.location} - /> -
-
-
-
-
#
-
Name
-
Description
-
- {preview.map((data: AssetData, index: number) => { - return ( -
-
{index + 1}
-
{data.name}
-
- {data.description} -
-
- ); - })} + {isValid && ( +
+ +
+ ({ + title: location.name, + description: location.facility.name, + value: location.id, + }))} + optionLabel={(o) => o.title} + optionValue={(o) => o.value} + placeholder="Select a location" + value={location} + onChange={({ value }) => setLocation(value)} + error={errors.location} + />
- ) : ( -
- -

- {dragProps.fileDropError !== "" - ? dragProps.fileDropError - : "Drag & drop JSON / Excel (xlsx, csv) file to upload"} -

- - -
)} - -
-
- -
-
- { - closeModal(); - dragProps.setFileDropError(""); - }} - disabled={isImporting} - /> - - {isImporting ? ( - - ) : ( - - )} - {isImporting ? "Importing..." : "Import"} - -
+ )} From b058f7f41d0c8fee34e1e010cafb643a6dd169c4 Mon Sep 17 00:00:00 2001 From: Uday Sagar Date: Sat, 9 Mar 2024 15:42:15 +0530 Subject: [PATCH 09/25] excel viewer component --- src/Components/Common/ExcelViewer.tsx | 269 ++++++++++++++++++++++++++ 1 file changed, 269 insertions(+) create mode 100644 src/Components/Common/ExcelViewer.tsx diff --git a/src/Components/Common/ExcelViewer.tsx b/src/Components/Common/ExcelViewer.tsx new file mode 100644 index 00000000000..f3304d47945 --- /dev/null +++ b/src/Components/Common/ExcelViewer.tsx @@ -0,0 +1,269 @@ +import { ReactNode, useEffect, useState } from "react"; +import CareIcon from "../../CAREUI/icons/CareIcon"; +import ButtonV2, { Cancel, Submit } from "./components/ButtonV2"; +import DialogModal from "./Dialog"; +import Pagination from "./Pagination"; +import { ParsedData } from "../../Common/schemaParser"; + +type FilePreviewProps = { + title?: ReactNode; + description?: ReactNode; + show: boolean; + onClose: () => void; + selectedFile: { name: string }; + fileData?: any[]; + downloadURL?: string; + className?: string; + errors?: { index: number; key: string; error: string }[]; + handleSubmit: (data: ParsedData[]) => void; + showCheckbox?: boolean; + parsedData?: ParsedData[]; +}; + +const ExcelViewer = ({ + title = "File Preview", + description, + show, + onClose, + className, + selectedFile, + fileData, + downloadURL, + showCheckbox = true, + handleSubmit, + parsedData, + errors = [], +}: FilePreviewProps) => { + const [currentPage, setCurrentPage] = useState(1); + const [rowsPerPage, setRowsPerPage] = useState(10); + const [selectedRowsData, setSelectedRowsData] = useState([]); + + const initialSelectedRows = fileData + ? fileData + .map((_, i) => i) + .filter((i) => !errors.some((err) => err.index === i)) ?? [] + : []; + + const [selectedRows, setSelectedRows] = + useState(initialSelectedRows); + + const handleClose = () => { + onClose?.(); + }; + + useEffect(() => { + setSelectedRowsData(selectedRows.map((rowIndex) => parsedData[rowIndex])); + }, [selectedRows]); + + return ( + { + handleClose(); + }} + title={title} + description={description} + show={show} + > + <> +
+

+ {selectedFile.name} +

+
+ {downloadURL && downloadURL.length > 0 && ( + + + + Download + + + )} +
+
+
+
+ {fileData && fileData[0] ? ( +
+ + + + {showCheckbox && ( + + )} + {Object.keys(fileData[0]).map((key) => ( + + ))} + + + + {fileData + .slice( + (currentPage - 1) * rowsPerPage, + (currentPage - 1) * rowsPerPage + rowsPerPage + ) + .map((row, rowIndex) => { + const currentRowIndex = + rowIndex + (currentPage - 1) * rowsPerPage; + return ( + + {showCheckbox && ( + + )} + {Object.entries(row).map( + ([key, value], colIndex) => { + const error = errors.find( + (err) => + err.index === currentRowIndex && + err.key == key + ); + + return ( + <> + + + ); + } + )} + + ); + })} + +
+ 0} + onChange={(e) => { + if (e.target.checked) { + setSelectedRows(fileData.map((_, i) => i)); + } else { + setSelectedRows([]); + } + }} + /> + + {key} +
+ {errors.some( + (err) => err.index === currentRowIndex + ) ? ( + + ) : ( + err.index === currentRowIndex + )} + onChange={() => { + if ( + selectedRows.includes(currentRowIndex) + ) { + setSelectedRows( + selectedRows.filter( + (i) => i !== currentRowIndex + ) + ); + } else { + setSelectedRows([ + ...selectedRows, + currentRowIndex, + ]); + } + }} + className="disabled:bg-danger-500" + /> + )} + + {value} +
+
+ ) : ( +
No data found
+ )} +
+ {fileData && fileData.length > 5 && ( +
+

+ Showing {currentPage * rowsPerPage - rowsPerPage + 1} to{" "} + {currentPage * rowsPerPage > fileData.length + ? fileData.length + : currentPage * rowsPerPage}{" "} + of {fileData.length} entries +

+ { + setCurrentPage(page); + setRowsPerPage(rowsPerPage); + }} + /> + +
+ )} +
+ +
+ + { + handleSubmit(selectedRowsData); + handleClose(); + }} + data-testid="asset-import-btn" + > + + Import {selectedRows.length} selected fields + +
+
+ ); +}; + +export default ExcelViewer; From c82f0174b662a7c09f4222d8c85a9964503a42d2 Mon Sep 17 00:00:00 2001 From: Uday Sagar Date: Sat, 9 Mar 2024 15:42:59 +0530 Subject: [PATCH 10/25] modified import name --- src/Components/ExternalResult/ResultList.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Components/ExternalResult/ResultList.tsx b/src/Components/ExternalResult/ResultList.tsx index 7e3c4fb5dc7..7d551ee4394 100644 --- a/src/Components/ExternalResult/ResultList.tsx +++ b/src/Components/ExternalResult/ResultList.tsx @@ -18,7 +18,7 @@ import useQuery from "../../Utils/request/useQuery"; import { parsePhoneNumber } from "../../Utils/utils"; import useAuthUser from "../../Common/hooks/useAuthUser"; import { NonReadOnlyUsers } from "../../Utils/AuthorizeFor"; -import ExternalResultUploadModal from "./ExternalResultUploadModal"; +import ExternalResultImportModal from "./ExternalResultImportModal"; const Loading = lazy(() => import("../Common/Loading")); @@ -269,7 +269,7 @@ export default function ResultList() { } > {importModalOpen && ( - setImportModalOpen(false)} /> From ece63ffe1091463cbffde0e1c0489f3197c26c50 Mon Sep 17 00:00:00 2001 From: Uday Sagar Date: Sat, 9 Mar 2024 15:43:49 +0530 Subject: [PATCH 11/25] external result upload modal --- .../ExternalResultImportModal.tsx | 90 ++++++++ .../ExternalResult/ExternalResultUpload.tsx | 213 ------------------ 2 files changed, 90 insertions(+), 213 deletions(-) create mode 100644 src/Components/ExternalResult/ExternalResultImportModal.tsx delete mode 100644 src/Components/ExternalResult/ExternalResultUpload.tsx diff --git a/src/Components/ExternalResult/ExternalResultImportModal.tsx b/src/Components/ExternalResult/ExternalResultImportModal.tsx new file mode 100644 index 00000000000..8d7fbbf5faf --- /dev/null +++ b/src/Components/ExternalResult/ExternalResultImportModal.tsx @@ -0,0 +1,90 @@ +import _ from "lodash-es"; +import { navigate } from "raviger"; +import { useEffect, useState } from "react"; +import useConfig from "../../Common/hooks/useConfig"; +import * as Notification from "../../Utils/Notifications.js"; +import request from "../../Utils/request/request"; +import routes from "../../Redux/api"; +import { ExternalResultImportSchema } from "../../Common/constants"; +import ExcelFileDragAndDrop from "../Common/ExcelFIleDragAndDrop"; +import DialogModal from "../Common/Dialog"; +import { IExternalResult } from "./models"; + +interface Props { + open: boolean; + onClose: () => void; +} + +export default function ExternalResultImportModal({ open, onClose }: Props) { + const { sample_format_external_result_import } = useConfig(); + const [loading, setLoading] = useState(false); + + const fetchUser = async () => { + const { data: userData } = await request(routes.currentUser, { + pathParams: {}, + }); + ExternalResultImportSchema.District.parse = (value: string) => { + if (value !== userData?.district_object?.name) { + throw new Error("District should be the same as the user's district"); + } + }; + }; + + useEffect(() => { + fetchUser(); + }, []); + + const handleSubmit = async (data: IExternalResult[]) => { + setLoading(true); + + if (data.length !== 0) { + try { + const { res } = await request(routes.externalResultUploadCsv, { + body: { + sample_tests: data, + }, + }); + + if (res && res.status === 202) { + setLoading(false); + navigate("/external_results"); + Notification.Success({ + msg: "External Results imported successfully", + }); + } else { + Notification.Error({ + msg: "Something went wrong", + }); + setLoading(false); + } + } catch (error) { + Notification.Error({ + msg: "Something went wrong: " + error, + }); + setLoading(false); + } finally { + setLoading(false); + } + } else { + setLoading(false); + } + }; + + return ( + + + + ); +} diff --git a/src/Components/ExternalResult/ExternalResultUpload.tsx b/src/Components/ExternalResult/ExternalResultUpload.tsx deleted file mode 100644 index 2f5337a242b..00000000000 --- a/src/Components/ExternalResult/ExternalResultUpload.tsx +++ /dev/null @@ -1,213 +0,0 @@ -import _ from "lodash-es"; -import { navigate } from "raviger"; -import { lazy, useEffect, useState } from "react"; -import CSVReader from "react-csv-reader"; -import useConfig from "../../Common/hooks/useConfig"; -import * as Notification from "../../Utils/Notifications.js"; -const PageTitle = lazy(() => import("../Common/PageTitle")); -import { useTranslation } from "react-i18next"; -import { Cancel, Submit } from "../Common/components/ButtonV2"; -import useAppHistory from "../../Common/hooks/useAppHistory"; -import request from "../../Utils/request/request"; -import routes from "../../Redux/api"; -import { IExternalResult } from "./models"; -import CareIcon from "../../CAREUI/icons/CareIcon"; - -export default function ExternalResultUpload() { - const { sample_format_external_result_import } = useConfig(); - // for disabling save button once clicked - const [loading, setLoading] = useState(false); - const [csvData, setCsvData] = useState(new Array()); - const [errors, setErrors] = useState([]); - const [validationErrorCount, setValidationErrorCount] = useState(0); - const [user, setUser] = useState({}); - const handleForce = (data: any) => { - setCsvData(data); - setValidationErrorCount( - data.filter( - (result: IExternalResult) => - result.district !== user.district_object.name - ).length - ); - }; - const { t } = useTranslation(); - const { goBack } = useAppHistory(); - - const fetchUser = async () => { - const { data: userData } = await request(routes.currentUser, { - pathParams: {}, - }); - setUser(userData); - }; - - useEffect(() => { - fetchUser(); - }, []); - - const papaparseOptions = { - header: true, - dynamicTyping: true, - skipEmptyLines: true, - transformHeader: (header: string) => - header.toLowerCase().replace(/\W/g, "_"), - }; - - const handleSubmit = async (e: any) => { - e.preventDefault(); - setLoading(true); - const valid = true; - - if (csvData.length !== 0) { - if (valid) { - setErrors([]); - - try { - const { res, data } = await request(routes.externalResultUploadCsv, { - body: { - sample_tests: validationErrorCount - ? csvData.filter( - (data: IExternalResult) => - data.district === user.district_object.name - ) - : csvData, - }, - }); - - if (res && res.status === 202) { - setLoading(false); - navigate("/external_results"); - Notification.Success({ - msg: "External Results imported successfully", - }); - } else { - if (data) { - setErrors(data.map((err: any) => Object.entries(err))); - } - setLoading(false); - } - } catch (error) { - console.error("An error occurred:", error); - Notification.Error({ - msg: "Something went wrong: " + error, - }); - setLoading(false); - } - } else { - setLoading(false); - } - } else { - Notification.Error({ - msg: t("please_upload_a_csv_file"), - }); - setLoading(false); - } - }; - - return ( -
- -
-
-
- -
- {csvData.length > 0 && ( -

Total: {csvData.length}

- )} -
- {csvData.map((data: any, index: number) => { - return ( -
-
{index + 1}
-
{data.name}
- -
- {errors && errors.length !== 0 - ? errors.map((error: any) => { - return ( -
- {_.startCase(_.camelCase(error[0][0]))} -{" "} - {error[0][1]} -
- ); - }) - : null} -
-
- {data.district !== user.district_object.name && ( -

- Different - districts -

- )} -
-
- ); - })} -
-
-
- goBack()} /> - -
-
-
-
- ); -} From d82afc9b7cdd8547d4ff8df65b96d76caf6c425e Mon Sep 17 00:00:00 2001 From: Uday Sagar Date: Sat, 9 Mar 2024 16:16:43 +0530 Subject: [PATCH 12/25] lazy import --- src/Components/Assets/AssetImportModal.tsx | 6 ++++-- src/Components/ExternalResult/ExternalResultImportModal.tsx | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Components/Assets/AssetImportModal.tsx b/src/Components/Assets/AssetImportModal.tsx index c3f1ae216b3..1f4396243d0 100644 --- a/src/Components/Assets/AssetImportModal.tsx +++ b/src/Components/Assets/AssetImportModal.tsx @@ -1,4 +1,4 @@ -import { useState } from "react"; +import { useState, lazy } from "react"; import { sleep } from "../../Utils/utils"; import { FacilityModel } from "../Facility/models"; import { AssetData } from "./AssetTypes"; @@ -11,7 +11,9 @@ import DialogModal from "../Common/Dialog"; import useQuery from "../../Utils/request/useQuery"; import routes from "../../Redux/api"; import { SelectFormField } from "../Form/FormFields/SelectFormField"; -import ExcelFileDragAndDrop from "../Common/ExcelFIleDragAndDrop"; +const ExcelFileDragAndDrop = lazy( + () => import("../Common/ExcelFIleDragAndDrop") +); interface Props { open: boolean; diff --git a/src/Components/ExternalResult/ExternalResultImportModal.tsx b/src/Components/ExternalResult/ExternalResultImportModal.tsx index 8d7fbbf5faf..4756d7603c2 100644 --- a/src/Components/ExternalResult/ExternalResultImportModal.tsx +++ b/src/Components/ExternalResult/ExternalResultImportModal.tsx @@ -1,14 +1,16 @@ import _ from "lodash-es"; import { navigate } from "raviger"; -import { useEffect, useState } from "react"; +import { useEffect, useState, lazy } from "react"; import useConfig from "../../Common/hooks/useConfig"; import * as Notification from "../../Utils/Notifications.js"; import request from "../../Utils/request/request"; import routes from "../../Redux/api"; import { ExternalResultImportSchema } from "../../Common/constants"; -import ExcelFileDragAndDrop from "../Common/ExcelFIleDragAndDrop"; import DialogModal from "../Common/Dialog"; import { IExternalResult } from "./models"; +const ExcelFileDragAndDrop = lazy( + () => import("../Common/ExcelFIleDragAndDrop") +); interface Props { open: boolean; From 227611273526f1aa33cb6ba1ce68bbc443f7b584 Mon Sep 17 00:00:00 2001 From: Uday Sagar Date: Sat, 9 Mar 2024 17:13:04 +0530 Subject: [PATCH 13/25] Modified templete for external results import file --- public/External-Results-Template.csv | 2 +- src/Common/constants.tsx | 36 ++++++++++++++-------------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/public/External-Results-Template.csv b/public/External-Results-Template.csv index 3ab2afc65ba..c2601f2d64f 100644 --- a/public/External-Results-Template.csv +++ b/public/External-Results-Template.csv @@ -1,3 +1,3 @@ -District,srf id,name,age,age in,gender,mobile number,address,ward,local body,local body type,source,Sample Collection Date,result date,test type,lab name,sample type,patient status,Is Repeat,patient category,result +District,SRF ID,Name,Age,Age in,Gender,Mobile Number,Address,Ward,Local Body,Local Body Type,Source,Sample Collection Date,Result Date,Test Type,Lab Name,Sample Type,Patient Status,Is Repeat,Patient Category,Result Ernakulam,00/EKM/0000,Bodhi CSN,24,years,m,8888888888,"CSN HQ Kochi, Kerala ",7,Poothrikka,grama panchayath,Secondary contact aparna,2020-10-14,2020-10-14,Antigen,Karothukuzhi Laboratory,Ag-SD_Biosensor_Standard_Q_COVID-19_Ag_detection_kit,Asymptomatic,NO,Cat 17: All individuals who wish to get themselves tested,Negative \ No newline at end of file diff --git a/src/Common/constants.tsx b/src/Common/constants.tsx index 89fecbaf8b6..cba072498a9 100644 --- a/src/Common/constants.tsx +++ b/src/Common/constants.tsx @@ -1023,17 +1023,17 @@ export const AssetImportSchema: SchemaType = { export const ExternalResultImportSchema: SchemaType = { District: { prop: "district", type: "any" }, - "srf id": { prop: "srf_id", type: "string" }, - name: { prop: "name", type: "string" }, - age: { prop: "age", type: "number" }, - "age in": { prop: "age_in", type: "string" }, - gender: { prop: "gender", type: "string" }, - "mobile number": { prop: "mobile_number", type: "any" }, - address: { prop: "address", type: "string" }, - ward: { prop: "ward", type: "number" }, - "local body": { prop: "local_body", type: "string" }, - "local body type": { prop: "local_body_type", type: "string" }, - source: { prop: "source", type: "string" }, + "SRF ID": { prop: "srf_id", type: "string" }, + Name: { prop: "name", type: "string" }, + Age: { prop: "age", type: "number" }, + "Age in": { prop: "age_in", type: "string" }, + Gender: { prop: "gender", type: "string" }, + "Mobile Number": { prop: "mobile_number", type: "any" }, + Address: { prop: "address", type: "string" }, + Ward: { prop: "ward", type: "number" }, + "Local Body": { prop: "local_body", type: "string" }, + "Local Body Type": { prop: "local_body_type", type: "string" }, + Source: { prop: "source", type: "string" }, "Sample Collection Date": { prop: "sample_collection_date", type: "string", @@ -1047,7 +1047,7 @@ export const ExternalResultImportSchema: SchemaType = { return dateQueryString(parsed); }, }, - "result date": { + "Result Date": { prop: "result_date", type: "string", parse: (date: string) => { @@ -1060,13 +1060,13 @@ export const ExternalResultImportSchema: SchemaType = { return dateQueryString(parsed); }, }, - "test type": { prop: "test_type", type: "string" }, - "lab name": { prop: "lab_name", type: "string" }, - "sample type": { prop: "sample_type", type: "string" }, - "patient status": { prop: "patient_status", type: "string" }, + "Test Type": { prop: "test_type", type: "string" }, + "Lab Name": { prop: "lab_name", type: "string" }, + "Sample Type": { prop: "sample_type", type: "string" }, + "Patient Status": { prop: "patient_status", type: "string" }, "Is Repeat": { prop: "is_repeat", type: "string" }, - "patient category": { prop: "patient_category", type: "string" }, - result: { prop: "result", type: "string" }, + "Patient Category": { prop: "patient_category", type: "string" }, + Result: { prop: "result", type: "string" }, }; export const USER_TYPES_MAP = { From aeb0e300e62d63f808f86943d1dc447575ed0ed1 Mon Sep 17 00:00:00 2001 From: Uday Sagar Date: Wed, 13 Mar 2024 00:38:03 +0530 Subject: [PATCH 14/25] cypress fix --- cypress/e2e/external_results_spec/external_result.cy.ts | 4 ++-- cypress/pageobject/Asset/AssetCreation.ts | 2 +- src/Components/Common/ExcelFIleDragAndDrop.tsx | 3 ++- src/Components/Common/ExcelViewer.tsx | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/cypress/e2e/external_results_spec/external_result.cy.ts b/cypress/e2e/external_results_spec/external_result.cy.ts index deb92ae5171..8a54b3c3d4b 100644 --- a/cypress/e2e/external_results_spec/external_result.cy.ts +++ b/cypress/e2e/external_results_spec/external_result.cy.ts @@ -42,10 +42,10 @@ describe("Edit Profile Testing", () => { cy.intercept("POST", "/api/v1/external_result/bulk_upsert").as("import"); cy.get("div").contains("Import/Export").click(); cy.get("div").contains("Import Results").click(); - cy.get("[id=result-upload]") + cy.get("[data-testid=import-file]") .selectFile("cypress/fixtures/externalresultsample.csv") .wait(100); - cy.get("button").contains("Save").click(); + cy.get("button").contains("Import").click(); cy.wait("@import").then((interception) => { expect(interception.response.statusCode).to.equal(202); }); diff --git a/cypress/pageobject/Asset/AssetCreation.ts b/cypress/pageobject/Asset/AssetCreation.ts index 8f611e97d92..421fee0cee2 100644 --- a/cypress/pageobject/Asset/AssetCreation.ts +++ b/cypress/pageobject/Asset/AssetCreation.ts @@ -246,7 +246,7 @@ export class AssetPage { } importAssetFile() { - cy.get("[data-testid=import-asset-file]") + cy.get("[data-testid=import-file]") .selectFile("cypress/fixtures/sampleAsset.xlsx", { force: true }) .wait(100); } diff --git a/src/Components/Common/ExcelFIleDragAndDrop.tsx b/src/Components/Common/ExcelFIleDragAndDrop.tsx index ae6a77a6251..1b5df44d511 100644 --- a/src/Components/Common/ExcelFIleDragAndDrop.tsx +++ b/src/Components/Common/ExcelFIleDragAndDrop.tsx @@ -155,6 +155,7 @@ export default function ExcelFileDragAndDrop({ {!selectedFile && "Drag & drop xlsx/csv file to upload"}

{ @@ -238,9 +239,9 @@ export default function ExcelFileDragAndDrop({ disabled={loading} /> handleSubmit(validData)} disabled={loading || !selectedFile || validData.length === 0} - data-testid="asset-import-btn" > {loading ? ( diff --git a/src/Components/Common/ExcelViewer.tsx b/src/Components/Common/ExcelViewer.tsx index f3304d47945..87215e99da3 100644 --- a/src/Components/Common/ExcelViewer.tsx +++ b/src/Components/Common/ExcelViewer.tsx @@ -256,7 +256,7 @@ const ExcelViewer = ({ handleSubmit(selectedRowsData); handleClose(); }} - data-testid="asset-import-btn" + data-testid="import-btn" > Import {selectedRows.length} selected fields From 8eae489a10b9f4829c3610d635521aa5b03b728d Mon Sep 17 00:00:00 2001 From: Uday Sagar Date: Wed, 13 Mar 2024 03:43:14 +0530 Subject: [PATCH 15/25] updated cypress templete --- cypress/fixtures/externalresultsample.csv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cypress/fixtures/externalresultsample.csv b/cypress/fixtures/externalresultsample.csv index d1e543200b2..2905cdc1af3 100644 --- a/cypress/fixtures/externalresultsample.csv +++ b/cypress/fixtures/externalresultsample.csv @@ -1,2 +1,2 @@ -District,srf id,name,age,age in,gender,mobile number,address,ward,local body,local body type,source,Sample Collection Date,result date,test type,lab name,sample type,patient status,Is Repeat,patient category,result +District,SRF ID,Name,Age,Age in,Gender,Mobile Number,Address,Ward,Local Body,Local Body Type,Source,Sample Collection Date,Result Date,Test Type,Lab Name,Sample Type,Patient Status,Is Repeat,Patient Category,Result Ernakulam,00/EKM/0000,Test Upload,24,years,m,8888888888,Upload test address,7,Poothrikka,grama panchayath,Secondary contact aparna,2020-10-14,2020-10-14,Antigen,Karothukuzhi Laboratory,Ag-SD_Biosensor_Standard_Q_COVID-19_Ag_detection_kit,Asymptomatic,NO,Cat 17: All individuals who wish to get themselves tested,Negative From e12dc4de18ae99c0995b238592851c975b627769 Mon Sep 17 00:00:00 2001 From: Uday Sagar Date: Wed, 13 Mar 2024 03:44:02 +0530 Subject: [PATCH 16/25] fixes incorrect date format with csv files --- src/Common/constants.tsx | 82 ++++++++++++++----- .../Common/ExcelFIleDragAndDrop.tsx | 14 +++- 2 files changed, 73 insertions(+), 23 deletions(-) diff --git a/src/Common/constants.tsx b/src/Common/constants.tsx index cba072498a9..9231a258463 100644 --- a/src/Common/constants.tsx +++ b/src/Common/constants.tsx @@ -973,12 +973,25 @@ export const AssetImportSchema: SchemaType = { type: "string", parse: (date: string) => { if (!date) return null; - const parsed = new Date(date); - if (String(parsed) === "Invalid Date") { - throw new Error("Invalid Warranty End Date:" + date); + //handles both "YYYY-MM-DD" and long date format eg : Wed Oct 14 2020 05:30:00 GMT+0530 (India Standard Time) + if (isNaN(Date.parse(date))) { + const parts = date.split("-"); + if (parts.length !== 3) { + throw new Error("Invalid Date Format: " + date); + } + const reformattedDateStr = `${parts[2]}-${parts[1]}-${parts[0]}`; + const parsed = new Date(reformattedDateStr); + if (String(parsed) === "Invalid Date") { + throw new Error("Invalid Date: " + date); + } + return dateQueryString(parsed); + } else { + const parsed = new Date(date); + if (String(parsed) === "Invalid Date") { + throw new Error("Invalid Date: " + date); + } + return dateQueryString(parsed); } - - return dateQueryString(parsed); }, }, "Last Service Date": { @@ -986,16 +999,27 @@ export const AssetImportSchema: SchemaType = { type: "string", parse: (date: string) => { if (!date) return null; - const parsed = new Date(date); - - if (String(parsed) === "Invalid Date") { - throw new Error("Invalid Last Service Date:" + date); + if (isNaN(Date.parse(date))) { + const parts = date.split("-"); + if (parts.length !== 3) { + throw new Error("Invalid Date Format: " + date); + } + const reformattedDateStr = `${parts[2]}-${parts[1]}-${parts[0]}`; + const parsed = new Date(reformattedDateStr); + if (String(parsed) === "Invalid Date") { + throw new Error("Invalid Date: " + date); + } + return dateQueryString(parsed); + } else { + const parsed = new Date(date); + if (String(parsed) === "Invalid Date") { + throw new Error("Invalid Date: " + date); + } + return dateQueryString(parsed); } - - return dateQueryString(parsed); }, }, - Notes: { prop: "notes", type: "string" }, + Notes: { prop: "note", type: "string" }, "Config - IP Address": { parent: "meta", prop: "local_ip_address", @@ -1039,12 +1063,19 @@ export const ExternalResultImportSchema: SchemaType = { type: "string", parse: (date: string) => { if (!date) return null; - const parsed = new Date(date); - if (String(parsed) === "Invalid Date") { - throw new Error("Invalid Date:" + date); + if (isNaN(Date.parse(date))) { + const parsed = new Date(date); + if (String(parsed) === "Invalid Date") { + throw new Error("Invalid Date: " + date); + } + return dateQueryString(parsed); + } else { + const parsed = new Date(date); + if (String(parsed) === "Invalid Date") { + throw new Error("Invalid Date: " + date); + } + return dateQueryString(parsed); } - - return dateQueryString(parsed); }, }, "Result Date": { @@ -1052,12 +1083,19 @@ export const ExternalResultImportSchema: SchemaType = { type: "string", parse: (date: string) => { if (!date) return null; - const parsed = new Date(date); - if (String(parsed) === "Invalid Date") { - throw new Error("Invalid Date:" + date); + if (isNaN(Date.parse(date))) { + const parsed = new Date(date); + if (String(parsed) === "Invalid Date") { + throw new Error("Invalid Date: " + date); + } + return dateQueryString(parsed); + } else { + const parsed = new Date(date); + if (String(parsed) === "Invalid Date") { + throw new Error("Invalid Date: " + date); + } + return dateQueryString(parsed); } - - return dateQueryString(parsed); }, }, "Test Type": { prop: "test_type", type: "string" }, diff --git a/src/Components/Common/ExcelFIleDragAndDrop.tsx b/src/Components/Common/ExcelFIleDragAndDrop.tsx index 1b5df44d511..f231067b40d 100644 --- a/src/Components/Common/ExcelFIleDragAndDrop.tsx +++ b/src/Components/Common/ExcelFIleDragAndDrop.tsx @@ -54,10 +54,22 @@ export default function ExcelFileDragAndDrop({ reader.onload = (e) => { const result = (e.target as FileReader).result; - const workbook = XLSX.read(result, { type: "binary" }); + const workbook = XLSX.read(result, { + type: "binary", + cellDates: true, + }); const worksheetName = workbook.SheetNames[0]; const worksheet = workbook.Sheets[worksheetName]; const data = XLSX.utils.sheet_to_json(worksheet, { defval: "" }); + //converts the date to string + data.forEach((row: any) => { + _.forIn(row, (value: any, key) => { + if (value instanceof Date) { + row[key] = value.toISOString().split("T")[0]; + } + }); + }); + setFileData(data); }; reader.onerror = () => { From 57a5bfabafc69923f6e7d72e21737d905b727b8a Mon Sep 17 00:00:00 2001 From: Uday Sagar Date: Wed, 13 Mar 2024 03:44:34 +0530 Subject: [PATCH 17/25] cypress fix --- cypress/e2e/external_results_spec/external_result.cy.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cypress/e2e/external_results_spec/external_result.cy.ts b/cypress/e2e/external_results_spec/external_result.cy.ts index 8a54b3c3d4b..314af792bbb 100644 --- a/cypress/e2e/external_results_spec/external_result.cy.ts +++ b/cypress/e2e/external_results_spec/external_result.cy.ts @@ -43,9 +43,9 @@ describe("Edit Profile Testing", () => { cy.get("div").contains("Import/Export").click(); cy.get("div").contains("Import Results").click(); cy.get("[data-testid=import-file]") - .selectFile("cypress/fixtures/externalresultsample.csv") + .selectFile("cypress/fixtures/externalresultsample.csv", { force: true }) .wait(100); - cy.get("button").contains("Import").click(); + cy.get("#submit").contains("Import").click(); cy.wait("@import").then((interception) => { expect(interception.response.statusCode).to.equal(202); }); From 0e4376c5099b7b79b1e24afecd4522025243dd0e Mon Sep 17 00:00:00 2001 From: Uday Sagar Date: Wed, 13 Mar 2024 04:16:28 +0530 Subject: [PATCH 18/25] Added documentation --- src/Common/schemaParser.ts | 45 +++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/src/Common/schemaParser.ts b/src/Common/schemaParser.ts index 7f16b1581aa..0a8b4b879f0 100644 --- a/src/Common/schemaParser.ts +++ b/src/Common/schemaParser.ts @@ -129,7 +129,50 @@ const parseDataWithSchema = ( return { dataWithErrors, parsedData, errors }; }; - +/** + * This function takes in an array of JSON data and a schema and returns the parsed data and the data with errors + * @param dataArray The array of JSON data to be parsed + * @param schema The schema to validate and parse the data against + * @returns An object containing the parsed data, data with errors, and data without errors + * @example + * const data = [ + * { name: "Ram", age: 25 }, + * { name: "Raj", age: "30" }, + * { name: "Sam", age: 35 }, + * ]; + * + * const schema = { + * name: { prop: "name", type: "string", required: true }, + * age: { prop: "age", type: "number", required: true , parse: (value) => { + * if(value < 0 || value > 100) throw new Error("age should be between 0 and 100"); + * return value; + * }, + * }; + * + * const { dataWithErrors, parsedData, ParsedDataWithOutErrors, errors } = schemaParser(data, schema); + * + * dataWithErrors => [ + * { name: { value: "Ram" }, age: { value: 25 } }, + * { name: { value: "Raj" }, age: { value: "30", error: "age should be of type number" } }, + * { name: { value: "Sam" }, age: { value: 35 } }, + * ] + * + * parsedData => [ + * { name: "Ram", age: 25 }, + * { name: "Raj", age: "30" }, + * { name: "Sam", age: 35 }, + * ] + * + * ParsedDataWithOutErrors => [ + * { name: "Ram", age: 25 }, + * { name: "Sam", age: 35 }, + * ] + * + * errors => [ + * { index: 1, key: "age", error: "age should be of type number" } + * ] + * + */ const schemaParser = ( dataArray: any[], schema: SchemaType From 8849b451ea89f31e150746b89cae87d18b3ab36f Mon Sep 17 00:00:00 2001 From: Uday Sagar Date: Tue, 19 Mar 2024 17:30:25 +0530 Subject: [PATCH 19/25] code reviews --- src/Components/Assets/AssetImportModal.tsx | 2 +- src/Components/Common/ExcelViewer.tsx | 26 ++++++++++--------- .../ExternalResultImportModal.tsx | 1 + 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/Components/Assets/AssetImportModal.tsx b/src/Components/Assets/AssetImportModal.tsx index 1f4396243d0..5b1ed5bc4fa 100644 --- a/src/Components/Assets/AssetImportModal.tsx +++ b/src/Components/Assets/AssetImportModal.tsx @@ -108,11 +108,11 @@ const AssetImportModal = ({ open, onClose, facility, onUpdate }: Props) => { await sleep(1000); setIsImporting(false); onUpdate?.(); + closeModal(); } else { Notification.Error({ msg: "Error importing some assets" }); await sleep(1000); setIsImporting(false); - closeModal(); } }; diff --git a/src/Components/Common/ExcelViewer.tsx b/src/Components/Common/ExcelViewer.tsx index 87215e99da3..a445520f334 100644 --- a/src/Components/Common/ExcelViewer.tsx +++ b/src/Components/Common/ExcelViewer.tsx @@ -211,25 +211,27 @@ const ExcelViewer = ({ )}
{fileData && fileData.length > 5 && ( -
-

+

+

Showing {currentPage * rowsPerPage - rowsPerPage + 1} to{" "} {currentPage * rowsPerPage > fileData.length ? fileData.length : currentPage * rowsPerPage}{" "} of {fileData.length} entries

- { - setCurrentPage(page); - setRowsPerPage(rowsPerPage); - }} - /> + {rowsPerPage < fileData.length && ( + { + setCurrentPage(page); + setRowsPerPage(rowsPerPage); + }} + /> + )} From 12a8f1e22154559d4b2b61040efe4c391da389c5 Mon Sep 17 00:00:00 2001 From: Uday Sagar Date: Tue, 26 Mar 2024 23:29:44 +0530 Subject: [PATCH 21/25] merges pr #7339 --- .../ExternalResultImportModal.tsx | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/Components/ExternalResult/ExternalResultImportModal.tsx b/src/Components/ExternalResult/ExternalResultImportModal.tsx index b044926fb42..502475bcd20 100644 --- a/src/Components/ExternalResult/ExternalResultImportModal.tsx +++ b/src/Components/ExternalResult/ExternalResultImportModal.tsx @@ -22,11 +22,31 @@ export default function ExternalResultImportModal({ open, onClose }: Props) { const [loading, setLoading] = useState(false); const fetchUser = async () => { - const { data: userData } = await request(routes.currentUser, { + const { data: user } = await request(routes.currentUser, { pathParams: {}, }); + + ExternalResultImportSchema.Address.parse = (value: string) => { + if ( + user?.user_type === "StateAdmin" || + user?.user_type === "StateLabAdmin" + ) { + if (value.split(",").pop()?.trim() === user?.state_object?.name) { + return value; + } else { + throw new Error("State should be the same as the user's state"); + } + } + return value; + }; + ExternalResultImportSchema.District.parse = (value: string) => { - if (value !== userData?.district_object?.name) { + if ( + user?.user_type === "StateAdmin" || + user?.user_type === "StateLabAdmin" + ) { + return value; + } else if (value !== user?.district_object?.name) { throw new Error("District should be the same as the user's district"); } }; From 942dd20c00f19c60dd6d78f17f0b590b91b0e605 Mon Sep 17 00:00:00 2001 From: Mohammed Nihal <57055998+nihal467@users.noreply.github.com> Date: Tue, 2 Apr 2024 17:05:18 +0530 Subject: [PATCH 22/25] fix the flaky test --- cypress/e2e/patient_spec/patient_logupdate.cy.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/cypress/e2e/patient_spec/patient_logupdate.cy.ts b/cypress/e2e/patient_spec/patient_logupdate.cy.ts index 143be363efc..859cf623f30 100644 --- a/cypress/e2e/patient_spec/patient_logupdate.cy.ts +++ b/cypress/e2e/patient_spec/patient_logupdate.cy.ts @@ -147,6 +147,7 @@ describe("Patient Log Update in Normal, Critical and TeleIcu", () => { patientLogupdate.typeRhythm(patientRhythm); cy.get("#consciousness_level-2").click(); cy.submitButton("Save"); + cy.wait(2000); cy.verifyNotification("Consultation Updates details created successfully"); // Verify the card content cy.get("#basic-information").scrollIntoView(); From 5136ea851a71bf8fb06dc6be732bc30d69b35060 Mon Sep 17 00:00:00 2001 From: Mohammed Nihal <57055998+nihal467@users.noreply.github.com> Date: Tue, 2 Apr 2024 17:26:57 +0530 Subject: [PATCH 23/25] change the cypress to use Reusable component --- cypress/e2e/external_results_spec/external_result.cy.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cypress/e2e/external_results_spec/external_result.cy.ts b/cypress/e2e/external_results_spec/external_result.cy.ts index 314af792bbb..2091a5f93be 100644 --- a/cypress/e2e/external_results_spec/external_result.cy.ts +++ b/cypress/e2e/external_results_spec/external_result.cy.ts @@ -45,7 +45,7 @@ describe("Edit Profile Testing", () => { cy.get("[data-testid=import-file]") .selectFile("cypress/fixtures/externalresultsample.csv", { force: true }) .wait(100); - cy.get("#submit").contains("Import").click(); + cy.submitButton("Import"); cy.wait("@import").then((interception) => { expect(interception.response.statusCode).to.equal(202); }); From f1d83c05b4142f14032fc5c52c4fbe314344b8f5 Mon Sep 17 00:00:00 2001 From: Uday Sagar Date: Tue, 2 Apr 2024 21:51:41 +0530 Subject: [PATCH 24/25] fix type errors --- src/Common/schemaParser.ts | 2 +- src/Components/Common/ExcelFIleDragAndDrop.tsx | 4 ++-- src/Components/Common/ExcelViewer.tsx | 11 ++++++----- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/Common/schemaParser.ts b/src/Common/schemaParser.ts index 0a8b4b879f0..f40965a5e24 100644 --- a/src/Common/schemaParser.ts +++ b/src/Common/schemaParser.ts @@ -78,7 +78,7 @@ const validateAndParse = ( } return { [key]: { value: parsedValue } }; - } catch (error) { + } catch (error: any) { return { [key]: { value, error: error.message } }; } }; diff --git a/src/Components/Common/ExcelFIleDragAndDrop.tsx b/src/Components/Common/ExcelFIleDragAndDrop.tsx index f231067b40d..6318b8e70c4 100644 --- a/src/Components/Common/ExcelFIleDragAndDrop.tsx +++ b/src/Components/Common/ExcelFIleDragAndDrop.tsx @@ -38,7 +38,7 @@ export default function ExcelFileDragAndDrop({ const [parsedData, setParsedData] = useState([]); const { t } = useTranslation(); - const fileInputRef = useRef(null); + const fileInputRef = useRef(null); const closeModal = () => { setSelectedFile(undefined); @@ -100,7 +100,7 @@ export default function ExcelFileDragAndDrop({ }, [fileData]); const dragProps = useDragAndDrop(); - const onDrop = (e) => { + const onDrop = (e: React.DragEvent) => { e.preventDefault(); dragProps.setDragOver(false); diff --git a/src/Components/Common/ExcelViewer.tsx b/src/Components/Common/ExcelViewer.tsx index f53ac4c74f9..99040e8c754 100644 --- a/src/Components/Common/ExcelViewer.tsx +++ b/src/Components/Common/ExcelViewer.tsx @@ -17,7 +17,7 @@ type FilePreviewProps = { errors?: { index: number; key: string; error: string }[]; handleSubmit: (data: ParsedData[]) => void; showCheckbox?: boolean; - parsedData?: ParsedData[]; + parsedData: ParsedData[]; }; const ExcelViewer = ({ @@ -186,7 +186,7 @@ const ExcelViewer = ({ )} {Object.entries(row).map( - ([key, value], colIndex) => { + ([key, value]: [string, any], colIndex) => { const error = errors.find( (err) => err.index === currentRowIndex && @@ -200,11 +200,12 @@ const ExcelViewer = ({ className={` max-w-[150px] overflow-hidden text-ellipsis whitespace-nowrap border px-4 py-2 ${!!error && "text-red-500"} - } `} - title={error ? error.error : value} + title={ + error ? error.error : String(value) + } > - {value} + {String(value)} ); From 481d3fa4549f3528df51aacd8689fee1d7da1e04 Mon Sep 17 00:00:00 2001 From: Uday Sagar Date: Fri, 19 Apr 2024 04:35:52 +0530 Subject: [PATCH 25/25] lint fix --- src/CAREUI/display/Card.tsx | 2 +- src/CAREUI/display/Chip.tsx | 2 +- src/CAREUI/display/NetworkSignal.tsx | 4 +- src/CAREUI/display/Timeline.tsx | 6 +- src/CAREUI/icons/icon.js | 2 +- src/CAREUI/interactive/KeyboardShortcut.tsx | 2 +- src/CAREUI/interactive/LegendInput.tsx | 4 +- src/CAREUI/interactive/ScrollOverlay.tsx | 2 +- src/CAREUI/interactive/SlideOver.tsx | 6 +- src/CAREUI/interactive/Switch.tsx | 2 +- src/CAREUI/misc/PaginatedList.tsx | 2 +- src/CAREUI/misc/ThemedFavicon.tsx | 2 +- src/Common/constants.tsx | 4 +- src/Common/hooks/useAsyncOptions.ts | 8 +-- src/Common/hooks/useAuthUser.ts | 2 +- src/Common/hooks/useBreakpoints.ts | 2 +- src/Common/hooks/useExport.tsx | 6 +- src/Common/hooks/useFeedPTZ.ts | 14 ++-- src/Common/hooks/useFilters.tsx | 6 +- src/Common/hooks/useFullscreen.ts | 10 +-- src/Common/hooks/useMSEplayer.ts | 6 +- src/Common/hooks/useRangePagination.ts | 4 +- src/Common/hooks/useSlug.ts | 2 +- src/Common/hooks/useWindowDimensions.ts | 2 +- src/Common/schemaParser.ts | 8 +-- src/Common/utils.tsx | 4 +- src/Common/validation.tsx | 2 +- .../ABDM/ConfigureHealthFacility.tsx | 6 +- src/Components/ABDM/LinkABHANumberModal.tsx | 30 ++++---- src/Components/Assets/AssetFilter.tsx | 6 +- src/Components/Assets/AssetImportModal.tsx | 4 +- src/Components/Assets/AssetManage.tsx | 20 +++--- .../Assets/AssetServiceEditModal.tsx | 4 +- .../Assets/AssetType/ONVIFCamera.tsx | 4 +- src/Components/Assets/AssetsList.tsx | 17 ++--- .../Assets/configure/MonitorConfigure.tsx | 4 +- src/Components/Auth/ResetPassword.tsx | 10 +-- src/Components/CameraFeed/CameraFeed.tsx | 2 +- src/Components/CameraFeed/FeedAlert.tsx | 2 +- src/Components/CameraFeed/FeedButton.tsx | 2 +- src/Components/CameraFeed/NoFeedAvailable.tsx | 2 +- src/Components/CameraFeed/usePlayer.tsx | 4 +- src/Components/CameraFeed/utils.ts | 2 +- src/Components/Common/AssetSelect.tsx | 2 +- src/Components/Common/BedSelect.tsx | 4 +- src/Components/Common/Breadcrumbs.tsx | 4 +- src/Components/Common/DateInputV2.tsx | 46 ++++++------ src/Components/Common/Dialog.tsx | 2 +- .../Common/ExcelFIleDragAndDrop.tsx | 2 +- src/Components/Common/ExcelViewer.tsx | 18 ++--- src/Components/Common/FacilitySelect.tsx | 4 +- src/Components/Common/GLocationPicker.tsx | 20 +++--- src/Components/Common/HeadedTabs.tsx | 2 +- src/Components/Common/LanguageSelector.tsx | 2 +- .../Common/LanguageSelectorLogin.tsx | 2 +- src/Components/Common/LocationSelect.tsx | 2 +- src/Components/Common/PDFViewer.tsx | 2 +- src/Components/Common/Pagination.tsx | 2 +- .../Common/RouteToFacilitySelect.tsx | 2 +- src/Components/Common/Sidebar/Sidebar.tsx | 4 +- src/Components/Common/Sidebar/SidebarItem.tsx | 8 +-- src/Components/Common/SkillSelect.tsx | 4 +- src/Components/Common/UpdatableApp.tsx | 4 +- src/Components/Common/Uptime.tsx | 32 ++++----- .../Common/UserAutocompleteFormField.tsx | 4 +- src/Components/Common/components/ButtonV2.tsx | 2 +- src/Components/Common/components/Menu.tsx | 6 +- .../Common/components/SwitchTabs.tsx | 2 +- .../InvestigationBuilder.tsx | 22 +++--- .../PrescriptionDropdown.tsx | 2 +- .../PrescriptionMultiselect.tsx | 8 +-- .../prescription-builder/ProcedureBuilder.tsx | 14 ++-- src/Components/Common/utils/Tooltip.tsx | 2 +- .../CriticalCare__API.tsx | 4 +- .../ConditionVerificationStatusMenu.tsx | 8 +-- .../AddICD11Diagnosis.tsx | 2 +- .../ConsultationDiagnosisBuilder.tsx | 22 +++--- .../ConsultationDiagnosisEntry.tsx | 8 +-- .../Diagnosis/DiagnosesListAccordion.tsx | 2 +- .../ExternalResultImportModal.tsx | 2 +- src/Components/ExternalResult/ListFilter.tsx | 8 +-- src/Components/ExternalResult/ResultList.tsx | 8 +-- .../ExternalResult/ResultUpdate.tsx | 4 +- src/Components/Facility/AddInventoryForm.tsx | 8 +-- src/Components/Facility/AddLocationForm.tsx | 2 +- src/Components/Facility/AssetCreate.tsx | 10 +-- src/Components/Facility/BedCapacity.tsx | 4 +- src/Components/Facility/BedManagement.tsx | 2 +- .../Facility/CentralNursingStation.tsx | 2 +- src/Components/Facility/ConsultationCard.tsx | 10 +-- .../Facility/ConsultationClaims.tsx | 4 +- .../ConsultationInvestigationsTab.tsx | 2 +- .../ConsultationNeurologicalMonitoringTab.tsx | 2 +- .../ConsultationUpdatesTab.tsx | 49 ++++++------- .../ConsultationDetails/Events/EventsList.tsx | 4 +- .../Facility/ConsultationDetails/index.tsx | 22 +++--- .../ConsultationDoctorNotes/index.tsx | 2 +- src/Components/Facility/ConsultationForm.tsx | 72 +++++++++---------- .../Facility/Consultations/Beds.tsx | 2 +- .../VirtualNursingAssistantLogUpdateCard.tsx | 2 +- .../Consultations/DailyRoundsFilter.tsx | 2 +- .../Consultations/DailyRoundsList.tsx | 2 +- .../Facility/Consultations/Feed.tsx | 22 +++--- .../Facility/Consultations/FeedButton.tsx | 2 +- .../Facility/Consultations/LiveFeed.tsx | 16 ++--- .../Facility/Consultations/Mews.tsx | 8 +-- .../Consultations/NeurologicalTables.tsx | 14 ++-- .../Facility/Consultations/NursingPlot.tsx | 8 +-- .../Facility/Consultations/NutritionPlots.tsx | 28 ++++---- .../Facility/Consultations/PainDiagrams.tsx | 4 +- .../Consultations/PressureSoreDiagrams.tsx | 6 +- .../Consultations/PrimaryParametersPlot.tsx | 6 +- .../Facility/Consultations/VentilatorPlot.tsx | 2 +- .../components/StackedLinePlot.tsx | 4 +- .../Facility/CoverImageEditModal.tsx | 4 +- src/Components/Facility/DischargeModal.tsx | 8 +-- .../Facility/DischargeSummaryModal.tsx | 12 ++-- .../Facility/DoctorVideoSlideover.tsx | 14 ++-- .../Facility/FacilityBedCapacity.tsx | 4 +- src/Components/Facility/FacilityCard.tsx | 13 ++-- src/Components/Facility/FacilityConfigure.tsx | 2 +- src/Components/Facility/FacilityCreate.tsx | 20 +++--- .../Facility/FacilityDoctorList.tsx | 2 +- .../FacilityFilter/DistrictSelect.tsx | 2 +- src/Components/Facility/FacilityHome.tsx | 8 +-- .../Facility/FacilityHomeTriage.tsx | 10 +-- src/Components/Facility/HospitalList.tsx | 10 +-- src/Components/Facility/InventoryList.tsx | 4 +- .../InvestigationSuggestions.tsx | 37 +++++----- .../Investigations/InvestigationTable.tsx | 4 +- .../Facility/Investigations/Reports/index.tsx | 20 +++--- .../Facility/Investigations/Reports/utils.tsx | 2 +- .../Investigations/ShowInvestigation.tsx | 11 +-- .../Facility/Investigations/Table.tsx | 4 +- .../Investigations/ViewInvestigations.tsx | 2 +- .../Facility/Investigations/index.tsx | 32 ++++----- .../Investigations/investigationsTab.tsx | 2 +- src/Components/Facility/MinQuantityList.tsx | 2 +- .../Facility/MinQuantityRequiredModal.tsx | 2 +- src/Components/Facility/PatientNoteCard.tsx | 4 +- .../Facility/PatientNotesSlideover.tsx | 8 +-- src/Components/Facility/SetInventoryForm.tsx | 4 +- .../Facility/TransferPatientDialog.tsx | 4 +- src/Components/Facility/TreatmentSummary.tsx | 8 +-- src/Components/Facility/TriageForm.tsx | 6 +- src/Components/Facility/models.tsx | 2 +- src/Components/Form/AutoCompleteAsync.tsx | 4 +- src/Components/Form/FieldValidators.tsx | 10 +-- src/Components/Form/Form.tsx | 2 +- src/Components/Form/FormContext.ts | 2 +- .../AutoExpandingTextInputFormField.tsx | 2 +- .../Form/FormFields/Autocomplete.tsx | 6 +- .../FormFields/AutocompleteMultiselect.tsx | 8 +-- src/Components/Form/FormFields/FormField.tsx | 4 +- .../FormFields/NumericWithUnitsFormField.tsx | 2 +- .../Form/FormFields/OtpFormField.tsx | 2 +- .../Form/FormFields/PhoneNumberFormField.tsx | 8 +-- .../FormFields/RangeAutocompleteFormField.tsx | 4 +- .../Form/FormFields/SelectFormField.tsx | 2 +- .../Form/FormFields/TextAreaFormField.tsx | 4 +- .../Form/FormFields/TextFormField.tsx | 2 +- src/Components/Form/FormFields/Utils.ts | 6 +- src/Components/Form/MultiSelectMenuV2.tsx | 6 +- src/Components/Form/SearchInput.tsx | 4 +- src/Components/Form/SelectMenuV2.tsx | 2 +- src/Components/Form/Utils.ts | 4 +- src/Components/HCX/ClaimDetailCard.tsx | 2 +- src/Components/HCX/ClaimsItemsBuilder.tsx | 8 +-- src/Components/HCX/CreateClaimCard.tsx | 10 +-- .../HCX/InsuranceDetailsBuilder.tsx | 12 ++-- .../HCX/PatientInsuranceDetailsEditor.tsx | 4 +- src/Components/HCX/PolicyEligibilityCheck.tsx | 2 +- src/Components/HCX/validators.ts | 2 +- .../Medicine/AdministerMedicine.tsx | 6 +- .../Medicine/CreatePrescriptionForm.tsx | 18 ++--- .../Medicine/EditPrescriptionForm.tsx | 2 +- .../MedibaseAutocompleteFormField.tsx | 4 +- .../Medicine/MedicineAdministration.tsx | 14 ++-- .../AdministrationEventCell.tsx | 6 +- .../AdministrationTable.tsx | 4 +- .../AdministrationTableRow.tsx | 12 ++-- .../MedicineAdministrationSheet/index.tsx | 6 +- .../MedicineAdministrationSheet/utils.ts | 8 +-- .../Medicine/PrescriptionBuilder.tsx | 2 +- .../Medicine/PrescriptionDetailCard.tsx | 8 +-- .../Medicine/PrescriptionsTable.tsx | 4 +- .../Medicine/PrescrpitionTimeline.tsx | 12 ++-- .../Medicine/ResponsiveMedicineTables.tsx | 2 +- src/Components/Medicine/validators.ts | 2 +- .../Notifications/NotificationsList.tsx | 22 +++--- .../Patient/DailyRoundListDetails.tsx | 4 +- src/Components/Patient/DailyRounds.tsx | 24 +++---- src/Components/Patient/FileUpload.tsx | 26 +++---- .../Patient/InsuranceDetailsCard.tsx | 2 +- src/Components/Patient/ManagePatients.tsx | 32 ++++----- .../Patient/PatientCategorySelect.tsx | 4 +- src/Components/Patient/PatientFilter.tsx | 24 +++---- src/Components/Patient/PatientHome.tsx | 46 ++++++------ src/Components/Patient/PatientInfoCard.tsx | 35 ++++----- src/Components/Patient/PatientRegister.tsx | 48 ++++++------- src/Components/Patient/SampleDetails.tsx | 6 +- src/Components/Patient/SamplePreview.tsx | 10 +-- src/Components/Patient/SampleTest.tsx | 4 +- src/Components/Patient/SampleTestCard.tsx | 8 +-- src/Components/Patient/SampleViewAdmin.tsx | 24 +++---- src/Components/Patient/ShiftCreate.tsx | 10 +-- src/Components/Patient/UpdateStatusDialog.tsx | 6 +- src/Components/Patient/Waveform.tsx | 2 +- src/Components/Resource/BadgesList.tsx | 12 ++-- src/Components/Resource/Commons.tsx | 4 +- src/Components/Resource/ResourceBoard.tsx | 6 +- src/Components/Resource/ResourceCreate.tsx | 4 +- src/Components/Resource/ResourceDetails.tsx | 2 +- .../Resource/ResourceDetailsUpdate.tsx | 2 +- src/Components/Scribe/Scribe.tsx | 10 +-- src/Components/Shifting/BadgesList.tsx | 14 ++-- src/Components/Shifting/BoardView.tsx | 6 +- src/Components/Shifting/Commons.tsx | 16 ++--- src/Components/Shifting/ListView.tsx | 4 +- src/Components/Shifting/ShiftDetails.tsx | 12 ++-- .../Shifting/ShiftDetailsUpdate.tsx | 6 +- src/Components/Shifting/ShiftingBoard.tsx | 10 +-- src/Components/Users/LinkFacilityDialog.tsx | 2 +- src/Components/Users/ManageUsers.tsx | 16 ++--- src/Components/Users/SkillsSlideOver.tsx | 8 +-- .../Users/SkillsSlideOverComponents.tsx | 2 +- src/Components/Users/UserAdd.tsx | 50 ++++++------- src/Components/Users/UserProfile.tsx | 14 ++-- .../VitalsMonitor/HL7DeviceClient.ts | 2 +- .../VitalsMonitor/HL7PatientVitalsMonitor.tsx | 8 +-- .../VitalsMonitor/HL7VitalsRenderer.ts | 2 +- .../VentilatorPatientVitalsMonitor.tsx | 4 +- .../VentilatorWaveformsRenderer.ts | 2 +- .../VitalsMonitorAssetPopover.tsx | 2 +- .../VitalsMonitor/useHL7VitalsMonitor.ts | 14 ++-- .../useVentilatorVitalsMonitor.ts | 16 ++--- .../useVitalsAspectRatioConfig.ts | 2 +- src/Components/VitalsMonitor/utils.ts | 4 +- src/Integrations/Plausible.tsx | 2 +- src/Providers/AuthUserProvider.tsx | 2 +- src/Providers/HistoryAPIProvider.tsx | 2 +- src/Redux/Reducer.tsx | 2 +- src/Redux/actions.tsx | 10 +-- src/Redux/fireRequest.tsx | 4 +- src/Routers/AppRouter.tsx | 6 +- src/Utils/AutoSave.tsx | 11 +-- src/Utils/request/handleResponse.ts | 2 +- src/Utils/request/request.ts | 4 +- src/Utils/request/uploadFile.ts | 2 +- src/Utils/request/useQuery.ts | 4 +- src/Utils/request/utils.ts | 10 +-- src/Utils/useRecorder.js | 2 +- src/Utils/useSegmentedRecorder.ts | 2 +- src/Utils/useVisibility.ts | 2 +- src/Utils/utils.ts | 36 +++++----- src/index.tsx | 2 +- src/service-worker.ts | 6 +- 257 files changed, 1037 insertions(+), 1024 deletions(-) diff --git a/src/CAREUI/display/Card.tsx b/src/CAREUI/display/Card.tsx index 82d535a5a0a..3772fa0b75b 100644 --- a/src/CAREUI/display/Card.tsx +++ b/src/CAREUI/display/Card.tsx @@ -3,7 +3,7 @@ import { HTMLAttributes, ReactNode } from "react"; export default function Card( props: { children?: ReactNode; - } & HTMLAttributes + } & HTMLAttributes, ) { const { children, ...rest } = props; return ( diff --git a/src/CAREUI/display/Chip.tsx b/src/CAREUI/display/Chip.tsx index 7bcbd6078e4..30f73ce4a43 100644 --- a/src/CAREUI/display/Chip.tsx +++ b/src/CAREUI/display/Chip.tsx @@ -43,7 +43,7 @@ export default function Chip({ custom: "", }[variant], - props.className + props.className, )} title={props.tooltip} > diff --git a/src/CAREUI/display/NetworkSignal.tsx b/src/CAREUI/display/NetworkSignal.tsx index b0ae2c541cb..2bcd2744acb 100644 --- a/src/CAREUI/display/NetworkSignal.tsx +++ b/src/CAREUI/display/NetworkSignal.tsx @@ -23,7 +23,7 @@ export default function NetworkSignal({ strength, children }: Props) { strength === 0 && "text-danger-500", strength === 1 && "text-danger-500", strength === 2 && "text-warning-500", - strength === 3 && "text-primary-500" + strength === 3 && "text-primary-500", )} >
@@ -45,7 +45,7 @@ export default function NetworkSignal({ strength, children }: Props) { i === 2 && "h-[15px]", // Whether to infill with strength color or not - strength > i ? "bg-current" : "bg-zinc-600" + strength > i ? "bg-current" : "bg-zinc-600", )} /> )) diff --git a/src/CAREUI/display/Timeline.tsx b/src/CAREUI/display/Timeline.tsx index 9889894ac47..b2401630e93 100644 --- a/src/CAREUI/display/Timeline.tsx +++ b/src/CAREUI/display/Timeline.tsx @@ -57,7 +57,7 @@ export const TimelineNode = (props: TimelineNodeProps) => {
@@ -66,14 +66,14 @@ export const TimelineNode = (props: TimelineNodeProps) => {
{props.title || ( diff --git a/src/CAREUI/icons/icon.js b/src/CAREUI/icons/icon.js index 0707d350f27..c917e664351 100644 --- a/src/CAREUI/icons/icon.js +++ b/src/CAREUI/icons/icon.js @@ -18,7 +18,7 @@ const createSvg = (className) => { const el = document.createElementNS(xmlns, "svg"); el.setAttribute( "class", - className.replace("care", "care-svg-icon__baseline") + className.replace("care", "care-svg-icon__baseline"), ); el.setAttribute("role", "img"); el.setAttribute("xmlns", xmlns); diff --git a/src/CAREUI/interactive/KeyboardShortcut.tsx b/src/CAREUI/interactive/KeyboardShortcut.tsx index 47a9fbfca28..06ce149fb51 100644 --- a/src/CAREUI/interactive/KeyboardShortcut.tsx +++ b/src/CAREUI/interactive/KeyboardShortcut.tsx @@ -21,7 +21,7 @@ export default function KeyboardShortcut(props: Props) { {props.helpText} diff --git a/src/CAREUI/interactive/LegendInput.tsx b/src/CAREUI/interactive/LegendInput.tsx index b057e7772c5..334c4b84838 100644 --- a/src/CAREUI/interactive/LegendInput.tsx +++ b/src/CAREUI/interactive/LegendInput.tsx @@ -97,7 +97,7 @@ export default function LegendInput(props: InputProps) { (focused || ref.current?.value) && props.size === "small" && "-top-[7px]", - props.error && "text-red-500" + props.error && "text-red-500", )} > {props.legend} @@ -134,7 +134,7 @@ export default function LegendInput(props: InputProps) { props.size === "large" && "px-5 py-4 text-lg", props.type === "PASSWORD" && "pr-10", props.error && "border-red-500", - props.className + props.className, )} /> {props.type === "PASSWORD" && ( diff --git a/src/CAREUI/interactive/ScrollOverlay.tsx b/src/CAREUI/interactive/ScrollOverlay.tsx index c49f7223149..7c481495b59 100644 --- a/src/CAREUI/interactive/ScrollOverlay.tsx +++ b/src/CAREUI/interactive/ScrollOverlay.tsx @@ -20,7 +20,7 @@ export default function ScrollOverlay(props: Props) {
{hasScrollContent && props.overlay} diff --git a/src/CAREUI/interactive/SlideOver.tsx b/src/CAREUI/interactive/SlideOver.tsx index a92344c41ba..68aa5dc088f 100644 --- a/src/CAREUI/interactive/SlideOver.tsx +++ b/src/CAREUI/interactive/SlideOver.tsx @@ -77,7 +77,7 @@ export default function SlideOver({
@@ -94,7 +94,7 @@ export default function SlideOver({ className={classNames( "pointer-events-auto fixed", directionClasses[slideFrom].stick, - !onlyChild && "md:p-2" + !onlyChild && "md:p-2", )} > {onlyChild ? ( @@ -104,7 +104,7 @@ export default function SlideOver({ className={classNames( "flex flex-col bg-white md:rounded-xl", directionClasses[slideFrom].proportions, - dialogClass + dialogClass, )} >
diff --git a/src/CAREUI/interactive/Switch.tsx b/src/CAREUI/interactive/Switch.tsx index 3e18795b034..48eca49151d 100644 --- a/src/CAREUI/interactive/Switch.tsx +++ b/src/CAREUI/interactive/Switch.tsx @@ -26,7 +26,7 @@ export default function Switch({ size === "lg" && "px-4 py-3 text-base", props.selected === tab ? "border-primary-500 bg-primary-500 font-semibold text-white hover:bg-primary-600 focus:border-primary-500 focus:ring-primary-500" - : "border-gray-400 bg-gray-50 hover:bg-gray-200 focus:border-primary-500 focus:ring-primary-500" + : "border-gray-400 bg-gray-50 hover:bg-gray-200 focus:border-primary-500 focus:ring-primary-500", )} onClick={() => props.onChange(tab as T)} > diff --git a/src/CAREUI/misc/PaginatedList.tsx b/src/CAREUI/misc/PaginatedList.tsx index 363e657f253..db68c6f042c 100644 --- a/src/CAREUI/misc/PaginatedList.tsx +++ b/src/CAREUI/misc/PaginatedList.tsx @@ -35,7 +35,7 @@ interface Props extends QueryOptions> { perPage?: number; children: ( ctx: PaginatedListContext, - query: ReturnType>> + query: ReturnType>>, ) => JSX.Element | JSX.Element[]; } diff --git a/src/CAREUI/misc/ThemedFavicon.tsx b/src/CAREUI/misc/ThemedFavicon.tsx index 55b8d34ec7e..b908f566b89 100644 --- a/src/CAREUI/misc/ThemedFavicon.tsx +++ b/src/CAREUI/misc/ThemedFavicon.tsx @@ -4,7 +4,7 @@ export default function ThemedFavicon() { useEffect(() => { const darkThemeMq = window.matchMedia("(prefers-color-scheme: dark)"); const favicon = document.querySelector( - "link[rel~='icon']" + "link[rel~='icon']", ) as HTMLLinkElement; favicon.href = darkThemeMq.matches ? "/favicon-light.ico" : "/favicon.ico"; diff --git a/src/Common/constants.tsx b/src/Common/constants.tsx index 382831f8ed8..862ba9e79ea 100644 --- a/src/Common/constants.tsx +++ b/src/Common/constants.tsx @@ -739,7 +739,7 @@ export const CAMERA_TYPE = [ export const GENDER: { [key: number]: string } = GENDER_TYPES.reduce( (acc, curr) => ({ ...acc, [curr.id]: curr.text }), - {} + {}, ); export type CameraPTZ = { @@ -1028,7 +1028,7 @@ export const AssetImportSchema: SchemaType = { if (!ip) return null; const isValid = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test( - ip + ip, ); if (!isValid) { diff --git a/src/Common/hooks/useAsyncOptions.ts b/src/Common/hooks/useAsyncOptions.ts index 4c9199b02be..1a632dc366e 100644 --- a/src/Common/hooks/useAsyncOptions.ts +++ b/src/Common/hooks/useAsyncOptions.ts @@ -34,7 +34,7 @@ interface IUseAsyncOptionsArgs { */ export function useAsyncOptions>( uniqueKey: keyof T, - args?: IUseAsyncOptionsArgs + args?: IUseAsyncOptionsArgs, ) { const dispatch = useDispatch(); const [queryOptions, setQueryOptions] = useState([]); @@ -47,18 +47,18 @@ export function useAsyncOptions>( const res = await dispatch(action); if (res?.data) setQueryOptions( - args?.queryResponseExtractor?.(res.data) ?? (res.data as T[]) + args?.queryResponseExtractor?.(res.data) ?? (res.data as T[]), ); setIsLoading(false); }, args?.debounceInterval ?? 300), - [dispatch, args?.debounceInterval] + [dispatch, args?.debounceInterval], ); const mergeValueWithQueryOptions = (selected?: T[]) => { return mergeQueryOptions( selected ?? [], queryOptions, - (obj) => obj[uniqueKey] + (obj) => obj[uniqueKey], ); }; diff --git a/src/Common/hooks/useAuthUser.ts b/src/Common/hooks/useAuthUser.ts index dda5f399952..78bf93fa8f8 100644 --- a/src/Common/hooks/useAuthUser.ts +++ b/src/Common/hooks/useAuthUser.ts @@ -17,7 +17,7 @@ export const useAuthContext = () => { const ctx = useContext(AuthUserContext); if (!ctx) { throw new Error( - "'useAuthContext' must be used within 'AuthUserProvider' only" + "'useAuthContext' must be used within 'AuthUserProvider' only", ); } return ctx; diff --git a/src/Common/hooks/useBreakpoints.ts b/src/Common/hooks/useBreakpoints.ts index 5428a8d1b93..065177a00ed 100644 --- a/src/Common/hooks/useBreakpoints.ts +++ b/src/Common/hooks/useBreakpoints.ts @@ -21,7 +21,7 @@ const BREAKPOINT_WIDTH: Record = { * @returns The value mapped to the current breakpoint. */ export default function useBreakpoints( - map: Partial> & { default: T } + map: Partial> & { default: T }, ) { const { width } = useWindowDimensions(); diff --git a/src/Common/hooks/useExport.tsx b/src/Common/hooks/useExport.tsx index f2ce1c57bf6..e7a76036b07 100644 --- a/src/Common/hooks/useExport.tsx +++ b/src/Common/hooks/useExport.tsx @@ -17,7 +17,7 @@ export default function useExport() { const exportCSV = async ( filenamePrefix: string, action: any, - parse = (data: string) => data + parse = (data: string) => data, ) => { setIsExporting(true); @@ -40,7 +40,7 @@ export default function useExport() { const exportJSON = async ( filenamePrefix: string, action: any, - parse = (data: string) => data + parse = (data: string) => data, ) => { setIsExporting(true); @@ -62,7 +62,7 @@ export default function useExport() { action: any, filePrefix = "export", type = "csv", - parse = (data: string) => data + parse = (data: string) => data, ) => { if (!action) return; diff --git a/src/Common/hooks/useFeedPTZ.ts b/src/Common/hooks/useFeedPTZ.ts index b064e9180ee..a393edc5922 100644 --- a/src/Common/hooks/useFeedPTZ.ts +++ b/src/Common/hooks/useFeedPTZ.ts @@ -50,7 +50,7 @@ interface UseMSEMediaPlayerReturnType { getPTZPayload: ( action: PTZ, precision?: number, - value?: number + value?: number, ) => PTZPayload; getCameraStatus: (options: IOptions) => void; getPresets: (options: IOptions) => void; @@ -80,7 +80,7 @@ const getCameraStatus = action: { type: "get_status", }, - }) + }), ); resp && (resp.status === 200 @@ -97,7 +97,7 @@ const getPresets = action: { type: "get_presets", }, - }) + }), ); resp && (resp.status === 200 @@ -119,7 +119,7 @@ const gotoPreset = type: "goto_preset", data: payload, }, - }) + }), ); resp && (resp.status === 200 @@ -137,7 +137,7 @@ const absoluteMove = type: "absolute_move", data: payload, }, - }) + }), ); resp && (resp.status === 200 @@ -155,7 +155,7 @@ const relativeMove = type: "relative_move", data: payload, }, - }) + }), ); resp && (resp.status === 200 @@ -166,7 +166,7 @@ const relativeMove = export const getPTZPayload = ( action: PTZ, precision = 1, - value?: number + value?: number, ): PTZPayload => { let x = 0; let y = 0; diff --git a/src/Common/hooks/useFilters.tsx b/src/Common/hooks/useFilters.tsx index 1c62a10d9d0..b86206c4b2d 100644 --- a/src/Common/hooks/useFilters.tsx +++ b/src/Common/hooks/useFilters.tsx @@ -39,7 +39,7 @@ export default function useFilters({ const setQueryParams = ( query: QueryParam, - options?: setQueryParamsOptions + options?: setQueryParamsOptions, ) => { query = FiltersCache.utils.clean(query); _setQueryParams(query, options); @@ -142,7 +142,7 @@ export default function useFilters({ falseLabel?: string; trueValue?: string; falseValue?: string; - } + }, ) { const { trueLabel = "Yes", @@ -222,7 +222,7 @@ export default function useFilters({ className={classNames( "flex w-full justify-center", totalCount > limit ? "visible" : "invisible", - !noMargin && "mt-4" + !noMargin && "mt-4", )} > void + (value: boolean, element?: HTMLElement) => void, ] { const [isFullscreen, _setIsFullscreen] = useState( - !!document.fullscreenElement + !!document.fullscreenElement, ); useEffect(() => { @@ -26,14 +26,16 @@ export default function useFullscreen(): [ function openFullscreen(elem: HTMLElementWithFullscreen) { // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore - if (elem.webkitEnterFullscreen) elem.webkitEnterFullscreen(); // Safari + if (elem.webkitEnterFullscreen) + elem.webkitEnterFullscreen(); // Safari else elem.requestFullscreen(); } function exitFullscreen(elem: HTMLElementWithFullscreen) { // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore - if (elem.webkitExitFullscreen) elem.webkitExitFullscreen(); // Safari + if (elem.webkitExitFullscreen) + elem.webkitExitFullscreen(); // Safari else document.exitFullscreen(); } diff --git a/src/Common/hooks/useMSEplayer.ts b/src/Common/hooks/useMSEplayer.ts index 23f9e7b70c7..482f991bc25 100644 --- a/src/Common/hooks/useMSEplayer.ts +++ b/src/Common/hooks/useMSEplayer.ts @@ -84,7 +84,7 @@ const Utf8ArrayToStr = (array: string | any[] | Uint8Array) => { char2 = array[i++]; char3 = array[i++]; out += String.fromCharCode( - ((c & 0x0f) << 12) | ((char2 & 0x3f) << 6) | ((char3 & 0x3f) << 0) + ((c & 0x0f) << 12) | ((char2 & 0x3f) << 6) | ((char3 & 0x3f) << 0), ); break; } @@ -163,7 +163,7 @@ export const useMSEMediaPlayer = ({ mimeCodec = Utf8ArrayToStr(decoded_arr); } mseSourceBuffer = mse.addSourceBuffer( - `video/mp4; codecs="${mimeCodec}"` + `video/mp4; codecs="${mimeCodec}"`, ); mseSourceBuffer.mode = "segments"; if (mseQueue.length > 0 && !mseSourceBuffer.updating) { @@ -177,7 +177,7 @@ export const useMSEMediaPlayer = ({ onError && onError(event); }; }, - false + false, ); } } catch (e) { diff --git a/src/Common/hooks/useRangePagination.ts b/src/Common/hooks/useRangePagination.ts index b7c8b8510a5..966596ffb33 100644 --- a/src/Common/hooks/useRangePagination.ts +++ b/src/Common/hooks/useRangePagination.ts @@ -14,7 +14,7 @@ interface Props { const useRangePagination = ({ bounds, perPage, ...props }: Props) => { const [currentRange, setCurrentRange] = useState( - getInitialBounds(bounds, perPage, props.defaultEnd) + getInitialBounds(bounds, perPage, props.defaultEnd), ); useEffect(() => { @@ -90,7 +90,7 @@ export default useRangePagination; const getInitialBounds = ( bounds: DateRange, perPage: number, - defaultEnd?: boolean + defaultEnd?: boolean, ) => { const deltaBounds = bounds.end.valueOf() - bounds.start.valueOf(); diff --git a/src/Common/hooks/useSlug.ts b/src/Common/hooks/useSlug.ts index 8885a074678..78d2a567e37 100644 --- a/src/Common/hooks/useSlug.ts +++ b/src/Common/hooks/useSlug.ts @@ -32,7 +32,7 @@ const findSlug = (segments: string[], prefix: string, fallback?: string) => { const index = segments.findIndex((segment) => segment === prefix); if (index === -1) { throw new Error( - `Prefix "${prefix}" not found in path "${segments.join("/")}"` + `Prefix "${prefix}" not found in path "${segments.join("/")}"`, ); } diff --git a/src/Common/hooks/useWindowDimensions.ts b/src/Common/hooks/useWindowDimensions.ts index 2118c158f86..372ea62f7e1 100644 --- a/src/Common/hooks/useWindowDimensions.ts +++ b/src/Common/hooks/useWindowDimensions.ts @@ -15,7 +15,7 @@ const getWindowDimensions = () => { */ export default function useWindowDimensions() { const [windowDimensions, setWindowDimensions] = useState( - getWindowDimensions() + getWindowDimensions(), ); useEffect(() => { diff --git a/src/Common/schemaParser.ts b/src/Common/schemaParser.ts index f40965a5e24..d4c2d89e1ee 100644 --- a/src/Common/schemaParser.ts +++ b/src/Common/schemaParser.ts @@ -37,7 +37,7 @@ interface parseDataProps { const validateAndParse = ( key: string, value: any, - schema: SingleKeySchema + schema: SingleKeySchema, ): { [key: string]: { value: any; error?: string } } => { try { const parsedValue = schema?.parse?.(value) ?? value; @@ -85,7 +85,7 @@ const validateAndParse = ( const parseDataWithSchema = ( data: any[], - schema: SchemaType + schema: SchemaType, ): parseDataProps => { const errors: ErrorData[] = []; const parsedData: ParsedData[] = []; @@ -175,11 +175,11 @@ const parseDataWithSchema = ( */ const schemaParser = ( dataArray: any[], - schema: SchemaType + schema: SchemaType, ): parseDataProps & { ParsedDataWithOutErrors: ParsedData[] } => { const { dataWithErrors, parsedData, errors } = parseDataWithSchema( dataArray, - schema + schema, ); const ParsedDataWithOutErrors = parsedData.filter((item, index) => { diff --git a/src/Common/utils.tsx b/src/Common/utils.tsx index b1e98a9e196..05022d8bc2e 100644 --- a/src/Common/utils.tsx +++ b/src/Common/utils.tsx @@ -10,7 +10,7 @@ type AbortableFunction = (status: statusType) => any; export const useAbortableEffect = ( effect: AbortableFunction, - dependencies: Array + dependencies: Array, ) => { const status: statusType = {}; // mutable status object useEffect(() => { @@ -32,7 +32,7 @@ export const useAbortableEffect = ( export const parseOptionId: ( options: readonly OptionsType[], - id: string | string[] + id: string | string[], ) => string = (options, id) => { const textArray = options .filter((option) => { diff --git a/src/Common/validation.tsx b/src/Common/validation.tsx index ef60a40bd79..c7c084354a8 100644 --- a/src/Common/validation.tsx +++ b/src/Common/validation.tsx @@ -23,7 +23,7 @@ export const validateEmailAddress = (email: string) => { export const getArrayValueByKey = ( arr: Array, attr: string, - value: string | number + value: string | number, ) => { for (let i = 0; i < arr.length; i++) { if (arr[i][attr] === value) { diff --git a/src/Components/ABDM/ConfigureHealthFacility.tsx b/src/Components/ABDM/ConfigureHealthFacility.tsx index e64841464a1..6f13cf01374 100644 --- a/src/Components/ABDM/ConfigureHealthFacility.tsx +++ b/src/Components/ABDM/ConfigureHealthFacility.tsx @@ -82,7 +82,7 @@ export const ConfigureHealthFacility = (props: any) => { pathParams: { facility_id: facilityId, }, - } + }, ); response = res; responseData = data; @@ -96,7 +96,7 @@ export const ConfigureHealthFacility = (props: any) => { body: { hf_id: state.form.hf_id, }, - } + }, ); response = res; responseData = data; @@ -156,7 +156,7 @@ export const ConfigureHealthFacility = (props: any) => { "tooltip cursor-pointer text-sm", state.form.health_facility?.registered ? "text-primary-600 hover:text-primary-800" - : "text-warning-600 hover:text-warning-800" + : "text-warning-600 hover:text-warning-800", )} > {state.form.health_facility?.registered ? ( diff --git a/src/Components/ABDM/LinkABHANumberModal.tsx b/src/Components/ABDM/LinkABHANumberModal.tsx index 8093ae94323..d7dfc9f60c1 100644 --- a/src/Components/ABDM/LinkABHANumberModal.tsx +++ b/src/Components/ABDM/LinkABHANumberModal.tsx @@ -17,7 +17,7 @@ import { ABDMError, ABHAQRContent } from "./models"; export const validateRule = ( condition: boolean, - content: JSX.Element | string + content: JSX.Element | string, ) => { return (
@@ -113,7 +113,7 @@ export default function LinkABHANumberModal({
{["AadhaarVerification", "MobileVerification", "HealthIDCreation"].find( - (step) => step === currentStep + (step) => step === currentStep, ) ? (

setCurrentStep("ScanExistingQR")} @@ -278,7 +278,7 @@ const ScanABHAQRSection = ({ txnId: txnId, patientId: patientId, }, - } + }, ); response = res; Rdata = data; @@ -296,7 +296,7 @@ const ScanABHAQRSection = ({ txnId: txnId, patientId: patientId, }, - } + }, ); response = res; Rdata = data; @@ -331,7 +331,7 @@ const ScanABHAQRSection = ({ onClick={async () => { const { res, data } = await request( routes.abha.initiateAbdmAuthentication, - { body: { authMethod: method, healthid: qrValue } } + { body: { authMethod: method, healthid: qrValue } }, ); if (res?.status === 200 && data?.txnId) { @@ -355,16 +355,16 @@ const ScanABHAQRSection = ({ body: { healthId: qrValue, }, - } + }, ); if (res?.status === 200 && data?.authMethods) { setAuthMethods( data.authMethods?.filter?.((method: string) => supportedAuthMethods.find( - (supported) => supported === method - ) - ) + (supported) => supported === method, + ), + ), ); } }} @@ -407,7 +407,7 @@ const VerifyAadhaarSection = ({ onVerified }: VerifyAadhaarSectionProps) => { const validateAadhaar = () => { if (aadhaarNumber.length !== 12 && aadhaarNumber.length !== 16) { setAadhaarNumberError( - "Should be a 12-digit aadhaar number or 16-digit virtual ID" + "Should be a 12-digit aadhaar number or 16-digit virtual ID", ); return false; } @@ -525,7 +525,7 @@ const VerifyAadhaarSection = ({ onVerified }: VerifyAadhaarSectionProps) => { Aadhaar number will not be stored by CARE @@ -841,19 +841,19 @@ const CreateHealthIDSection = ({

{validateRule( healthId.length >= 4, - "Should be atleast 4 character long" + "Should be atleast 4 character long", )} {validateRule( isNaN(Number(healthId[0])) && healthId[0] !== ".", - "Shouldn't start with a number or dot (.)" + "Shouldn't start with a number or dot (.)", )} {validateRule( healthId[healthId.length - 1] !== ".", - "Shouldn't end with a dot (.)" + "Shouldn't end with a dot (.)", )} {validateRule( /^[0-9a-zA-Z.]+$/.test(healthId), - "Should only contain letters, numbers and dot (.)" + "Should only contain letters, numbers and dot (.)", )}
)} diff --git a/src/Components/Assets/AssetFilter.tsx b/src/Components/Assets/AssetFilter.tsx index 1fca1475269..0470ea7f701 100644 --- a/src/Components/Assets/AssetFilter.tsx +++ b/src/Components/Assets/AssetFilter.tsx @@ -23,7 +23,7 @@ function AssetFilter(props: any) { const [facility, setFacility] = useState(null); const [asset_status, setAssetStatus] = useState(filter.status || ""); const [asset_class, setAssetClass] = useState( - filter.asset_class || "" + filter.asset_class || "", ); const [facilityId, setFacilityId] = useState(filter.facility); const [locationId, setLocationId] = useState(filter.location); @@ -46,7 +46,7 @@ function AssetFilter(props: any) { useEffect(() => { setFacilityId(facility?.id ? `${facility?.id}` : ""); setLocationId( - facility?.id === qParams.facility ? qParams.location ?? "" : "" + facility?.id === qParams.facility ? qParams.location ?? "" : "", ); }, [facility?.id, qParams.facility, qParams.location]); @@ -62,7 +62,7 @@ function AssetFilter(props: any) { status: asset_status ?? "", location: locationId ?? "", warranty_amc_end_of_validity_before: dateQueryString( - warrantyExpiry.before + warrantyExpiry.before, ), warranty_amc_end_of_validity_after: dateQueryString(warrantyExpiry.after), }; diff --git a/src/Components/Assets/AssetImportModal.tsx b/src/Components/Assets/AssetImportModal.tsx index 5b1ed5bc4fa..8c020e1a006 100644 --- a/src/Components/Assets/AssetImportModal.tsx +++ b/src/Components/Assets/AssetImportModal.tsx @@ -12,7 +12,7 @@ import useQuery from "../../Utils/request/useQuery"; import routes from "../../Redux/api"; import { SelectFormField } from "../Form/FormFields/SelectFormField"; const ExcelFileDragAndDrop = lazy( - () => import("../Common/ExcelFIleDragAndDrop") + () => import("../Common/ExcelFIleDragAndDrop"), ); interface Props { @@ -41,7 +41,7 @@ const AssetImportModal = ({ open, onClose, facility, onUpdate }: Props) => { const locations = data?.results || []; const handleUpload = async ( - data: (AssetData & { notes?: string; last_serviced_on?: string })[] + data: (AssetData & { notes?: string; last_serviced_on?: string })[], ) => { if (!data) { closeModal(); diff --git a/src/Components/Assets/AssetManage.tsx b/src/Components/Assets/AssetManage.tsx index 786f24fce55..5835ad297f5 100644 --- a/src/Components/Assets/AssetManage.tsx +++ b/src/Components/Assets/AssetManage.tsx @@ -73,7 +73,7 @@ const AssetManage = (props: AssetManageProps) => { setTransactionFilter( data.qr_code_id ? { qr_code_id: data.qr_code_id } - : { external_id: assetId } + : { external_id: assetId }, ); } }, @@ -99,7 +99,7 @@ const AssetManage = (props: AssetManageProps) => { pathParams: { asset_external_id: assetId, }, - } + }, ); const handlePagination = (page: number, limit: number) => { @@ -158,7 +158,7 @@ const AssetManage = (props: AssetManageProps) => { - )) + )), ); } else { setTransactionDetails( @@ -169,7 +169,7 @@ const AssetManage = (props: AssetManageProps) => { >
No Transactions Found
- + , ); } }; @@ -235,7 +235,7 @@ const AssetManage = (props: AssetManageProps) => { - )) + )), ); } else { setServiceDetails( @@ -246,7 +246,7 @@ const AssetManage = (props: AssetManageProps) => { >
No Service Logs Found
- + , ); } }; @@ -386,7 +386,7 @@ const AssetManage = (props: AssetManageProps) => { /> )} {warrantyAmcValidityChip( - asset?.warranty_amc_end_of_validity as string + asset?.warranty_amc_end_of_validity as string, )} {asset?.latest_status === "Down" && ( { className="flex gap-2" onClick={() => navigate( - `/facility/${asset?.location_object.facility?.id}/assets/${asset?.id}/update` + `/facility/${asset?.location_object.facility?.id}/assets/${asset?.id}/update`, ) } id="update-asset" @@ -439,12 +439,12 @@ const AssetManage = (props: AssetManageProps) => { {asset?.asset_class && (asset?.asset_class !== "ONVIF" || ["DistrictAdmin", "StateAdmin", "Doctor"].includes( - authUser.user_type + authUser.user_type, )) && ( navigate( - `/facility/${asset?.location_object.facility?.id}/assets/${asset?.id}/configure` + `/facility/${asset?.location_object.facility?.id}/assets/${asset?.id}/configure`, ) } id="configure-asset" diff --git a/src/Components/Assets/AssetServiceEditModal.tsx b/src/Components/Assets/AssetServiceEditModal.tsx index 13a91e36477..87bf561d471 100644 --- a/src/Components/Assets/AssetServiceEditModal.tsx +++ b/src/Components/Assets/AssetServiceEditModal.tsx @@ -197,12 +197,12 @@ export const AssetServiceEditModal = (props: { if ( dayjs(date.value).format("YYYY-MM-DD") > new Date( - props.service_record.created_date + props.service_record.created_date, ).toLocaleDateString("en-ca") ) { Notification.Error({ msg: `Service date can't be after ${formatDate( - props.service_record.created_date + props.service_record.created_date, )} (Creation date)`, }); } else { diff --git a/src/Components/Assets/AssetType/ONVIFCamera.tsx b/src/Components/Assets/AssetType/ONVIFCamera.tsx index ba023788496..21beb5f7bf8 100644 --- a/src/Components/Assets/AssetType/ONVIFCamera.tsx +++ b/src/Components/Assets/AssetType/ONVIFCamera.tsx @@ -40,7 +40,7 @@ const ONVIFCamera = ({ assetId, facilityId, asset, onUpdated }: Props) => { const [loadingAddPreset, setLoadingAddPreset] = useState(false); const [loadingSetConfiguration, setLoadingSetConfiguration] = useState(false); const [refreshPresetsHash, setRefreshPresetsHash] = useState( - Number(new Date()) + Number(new Date()), ); const { data: facility, loading } = useQuery(routes.getPermittedFacility, { pathParams: { id: facilityId }, @@ -101,7 +101,7 @@ const ONVIFCamera = ({ assetId, facilityId, asset, onUpdated }: Props) => { setLoadingAddPreset(true); const response = await fetch( - `https://${resolvedMiddleware?.hostname}/status?hostname=${config.hostname}&port=${config.port}&username=${config.username}&password=${config.password}` + `https://${resolvedMiddleware?.hostname}/status?hostname=${config.hostname}&port=${config.port}&username=${config.username}&password=${config.password}`, ); if (!response.ok) { throw new Error("Network error"); diff --git a/src/Components/Assets/AssetsList.tsx b/src/Components/Assets/AssetsList.tsx index f7283250010..9e1469c91a5 100644 --- a/src/Components/Assets/AssetsList.tsx +++ b/src/Components/Assets/AssetsList.tsx @@ -130,7 +130,7 @@ const AssetsList = () => { try { if (assetData) { navigate( - `/facility/${assetData.location_object.facility?.id}/assets/${assetId}` + `/facility/${assetData.location_object.facility?.id}/assets/${assetId}`, ); } } catch (err) { @@ -143,7 +143,7 @@ const AssetsList = () => { }; const authorizedForImportExport = useIsAuthorized( - AuthorizeFor(["DistrictAdmin", "StateAdmin"]) + AuthorizeFor(["DistrictAdmin", "StateAdmin"]), ); if (isScannerActive) @@ -390,7 +390,7 @@ const AssetsList = () => { value( "Facility", "facility", - qParams.facility && facilityObject?.name + qParams.facility && facilityObject?.name, ), badge("Name/Serial No./QR ID", "search"), value("Asset Class", "asset_class", asset_class ?? ""), @@ -398,17 +398,17 @@ const AssetsList = () => { value( "Location", "location", - qParams.location && locationObject?.name + qParams.location && locationObject?.name, ), value( "Warranty AMC End Of Validity Before", "warranty_amc_end_of_validity_before", - qParams.warranty_amc_end_of_validity_before ?? "" + qParams.warranty_amc_end_of_validity_before ?? "", ), value( "Warranty AMC End Of Validity After", "warranty_amc_end_of_validity_after", - qParams.warranty_amc_end_of_validity_after ?? "" + qParams.warranty_amc_end_of_validity_after ?? "", ), ]} /> @@ -468,7 +468,7 @@ const AssetsList = () => { }; export const warrantyAmcValidityChip = ( - warranty_amc_end_of_validity: string + warranty_amc_end_of_validity: string, ) => { if (warranty_amc_end_of_validity === "" || !warranty_amc_end_of_validity) return; @@ -476,7 +476,8 @@ export const warrantyAmcValidityChip = ( const warrantyAmcEndDate = new Date(warranty_amc_end_of_validity); const days = Math.ceil( - Math.abs(Number(warrantyAmcEndDate) - Number(today)) / (1000 * 60 * 60 * 24) + Math.abs(Number(warrantyAmcEndDate) - Number(today)) / + (1000 * 60 * 60 * 24), ); if (warrantyAmcEndDate < today) { diff --git a/src/Components/Assets/configure/MonitorConfigure.tsx b/src/Components/Assets/configure/MonitorConfigure.tsx index 62931617b68..5053b5b7d02 100644 --- a/src/Components/Assets/configure/MonitorConfigure.tsx +++ b/src/Components/Assets/configure/MonitorConfigure.tsx @@ -22,7 +22,7 @@ const saveLink = async (assetId: string, bedId: string) => { const update_Link = async ( assetbedId: string, assetId: string, - bed: BedModel + bed: BedModel, ) => { await request(routes.partialUpdateAssetBed, { pathParams: { external_id: assetbedId }, @@ -55,7 +55,7 @@ export default function MonitorConfigure({ asset }: { asset: AssetData }) { update_Link( assetBed?.results[0].id as string, asset.id as string, - bed as BedModel + bed as BedModel, ); } else { saveLink(asset.id as string, bed?.id as string); diff --git a/src/Components/Auth/ResetPassword.tsx b/src/Components/Auth/ResetPassword.tsx index 47d120e1a97..325a53b9c80 100644 --- a/src/Components/Auth/ResetPassword.tsx +++ b/src/Components/Auth/ResetPassword.tsx @@ -127,19 +127,19 @@ export const ResetPassword = (props: any) => {
{validateRule( form.password?.length >= 8, - "Password should be atleast 8 characters long" + "Password should be atleast 8 characters long", )} {validateRule( form.password !== form.password.toUpperCase(), - "Password should contain at least 1 lowercase letter" + "Password should contain at least 1 lowercase letter", )} {validateRule( form.password !== form.password.toLowerCase(), - "Password should contain at least 1 uppercase letter" + "Password should contain at least 1 uppercase letter", )} {validateRule( /\d/.test(form.password), - "Password should contain at least 1 number" + "Password should contain at least 1 number", )}
)} @@ -156,7 +156,7 @@ export const ResetPassword = (props: any) => { form.confirm.length > 0 && validateRule( form.confirm === form.password, - "Confirm password should match the entered password" + "Confirm password should match the entered password", )}
diff --git a/src/Components/CameraFeed/CameraFeed.tsx b/src/Components/CameraFeed/CameraFeed.tsx index 6e2d8647c83..d5ea120e126 100644 --- a/src/Components/CameraFeed/CameraFeed.tsx +++ b/src/Components/CameraFeed/CameraFeed.tsx @@ -91,7 +91,7 @@ export default function CameraFeed(props: Props) {
diff --git a/src/Components/CameraFeed/FeedAlert.tsx b/src/Components/CameraFeed/FeedAlert.tsx index 0c2eb6aa429..a4f8a3beb18 100644 --- a/src/Components/CameraFeed/FeedAlert.tsx +++ b/src/Components/CameraFeed/FeedAlert.tsx @@ -58,7 +58,7 @@ export default function FeedAlert({ state }: Props) { diff --git a/src/Components/CameraFeed/FeedButton.tsx b/src/Components/CameraFeed/FeedButton.tsx index 033ffcc11ed..f0e568d4ad4 100644 --- a/src/Components/CameraFeed/FeedButton.tsx +++ b/src/Components/CameraFeed/FeedButton.tsx @@ -16,7 +16,7 @@ export default function FeedButton(props: Props) {