@openmrs/esm-stock-management-app 1.0.1-pre.350 → 1.0.1-pre.357
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/304.js +2 -0
- package/dist/304.js.map +1 -0
- package/dist/969.js +1 -0
- package/dist/969.js.map +1 -0
- 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 +41 -41
- package/dist/routes.json +1 -1
- package/package.json +1 -1
- package/src/stock-batch/stock-batch.resource.ts +7 -5
- package/src/stock-items/add-stock-item/stock-item-rules/stock-rules.resource.ts +7 -5
- package/src/stock-items/stock-items.resource.ts +23 -19
- package/src/stock-items/types.ts +79 -0
- package/src/stock-locations/add-locations-form.component.tsx +74 -0
- package/src/stock-locations/location-admin-form.component.tsx +164 -0
- package/src/stock-locations/stock-locations-table.component.tsx +33 -10
- package/src/stock-locations/stock-locations-table.resource.tsx +67 -12
- package/src/stock-locations/stock-locations-table.scss +3 -0
- package/src/stock-lookups/stock-lookups.resource.ts +15 -15
- package/src/stock-operations/add-stock-operation/add-stock-operation.component.tsx +10 -5
- package/src/stock-operations/stock-operations.resource.ts +18 -14
- package/src/stock-sources/stock-sources.resource.ts +5 -5
- package/src/stock-user-role-scopes/stock-user-role-scopes.resource.ts +5 -5
- package/dist/500.js +0 -2
- package/dist/500.js.map +0 -1
- package/dist/842.js +0 -1
- package/dist/842.js.map +0 -1
- /package/dist/{500.js.LICENSE.txt → 304.js.LICENSE.txt} +0 -0
@@ -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(
|
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(304),t.e(672),t.e(969)]).then((()=>()=>t(2313)))},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.4.1-pre.1561",(()=>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],969:[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": "2b9571af3f64de96",
|
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": 4732380,
|
90
90
|
"sizes": {
|
91
91
|
"consume-shared": 252,
|
92
|
-
"javascript":
|
92
|
+
"javascript": 4710431,
|
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": "a6410f7bcf3930fb",
|
110
110
|
"childrenByOrder": {}
|
111
111
|
},
|
112
112
|
{
|
@@ -138,23 +138,25 @@
|
|
138
138
|
"initial": false,
|
139
139
|
"entry": false,
|
140
140
|
"recorded": false,
|
141
|
-
"
|
141
|
+
"reason": "split chunk (cache group: defaultVendors)",
|
142
|
+
"size": 3598866,
|
142
143
|
"sizes": {
|
143
|
-
"javascript":
|
144
|
+
"javascript": 3598866
|
144
145
|
},
|
145
146
|
"names": [],
|
146
|
-
"idHints": [
|
147
|
+
"idHints": [
|
148
|
+
"vendors"
|
149
|
+
],
|
147
150
|
"runtime": [
|
148
|
-
"@openmrs/esm-stock-management-app"
|
149
|
-
"main"
|
151
|
+
"@openmrs/esm-stock-management-app"
|
150
152
|
],
|
151
153
|
"files": [
|
152
|
-
"
|
154
|
+
"304.js"
|
153
155
|
],
|
154
156
|
"auxiliaryFiles": [
|
155
|
-
"
|
157
|
+
"304.js.map"
|
156
158
|
],
|
157
|
-
"hash": "
|
159
|
+
"hash": "8bcf539de0b31b14",
|
158
160
|
"childrenByOrder": {}
|
159
161
|
},
|
160
162
|
{
|
@@ -162,25 +164,23 @@
|
|
162
164
|
"initial": false,
|
163
165
|
"entry": false,
|
164
166
|
"recorded": false,
|
165
|
-
"
|
166
|
-
"size": 3552100,
|
167
|
+
"size": 7160,
|
167
168
|
"sizes": {
|
168
|
-
"javascript":
|
169
|
+
"javascript": 7160
|
169
170
|
},
|
170
171
|
"names": [],
|
171
|
-
"idHints": [
|
172
|
-
"vendors"
|
173
|
-
],
|
172
|
+
"idHints": [],
|
174
173
|
"runtime": [
|
175
|
-
"@openmrs/esm-stock-management-app"
|
174
|
+
"@openmrs/esm-stock-management-app",
|
175
|
+
"main"
|
176
176
|
],
|
177
177
|
"files": [
|
178
|
-
"
|
178
|
+
"484.js"
|
179
179
|
],
|
180
180
|
"auxiliaryFiles": [
|
181
|
-
"
|
181
|
+
"484.js.map"
|
182
182
|
],
|
183
|
-
"hash": "
|
183
|
+
"hash": "0eb218fc21d670bb",
|
184
184
|
"childrenByOrder": {}
|
185
185
|
},
|
186
186
|
{
|
@@ -306,23 +306,26 @@
|
|
306
306
|
"initial": false,
|
307
307
|
"entry": false,
|
308
308
|
"recorded": false,
|
309
|
-
"
|
309
|
+
"reason": "split chunk (cache group: defaultVendors)",
|
310
|
+
"size": 137533,
|
310
311
|
"sizes": {
|
311
|
-
"javascript":
|
312
|
-
"consume-shared": 210
|
312
|
+
"javascript": 137533
|
313
313
|
},
|
314
314
|
"names": [],
|
315
|
-
"idHints": [
|
315
|
+
"idHints": [
|
316
|
+
"vendors"
|
317
|
+
],
|
316
318
|
"runtime": [
|
317
|
-
"@openmrs/esm-stock-management-app"
|
319
|
+
"@openmrs/esm-stock-management-app",
|
320
|
+
"main"
|
318
321
|
],
|
319
322
|
"files": [
|
320
|
-
"
|
323
|
+
"935.js"
|
321
324
|
],
|
322
325
|
"auxiliaryFiles": [
|
323
|
-
"
|
326
|
+
"935.js.map"
|
324
327
|
],
|
325
|
-
"hash": "
|
328
|
+
"hash": "ec5f549cbfd789c7",
|
326
329
|
"childrenByOrder": {}
|
327
330
|
},
|
328
331
|
{
|
@@ -330,26 +333,23 @@
|
|
330
333
|
"initial": false,
|
331
334
|
"entry": false,
|
332
335
|
"recorded": false,
|
333
|
-
"
|
334
|
-
"size": 137533,
|
336
|
+
"size": 974242,
|
335
337
|
"sizes": {
|
336
|
-
"javascript":
|
338
|
+
"javascript": 974032,
|
339
|
+
"consume-shared": 210
|
337
340
|
},
|
338
341
|
"names": [],
|
339
|
-
"idHints": [
|
340
|
-
"vendors"
|
341
|
-
],
|
342
|
+
"idHints": [],
|
342
343
|
"runtime": [
|
343
|
-
"@openmrs/esm-stock-management-app"
|
344
|
-
"main"
|
344
|
+
"@openmrs/esm-stock-management-app"
|
345
345
|
],
|
346
346
|
"files": [
|
347
|
-
"
|
347
|
+
"969.js"
|
348
348
|
],
|
349
349
|
"auxiliaryFiles": [
|
350
|
-
"
|
350
|
+
"969.js.map"
|
351
351
|
],
|
352
|
-
"hash": "
|
352
|
+
"hash": "964d7f39ff7a00ca",
|
353
353
|
"childrenByOrder": {}
|
354
354
|
}
|
355
355
|
]
|
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"}],"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"}],"pages":[{"component":"stockManagement","route":"stock-management"}],"version":"1.0.1-pre.357"}
|
package/package.json
CHANGED
@@ -2,7 +2,7 @@ import useSWR from "swr";
|
|
2
2
|
import { ResourceFilterCriteria, toQueryParams } from "../core/api/api";
|
3
3
|
import { BatchJob, BatchJobType } from "../core/api/types/BatchJob";
|
4
4
|
import { PageableResult } from "../core/api/types/PageableResult";
|
5
|
-
import { openmrsFetch } from "@openmrs/esm-framework";
|
5
|
+
import { openmrsFetch, restBaseUrl } from "@openmrs/esm-framework";
|
6
6
|
import { ReportType } from "../stock-reports/ReportType";
|
7
7
|
|
8
8
|
export interface BatchJobFilter extends ResourceFilterCriteria {
|
@@ -17,7 +17,9 @@ export interface BatchJobFilter extends ResourceFilterCriteria {
|
|
17
17
|
|
18
18
|
// getBatchJobs
|
19
19
|
export function useBatchJobs(filter: BatchJobFilter) {
|
20
|
-
const apiUrl =
|
20
|
+
const apiUrl = `${restBaseUrl}/stockmanagement/batchjob${toQueryParams(
|
21
|
+
filter
|
22
|
+
)}`;
|
21
23
|
const { data, error, isLoading } = useSWR<
|
22
24
|
{ data: PageableResult<BatchJob> },
|
23
25
|
Error
|
@@ -40,7 +42,7 @@ export function cancelBatchJobs(ids: string[]) {
|
|
40
42
|
if (otherIds.length > 0) {
|
41
43
|
otherIds = "?ids=" + otherIds;
|
42
44
|
}
|
43
|
-
const apiUrl =
|
45
|
+
const apiUrl = `${restBaseUrl}/stockmanagement/batchjob/${ids[0]}${otherIds}`;
|
44
46
|
const abortController = new AbortController();
|
45
47
|
return openmrsFetch(apiUrl, {
|
46
48
|
method: "DELETE",
|
@@ -53,7 +55,7 @@ export function cancelBatchJobs(ids: string[]) {
|
|
53
55
|
|
54
56
|
// createBatchJob
|
55
57
|
export function createBatchJob(item: BatchJob) {
|
56
|
-
const apiUrl =
|
58
|
+
const apiUrl = `${restBaseUrl}/stockmanagement/batchjob`;
|
57
59
|
const abortController = new AbortController();
|
58
60
|
return openmrsFetch(apiUrl, {
|
59
61
|
method: "POST",
|
@@ -66,7 +68,7 @@ export function createBatchJob(item: BatchJob) {
|
|
66
68
|
}
|
67
69
|
// getReportTypes
|
68
70
|
export function useReportTypes() {
|
69
|
-
const apiUrl =
|
71
|
+
const apiUrl = `${restBaseUrl}/stockmanagement/report?v=default`;
|
70
72
|
const { data, error, isLoading } = useSWR<
|
71
73
|
{ data: PageableResult<ReportType> },
|
72
74
|
Error
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { openmrsFetch } from "@openmrs/esm-framework";
|
1
|
+
import { openmrsFetch, restBaseUrl } from "@openmrs/esm-framework";
|
2
2
|
import { ResourceFilterCriteria, toQueryParams } from "../../../core/api/api";
|
3
3
|
import useSWR from "swr";
|
4
4
|
import { PageableResult } from "../../../core/api/types/PageableResult";
|
@@ -10,7 +10,9 @@ export interface StockSourceFilter extends ResourceFilterCriteria {
|
|
10
10
|
|
11
11
|
// Get Stock Rules
|
12
12
|
export function useStockRules(filter: StockSourceFilter) {
|
13
|
-
const apiUrl =
|
13
|
+
const apiUrl = `${restBaseUrl}/stockmanagement/stockrule${toQueryParams(
|
14
|
+
filter
|
15
|
+
)}`;
|
14
16
|
|
15
17
|
const { data, error, isLoading } = useSWR<
|
16
18
|
{ data: PageableResult<StockRule> },
|
@@ -26,7 +28,7 @@ export function useStockRules(filter: StockSourceFilter) {
|
|
26
28
|
|
27
29
|
// Get Stock Rule
|
28
30
|
export function useStockRule(id: string) {
|
29
|
-
const apiUrl =
|
31
|
+
const apiUrl = `${restBaseUrl}/stockmanagement/stockrule/${id}`;
|
30
32
|
const { data, error, isLoading } = useSWR<{ data: StockRule }, Error>(
|
31
33
|
apiUrl,
|
32
34
|
openmrsFetch
|
@@ -48,7 +50,7 @@ export function deleteStockRule(ids: string[]) {
|
|
48
50
|
if (otherIds.length > 0) {
|
49
51
|
otherIds = "?ids=" + otherIds;
|
50
52
|
}
|
51
|
-
const apiUrl =
|
53
|
+
const apiUrl = `${restBaseUrl}/stockmanagement/stockrule/${ids[0]}${otherIds}`;
|
52
54
|
const abortController = new AbortController();
|
53
55
|
return openmrsFetch(apiUrl, {
|
54
56
|
method: "DELETE",
|
@@ -63,7 +65,7 @@ export function deleteStockRule(ids: string[]) {
|
|
63
65
|
export function createOrUpdateStockRule(item: StockRule) {
|
64
66
|
const isNew = item.uuid != null;
|
65
67
|
|
66
|
-
const apiUrl =
|
68
|
+
const apiUrl = `${restBaseUrl}/stockmanagement/stockrule${
|
67
69
|
isNew ? "/" + item.uuid : ""
|
68
70
|
}`;
|
69
71
|
const abortController = new AbortController();
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { openmrsFetch } from "@openmrs/esm-framework";
|
1
|
+
import { openmrsFetch, restBaseUrl } from "@openmrs/esm-framework";
|
2
2
|
import { ResourceFilterCriteria, toQueryParams } from "../core/api/api";
|
3
3
|
import { PageableResult } from "../core/api/types/PageableResult";
|
4
4
|
import {
|
@@ -65,7 +65,9 @@ export interface StockRuleFilter extends ResourceFilterCriteria {
|
|
65
65
|
|
66
66
|
// getStockItems
|
67
67
|
export function useStockItems(filter: StockItemFilter) {
|
68
|
-
const apiUrl =
|
68
|
+
const apiUrl = `${restBaseUrl}/stockmanagement/stockitem${toQueryParams(
|
69
|
+
filter
|
70
|
+
)}`;
|
69
71
|
const { data, error, isLoading } = useSWR<
|
70
72
|
{
|
71
73
|
data: PageableResult<StockItemDTO>;
|
@@ -82,7 +84,7 @@ export function useStockItems(filter: StockItemFilter) {
|
|
82
84
|
|
83
85
|
// getStockItemTransactions
|
84
86
|
export function useStockItemTransactions(filter: StockItemTransactionFilter) {
|
85
|
-
const apiUrl =
|
87
|
+
const apiUrl = `${restBaseUrl}/stockmanagement/stockitemtransaction${toQueryParams(
|
86
88
|
filter
|
87
89
|
)}`;
|
88
90
|
const { data, error, isLoading } = useSWR<
|
@@ -101,7 +103,7 @@ export function useStockItemTransactions(filter: StockItemTransactionFilter) {
|
|
101
103
|
|
102
104
|
// getStockItemInventory
|
103
105
|
export function useStockItemInventory(filter: StockItemInventoryFilter) {
|
104
|
-
const apiUrl =
|
106
|
+
const apiUrl = `${restBaseUrl}/stockmanagement/stockiteminventory${toQueryParams(
|
105
107
|
filter
|
106
108
|
)}`;
|
107
109
|
const { data, error, isLoading } = useSWR<
|
@@ -120,7 +122,7 @@ export function useStockItemInventory(filter: StockItemInventoryFilter) {
|
|
120
122
|
|
121
123
|
// getStockOperationItemsCost
|
122
124
|
export function useStockOperationItemsCost(filter: string) {
|
123
|
-
const apiUrl =
|
125
|
+
const apiUrl = `${restBaseUrl}/stockmanagement/stockoperationitemcost?v=default&stockOperationUuid=${filter}`;
|
124
126
|
const { data, error, isLoading } = useSWR<
|
125
127
|
{
|
126
128
|
data: PageableResult<StockOperationItemCost>;
|
@@ -136,7 +138,7 @@ export function useStockOperationItemsCost(filter: string) {
|
|
136
138
|
|
137
139
|
// getStockBatches
|
138
140
|
export function useStockBatches(filter: StockBatchFilter) {
|
139
|
-
const apiUrl =
|
141
|
+
const apiUrl = `${restBaseUrl}/stockmanagement/stockbatch${toQueryParams(
|
140
142
|
filter
|
141
143
|
)}`;
|
142
144
|
const { data, error, isLoading } = useSWR<
|
@@ -154,7 +156,7 @@ export function useStockBatches(filter: StockBatchFilter) {
|
|
154
156
|
|
155
157
|
// getStockItemPackagingUOMs
|
156
158
|
export function useStockItemPackagingUOMs(filter: StockItemPackagingUOMFilter) {
|
157
|
-
const apiUrl =
|
159
|
+
const apiUrl = `${restBaseUrl}/stockmanagement/stockitempackaginguom${toQueryParams(
|
158
160
|
filter
|
159
161
|
)}`;
|
160
162
|
const { data, error, isLoading } = useSWR<
|
@@ -173,7 +175,7 @@ export function useStockItemPackagingUOMs(filter: StockItemPackagingUOMFilter) {
|
|
173
175
|
|
174
176
|
// getStockItem
|
175
177
|
export function useStockItem(id: string) {
|
176
|
-
const apiUrl =
|
178
|
+
const apiUrl = `${restBaseUrl}/stockmanagement/stockitem/${id}?v=full`;
|
177
179
|
const { data, error, isLoading } = useSWR<
|
178
180
|
{
|
179
181
|
data: StockItemDTO;
|
@@ -198,7 +200,7 @@ export function deleteStockItems(ids: string[]) {
|
|
198
200
|
otherIds = "?ids=" + otherIds;
|
199
201
|
}
|
200
202
|
|
201
|
-
const apiUrl =
|
203
|
+
const apiUrl = `${restBaseUrl}/stockmanagement/stockitem/${ids[0]}${otherIds}`;
|
202
204
|
|
203
205
|
const abortController = new AbortController();
|
204
206
|
|
@@ -213,7 +215,7 @@ export function deleteStockItems(ids: string[]) {
|
|
213
215
|
|
214
216
|
// deleteStockItemPackagingUnit
|
215
217
|
export function deleteStockItemPackagingUnit(id: string) {
|
216
|
-
const apiUrl =
|
218
|
+
const apiUrl = `${restBaseUrl}/stockmanagement/stockitempackaginguom/${id}`;
|
217
219
|
const abortController = new AbortController();
|
218
220
|
|
219
221
|
return openmrsFetch(apiUrl, {
|
@@ -227,7 +229,7 @@ export function deleteStockItemPackagingUnit(id: string) {
|
|
227
229
|
|
228
230
|
// createStockItem
|
229
231
|
export function createStockItem(item: StockItemDTO) {
|
230
|
-
const apiUrl =
|
232
|
+
const apiUrl = `${restBaseUrl}/stockmanagement/stockitem`;
|
231
233
|
const abortController = new AbortController();
|
232
234
|
delete item.isDrug;
|
233
235
|
return openmrsFetch(apiUrl, {
|
@@ -242,7 +244,7 @@ export function createStockItem(item: StockItemDTO) {
|
|
242
244
|
|
243
245
|
// updateStockItem
|
244
246
|
export function updateStockItem(item: StockItemDTO) {
|
245
|
-
const apiUrl =
|
247
|
+
const apiUrl = `${restBaseUrl}/stockmanagement/stockitem/${item.uuid}`;
|
246
248
|
const abortController = new AbortController();
|
247
249
|
delete item.isDrug;
|
248
250
|
delete item.dateCreated;
|
@@ -258,7 +260,7 @@ export function updateStockItem(item: StockItemDTO) {
|
|
258
260
|
|
259
261
|
// createStockItemPackagingUnit
|
260
262
|
export function createStockItemPackagingUnit(item: StockItemPackagingUOMDTO) {
|
261
|
-
const apiUrl =
|
263
|
+
const apiUrl = `${restBaseUrl}/stockmanagement/stockitempackaginguom`;
|
262
264
|
const abortController = new AbortController();
|
263
265
|
return openmrsFetch(apiUrl, {
|
264
266
|
method: "POST",
|
@@ -272,7 +274,7 @@ export function createStockItemPackagingUnit(item: StockItemPackagingUOMDTO) {
|
|
272
274
|
|
273
275
|
// updateStockItemPackagingUnit
|
274
276
|
export function updateStockItemPackagingUnit(item: StockItemDTO, uuid: string) {
|
275
|
-
const apiUrl =
|
277
|
+
const apiUrl = `${restBaseUrl}/stockmanagement/stockitempackaginguom/${uuid}`;
|
276
278
|
const abortController = new AbortController();
|
277
279
|
return openmrsFetch(apiUrl, {
|
278
280
|
method: "POST",
|
@@ -286,7 +288,7 @@ export function updateStockItemPackagingUnit(item: StockItemDTO, uuid: string) {
|
|
286
288
|
|
287
289
|
// importStockItem
|
288
290
|
export function importStockItem(item: FormData) {
|
289
|
-
const apiUrl =
|
291
|
+
const apiUrl = `${restBaseUrl}/stockmanagement/stockitemimport`;
|
290
292
|
const abortController = new AbortController();
|
291
293
|
return openmrsFetch(apiUrl, {
|
292
294
|
method: "POST",
|
@@ -302,7 +304,9 @@ export function importStockItem(item: FormData) {
|
|
302
304
|
// getStockRules
|
303
305
|
export function useStockRules(filter: StockRuleFilter) {
|
304
306
|
console.warn("Rules filter: " + JSON.stringify(filter));
|
305
|
-
const apiUrl =
|
307
|
+
const apiUrl = `${restBaseUrl}/stockmanagement/stockrule${toQueryParams(
|
308
|
+
filter
|
309
|
+
)}`;
|
306
310
|
const { data, error, isLoading } = useSWR<
|
307
311
|
{
|
308
312
|
data: PageableResult<StockRule>;
|
@@ -325,7 +329,7 @@ export function useStockRules(filter: StockRuleFilter) {
|
|
325
329
|
|
326
330
|
// createStockRule
|
327
331
|
export function createStockRule(item: StockRule) {
|
328
|
-
const apiUrl =
|
332
|
+
const apiUrl = `${restBaseUrl}/stockmanagement/stockrule`;
|
329
333
|
const abortController = new AbortController();
|
330
334
|
return openmrsFetch(apiUrl, {
|
331
335
|
method: "POST",
|
@@ -339,7 +343,7 @@ export function createStockRule(item: StockRule) {
|
|
339
343
|
|
340
344
|
// updateStockRule
|
341
345
|
export function updateStockRule(item: StockRule, uuid: string) {
|
342
|
-
const apiUrl =
|
346
|
+
const apiUrl = `${restBaseUrl}/stockmanagement/stockrule/${uuid}`;
|
343
347
|
const abortController = new AbortController();
|
344
348
|
return openmrsFetch(apiUrl, {
|
345
349
|
method: "POST",
|
@@ -353,7 +357,7 @@ export function updateStockRule(item: StockRule, uuid: string) {
|
|
353
357
|
|
354
358
|
// deleteStockRule
|
355
359
|
export function deleteStockRule(id: string) {
|
356
|
-
const apiUrl =
|
360
|
+
const apiUrl = `${restBaseUrl}/stockmanagement/stockrule/${id}`;
|
357
361
|
const abortController = new AbortController();
|
358
362
|
return openmrsFetch(apiUrl, {
|
359
363
|
method: "DELETE",
|
package/src/stock-items/types.ts
CHANGED
@@ -1,8 +1,87 @@
|
|
1
1
|
import { StockItemDTO } from "../core/api/types/stockItem/StockItem";
|
2
2
|
import { StockOperationDTO } from "../core/api/types/stockOperation/StockOperationDTO";
|
3
|
+
import { KeyedMutator } from "swr";
|
3
4
|
|
4
5
|
export type SaveStockItem = (item: StockItemDTO) => Promise<void>;
|
5
6
|
export type SaveStockOperation = (item: StockOperationDTO) => Promise<void>;
|
6
7
|
export type SaveStockOperationAction = (
|
7
8
|
item: StockOperationDTO
|
8
9
|
) => Promise<void>;
|
10
|
+
|
11
|
+
export type LocationMutator = KeyedMutator<{
|
12
|
+
data: {
|
13
|
+
results: Array<Location>;
|
14
|
+
};
|
15
|
+
}>;
|
16
|
+
|
17
|
+
export type Location = {
|
18
|
+
uuid: string;
|
19
|
+
display: string;
|
20
|
+
name: string;
|
21
|
+
description: string | null;
|
22
|
+
address1: string | null;
|
23
|
+
address2: string | null;
|
24
|
+
cityVillage: string | null;
|
25
|
+
stateProvince: string | null;
|
26
|
+
country: string | null;
|
27
|
+
postalCode: string | null;
|
28
|
+
latitude: string | null;
|
29
|
+
longitude: string | null;
|
30
|
+
countyDistrict: string | null;
|
31
|
+
address3: string | null;
|
32
|
+
address4: string | null;
|
33
|
+
address5: string | null;
|
34
|
+
address6: string | null;
|
35
|
+
tags: Tag[];
|
36
|
+
parentLocation: Location;
|
37
|
+
childLocations: Location[];
|
38
|
+
retired: boolean;
|
39
|
+
auditInfo: {
|
40
|
+
creator: {
|
41
|
+
uuid: string;
|
42
|
+
display: string;
|
43
|
+
links: Array<{
|
44
|
+
rel: string;
|
45
|
+
uri: string;
|
46
|
+
resourceAlias: string;
|
47
|
+
}>;
|
48
|
+
};
|
49
|
+
dateCreated: string;
|
50
|
+
changedBy: null;
|
51
|
+
dateChanged: null;
|
52
|
+
};
|
53
|
+
address7: string | null;
|
54
|
+
address8: string | null;
|
55
|
+
address9: string | null;
|
56
|
+
address10: string | null;
|
57
|
+
address11: string | null;
|
58
|
+
address12: string | null;
|
59
|
+
address13: string | null;
|
60
|
+
address14: string | null;
|
61
|
+
address15: string | null;
|
62
|
+
links: Array<{
|
63
|
+
rel: string;
|
64
|
+
uri: string;
|
65
|
+
resourceAlias: string;
|
66
|
+
}>;
|
67
|
+
resourceVersion: string;
|
68
|
+
};
|
69
|
+
|
70
|
+
export type Tag = {
|
71
|
+
uuid: string;
|
72
|
+
display: string;
|
73
|
+
name: string;
|
74
|
+
description?: string;
|
75
|
+
retired: boolean;
|
76
|
+
links: Array<{
|
77
|
+
rel: string;
|
78
|
+
uri: string;
|
79
|
+
resourceAlias: string;
|
80
|
+
}>;
|
81
|
+
resourceVersion: string;
|
82
|
+
};
|
83
|
+
export interface locationData {
|
84
|
+
uuid?: string;
|
85
|
+
name: string;
|
86
|
+
tags: [];
|
87
|
+
}
|
@@ -0,0 +1,74 @@
|
|
1
|
+
import React, { useCallback } from "react";
|
2
|
+
import { useTranslation } from "react-i18next";
|
3
|
+
import { showToast, showNotification, useConfig } from "@openmrs/esm-framework";
|
4
|
+
import { saveLocation } from "./stock-locations-table.resource";
|
5
|
+
import { locationData, LocationMutator } from "../stock-items/types";
|
6
|
+
import LocationAdministrationForm from "./location-admin-form.component";
|
7
|
+
|
8
|
+
interface LocationFormProps {
|
9
|
+
showModal: boolean;
|
10
|
+
onModalChange: (showModal: boolean) => void;
|
11
|
+
mutate: LocationMutator;
|
12
|
+
}
|
13
|
+
|
14
|
+
const NewLocationForm: React.FC<LocationFormProps> = ({
|
15
|
+
showModal,
|
16
|
+
onModalChange,
|
17
|
+
mutate,
|
18
|
+
}) => {
|
19
|
+
const { t } = useTranslation();
|
20
|
+
const headerTitle = t("addLocation", "Create new Location");
|
21
|
+
|
22
|
+
const initialData: locationData = {
|
23
|
+
uuid: "",
|
24
|
+
name: "",
|
25
|
+
tags: [],
|
26
|
+
};
|
27
|
+
|
28
|
+
const handleCreateQuestion = useCallback(
|
29
|
+
(formData: locationData) => {
|
30
|
+
const { name, tags } = formData;
|
31
|
+
|
32
|
+
const locationbject = {
|
33
|
+
name,
|
34
|
+
tags,
|
35
|
+
};
|
36
|
+
saveLocation({ locationPayload: locationbject })
|
37
|
+
.then(() => {
|
38
|
+
showToast({
|
39
|
+
title: t("formCreated", "Add Location"),
|
40
|
+
kind: "success",
|
41
|
+
critical: true,
|
42
|
+
description: t(`Location ${name} was created successfully.`),
|
43
|
+
});
|
44
|
+
|
45
|
+
mutate();
|
46
|
+
onModalChange(false);
|
47
|
+
})
|
48
|
+
.catch((error) => {
|
49
|
+
showNotification({
|
50
|
+
title: t("errorCreatingForm", "Error creating location"),
|
51
|
+
kind: "error",
|
52
|
+
critical: true,
|
53
|
+
description: error?.message,
|
54
|
+
});
|
55
|
+
onModalChange(false);
|
56
|
+
});
|
57
|
+
onModalChange(false);
|
58
|
+
},
|
59
|
+
[onModalChange, mutate, t]
|
60
|
+
);
|
61
|
+
|
62
|
+
return (
|
63
|
+
<>
|
64
|
+
<LocationAdministrationForm
|
65
|
+
onModalChange={onModalChange}
|
66
|
+
showModal={showModal}
|
67
|
+
handleCreateQuestion={handleCreateQuestion}
|
68
|
+
headerTitle={headerTitle}
|
69
|
+
initialData={initialData}
|
70
|
+
/>
|
71
|
+
</>
|
72
|
+
);
|
73
|
+
};
|
74
|
+
export default NewLocationForm;
|