@openmrs/esm-stock-management-app 1.0.1-pre.345 → 1.0.1-pre.348
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/117.js +1 -0
- package/dist/117.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 +28 -28
- package/dist/routes.json +1 -1
- package/package.json +1 -1
- package/src/dashboard/stock-management-dashboard-side-nav.component.tsx +4 -0
- package/src/dashboard/stock-management-dashboard.component.tsx +2 -0
- package/src/routes.json +2 -2
- package/src/stock-reports/ReportType.ts +1 -0
- package/src/stock-reports/generate-report/create-stock-report.component.tsx +84 -0
- package/src/stock-reports/generate-report/create-stock-report.scss +22 -0
- package/src/stock-reports/report-list/new-report-button.component.tsx +21 -0
- package/src/stock-reports/report-list/stock-reports.component.tsx +172 -0
- package/src/stock-reports/report-list/stock-reports.scss +61 -0
- package/src/stock-reports/stock-reports.resource.ts +16 -0
- package/dist/220.js +0 -1
- package/dist/220.js.map +0 -1
- package/src/stock-reports/stock-reports.component.tsx +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(33),t.e(672),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(33),t.e(672),t.e(117)]).then((()=>()=>t(7568)))},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={117:[1914,2653,3397,5512,7248],672:[1672]},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=_})();
|
@@ -80,6 +80,30 @@
|
|
80
80
|
"hash": "acc8ddae60337eb2",
|
81
81
|
"childrenByOrder": {}
|
82
82
|
},
|
83
|
+
{
|
84
|
+
"rendered": true,
|
85
|
+
"initial": false,
|
86
|
+
"entry": false,
|
87
|
+
"recorded": false,
|
88
|
+
"size": 937431,
|
89
|
+
"sizes": {
|
90
|
+
"javascript": 937221,
|
91
|
+
"consume-shared": 210
|
92
|
+
},
|
93
|
+
"names": [],
|
94
|
+
"idHints": [],
|
95
|
+
"runtime": [
|
96
|
+
"@openmrs/esm-stock-management-app"
|
97
|
+
],
|
98
|
+
"files": [
|
99
|
+
"117.js"
|
100
|
+
],
|
101
|
+
"auxiliaryFiles": [
|
102
|
+
"117.js.map"
|
103
|
+
],
|
104
|
+
"hash": "ccb5dc4662a7f830",
|
105
|
+
"childrenByOrder": {}
|
106
|
+
},
|
83
107
|
{
|
84
108
|
"rendered": true,
|
85
109
|
"initial": true,
|
@@ -104,7 +128,7 @@
|
|
104
128
|
"auxiliaryFiles": [
|
105
129
|
"openmrs-esm-stock-management-app.js.map"
|
106
130
|
],
|
107
|
-
"hash": "
|
131
|
+
"hash": "dcf4c7d51b8d2f77",
|
108
132
|
"childrenByOrder": {}
|
109
133
|
},
|
110
134
|
{
|
@@ -112,10 +136,10 @@
|
|
112
136
|
"initial": true,
|
113
137
|
"entry": true,
|
114
138
|
"recorded": false,
|
115
|
-
"size":
|
139
|
+
"size": 4374228,
|
116
140
|
"sizes": {
|
117
141
|
"consume-shared": 252,
|
118
|
-
"javascript":
|
142
|
+
"javascript": 4352280,
|
119
143
|
"share-init": 252,
|
120
144
|
"runtime": 21444
|
121
145
|
},
|
@@ -132,31 +156,7 @@
|
|
132
156
|
"auxiliaryFiles": [
|
133
157
|
"main.js.map"
|
134
158
|
],
|
135
|
-
"hash": "
|
136
|
-
"childrenByOrder": {}
|
137
|
-
},
|
138
|
-
{
|
139
|
-
"rendered": true,
|
140
|
-
"initial": false,
|
141
|
-
"entry": false,
|
142
|
-
"recorded": false,
|
143
|
-
"size": 917693,
|
144
|
-
"sizes": {
|
145
|
-
"javascript": 917483,
|
146
|
-
"consume-shared": 210
|
147
|
-
},
|
148
|
-
"names": [],
|
149
|
-
"idHints": [],
|
150
|
-
"runtime": [
|
151
|
-
"@openmrs/esm-stock-management-app"
|
152
|
-
],
|
153
|
-
"files": [
|
154
|
-
"220.js"
|
155
|
-
],
|
156
|
-
"auxiliaryFiles": [
|
157
|
-
"220.js.map"
|
158
|
-
],
|
159
|
-
"hash": "3913a34587c13a55",
|
159
|
+
"hash": "e96c048b0aa2d2a0",
|
160
160
|
"childrenByOrder": {}
|
161
161
|
},
|
162
162
|
{
|
package/dist/routes.json
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"fhir2":"
|
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.348"}
|
package/package.json
CHANGED
@@ -32,6 +32,10 @@ const StockManagementDashboardSideNav = () => {
|
|
32
32
|
name: t("stockManagementLocations", "Stock Locations"),
|
33
33
|
link: "stock-locations",
|
34
34
|
},
|
35
|
+
{
|
36
|
+
name: t("stockManagementReports", "Stock Reports"),
|
37
|
+
link: "stock-reports",
|
38
|
+
},
|
35
39
|
{
|
36
40
|
name: t("stockManagementSettings", "Stock Settings"),
|
37
41
|
link: `admin/maintenance/settings.list?show=Stockmanagement`,
|
@@ -11,6 +11,7 @@ import StockOperationsComponent from "../stock-operations/stock-operations.compo
|
|
11
11
|
import StockItems from "../stock-items/stock-items.component";
|
12
12
|
import StockSettings from "../stock-settings/stock-settings.component";
|
13
13
|
import StockLocations from "../stock-locations/stock-locations.component";
|
14
|
+
import StockReports from "../stock-reports/report-list/stock-reports.component";
|
14
15
|
|
15
16
|
export default function StockManagementDashboard() {
|
16
17
|
const basePath = `${window.getOpenmrsSpaBase()}stock-management`;
|
@@ -31,6 +32,7 @@ export default function StockManagementDashboard() {
|
|
31
32
|
<Route path="stock-user-scopes" element={<StockUserScopes />} />
|
32
33
|
<Route path="stock-sources" element={<StockSources />} />
|
33
34
|
<Route path="stock-locations" element={<StockLocations />} />
|
35
|
+
<Route path="stock-reports" element={<StockReports />} />
|
34
36
|
<Route path="stock-settings" element={<StockSettings />} />
|
35
37
|
</Routes>
|
36
38
|
</div>
|
package/src/routes.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"$schema": "https://json.openmrs.org/routes.schema.json",
|
3
3
|
"backendDependencies": {
|
4
|
-
"fhir2": "
|
4
|
+
"fhir2": ">=1.2",
|
5
5
|
"webservices.rest": "^2.24.0"
|
6
6
|
},
|
7
7
|
"extensions": [
|
@@ -50,4 +50,4 @@
|
|
50
50
|
"route": "stock-management"
|
51
51
|
}
|
52
52
|
]
|
53
|
-
}
|
53
|
+
}
|
@@ -0,0 +1,84 @@
|
|
1
|
+
import {
|
2
|
+
Button,
|
3
|
+
Form,
|
4
|
+
ModalBody,
|
5
|
+
ModalFooter,
|
6
|
+
ModalHeader,
|
7
|
+
InlineLoading,
|
8
|
+
ComboBox,
|
9
|
+
} from "@carbon/react";
|
10
|
+
import React from "react";
|
11
|
+
import styles from "./create-stock-report.scss";
|
12
|
+
import { useTranslation } from "react-i18next";
|
13
|
+
import { closeOverlay } from "../../core/components/overlay/hook";
|
14
|
+
import { useReportTypes } from "../stock-reports.resource";
|
15
|
+
|
16
|
+
interface CreateReportProps {
|
17
|
+
model?: ReportModel;
|
18
|
+
}
|
19
|
+
|
20
|
+
export interface ReportModel {
|
21
|
+
reportSystemName?: string;
|
22
|
+
reportName?: string;
|
23
|
+
parameters?: string[];
|
24
|
+
date?: Date;
|
25
|
+
startDate?: Date;
|
26
|
+
endDate?: Date;
|
27
|
+
stockItemCategory?: string;
|
28
|
+
stockItemCategoryConceptUuid?: string;
|
29
|
+
location?: string;
|
30
|
+
locationUuid?: string;
|
31
|
+
childLocations: boolean;
|
32
|
+
stockSourceUuid?: string;
|
33
|
+
stockSource?: string;
|
34
|
+
stockSourceDestinationUuid?: string;
|
35
|
+
stockSourceDestination?: string;
|
36
|
+
}
|
37
|
+
const CreateReport: React.FC<CreateReportProps> = ({ model }) => {
|
38
|
+
const { t } = useTranslation();
|
39
|
+
|
40
|
+
const { reportTypes, isLoading } = useReportTypes();
|
41
|
+
if (isLoading) {
|
42
|
+
return (
|
43
|
+
<InlineLoading
|
44
|
+
status="active"
|
45
|
+
iconDescription="Loading"
|
46
|
+
description="Loading data..."
|
47
|
+
/>
|
48
|
+
);
|
49
|
+
}
|
50
|
+
|
51
|
+
return (
|
52
|
+
<div>
|
53
|
+
<Form>
|
54
|
+
<ModalHeader />
|
55
|
+
<ModalBody>
|
56
|
+
<section className={styles.section}>
|
57
|
+
<div>
|
58
|
+
<>
|
59
|
+
<span className={styles.subTitle}>{t("report", "Report")}</span>
|
60
|
+
<ComboBox
|
61
|
+
id="report"
|
62
|
+
size="md"
|
63
|
+
labelText={t("reportName", "Report")}
|
64
|
+
items={reportTypes ?? []}
|
65
|
+
itemToString={(item) => `${item?.name ?? item?.name ?? ""}`}
|
66
|
+
placeholder="Filter..."
|
67
|
+
/>
|
68
|
+
</>
|
69
|
+
</div>
|
70
|
+
</section>
|
71
|
+
<br />
|
72
|
+
</ModalBody>
|
73
|
+
<ModalFooter>
|
74
|
+
<Button kind="secondary" onClick={closeOverlay}>
|
75
|
+
{t("cancel", "Cancel")}
|
76
|
+
</Button>
|
77
|
+
<Button type="submit">{t("continue", "Continue")}</Button>
|
78
|
+
</ModalFooter>
|
79
|
+
</Form>
|
80
|
+
</div>
|
81
|
+
);
|
82
|
+
};
|
83
|
+
|
84
|
+
export default CreateReport;
|
@@ -0,0 +1,22 @@
|
|
1
|
+
@use '@carbon/styles/scss/spacing';
|
2
|
+
@use '@carbon/styles/scss/type';
|
3
|
+
@import '~@openmrs/esm-styleguide/src/vars';
|
4
|
+
|
5
|
+
.section {
|
6
|
+
// margin: spacing.$spacing-03;
|
7
|
+
}
|
8
|
+
|
9
|
+
.sectionTitle {
|
10
|
+
@include type.type-style('heading-compact-02');
|
11
|
+
color: $text-02;
|
12
|
+
margin-bottom: spacing.$spacing-04;
|
13
|
+
}
|
14
|
+
|
15
|
+
.subTitle {
|
16
|
+
font-size: 14px;
|
17
|
+
margin-bottom: spacing.$spacing-04;
|
18
|
+
}
|
19
|
+
|
20
|
+
.modalBody {
|
21
|
+
padding-bottom: spacing.$spacing-05;
|
22
|
+
}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import { Button } from "@carbon/react";
|
2
|
+
import React, { useCallback } from "react";
|
3
|
+
import { useTranslation } from "react-i18next";
|
4
|
+
import CreateReport from "../generate-report/create-stock-report.component";
|
5
|
+
import { launchOverlay } from "../../core/components/overlay/hook";
|
6
|
+
|
7
|
+
const NewReportActionButton: React.FC = () => {
|
8
|
+
const { t } = useTranslation();
|
9
|
+
|
10
|
+
const handleClick = useCallback(() => {
|
11
|
+
launchOverlay("New Report", <CreateReport />);
|
12
|
+
}, []);
|
13
|
+
|
14
|
+
return (
|
15
|
+
<Button onClick={handleClick} size="md" kind="primary">
|
16
|
+
{t("newReport", "New Report")}
|
17
|
+
</Button>
|
18
|
+
);
|
19
|
+
};
|
20
|
+
|
21
|
+
export default NewReportActionButton;
|
@@ -0,0 +1,172 @@
|
|
1
|
+
import React, { useMemo } from "react";
|
2
|
+
import { useTranslation } from "react-i18next";
|
3
|
+
import {
|
4
|
+
DataTable,
|
5
|
+
DataTableSkeleton,
|
6
|
+
Link,
|
7
|
+
TabPanel,
|
8
|
+
Pagination,
|
9
|
+
Table,
|
10
|
+
TableBody,
|
11
|
+
TableCell,
|
12
|
+
TableContainer,
|
13
|
+
TableHead,
|
14
|
+
TableHeader,
|
15
|
+
TableRow,
|
16
|
+
TableToolbar,
|
17
|
+
TableToolbarContent,
|
18
|
+
TableToolbarSearch,
|
19
|
+
Tile,
|
20
|
+
} from "@carbon/react";
|
21
|
+
import styles from "./stock-reports.scss";
|
22
|
+
import { isDesktop } from "@openmrs/esm-framework";
|
23
|
+
|
24
|
+
import NewReportActionButton from "./new-report-button.component";
|
25
|
+
|
26
|
+
const StockReports: React.FC = () => {
|
27
|
+
const { t } = useTranslation();
|
28
|
+
const tableHeaders = useMemo(
|
29
|
+
() => [
|
30
|
+
{
|
31
|
+
id: 0,
|
32
|
+
header: t("report", "Report"),
|
33
|
+
key: "report",
|
34
|
+
},
|
35
|
+
|
36
|
+
{
|
37
|
+
id: 1,
|
38
|
+
header: t("parameters", "Parameters"),
|
39
|
+
key: "parameters",
|
40
|
+
},
|
41
|
+
{
|
42
|
+
id: 2,
|
43
|
+
header: t("DateRequested", "Date Requested"),
|
44
|
+
key: "DateRequested",
|
45
|
+
},
|
46
|
+
{
|
47
|
+
id: 3,
|
48
|
+
header: t("requestedBy", "Requested By"),
|
49
|
+
key: "requestedBy",
|
50
|
+
},
|
51
|
+
{
|
52
|
+
id: 4,
|
53
|
+
header: t("status", "Status"),
|
54
|
+
key: "status",
|
55
|
+
},
|
56
|
+
{
|
57
|
+
id: 8,
|
58
|
+
header: t("actions", "Actions"),
|
59
|
+
key: "actions",
|
60
|
+
},
|
61
|
+
],
|
62
|
+
[]
|
63
|
+
);
|
64
|
+
|
65
|
+
const tableRows = useMemo(() => {
|
66
|
+
return [];
|
67
|
+
}, []);
|
68
|
+
|
69
|
+
return (
|
70
|
+
<div className={styles.tableOverride}>
|
71
|
+
<TabPanel>
|
72
|
+
{t("ReportDescription", "List of reports requested by users")}
|
73
|
+
</TabPanel>
|
74
|
+
<div id="table-tool-bar">
|
75
|
+
<div></div>
|
76
|
+
<div className="right-filters"></div>
|
77
|
+
</div>
|
78
|
+
<DataTable
|
79
|
+
rows={tableRows ?? []}
|
80
|
+
headers={tableHeaders}
|
81
|
+
isSortable={true}
|
82
|
+
useZebraStyles={true}
|
83
|
+
render={({
|
84
|
+
rows,
|
85
|
+
headers,
|
86
|
+
getHeaderProps,
|
87
|
+
getTableProps,
|
88
|
+
getRowProps,
|
89
|
+
onInputChange,
|
90
|
+
}) => (
|
91
|
+
<TableContainer>
|
92
|
+
<TableToolbar
|
93
|
+
style={{
|
94
|
+
position: "static",
|
95
|
+
overflow: "visible",
|
96
|
+
backgroundColor: "color",
|
97
|
+
}}
|
98
|
+
>
|
99
|
+
<TableToolbarContent className={styles.toolbarContent}>
|
100
|
+
<TableToolbarSearch persistent onChange={onInputChange} />
|
101
|
+
<NewReportActionButton />
|
102
|
+
</TableToolbarContent>
|
103
|
+
</TableToolbar>
|
104
|
+
<Table {...getTableProps()}>
|
105
|
+
<TableHead>
|
106
|
+
<TableRow>
|
107
|
+
{headers.map(
|
108
|
+
(header: any) =>
|
109
|
+
header.key !== "details" && (
|
110
|
+
<TableHeader
|
111
|
+
{...getHeaderProps({
|
112
|
+
header,
|
113
|
+
isSortable: header.isSortable,
|
114
|
+
})}
|
115
|
+
className={
|
116
|
+
isDesktop
|
117
|
+
? styles.desktopHeader
|
118
|
+
: styles.tabletHeader
|
119
|
+
}
|
120
|
+
key={`${header.key}`}
|
121
|
+
>
|
122
|
+
{header.header?.content ?? header.header}
|
123
|
+
</TableHeader>
|
124
|
+
)
|
125
|
+
)}
|
126
|
+
<TableHeader></TableHeader>
|
127
|
+
</TableRow>
|
128
|
+
</TableHead>
|
129
|
+
<TableBody>
|
130
|
+
{rows.map((row: any) => {
|
131
|
+
return (
|
132
|
+
<React.Fragment key={row.id}>
|
133
|
+
<TableRow
|
134
|
+
className={
|
135
|
+
isDesktop ? styles.desktopRow : styles.tabletRow
|
136
|
+
}
|
137
|
+
{...getRowProps({ row })}
|
138
|
+
>
|
139
|
+
{row.cells.map(
|
140
|
+
(cell: any) =>
|
141
|
+
cell?.info?.header !== "details" && (
|
142
|
+
<TableCell key={cell.id}>{cell.value}</TableCell>
|
143
|
+
)
|
144
|
+
)}
|
145
|
+
</TableRow>
|
146
|
+
</React.Fragment>
|
147
|
+
);
|
148
|
+
})}
|
149
|
+
</TableBody>
|
150
|
+
</Table>
|
151
|
+
{rows.length === 0 ? (
|
152
|
+
<div className={styles.tileContainer}>
|
153
|
+
<Tile className={styles.tile}>
|
154
|
+
<div className={styles.tileContent}>
|
155
|
+
<p className={styles.content}>
|
156
|
+
{t("noReportsToDisplay", "No Stock reports to display")}
|
157
|
+
</p>
|
158
|
+
<p className={styles.helper}>
|
159
|
+
{t("checkFilters", "Check the filters above")}
|
160
|
+
</p>
|
161
|
+
</div>
|
162
|
+
</Tile>
|
163
|
+
</div>
|
164
|
+
) : null}
|
165
|
+
</TableContainer>
|
166
|
+
)}
|
167
|
+
></DataTable>
|
168
|
+
</div>
|
169
|
+
);
|
170
|
+
};
|
171
|
+
|
172
|
+
export default StockReports;
|
@@ -0,0 +1,61 @@
|
|
1
|
+
@use '@carbon/styles/scss/colors';
|
2
|
+
@use '@carbon/styles/scss/type';
|
3
|
+
@import '~@openmrs/esm-styleguide/src/vars';
|
4
|
+
|
5
|
+
.content {
|
6
|
+
@include type.type-style('heading-compact-02');
|
7
|
+
color: $text-02;
|
8
|
+
margin-bottom: 0.5rem;
|
9
|
+
}
|
10
|
+
|
11
|
+
.helper {
|
12
|
+
@include type.type-style('body-compact-01');
|
13
|
+
color: $text-02;
|
14
|
+
}
|
15
|
+
|
16
|
+
.separator {
|
17
|
+
@include type.type-style('body-compact-02');
|
18
|
+
color: $text-02;
|
19
|
+
width: 80%;
|
20
|
+
margin: 1.5rem auto;
|
21
|
+
overflow: hidden;
|
22
|
+
text-align: center;
|
23
|
+
|
24
|
+
&::before,
|
25
|
+
&::after {
|
26
|
+
background-color: $text-03;
|
27
|
+
content: '';
|
28
|
+
display: inline-block;
|
29
|
+
height: 1px;
|
30
|
+
position: relative;
|
31
|
+
vertical-align: middle;
|
32
|
+
width: 50%;
|
33
|
+
}
|
34
|
+
|
35
|
+
&::before {
|
36
|
+
right: 0.5rem;
|
37
|
+
margin-left: -50%;
|
38
|
+
}
|
39
|
+
|
40
|
+
&::after {
|
41
|
+
left: 0.5rem;
|
42
|
+
margin-right: -50%;
|
43
|
+
}
|
44
|
+
}
|
45
|
+
|
46
|
+
.tileContainer {
|
47
|
+
background-color: $ui-02;
|
48
|
+
border-top: 1px solid $ui-03;
|
49
|
+
padding: 5rem 0;
|
50
|
+
}
|
51
|
+
|
52
|
+
.tile {
|
53
|
+
margin: auto;
|
54
|
+
width: fit-content;
|
55
|
+
}
|
56
|
+
|
57
|
+
.tileContent {
|
58
|
+
display: flex;
|
59
|
+
flex-direction: column;
|
60
|
+
align-items: center;
|
61
|
+
}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import { openmrsFetch, restBaseUrl } from "@openmrs/esm-framework";
|
2
|
+
import useSWR from "swr";
|
3
|
+
import { ReportType } from "./ReportType";
|
4
|
+
|
5
|
+
export function useReportTypes() {
|
6
|
+
const apiUrl = `${restBaseUrl}/stockmanagement/report?v=default`;
|
7
|
+
const { data, error, isLoading } = useSWR<
|
8
|
+
{ data: { results: ReportType } },
|
9
|
+
Error
|
10
|
+
>(apiUrl, openmrsFetch);
|
11
|
+
return {
|
12
|
+
reportTypes: data?.data?.results ?? [],
|
13
|
+
isLoading,
|
14
|
+
isError: error,
|
15
|
+
};
|
16
|
+
}
|