@openmrs/esm-stock-management-app 1.0.1-pre.702 → 1.0.1-pre.706

Sign up to get free protection for your applications and to get access to all the features.
package/dist/627.js CHANGED
@@ -1 +1 @@
1
- "use strict";(globalThis.webpackChunk_openmrs_esm_stock_management_app=globalThis.webpackChunk_openmrs_esm_stock_management_app||[]).push([[627],{7627:(e,t,n)=>{n.r(t),n.d(t,{default:()=>f});var r=n(1672),o=n.n(r),l=n(3397),a=n(2167),i=n(7248);function c(e,t,n,r,o,l,a){try{var i=e[l](a),c=i.value}catch(e){return void n(e)}i.done?t(c):Promise.resolve(c).then(r,o)}function u(){var e;return e=function(e){var t;return function(e,t){var n,r,o,l,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return l={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(l[Symbol.iterator]=function(){return this}),l;function i(l){return function(i){return function(l){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&l[0]?r.return:l[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,l[1])).done)return o;switch(r=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return a.label++,{value:l[1],done:!1};case 5:a.label++,r=l[1],l=[0];continue;case 7:l=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==l[0]&&2!==l[0])){a=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){a.label=l[1];break}if(6===l[0]&&a.label<o[1]){a.label=o[1],o=l;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(l);break}o[2]&&a.ops.pop(),a.trys.pop();continue}l=t.call(e,a)}catch(e){l=[6,e],r=0}finally{n=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([l,i])}}}(this,(function(n){return t=new AbortController,[2,(0,i.openmrsFetch)("".concat(i.restBaseUrl,"/stockmanagement/stockitemimport"),{method:"POST",signal:t.signal,body:e})]}))},u=function(){var t=this,n=arguments;return new Promise((function(r,o){var l=e.apply(t,n);function a(e){c(l,r,o,a,i,"next",e)}function i(e){c(l,r,o,a,i,"throw",e)}a(void 0)}))},u.apply(this,arguments)}function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}const f=function(e){var t,n,c=e.closeModal,f=(0,l.useTranslation)().t,p=(t=(0,r.useState)(),n=2,function(e){if(Array.isArray(e))return e}(t)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,l=[],a=!0,i=!1;try{for(n=n.call(e);!(a=(r=n.next()).done)&&(l.push(r.value),!t||l.length!==t);a=!0);}catch(e){i=!0,o=e}finally{try{a||null==n.return||n.return()}finally{if(i)throw o}}return l}}(t,n)||function(e,t){if(e){if("string"==typeof e)return s(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(n):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?s(e,t):void 0}}(t,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),m=p[0],d=p[1];return o().createElement("div",null,o().createElement(a.l09,null,o().createElement(a.xBx,{closeModal:c,title:f("importStockItems","Import Stock Items")}),o().createElement(a.fef,null,o().createElement(a.bAu,{accept:[".csv"],multiple:!1,name:"file",buttonLabel:"Select file",labelDescription:"Only .csv files at 2mb or less",filenameStatus:"edit",labelTitle:"",size:"small",onChange:function(e){var t,n,r=null==e||null===(n=e.target)||void 0===n||null===(t=n.files)||void 0===t?void 0:t[0];r?d(r):e.preventDefault()}})),o().createElement(a.mzw,null,o().createElement(a.zxk,{kind:"secondary",onClick:c},f("cancel","Cancel")),o().createElement(a.zxk,{type:"button",onClick:function(){if(m){var e=new FormData;m&&(e.append("file",m,"Import_Stock_Items.csv"),e.append("hasHeader","true")),function(e){return u.apply(this,arguments)}(e).then((function(){(0,i.showSnackbar)({isLowContrast:!0,title:f("rejectOrder","Uploaded Order"),kind:"success",subtitle:f("SuccessfullyUploadedStockItem","You have successfully uploaded stock items")}),c()}),(function(e){(0,i.showSnackbar)({title:f("errorUploadingItems","An error occurred uploading stock items"),kind:"error",isLowContrast:!0,subtitle:null==e?void 0:e.message})}))}}},f("uploadStockItems","Upload StockItems")))))}}}]);
1
+ "use strict";(globalThis.webpackChunk_openmrs_esm_stock_management_app=globalThis.webpackChunk_openmrs_esm_stock_management_app||[]).push([[627],{7627:(e,t,n)=>{n.r(t),n.d(t,{default:()=>f});var r=n(1672),o=n.n(r),l=n(3397),a=n(2167),i=n(7248);function c(e,t,n,r,o,l,a){try{var i=e[l](a),c=i.value}catch(e){return void n(e)}i.done?t(c):Promise.resolve(c).then(r,o)}function u(){var e;return e=function(e){var t;return function(e,t){var n,r,o,l,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return l={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(l[Symbol.iterator]=function(){return this}),l;function i(l){return function(i){return function(l){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&l[0]?r.return:l[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,l[1])).done)return o;switch(r=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return a.label++,{value:l[1],done:!1};case 5:a.label++,r=l[1],l=[0];continue;case 7:l=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==l[0]&&2!==l[0])){a=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){a.label=l[1];break}if(6===l[0]&&a.label<o[1]){a.label=o[1],o=l;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(l);break}o[2]&&a.ops.pop(),a.trys.pop();continue}l=t.call(e,a)}catch(e){l=[6,e],r=0}finally{n=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([l,i])}}}(this,(function(n){return t=new AbortController,[2,(0,i.openmrsFetch)("".concat(i.restBaseUrl,"/stockmanagement/stockitemimport"),{method:"POST",signal:t.signal,body:e})]}))},u=function(){var t=this,n=arguments;return new Promise((function(r,o){var l=e.apply(t,n);function a(e){c(l,r,o,a,i,"next",e)}function i(e){c(l,r,o,a,i,"throw",e)}a(void 0)}))},u.apply(this,arguments)}function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}const f=function(e){var t,n,c=e.closeModal,f=(0,l.useTranslation)().t,p=(t=(0,r.useState)(),n=2,function(e){if(Array.isArray(e))return e}(t)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,l=[],a=!0,i=!1;try{for(n=n.call(e);!(a=(r=n.next()).done)&&(l.push(r.value),!t||l.length!==t);a=!0);}catch(e){i=!0,o=e}finally{try{a||null==n.return||n.return()}finally{if(i)throw o}}return l}}(t,n)||function(e,t){if(e){if("string"==typeof e)return s(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(n):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?s(e,t):void 0}}(t,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),m=p[0],d=p[1];return o().createElement("div",null,o().createElement(a.l09,null,o().createElement(a.xBx,{closeModal:c,title:f("importStockItems","Import Stock Items")}),o().createElement(a.fef,null,o().createElement(a.bAu,{accept:[".csv"],multiple:!1,name:"file",buttonLabel:"Select file",labelDescription:"Only .csv files at 2mb or less",filenameStatus:"edit",labelTitle:"",size:"sm",onChange:function(e){var t,n,r=null==e||null===(n=e.target)||void 0===n||null===(t=n.files)||void 0===t?void 0:t[0];r?d(r):e.preventDefault()}})),o().createElement(a.mzw,null,o().createElement(a.zxk,{kind:"secondary",onClick:c},f("cancel","Cancel")),o().createElement(a.zxk,{type:"button",onClick:function(){if(m){var e=new FormData;m&&(e.append("file",m,"Import_Stock_Items.csv"),e.append("hasHeader","true")),function(e){return u.apply(this,arguments)}(e).then((function(){(0,i.showSnackbar)({isLowContrast:!0,title:f("rejectOrder","Uploaded Order"),kind:"success",subtitle:f("SuccessfullyUploadedStockItem","You have successfully uploaded stock items")}),c()}),(function(e){(0,i.showSnackbar)({title:f("errorUploadingItems","An error occurred uploading stock items"),kind:"error",isLowContrast:!0,subtitle:null==e?void 0:e.message})}))}}},f("uploadStockItems","Upload StockItems")))))}}}]);
package/dist/627.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"627.js","mappings":"sXAEsBA,I,eAAf,SAAgCC,G,IAC/BC,E,8jCAEN,OAFMA,EAAkB,IAAIC,gBAErB,C,GAAAC,EAAAA,EAAAA,cAAa,GAAe,OAAZC,EAAAA,YAAY,oCAAmC,CACpEC,OAAQ,OAIRC,OAAQL,EAAgBK,OACxBN,KAAMA,I,GAEV,EAXsBD,E,8KAAAA,EAAAA,MAAAA,KAAAA,U,2GCiFtB,QAzE4D,Y,QAAGQ,EAAAA,EAAAA,WACvD,GAAQC,EAAAA,EAAAA,kBAANC,EACgCC,G,GAAAA,EAAAA,EAAAA,Y,EAAQA,E,+zBAAzCC,EAAiCD,EAAAA,GAAnBE,EAAmBF,EAAAA,GAyCxC,OACE,kBAACG,MAAAA,KACC,kBAACC,EAAAA,IAAIA,KACH,kBAACC,EAAAA,IAAWA,CAACR,WAAYA,EAAYS,MAAOP,EAAE,mBAAoB,wBAClE,kBAACQ,EAAAA,IAASA,KACR,kBAACC,EAAAA,IAAYA,CACXC,OAAQ,CAAC,QACTC,UAAU,EACVC,KAAM,OACNC,YAAY,cACZC,iBAAiB,iCACjBC,eAAe,OACfC,WAAW,GACXC,KAAK,QACLC,SAvBY,SAACC,G,IACRA,EAAAA,EAAPC,EAAOD,SAAa,QAAbA,EAAAA,EAAOE,cAAPF,IAAAA,GAAoB,QAApBA,EAAAA,EAAeG,aAAfH,IAAAA,OAAAA,EAAAA,EAAuB,GAChCC,EACFjB,EAAgBiB,GAEhBD,EAAMI,gBAEV,KAmBM,kBAACC,EAAAA,IAAWA,KACV,kBAACC,EAAAA,IAAMA,CAACC,KAAK,YAAYC,QAAS7B,GAC/BE,EAAE,SAAU,WAEf,kBAACyB,EAAAA,IAAMA,CAACG,KAAK,SAASD,QA5DN,WACtB,GAAKzB,EAAL,CAGA,IAAM2B,EAAW,IAAIC,SACjB5B,IACF2B,EAASE,OAAO,OAAQ7B,EAAc,0BACtC2B,EAASE,OAAO,YAAa,SDnB5B,SAAgCxC,G,OAAjBD,EAAAA,MAAAA,KAAAA,U,CCqBlBA,CAAiBuC,GAAUG,MACzB,YACEC,EAAAA,EAAAA,cAAa,CACXC,eAAe,EACf3B,MAAOP,EAAE,cAAe,kBACxB0B,KAAM,UACNS,SAAUnC,EAAE,gCAAkC,gDAEhDF,GACF,IACA,SAACsC,IACCH,EAAAA,EAAAA,cAAa,CACX1B,MAAOP,EAAE,sBAAuB,2CAChC0B,KAAM,QACNQ,eAAe,EACfC,SAAUC,aAAAA,EAAAA,EAAKC,SAEnB,GAvBF,CAyBF,GAiCWrC,EAAE,mBAAoB,wBAMnC,C","sources":["webpack://@openmrs/esm-stock-management-app/./src/stock-items/add-bulk-stock-item/stock-items-bulk-import.resource.ts","webpack://@openmrs/esm-stock-management-app/./src/stock-items/add-bulk-stock-item/stock-items-bulk-import.component.tsx"],"names":["UploadStockItems","body","abortController","AbortController","openmrsFetch","restBaseUrl","method","signal","closeModal","useTranslation","t","useState","selectedFile","setSelectedFile","div","Form","ModalHeader","title","ModalBody","FileUploader","accept","multiple","name","buttonLabel","labelDescription","filenameStatus","labelTitle","size","onChange","event","file","target","files","preventDefault","ModalFooter","Button","kind","onClick","type","formData","FormData","append","then","showSnackbar","isLowContrast","subtitle","err","message"],"sourceRoot":""}
1
+ {"version":3,"file":"627.js","mappings":"sXAEsBA,I,eAAf,SAAgCC,G,IAC/BC,E,8jCAEN,OAFMA,EAAkB,IAAIC,gBAErB,C,GAAAC,EAAAA,EAAAA,cAAa,GAAe,OAAZC,EAAAA,YAAY,oCAAmC,CACpEC,OAAQ,OAIRC,OAAQL,EAAgBK,OACxBN,KAAMA,I,GAEV,EAXsBD,E,8KAAAA,EAAAA,MAAAA,KAAAA,U,2GCiFtB,QAzE4D,Y,QAAGQ,EAAAA,EAAAA,WACvD,GAAQC,EAAAA,EAAAA,kBAANC,EACgCC,G,GAAAA,EAAAA,EAAAA,Y,EAAQA,E,+zBAAzCC,EAAiCD,EAAAA,GAAnBE,EAAmBF,EAAAA,GAyCxC,OACE,kBAACG,MAAAA,KACC,kBAACC,EAAAA,IAAIA,KACH,kBAACC,EAAAA,IAAWA,CAACR,WAAYA,EAAYS,MAAOP,EAAE,mBAAoB,wBAClE,kBAACQ,EAAAA,IAASA,KACR,kBAACC,EAAAA,IAAYA,CACXC,OAAQ,CAAC,QACTC,UAAU,EACVC,KAAM,OACNC,YAAY,cACZC,iBAAiB,iCACjBC,eAAe,OACfC,WAAW,GACXC,KAAK,KACLC,SAvBY,SAACC,G,IACRA,EAAAA,EAAPC,EAAOD,SAAa,QAAbA,EAAAA,EAAOE,cAAPF,IAAAA,GAAoB,QAApBA,EAAAA,EAAeG,aAAfH,IAAAA,OAAAA,EAAAA,EAAuB,GAChCC,EACFjB,EAAgBiB,GAEhBD,EAAMI,gBAEV,KAmBM,kBAACC,EAAAA,IAAWA,KACV,kBAACC,EAAAA,IAAMA,CAACC,KAAK,YAAYC,QAAS7B,GAC/BE,EAAE,SAAU,WAEf,kBAACyB,EAAAA,IAAMA,CAACG,KAAK,SAASD,QA5DN,WACtB,GAAKzB,EAAL,CAGA,IAAM2B,EAAW,IAAIC,SACjB5B,IACF2B,EAASE,OAAO,OAAQ7B,EAAc,0BACtC2B,EAASE,OAAO,YAAa,SDnB5B,SAAgCxC,G,OAAjBD,EAAAA,MAAAA,KAAAA,U,CCqBlBA,CAAiBuC,GAAUG,MACzB,YACEC,EAAAA,EAAAA,cAAa,CACXC,eAAe,EACf3B,MAAOP,EAAE,cAAe,kBACxB0B,KAAM,UACNS,SAAUnC,EAAE,gCAAkC,gDAEhDF,GACF,IACA,SAACsC,IACCH,EAAAA,EAAAA,cAAa,CACX1B,MAAOP,EAAE,sBAAuB,2CAChC0B,KAAM,QACNQ,eAAe,EACfC,SAAUC,aAAAA,EAAAA,EAAKC,SAEnB,GAvBF,CAyBF,GAiCWrC,EAAE,mBAAoB,wBAMnC,C","sources":["webpack://@openmrs/esm-stock-management-app/./src/stock-items/add-bulk-stock-item/stock-items-bulk-import.resource.ts","webpack://@openmrs/esm-stock-management-app/./src/stock-items/add-bulk-stock-item/stock-items-bulk-import.component.tsx"],"names":["UploadStockItems","body","abortController","AbortController","openmrsFetch","restBaseUrl","method","signal","closeModal","useTranslation","t","useState","selectedFile","setSelectedFile","div","Form","ModalHeader","title","ModalBody","FileUploader","accept","multiple","name","buttonLabel","labelDescription","filenameStatus","labelTitle","size","onChange","event","file","target","files","preventDefault","ModalFooter","Button","kind","onClick","type","formData","FormData","append","then","showSnackbar","isLowContrast","subtitle","err","message"],"sourceRoot":""}
@@ -372,9 +372,9 @@
372
372
  "initial": false,
