@openmrs/esm-stock-management-app 1.0.1-pre.437 → 1.0.1-pre.442
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/574.js +1 -1
- package/dist/699.js +1 -1
- package/dist/699.js.map +1 -1
- package/dist/800.js +1 -1
- package/dist/800.js.map +1 -1
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/openmrs-esm-stock-management-app.js +1 -1
- package/dist/openmrs-esm-stock-management-app.js.buildmanifest.json +13 -13
- package/dist/routes.json +1 -1
- package/package.json +1 -1
- package/src/core/components/carbon/controlled-number-input/controlled-number-input.component.tsx +1 -1
- package/src/core/components/tabs/vertical-tabs.scss +1 -2
- package/src/stock-items/add-stock-item/packaging-units/packaging-units.component.tsx +179 -64
- package/src/stock-items/add-stock-item/packaging-units/packaging-units.scss +33 -21
- package/src/stock-items/add-stock-item/packaging-units-concept-selector/packaging-units-concept-selector.component.tsx +4 -2
- package/src/stock-items/stock-items.resource.ts +4 -1
- package/translations/en.json +271 -24
@@ -1 +1 @@
|
|
1
|
-
var _openmrs_esm_stock_management_app;(()=>{"use strict";var e,r,t,n,o,a,i,l,s,u,f,p,c,d,h,m,v,g={1371:(e,r,t)=>{var n={"./start":()=>Promise.all([t.e(935),t.e(180),t.e(672),t.e(699)]).then((()=>()=>t(1280)))},o=(e,r)=>(t.R=r,r=t.o(n,e)?n[e]():Promise.resolve().then((()=>{throw new Error('Module "'+e+'" does not exist in container.')})),t.R=void 0,r),a=(e,r)=>{if(t.S){var n="default",o=t.S[n];if(o&&o!==e)throw new Error("Container initialization failed as it has already been initialized with a different share scope");return t.S[n]=e,t.I(n,r)}};t.d(r,{get:()=>o,init:()=>a})}},b={};function y(e){var r=b[e];if(void 0!==r)return r.exports;var t=b[e]={id:e,loaded:!1,exports:{}};return g[e].call(t.exports,t,t.exports,y),t.loaded=!0,t.exports}y.m=g,y.c=b,y.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return y.d(r,{a:r}),r},r=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,y.t=function(t,n){if(1&n&&(t=this(t)),8&n)return t;if("object"==typeof t&&t){if(4&n&&t.__esModule)return t;if(16&n&&"function"==typeof t.then)return t}var o=Object.create(null);y.r(o);var a={};e=e||[null,r({}),r([]),r(r)];for(var i=2&n&&t;"object"==typeof i&&!~e.indexOf(i);i=r(i))Object.getOwnPropertyNames(i).forEach((e=>a[e]=()=>t[e]));return a.default=()=>t,y.d(o,a),o},y.d=(e,r)=>{for(var t in r)y.o(r,t)&&!y.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},y.f={},y.e=e=>Promise.all(Object.keys(y.f).reduce(((r,t)=>(y.f[t](e,r),r)),[])),y.u=e=>e+".js",y.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),y.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),t={},n="@openmrs/esm-stock-management-app:",y.l=(e,r,o,a)=>{if(t[e])t[e].push(r);else{var i,l;if(void 0!==o)for(var s=document.getElementsByTagName("script"),u=0;u<s.length;u++){var f=s[u];if(f.getAttribute("src")==e||f.getAttribute("data-webpack")==n+o){i=f;break}}i||(l=!0,(i=document.createElement("script")).charset="utf-8",i.timeout=120,y.nc&&i.setAttribute("nonce",y.nc),i.setAttribute("data-webpack",n+o),i.src=e),t[e]=[r];var p=(r,n)=>{i.onerror=i.onload=null,clearTimeout(c);var o=t[e];if(delete t[e],i.parentNode&&i.parentNode.removeChild(i),o&&o.forEach((e=>e(n))),r)return r(n)},c=setTimeout(p.bind(null,void 0,{type:"timeout",target:i}),12e4);i.onerror=p.bind(null,i.onerror),i.onload=p.bind(null,i.onload),l&&document.head.appendChild(i)}},y.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},y.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),(()=>{y.S={};var e={},r={};y.I=(t,n)=>{n||(n=[]);var o=r[t];if(o||(o=r[t]={}),!(n.indexOf(o)>=0)){if(n.push(o),e[t])return e[t];y.o(y.S,t)||(y.S[t]={});var a=y.S[t],i="@openmrs/esm-stock-management-app",l=(e,r,t,n)=>{var o=a[e]=a[e]||{},l=o[r];(!l||!l.loaded&&(!n!=!l.eager?n:i>l.from))&&(o[r]={get:t,from:i,eager:!!n})},s=[];return"default"===t&&(l("@openmrs/esm-framework","5.
|
1
|
+
var _openmrs_esm_stock_management_app;(()=>{"use strict";var e,r,t,n,o,a,i,l,s,u,f,p,c,d,h,m,v,g={1371:(e,r,t)=>{var n={"./start":()=>Promise.all([t.e(935),t.e(180),t.e(672),t.e(699)]).then((()=>()=>t(1280)))},o=(e,r)=>(t.R=r,r=t.o(n,e)?n[e]():Promise.resolve().then((()=>{throw new Error('Module "'+e+'" does not exist in container.')})),t.R=void 0,r),a=(e,r)=>{if(t.S){var n="default",o=t.S[n];if(o&&o!==e)throw new Error("Container initialization failed as it has already been initialized with a different share scope");return t.S[n]=e,t.I(n,r)}};t.d(r,{get:()=>o,init:()=>a})}},b={};function y(e){var r=b[e];if(void 0!==r)return r.exports;var t=b[e]={id:e,loaded:!1,exports:{}};return g[e].call(t.exports,t,t.exports,y),t.loaded=!0,t.exports}y.m=g,y.c=b,y.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return y.d(r,{a:r}),r},r=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,y.t=function(t,n){if(1&n&&(t=this(t)),8&n)return t;if("object"==typeof t&&t){if(4&n&&t.__esModule)return t;if(16&n&&"function"==typeof t.then)return t}var o=Object.create(null);y.r(o);var a={};e=e||[null,r({}),r([]),r(r)];for(var i=2&n&&t;"object"==typeof i&&!~e.indexOf(i);i=r(i))Object.getOwnPropertyNames(i).forEach((e=>a[e]=()=>t[e]));return a.default=()=>t,y.d(o,a),o},y.d=(e,r)=>{for(var t in r)y.o(r,t)&&!y.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},y.f={},y.e=e=>Promise.all(Object.keys(y.f).reduce(((r,t)=>(y.f[t](e,r),r)),[])),y.u=e=>e+".js",y.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),y.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),t={},n="@openmrs/esm-stock-management-app:",y.l=(e,r,o,a)=>{if(t[e])t[e].push(r);else{var i,l;if(void 0!==o)for(var s=document.getElementsByTagName("script"),u=0;u<s.length;u++){var f=s[u];if(f.getAttribute("src")==e||f.getAttribute("data-webpack")==n+o){i=f;break}}i||(l=!0,(i=document.createElement("script")).charset="utf-8",i.timeout=120,y.nc&&i.setAttribute("nonce",y.nc),i.setAttribute("data-webpack",n+o),i.src=e),t[e]=[r];var p=(r,n)=>{i.onerror=i.onload=null,clearTimeout(c);var o=t[e];if(delete t[e],i.parentNode&&i.parentNode.removeChild(i),o&&o.forEach((e=>e(n))),r)return r(n)},c=setTimeout(p.bind(null,void 0,{type:"timeout",target:i}),12e4);i.onerror=p.bind(null,i.onerror),i.onload=p.bind(null,i.onload),l&&document.head.appendChild(i)}},y.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},y.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),(()=>{y.S={};var e={},r={};y.I=(t,n)=>{n||(n=[]);var o=r[t];if(o||(o=r[t]={}),!(n.indexOf(o)>=0)){if(n.push(o),e[t])return e[t];y.o(y.S,t)||(y.S[t]={});var a=y.S[t],i="@openmrs/esm-stock-management-app",l=(e,r,t,n)=>{var o=a[e]=a[e]||{},l=o[r];(!l||!l.loaded&&(!n!=!l.eager?n:i>l.from))&&(o[r]={get:t,from:i,eager:!!n})},s=[];return"default"===t&&(l("@openmrs/esm-framework","5.7.1-pre.2076",(()=>Promise.all([y.e(800),y.e(672)]).then((()=>()=>y(4800))))),l("dayjs","1.11.10",(()=>y.e(484).then((()=>()=>y(7484))))),l("react-i18next","11.18.6",(()=>Promise.all([y.e(672),y.e(629)]).then((()=>()=>y(707))))),l("react-router-dom","6.21.1",(()=>Promise.all([y.e(26),y.e(935),y.e(672)]).then((()=>()=>y(8026))))),l("react","18.2.0",(()=>y.e(294).then((()=>()=>y(7294))))),l("swr/_internal","2.2.5",(()=>Promise.all([y.e(46),y.e(672)]).then((()=>()=>y(46)))))),e[t]=s.length?Promise.all(s).then((()=>e[t]=1)):1}}})(),(()=>{var e;y.g.importScripts&&(e=y.g.location+"");var r=y.g.document;if(!e&&r&&(r.currentScript&&(e=r.currentScript.src),!e)){var t=r.getElementsByTagName("script");if(t.length)for(var n=t.length-1;n>-1&&!e;)e=t[n--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),y.p=e})(),o=e=>{var r=e=>e.split(".").map((e=>+e==e?+e:e)),t=/^([^-+]+)?(?:-([^+]+))?(?:\+(.+))?$/.exec(e),n=t[1]?r(t[1]):[];return t[2]&&(n.length++,n.push.apply(n,r(t[2]))),t[3]&&(n.push([]),n.push.apply(n,r(t[3]))),n},a=(e,r)=>{e=o(e),r=o(r);for(var t=0;;){if(t>=e.length)return t<r.length&&"u"!=(typeof r[t])[0];var n=e[t],a=(typeof n)[0];if(t>=r.length)return"u"==a;var i=r[t],l=(typeof i)[0];if(a!=l)return"o"==a&&"n"==l||"s"==l||"u"==a;if("o"!=a&&"u"!=a&&n!=i)return n<i;t++}},i=e=>{var r=e[0],t="";if(1===e.length)return"*";if(r+.5){t+=0==r?">=":-1==r?"<":1==r?"^":2==r?"~":r>0?"=":"!=";for(var n=1,o=1;o<e.length;o++)n--,t+="u"==(typeof(l=e[o]))[0]?"-":(n>0?".":"")+(n=2,l);return t}var a=[];for(o=1;o<e.length;o++){var l=e[o];a.push(0===l?"not("+s()+")":1===l?"("+s()+" || "+s()+")":2===l?a.pop()+" "+a.pop():i(l))}return s();function s(){return a.pop().replace(/^\((.+)\)$/,"$1")}},l=(e,r)=>{if(0 in e){r=o(r);var t=e[0],n=t<0;n&&(t=-t-1);for(var a=0,i=1,s=!0;;i++,a++){var u,f,p=i<e.length?(typeof e[i])[0]:"";if(a>=r.length||"o"==(f=(typeof(u=r[a]))[0]))return!s||("u"==p?i>t&&!n:""==p!=n);if("u"==f){if(!s||"u"!=p)return!1}else if(s)if(p==f)if(i<=t){if(u!=e[i])return!1}else{if(n?u>e[i]:u<e[i])return!1;u!=e[i]&&(s=!1)}else if("s"!=p&&"n"!=p){if(n||i<=t)return!1;s=!1,i--}else{if(i<=t||f<p!=n)return!1;s=!1}else"s"!=p&&"n"!=p&&(s=!1,i--)}}var c=[],d=c.pop.bind(c);for(a=1;a<e.length;a++){var h=e[a];c.push(1==h?d()|d():2==h?d()&d():h?l(h,r):!d())}return!!d()},s=(e,r)=>{var t=e[r];return Object.keys(t).reduce(((e,r)=>!e||!t[e].loaded&&a(e,r)?r:e),0)},u=(e,r,t,n)=>"Unsatisfied version "+t+" from "+(t&&e[r][t].from)+" of shared singleton module "+r+" (required "+i(n)+")",f=(e,r,t,n)=>{var o=s(e,t);return l(n,o)||p(u(e,t,o,n)),c(e[t][o])},p=e=>{"undefined"!=typeof console&&console.warn&&console.warn(e)},c=e=>(e.loaded=1,e.get()),d=(e=>function(r,t,n,o){var a=y.I(r);return a&&a.then?a.then(e.bind(e,r,y.S[r],t,n,o)):e(0,y.S[r],t,n,o)})(((e,r,t,n,o)=>r&&y.o(r,t)?f(r,0,t,n):o())),h={},m={1672:()=>d("default","react",[1,18],(()=>y.e(294).then((()=>()=>y(7294))))),1914:()=>d("default","react-router-dom",[1,6],(()=>y.e(26).then((()=>()=>y(8026))))),2653:()=>d("default","dayjs",[1,1],(()=>y.e(484).then((()=>()=>y(7484))))),3397:()=>d("default","react-i18next",[1,11],(()=>y.e(707).then((()=>()=>y(707))))),5512:()=>d("default","swr/_internal",[1,2],(()=>y.e(46).then((()=>()=>y(46))))),7248:()=>d("default","@openmrs/esm-framework",[1,5],(()=>y.e(800).then((()=>()=>y(4800)))))},v={672:[1672],699:[1914,2653,3397,5512,7248]},y.f.consumes=(e,r)=>{y.o(v,e)&&v[e].forEach((e=>{if(y.o(h,e))return r.push(h[e]);var t=r=>{h[e]=0,y.m[e]=t=>{delete y.c[e],t.exports=r()}},n=r=>{delete h[e],y.m[e]=t=>{throw delete y.c[e],r}};try{var o=m[e]();o.then?r.push(h[e]=o.then(t).catch(n)):t(o)}catch(e){n(e)}}))},(()=>{var e={122:0};y.f.j=(r,t)=>{var n=y.o(e,r)?e[r]:void 0;if(0!==n)if(n)t.push(n[2]);else if(672!=r){var o=new Promise(((t,o)=>n=e[r]=[t,o]));t.push(n[2]=o);var a=y.p+y.u(r),i=new Error;y.l(a,(t=>{if(y.o(e,r)&&(0!==(n=e[r])&&(e[r]=void 0),n)){var o=t&&("load"===t.type?"missing":t.type),a=t&&t.target&&t.target.src;i.message="Loading chunk "+r+" failed.\n("+o+": "+a+")",i.name="ChunkLoadError",i.type=o,i.request=a,n[1](i)}}),"chunk-"+r,r)}else e[r]=0};var r=(r,t)=>{var n,o,[a,i,l]=t,s=0;if(a.some((r=>0!==e[r]))){for(n in i)y.o(i,n)&&(y.m[n]=i[n]);l&&l(y)}for(r&&r(t);s<a.length;s++)o=a[s],y.o(e,o)&&e[o]&&e[o][0](),e[o]=0},t=globalThis.webpackChunk_openmrs_esm_stock_management_app=globalThis.webpackChunk_openmrs_esm_stock_management_app||[];t.forEach(r.bind(null,0)),t.push=r.bind(null,t.push.bind(t))})(),y.nc=void 0;var _=y(1371);_openmrs_esm_stock_management_app=_})();
|
@@ -78,7 +78,7 @@
|
|
78
78
|
"auxiliaryFiles": [
|
79
79
|
"openmrs-esm-stock-management-app.js.map"
|
80
80
|
],
|
81
|
-
"hash": "
|
81
|
+
"hash": "c719e4e5fbaef2e1",
|
82
82
|
"childrenByOrder": {}
|
83
83
|
},
|
84
84
|
{
|
@@ -86,10 +86,10 @@
|
|
86
86
|
"initial": true,
|
87
87
|
"entry": true,
|
88
88
|
"recorded": false,
|
89
|
-
"size":
|
89
|
+
"size": 4771452,
|
90
90
|
"sizes": {
|
91
91
|
"consume-shared": 252,
|
92
|
-
"javascript":
|
92
|
+
"javascript": 4749503,
|
93
93
|
"share-init": 252,
|
94
94
|
"runtime": 21445
|
95
95
|
},
|
@@ -106,7 +106,7 @@
|
|
106
106
|
"auxiliaryFiles": [
|
107
107
|
"main.js.map"
|
108
108
|
],
|
109
|
-
"hash": "
|
109
|
+
"hash": "c88a499a2b1f229e",
|
110
110
|
"childrenByOrder": {}
|
111
111
|
},
|
112
112
|
{
|
@@ -188,9 +188,9 @@
|
|
188
188
|
"initial": false,
|
189
189
|
"entry": false,
|
190
190
|
"recorded": false,
|
191
|
-
"size":
|
191
|
+
"size": 9343,
|
192
192
|
"sizes": {
|
193
|
-
"javascript":
|
193
|
+
"javascript": 9343
|
194
194
|
},
|
195
195
|
"names": [],
|
196
196
|
"idHints": [],
|
@@ -202,7 +202,7 @@
|
|
202
202
|
"574.js"
|
203
203
|
],
|
204
204
|
"auxiliaryFiles": [],
|
205
|
-
"hash": "
|
205
|
+
"hash": "40ad58e901f8bf23",
|
206
206
|
"childrenByOrder": {}
|
207
207
|
},
|
208
208
|
{
|
@@ -255,9 +255,9 @@
|
|
255
255
|
"initial": false,
|
256
256
|
"entry": false,
|
257
257
|
"recorded": false,
|
258
|
-
"size":
|
258
|
+
"size": 1080271,
|
259
259
|
"sizes": {
|
260
|
-
"javascript":
|
260
|
+
"javascript": 1080061,
|
261
261
|
"consume-shared": 210
|
262
262
|
},
|
263
263
|
"names": [],
|
@@ -271,7 +271,7 @@
|
|
271
271
|
"auxiliaryFiles": [
|
272
272
|
"699.js.map"
|
273
273
|
],
|
274
|
-
"hash": "
|
274
|
+
"hash": "4a6b0e37903f4bcd",
|
275
275
|
"childrenByOrder": {}
|
276
276
|
},
|
277
277
|
{
|
@@ -304,9 +304,9 @@
|
|
304
304
|
"entry": false,
|
305
305
|
"recorded": false,
|
306
306
|
"reason": "reused as split chunk (cache group: defaultVendors)",
|
307
|
-
"size":
|
307
|
+
"size": 1783159,
|
308
308
|
"sizes": {
|
309
|
-
"javascript":
|
309
|
+
"javascript": 1783159
|
310
310
|
},
|
311
311
|
"names": [],
|
312
312
|
"idHints": [
|
@@ -322,7 +322,7 @@
|
|
322
322
|
"auxiliaryFiles": [
|
323
323
|
"800.js.map"
|
324
324
|
],
|
325
|
-
"hash": "
|
325
|
+
"hash": "63121f39673cb859",
|
326
326
|
"childrenByOrder": {}
|
327
327
|
},
|
328
328
|
{
|
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-management-dashboard","slot":"stock-management-dashboard-slot","component":"stockManagementDashboard"},{"name":"stock-management-admin-card-link","slot":"system-admin-page-card-link-slot","component":"stockManagementAdminCardLink"},{"name":"stock-operation-dialog","component":"stockOperationDialog"},{"name":"import-bulk-stock-items","component":"importBulkStockItemsDialog"},{"name":"delete-stock-modal","component":"deleteStockModal"},{"name":"delete-stock-user-scope-modal","component":"deleteUserScopeModal"},{"name":"stock-management-app-menu-item","component":"stockManagementAppMenuItem","slot":"app-menu-item-slot","meta":{"name":" Stock Management"}},{"name":"delete-stock-rule-modal","component":"deleteStockRuleModal"},{"name":"delete-packaging-unit-modal","component":"deletePackagingUnitModal"},{"name":"delete-packaging-unit-button","component":"deletePackagingUnitButton"}],"pages":[{"component":"stockManagement","route":"stock-management"}],"version":"1.0.1-pre.
|
1
|
+
{"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"fhir2":">=1.2","webservices.rest":"^2.24.0"},"extensions":[{"name":"stock-management-dashboard","slot":"stock-management-dashboard-slot","component":"stockManagementDashboard"},{"name":"stock-management-admin-card-link","slot":"system-admin-page-card-link-slot","component":"stockManagementAdminCardLink"},{"name":"stock-operation-dialog","component":"stockOperationDialog"},{"name":"import-bulk-stock-items","component":"importBulkStockItemsDialog"},{"name":"delete-stock-modal","component":"deleteStockModal"},{"name":"delete-stock-user-scope-modal","component":"deleteUserScopeModal"},{"name":"stock-management-app-menu-item","component":"stockManagementAppMenuItem","slot":"app-menu-item-slot","meta":{"name":" Stock Management"}},{"name":"delete-stock-rule-modal","component":"deleteStockRuleModal"},{"name":"delete-packaging-unit-modal","component":"deletePackagingUnitModal"},{"name":"delete-packaging-unit-button","component":"deletePackagingUnitButton"}],"pages":[{"component":"stockManagement","route":"stock-management"}],"version":"1.0.1-pre.442"}
|
package/package.json
CHANGED
package/src/core/components/carbon/controlled-number-input/controlled-number-input.component.tsx
CHANGED
@@ -20,7 +20,7 @@ const ControlledNumberInput = <T,>(props: ControlledNumberInputProps<T>) => {
|
|
20
20
|
render={({ field: { onChange, value, ref } }) => (
|
21
21
|
<NumberInput
|
22
22
|
label={props.label}
|
23
|
-
id={`${props.name}-${props.
|
23
|
+
id={`${props.name}-${props.id}-${props.row?.uuid}`}
|
24
24
|
value={props.row?.factor ?? value}
|
25
25
|
min={props.min}
|
26
26
|
hideSteppers={props.hideSteppers || false}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import React, { useEffect, useMemo } from "react";
|
1
|
+
import React, { useEffect, useMemo, useState } from "react";
|
2
2
|
import { showSnackbar } from "@openmrs/esm-framework";
|
3
3
|
import { useTranslation } from "react-i18next";
|
4
4
|
import { useStockItemPackageUnitsHook } from "./packaging-units.resource";
|
@@ -21,7 +21,10 @@ import { FormProvider, useForm, useFormContext } from "react-hook-form";
|
|
21
21
|
import { zodResolver } from "@hookform/resolvers/zod";
|
22
22
|
import { PackageUnitFormData, packageUnitSchema } from "./validationSchema";
|
23
23
|
import { StockItemPackagingUOMDTO } from "../../../core/api/types/stockItem/StockItemPackagingUOM";
|
24
|
-
import {
|
24
|
+
import {
|
25
|
+
createStockItemPackagingUnit,
|
26
|
+
updateStockItemPackagingUnit,
|
27
|
+
} from "../../stock-items.resource";
|
25
28
|
import DeleteModalButton from "./packaging-units-delete-modal-button.component";
|
26
29
|
|
27
30
|
import styles from "./packaging-units.scss";
|
@@ -39,10 +42,28 @@ const PackagingUnits: React.FC<PackagingUnitsProps> = ({
|
|
39
42
|
}) => {
|
40
43
|
const { items, isLoading, setStockItemUuid, mutate } =
|
41
44
|
useStockItemPackageUnitsHook();
|
45
|
+
|
46
|
+
const [packagingUnits, setPackagingUnits] =
|
47
|
+
useState<StockItemPackagingUOMDTO[]>(items);
|
48
|
+
|
49
|
+
const [newUnit, setNewUnit] = useState<{
|
50
|
+
factor: number;
|
51
|
+
packagingUomUuid: string;
|
52
|
+
packagingUomName: string;
|
53
|
+
}>({
|
54
|
+
packagingUomUuid: undefined,
|
55
|
+
factor: 0,
|
56
|
+
packagingUomName: "",
|
57
|
+
});
|
58
|
+
|
42
59
|
useEffect(() => {
|
43
60
|
setStockItemUuid(stockItemUuid);
|
44
61
|
}, [stockItemUuid, setStockItemUuid]);
|
45
62
|
|
63
|
+
useEffect(() => {
|
64
|
+
setPackagingUnits(items);
|
65
|
+
}, [items]);
|
66
|
+
|
46
67
|
const { t } = useTranslation();
|
47
68
|
const tableHeaders = useMemo(
|
48
69
|
() => [
|
@@ -72,40 +93,118 @@ const PackagingUnits: React.FC<PackagingUnitsProps> = ({
|
|
72
93
|
});
|
73
94
|
|
74
95
|
const handleSavePackageUnits = () => {
|
75
|
-
const {
|
76
|
-
|
77
|
-
const
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
96
|
+
const { reset } = packageUnitForm;
|
97
|
+
|
98
|
+
const newPayload = newUnit
|
99
|
+
? {
|
100
|
+
factor: newUnit.factor,
|
101
|
+
packagingUomUuid: newUnit.packagingUomUuid,
|
102
|
+
stockItemUuid,
|
103
|
+
}
|
104
|
+
: null;
|
105
|
+
|
106
|
+
// Filter changed units
|
107
|
+
const updatedUnits = packagingUnits.filter((unit) => {
|
108
|
+
const originalUnit = items.find((item) => item.uuid === unit.uuid);
|
109
|
+
return originalUnit && originalUnit.factor !== unit.factor;
|
110
|
+
});
|
111
|
+
|
112
|
+
// Create new unit
|
113
|
+
const createPromises = newPayload.packagingUomUuid
|
114
|
+
? createStockItemPackagingUnit(newPayload).then(
|
115
|
+
() => {
|
116
|
+
showSnackbar({
|
117
|
+
title: t("savePackingUnitTitle", "Package Unit"),
|
118
|
+
subtitle: t(
|
119
|
+
"savePackingUnitMessage",
|
120
|
+
"Package Unit saved successfully"
|
121
|
+
),
|
122
|
+
kind: "success",
|
123
|
+
});
|
124
|
+
setNewUnit({
|
125
|
+
factor: 0,
|
126
|
+
packagingUomUuid: undefined,
|
127
|
+
packagingUomName: "",
|
128
|
+
}); // Reset new unit
|
129
|
+
},
|
130
|
+
() => {
|
131
|
+
showSnackbar({
|
132
|
+
title: t("savePackagingUnitErrorTitle", "Package Unit"),
|
133
|
+
subtitle: t(
|
134
|
+
"savePackagingUnitErrorMessage",
|
135
|
+
"Error saving package unit"
|
136
|
+
),
|
137
|
+
kind: "error",
|
138
|
+
});
|
139
|
+
}
|
140
|
+
)
|
141
|
+
: Promise.resolve({ status: "no-create" });
|
142
|
+
|
143
|
+
// Update existing units
|
144
|
+
const updatePromises = updatedUnits.map((unit) =>
|
145
|
+
updateStockItemPackagingUnit(unit, unit.uuid).then(
|
146
|
+
() => {
|
147
|
+
showSnackbar({
|
148
|
+
title: t("updatePackingUnitTitle", "Package Unit"),
|
149
|
+
subtitle: t(
|
150
|
+
"updatePackingUnitMessage",
|
151
|
+
"Package Unit {{ name }} updated successfully",
|
152
|
+
{ name: unit.packagingUomName }
|
153
|
+
),
|
154
|
+
kind: "success",
|
155
|
+
});
|
156
|
+
},
|
157
|
+
() => {
|
158
|
+
showSnackbar({
|
159
|
+
title: t("updatePackagingUnitErrorTitle", "Package Unit"),
|
160
|
+
subtitle: t(
|
161
|
+
"updatePackagingUnitErrorMessage",
|
162
|
+
"Error updating package unit {{name}}",
|
163
|
+
{ name: unit.packagingUomName }
|
164
|
+
),
|
165
|
+
kind: "error",
|
166
|
+
});
|
167
|
+
}
|
168
|
+
)
|
169
|
+
);
|
170
|
+
|
171
|
+
// Wait for all requests to complete
|
172
|
+
Promise.all([createPromises, ...updatePromises]).then(() => {
|
173
|
+
mutate();
|
174
|
+
reset();
|
175
|
+
handleTabChange(0);
|
176
|
+
});
|
177
|
+
};
|
178
|
+
|
179
|
+
const handleNewUnitFactorChange = (value: string | number) => {
|
180
|
+
setNewUnit({
|
181
|
+
...newUnit,
|
182
|
+
factor: Number(value),
|
183
|
+
});
|
184
|
+
};
|
185
|
+
|
186
|
+
const handleNewUnitPackageUnitChange = (unit: {
|
187
|
+
uuid: string;
|
188
|
+
display: string;
|
189
|
+
}) => {
|
190
|
+
setNewUnit({
|
191
|
+
...newUnit,
|
192
|
+
packagingUomUuid: unit.uuid,
|
193
|
+
packagingUomName: unit.display,
|
194
|
+
});
|
195
|
+
};
|
196
|
+
|
197
|
+
const onFactorFieldUpdate = (
|
198
|
+
row: StockItemPackagingUOMDTO,
|
199
|
+
value: string | number
|
200
|
+
) => {
|
201
|
+
const qtyValue = typeof value === "number" ? value : parseFloat(value);
|
202
|
+
|
203
|
+
setPackagingUnits((prevState) =>
|
204
|
+
prevState.map((item) =>
|
205
|
+
item.uuid === row.uuid ? { ...item, factor: qtyValue } : item
|
206
|
+
)
|
107
207
|
);
|
108
|
-
handleTabChange(0);
|
109
208
|
};
|
110
209
|
|
111
210
|
if (isLoading)
|
@@ -147,25 +246,38 @@ const PackagingUnits: React.FC<PackagingUnitsProps> = ({
|
|
147
246
|
</TableHead>
|
148
247
|
<TableBody className={styles.packingTableBody}>
|
149
248
|
{items?.map((row: StockItemPackagingUOMDTO, index) => (
|
150
|
-
<PackagingUnitRow
|
249
|
+
<PackagingUnitRow
|
250
|
+
row={row}
|
251
|
+
id={`${index}-${row?.uuid}`}
|
252
|
+
onChange={(value) => onFactorFieldUpdate(row, value)}
|
253
|
+
/>
|
151
254
|
))}
|
152
|
-
<PackagingUnitRow
|
255
|
+
<PackagingUnitRow
|
256
|
+
row={newUnit || {}}
|
257
|
+
id="new-package-unit"
|
258
|
+
isEditing
|
259
|
+
onChangePackageUnit={(value) =>
|
260
|
+
handleNewUnitPackageUnitChange(value)
|
261
|
+
}
|
262
|
+
onChange={(value) => handleNewUnitFactorChange(value)}
|
263
|
+
/>
|
153
264
|
</TableBody>
|
154
265
|
</Table>
|
155
266
|
</TableContainer>
|
156
267
|
)}
|
157
268
|
/>
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
269
|
+
<div className={styles.packageUnitsBtn}>
|
270
|
+
<Button
|
271
|
+
name="save"
|
272
|
+
type="submit"
|
273
|
+
className="submitButton"
|
274
|
+
onClick={handleSavePackageUnits}
|
275
|
+
kind="primary"
|
276
|
+
renderIcon={Save}
|
277
|
+
>
|
278
|
+
{t("save", "Save")}
|
279
|
+
</Button>
|
280
|
+
</div>
|
169
281
|
</FormProvider>
|
170
282
|
);
|
171
283
|
};
|
@@ -175,8 +287,10 @@ export default PackagingUnits;
|
|
175
287
|
const PackagingUnitRow: React.FC<{
|
176
288
|
isEditing?: boolean;
|
177
289
|
row: StockItemPackagingUOMDTO;
|
178
|
-
|
179
|
-
|
290
|
+
id?: string;
|
291
|
+
onChange?: (value: string | number) => void;
|
292
|
+
onChangePackageUnit?: (value: { uuid: string; display: string }) => void;
|
293
|
+
}> = ({ isEditing, row, id, onChange, onChangePackageUnit }) => {
|
180
294
|
const {
|
181
295
|
control,
|
182
296
|
formState: { errors },
|
@@ -194,6 +308,7 @@ const PackagingUnitRow: React.FC<{
|
|
194
308
|
name="packagingUomUuid"
|
195
309
|
placeholder="Filter"
|
196
310
|
control={control}
|
311
|
+
onPackageUnitChange={(concept) => onChangePackageUnit(concept)}
|
197
312
|
invalid={!!errors.packagingUomUuid}
|
198
313
|
/>
|
199
314
|
) : (
|
@@ -202,20 +317,20 @@ const PackagingUnitRow: React.FC<{
|
|
202
317
|
)}
|
203
318
|
</TableCell>
|
204
319
|
<TableCell>
|
205
|
-
<
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
320
|
+
<ControlledNumberInput
|
321
|
+
row={row}
|
322
|
+
controllerName="factor"
|
323
|
+
name="factor"
|
324
|
+
min={minPackagingQuantity}
|
325
|
+
control={control}
|
326
|
+
id={id}
|
327
|
+
invalid={!!errors.factor}
|
328
|
+
hideSteppers={true}
|
329
|
+
onChange={(e, state) => onChange(state.value)}
|
330
|
+
/>
|
331
|
+
</TableCell>
|
332
|
+
<TableCell>
|
333
|
+
<DeleteModalButton closeModal={() => true} row={row} />
|
219
334
|
</TableCell>
|
220
335
|
</TableRow>
|
221
336
|
</>
|
@@ -1,44 +1,56 @@
|
|
1
1
|
@use '@carbon/styles/scss/colors';
|
2
2
|
@use "@carbon/styles/scss/spacing";
|
3
3
|
@use "@carbon/styles/scss/type";
|
4
|
+
|
4
5
|
.packingTable {
|
5
|
-
|
6
|
-
|
6
|
+
min-height: 15rem;
|
7
|
+
display: block;
|
7
8
|
}
|
8
9
|
|
9
10
|
.packingTableCell {
|
10
|
-
|
11
|
-
|
11
|
+
display: flex;
|
12
|
+
align-items: center;
|
12
13
|
}
|
13
14
|
|
14
15
|
.packagingTableBody {
|
15
|
-
|
16
|
+
min-height: spacing.$spacing-13;
|
16
17
|
}
|
17
18
|
|
18
19
|
.packagingTableContainer {
|
19
|
-
|
20
|
-
|
20
|
+
padding-bottom: 1rem;
|
21
|
+
min-height: 15rem;
|
22
|
+
display: block;
|
23
|
+
|
24
|
+
:global(.cds--data-table-content) {
|
25
|
+
overflow-x: visible;
|
26
|
+
}
|
21
27
|
}
|
22
28
|
|
23
29
|
.searchAndSave {
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
+
display: flex;
|
31
|
+
flex-direction: column;
|
32
|
+
align-items: flex-start;
|
33
|
+
.submitButton {
|
34
|
+
margin-top: 1rem;
|
35
|
+
}
|
30
36
|
}
|
31
37
|
|
32
38
|
.deleteModal {
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
}
|
39
|
+
:global(.cds--modal-container.cds--modal-container--sm) {
|
40
|
+
:global(.cds--modal-content) {
|
41
|
+
:global(.cds--form-item) {
|
42
|
+
margin-top: 1rem;
|
43
|
+
}
|
39
44
|
}
|
45
|
+
}
|
46
|
+
}
|
47
|
+
|
48
|
+
.packageUnitsBtn {
|
49
|
+
display: flex;
|
50
|
+
justify-content: flex-end;
|
51
|
+
margin-right: 2rem;
|
40
52
|
}
|
41
53
|
|
42
54
|
:global(cds--form-item) {
|
43
|
-
|
44
|
-
}
|
55
|
+
margin-top: 1rem;
|
56
|
+
}
|
@@ -9,7 +9,7 @@ import { type ConfigObject } from "../../../config-schema";
|
|
9
9
|
|
10
10
|
interface PackagingUnitsConceptSelectorProps<T> {
|
11
11
|
row?: StockItemPackagingUOMDTO;
|
12
|
-
onPackageUnitChange?: (unit:
|
12
|
+
onPackageUnitChange?: (unit: { uuid: string; display: string }) => void;
|
13
13
|
title?: string;
|
14
14
|
placeholder?: string;
|
15
15
|
invalid?: boolean;
|
@@ -62,7 +62,9 @@ const PackagingUnitsConceptSelector = <T,>(
|
|
62
62
|
]
|
63
63
|
: dispensingUnits || []
|
64
64
|
}
|
65
|
-
onChange={(data: {
|
65
|
+
onChange={(data: {
|
66
|
+
selectedItem: { uuid: string; display: string };
|
67
|
+
}) => {
|
66
68
|
props.onPackageUnitChange?.(data?.selectedItem);
|
67
69
|
onChange(data?.selectedItem?.uuid || ""); // Provide a default value if needed
|
68
70
|
}}
|
@@ -282,7 +282,10 @@ export function createStockItemPackagingUnit(item: StockItemPackagingUOMDTO) {
|
|
282
282
|
}
|
283
283
|
|
284
284
|
// updateStockItemPackagingUnit
|
285
|
-
export function updateStockItemPackagingUnit(
|
285
|
+
export function updateStockItemPackagingUnit(
|
286
|
+
item: StockItemPackagingUOMDTO,
|
287
|
+
uuid: string
|
288
|
+
) {
|
286
289
|
const apiUrl = `${restBaseUrl}/stockmanagement/stockitempackaginguom/${uuid}`;
|
287
290
|
const abortController = new AbortController();
|
288
291
|
return openmrsFetch(apiUrl, {
|