373
373
  "entry": false,
374
374
  "recorded": false,
375
- "size": 9348,
375
+ "size": 9345,
376
376
  "sizes": {
377
- "javascript": 9348
377
+ "javascript": 9345
378
378
  },
379
379
  "names": [],
380
380
  "idHints": [],
@@ -388,7 +388,7 @@
388
388
  "auxiliaryFiles": [
389
389
  "627.js.map"
390
390
  ],
391
- "hash": "e44bfcef4206b456",
391
+ "hash": "0b31b4561c627de5",
392
392
  "childrenByOrder": {}
393
393
  },
394
394
  {
package/dist/routes.json CHANGED
@@ -1 +1 @@
1
- {"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"fhir2":">=1.2","webservices.rest":"^2.24.0"},"extensions":[{"name":"stock-nav-menu","slot":"stock-sidebar-slot","component":"stockNavMenu","online":true,"offline":true},{"name":"overview-db-link","slot":"stock-page-dashboard-slot","component":"stockOverviewLink","meta":{"name":"overview","slot":"overview-dashboard-slot","title":"overview"},"order":0,"online":true,"offline":true},{"name":"stock-overview-db","slot":"overview-dashboard-slot","component":"stockOverview"},{"name":"operations-db-link","slot":"stock-page-dashboard-slot","component":"stockOperationsLink","meta":{"name":"operations","slot":"operations-dashboard-slot","title":"operations"},"order":2,"online":true,"offline":true},{"name":"stock-operations-db","slot":"operations-dashboard-slot","component":"stockOperations"},{"name":"items-db-link","slot":"stock-page-dashboard-slot","component":"stockItemsLink","meta":{"name":"items","slot":"items-dashboard-slot","title":"items"},"order":1,"online":true,"offline":true},{"name":"stock-items-db","slot":"items-dashboard-slot","component":"stockItems"},{"name":"user-scopes-db-link","slot":"stock-page-dashboard-slot","component":"stockUserScopesLink","meta":{"name":"user-scopes","slot":"user-scopes-dashboard-slot","title":"user-scopes"},"order":3,"online":true,"offline":true},{"name":"stock-user-scopes-db","slot":"user-scopes-dashboard-slot","component":"stockUserScopes"},{"name":"sources-db-link","slot":"stock-page-dashboard-slot","component":"stockSourcesLink","meta":{"name":"sources","slot":"sources-dashboard-slot","title":"Sources"},"order":2,"online":true,"offline":true},{"name":"stock-sources-db","slot":"sources-dashboard-slot","component":"stockSources"},{"name":"locations-db-link","slot":"stock-page-dashboard-slot","component":"stockLocationsLink","meta":{"name":"locations","slot":"locations-dashboard-slot","title":"Locations"},"order":4,"online":true,"offline":true},{"name":"stock-locations-db","slot":"locations-dashboard-slot","component":"stockLocations"},{"name":"reports-db-link","slot":"stock-page-dashboard-slot","component":"stockReportsLink","meta":{"name":"reports","slot":"reports-dashboard-slot","title":"Reports"},"order":5,"online":true,"offline":true},{"name":"stock-reports-db","slot":"reports-dashboard-slot","component":"stockReports"},{"name":"settings-db-link","slot":"stock-page-dashboard-slot","component":"stockSettingsLink","meta":{"name":"settings","slot":"settings-dashboard-slot","title":"Settings"},"order":6,"online":true,"offline":true},{"name":"stock-settings-db","slot":"settings-dashboard-slot","component":"stockSettings"},{"name":"stock-management-admin-card-link","slot":"system-admin-page-card-link-slot","component":"stockManagementAdminCardLink"},{"name":"stock-management-app-menu-item","component":"stockManagementAppMenuItem","slot":"app-menu-item-slot","meta":{"name":" Stock Management"}},{"name":"delete-packaging-unit-button","component":"deletePackagingUnitButton"}],"modals":[{"name":"delete-stock-modal","component":"deleteStockModal"},{"name":"delete-stock-user-scope-modal","component":"deleteUserScopeModal"},{"name":"delete-stock-rule-modal","component":"deleteStockRuleModal"},{"name":"delete-packaging-unit-modal","component":"deletePackagingUnitModal"},{"name":"import-bulk-stock-items","component":"importBulkStockItemsModal"},{"name":"stock-operation-dialog","component":"stockOperationModal"}],"pages":[{"component":"root","route":"stock-management"}],"version":"1.0.1-pre.702"}
1
+ {"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"fhir2":">=1.2","webservices.rest":"^2.24.0"},"extensions":[{"name":"stock-nav-menu","slot":"stock-sidebar-slot","component":"stockNavMenu","online":true,"offline":true},{"name":"overview-db-link","slot":"stock-page-dashboard-slot","component":"stockOverviewLink","meta":{"name":"overview","slot":"overview-dashboard-slot","title":"overview"},"order":0,"online":true,"offline":true},{"name":"stock-overview-db","slot":"overview-dashboard-slot","component":"stockOverview"},{"name":"operations-db-link","slot":"stock-page-dashboard-slot","component":"stockOperationsLink","meta":{"name":"operations","slot":"operations-dashboard-slot","title":"operations"},"order":2,"online":true,"offline":true},{"name":"stock-operations-db","slot":"operations-dashboard-slot","component":"stockOperations"},{"name":"items-db-link","slot":"stock-page-dashboard-slot","component":"stockItemsLink","meta":{"name":"items","slot":"items-dashboard-slot","title":"items"},"order":1,"online":true,"offline":true},{"name":"stock-items-db","slot":"items-dashboard-slot","component":"stockItems"},{"name":"user-scopes-db-link","slot":"stock-page-dashboard-slot","component":"stockUserScopesLink","meta":{"name":"user-scopes","slot":"user-scopes-dashboard-slot","title":"user-scopes"},"order":3,"online":true,"offline":true},{"name":"stock-user-scopes-db","slot":"user-scopes-dashboard-slot","component":"stockUserScopes"},{"name":"sources-db-link","slot":"stock-page-dashboard-slot","component":"stockSourcesLink","meta":{"name":"sources","slot":"sources-dashboard-slot","title":"Sources"},"order":2,"online":true,"offline":true},{"name":"stock-sources-db","slot":"sources-dashboard-slot","component":"stockSources"},{"name":"locations-db-link","slot":"stock-page-dashboard-slot","component":"stockLocationsLink","meta":{"name":"locations","slot":"locations-dashboard-slot","title":"Locations"},"order":4,"online":true,"offline":true},{"name":"stock-locations-db","slot":"locations-dashboard-slot","component":"stockLocations"},{"name":"reports-db-link","slot":"stock-page-dashboard-slot","component":"stockReportsLink","meta":{"name":"reports","slot":"reports-dashboard-slot","title":"Reports"},"order":5,"online":true,"offline":true},{"name":"stock-reports-db","slot":"reports-dashboard-slot","component":"stockReports"},{"name":"settings-db-link","slot":"stock-page-dashboard-slot","component":"stockSettingsLink","meta":{"name":"settings","slot":"settings-dashboard-slot","title":"Settings"},"order":6,"online":true,"offline":true},{"name":"stock-settings-db","slot":"settings-dashboard-slot","component":"stockSettings"},{"name":"stock-management-admin-card-link","slot":"system-admin-page-card-link-slot","component":"stockManagementAdminCardLink"},{"name":"stock-management-app-menu-item","component":"stockManagementAppMenuItem","slot":"app-menu-item-slot","meta":{"name":" Stock Management"}},{"name":"delete-packaging-unit-button","component":"deletePackagingUnitButton"}],"modals":[{"name":"delete-stock-modal","component":"deleteStockModal"},{"name":"delete-stock-user-scope-modal","component":"deleteUserScopeModal"},{"name":"delete-stock-rule-modal","component":"deleteStockRuleModal"},{"name":"delete-packaging-unit-modal","component":"deletePackagingUnitModal"},{"name":"import-bulk-stock-items","component":"importBulkStockItemsModal"},{"name":"stock-operation-dialog","component":"stockOperationModal"}],"pages":[{"component":"root","route":"stock-management"}],"version":"1.0.1-pre.706"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openmrs/esm-stock-management-app",
3
- "version": "1.0.1-pre.702",
3
+ "version": "1.0.1-pre.706",
4
4
  "license": "MPL-2.0",
5
5
  "description": "Stock management microfrontend for OpenMRS 3.x",
6
6
  "browser": "dist/openmrs-esm-stock-management-app.js",
@@ -64,7 +64,7 @@ const ImportDialogPopup: React.FC<ImportDialogPopupProps> = ({ closeModal }) =>
64
64
  labelDescription="Only .csv files at 2mb or less"
65
65
  filenameStatus="edit"
66
66
  labelTitle=""
67
- size="small"
67
+ size="sm"
68
68
  onChange={onFileChanged}
69
69
  />
70
70
  </ModalBody>
@@ -0,0 +1,105 @@
1
+ import React from 'react';
2
+ import { render, screen, waitFor } from '@testing-library/react';
3
+ import userEvent from '@testing-library/user-event';
4
+ import ImportDialogPopup from './stock-items-bulk-import.component';
5
+ import { showSnackbar } from '@openmrs/esm-framework';
6
+ import { UploadStockItems } from './stock-items-bulk-import.resource';
7
+
8
+ jest.mock('@openmrs/esm-framework', () => ({
9
+ showSnackbar: jest.fn(),
10
+ }));
11
+
12
+ jest.mock('./stock-items-bulk-import.resource', () => ({
13
+ UploadStockItems: jest.fn(),
14
+ }));
15
+
16
+ describe('ImportDialogPopup', () => {
17
+ const mockCloseModal = jest.fn();
18
+
19
+ beforeEach(() => {
20
+ jest.clearAllMocks();
21
+ });
22
+
23
+ it('renders with initial state and UI elements', () => {
24
+ render(<ImportDialogPopup closeModal={mockCloseModal} />);
25
+
26
+ expect(screen.getByText('Import Stock Items')).toBeInTheDocument();
27
+ expect(screen.getByRole('button', { name: 'Select file' })).toBeInTheDocument();
28
+ expect(screen.getByText('Only .csv files at 2mb or less')).toBeInTheDocument();
29
+ expect(screen.getByRole('button', { name: 'Cancel' })).toBeInTheDocument();
30
+ expect(screen.getByRole('button', { name: 'Upload StockItems' })).toBeInTheDocument();
31
+ });
32
+
33
+ it('allows only CSV files', async () => {
34
+ render(<ImportDialogPopup closeModal={mockCloseModal} />);
35
+
36
+ const fileInput = screen.getByLabelText('Select file') as HTMLInputElement;
37
+ expect(fileInput.accept).toBe('.csv');
38
+ });
39
+
40
+ it('closes modal when cancel button is clicked', async () => {
41
+ render(<ImportDialogPopup closeModal={mockCloseModal} />);
42
+
43
+ const cancelButton = screen.getByRole('button', { name: 'Cancel' });
44
+ await userEvent.click(cancelButton);
45
+
46
+ expect(mockCloseModal).toHaveBeenCalledTimes(1);
47
+ });
48
+
49
+ it('does nothing when upload is clicked without a file', async () => {
50
+ render(<ImportDialogPopup closeModal={mockCloseModal} />);
51
+
52
+ const uploadButton = screen.getByRole('button', { name: 'Upload StockItems' });
53
+ await userEvent.click(uploadButton);
54
+
55
+ expect(UploadStockItems).not.toHaveBeenCalled();
56
+ expect(showSnackbar).not.toHaveBeenCalled();
57
+ expect(mockCloseModal).not.toHaveBeenCalled();
58
+ });
59
+
60
+ it('uploads file successfully and shows success snackbar', async () => {
61
+ (UploadStockItems as jest.Mock).mockResolvedValue({});
62
+ render(<ImportDialogPopup closeModal={mockCloseModal} />);
63
+
64
+ const validFile = new File(['test content'], 'valid.csv', { type: 'text/csv' });
65
+ const fileInput = screen.getByLabelText('Select file') as HTMLInputElement;
66
+ await userEvent.upload(fileInput, validFile);
67
+
68
+ const uploadButton = screen.getByRole('button', { name: 'Upload StockItems' });
69
+ await userEvent.click(uploadButton);
70
+
71
+ await waitFor(() => expect(UploadStockItems).toHaveBeenCalled());
72
+ await waitFor(() =>
73
+ expect(showSnackbar).toHaveBeenCalledWith(
74
+ expect.objectContaining({
75
+ kind: 'success',
76
+ title: 'Uploaded Order',
77
+ }),
78
+ ),
79
+ );
80
+ await waitFor(() => expect(mockCloseModal).toHaveBeenCalledTimes(1));
81
+ });
82
+
83
+ it('shows error snackbar on upload failure', async () => {
84
+ (UploadStockItems as jest.Mock).mockRejectedValue(new Error('Upload failed'));
85
+ render(<ImportDialogPopup closeModal={mockCloseModal} />);
86
+
87
+ const validFile = new File(['test content'], 'valid.csv', { type: 'text/csv' });
88
+ const fileInput = screen.getByLabelText('Select file') as HTMLInputElement;
89
+ await userEvent.upload(fileInput, validFile);
90
+
91
+ const uploadButton = screen.getByRole('button', { name: 'Upload StockItems' });
92
+ await userEvent.click(uploadButton);
93
+
94
+ await waitFor(() => expect(UploadStockItems).toHaveBeenCalled());
95
+ await waitFor(() =>
96
+ expect(showSnackbar).toHaveBeenCalledWith(
97
+ expect.objectContaining({
98
+ kind: 'error',
99
+ title: 'An error occurred uploading stock items',
100
+ }),
101
+ ),
102
+ );
103
+ await waitFor(() => expect(mockCloseModal).not.toHaveBeenCalled());
104
+ });
105
+ });