@openmrs/esm-openconceptlab-app 3.0.1-pre.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/.turbo/turbo-build.log +36 -0
  2. package/LICENSE +401 -0
  3. package/README.md +8 -0
  4. package/dist/316.js +2 -0
  5. package/dist/316.js.LICENSE.txt +19 -0
  6. package/dist/452.js +1 -0
  7. package/dist/574.js +1 -0
  8. package/dist/645.js +2 -0
  9. package/dist/645.js.LICENSE.txt +20 -0
  10. package/dist/709.js +1 -0
  11. package/dist/784.js +2 -0
  12. package/dist/784.js.LICENSE.txt +9 -0
  13. package/dist/858.js +2 -0
  14. package/dist/858.js.LICENSE.txt +1 -0
  15. package/dist/862.js +1 -0
  16. package/dist/main.js +1 -0
  17. package/dist/openmrs-esm-openconceptlab-app.js +1 -0
  18. package/dist/openmrs-esm-openconceptlab-app.js.buildmanifest.json +265 -0
  19. package/dist/openmrs-esm-openconceptlab-app.old +1 -0
  20. package/package.json +53 -0
  21. package/src/config-schema.ts +5 -0
  22. package/src/declarations.d.tsx +2 -0
  23. package/src/import/import.component.scss +27 -0
  24. package/src/import/import.component.tsx +190 -0
  25. package/src/import/import.resource.ts +40 -0
  26. package/src/import/import.test.tsx +103 -0
  27. package/src/index.ts +61 -0
  28. package/src/previous-imports/import-overview/import-items.component.scss +24 -0
  29. package/src/previous-imports/import-overview/import-items.component.tsx +124 -0
  30. package/src/previous-imports/import-overview/import-items.resource.ts +10 -0
  31. package/src/previous-imports/import-overview/import-items.test.tsx +93 -0
  32. package/src/previous-imports/import-overview/import-overview.component.scss +11 -0
  33. package/src/previous-imports/import-overview/import-overview.component.tsx +65 -0
  34. package/src/previous-imports/import-overview/import-overview.test.tsx +83 -0
  35. package/src/previous-imports/previous-imports.component.scss +39 -0
  36. package/src/previous-imports/previous-imports.component.tsx +136 -0
  37. package/src/previous-imports/previous-imports.resource.ts +17 -0
  38. package/src/previous-imports/previous-imports.test.tsx +77 -0
  39. package/src/root.component.scss +23 -0
  40. package/src/root.component.tsx +39 -0
  41. package/src/root.test.tsx +22 -0
  42. package/src/setup-tests.ts +1 -0
  43. package/src/subscription/subscription.component.scss +27 -0
  44. package/src/subscription/subscription.component.tsx +244 -0
  45. package/src/subscription/subscription.resource.ts +40 -0
  46. package/src/subscription/subscription.test.tsx +181 -0
  47. package/src/types.ts +34 -0
  48. package/translations/en.json +51 -0
  49. package/tsconfig.json +23 -0
  50. package/webpack.config.js +1 -0
@@ -0,0 +1 @@
1
+ /*! For license information please see openmrs-esm-react-utils.js.LICENSE.txt */
package/dist/862.js ADDED
@@ -0,0 +1 @@
1
+ (self.webpackChunk_openmrs_esm_openconceptlab_app=self.webpackChunk_openmrs_esm_openconceptlab_app||[]).push([[862],{4862:(e,n,o)=>{"use strict";o.r(n),o.d(n,{backendDependencies:()=>a,importTranslation:()=>t,setupOpenMRS:()=>c});var r=o(906),p={},t=o(3979),a={openconceptlab:"^1.2.0","webservices.rest":"^2.2.0"};function c(){var e="@openmrs/esm-openconceptlab-app",n={featureName:"openconceptlab",moduleName:e};return(0,r.defineConfigSchema)(e,p),{pages:[{load:(0,r.getAsyncLifecycle)((function(){return Promise.all([o.e(645),o.e(268),o.e(452)]).then(o.bind(o,7564))}),n),route:"ocl"}]}}},3979:(e,n,o)=>{var r={"./en.json":[3574,574]};function p(e){if(!o.o(r,e))return Promise.resolve().then((()=>{var n=new Error("Cannot find module '"+e+"'");throw n.code="MODULE_NOT_FOUND",n}));var n=r[e],p=n[0];return o.e(n[1]).then((()=>o(p)))}p.keys=()=>Object.keys(r),p.id=3979,e.exports=p}}]);
package/dist/main.js ADDED
@@ -0,0 +1 @@
1
+ (()=>{var e,r,t={4862:(e,r,t)=>{"use strict";t(906),t(3979)},3979:(e,r,t)=>{var n={"./en.json":[3574,574]};function o(e){if(!t.o(n,e))return Promise.resolve().then((()=>{var r=new Error("Cannot find module '"+e+"'");throw r.code="MODULE_NOT_FOUND",r}));var r=n[e],o=r[0];return t.e(r[1]).then((()=>t(o)))}o.keys=()=>Object.keys(n),o.id=3979,e.exports=o}},n={};function o(e){var r=n[e];if(void 0!==r)return r.exports;var a=n[e]={id:e,loaded:!1,exports:{}};return t[e].call(a.exports,a,a.exports,o),a.loaded=!0,a.exports}o.m=t,o.c=n,o.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return o.d(r,{a:r}),r},o.d=(e,r)=>{for(var t in r)o.o(r,t)&&!o.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},o.f={},o.e=e=>Promise.all(Object.keys(o.f).reduce(((r,t)=>(o.f[t](e,r),r)),[])),o.u=e=>e+".js",o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),o.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),e={},r="@openmrs/esm-openconceptlab-app:",o.l=(t,n,a,i)=>{if(e[t])e[t].push(n);else{var l,u;if(void 0!==a)for(var s=document.getElementsByTagName("script"),p=0;p<s.length;p++){var f=s[p];if(f.getAttribute("src")==t||f.getAttribute("data-webpack")==r+a){l=f;break}}l||(u=!0,(l=document.createElement("script")).charset="utf-8",l.timeout=120,o.nc&&l.setAttribute("nonce",o.nc),l.setAttribute("data-webpack",r+a),l.src=t),e[t]=[n];var c=(r,n)=>{l.onerror=l.onload=null,clearTimeout(d);var o=e[t];if(delete e[t],l.parentNode&&l.parentNode.removeChild(l),o&&o.forEach((e=>e(n))),r)return r(n)},d=setTimeout(c.bind(null,void 0,{type:"timeout",target:l}),12e4);l.onerror=c.bind(null,l.onerror),l.onload=c.bind(null,l.onload),u&&document.head.appendChild(l)}},o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),(()=>{o.S={};var e={},r={};o.I=(t,n)=>{n||(n=[]);var a=r[t];if(a||(a=r[t]={}),!(n.indexOf(a)>=0)){if(n.push(a),e[t])return e[t];o.o(o.S,t)||(o.S[t]={});var i=o.S[t],l="@openmrs/esm-openconceptlab-app",u=(e,r,t,n)=>{var o=i[e]=i[e]||{},a=o[r];(!a||!a.loaded&&(!n!=!a.eager?n:l>a.from))&&(o[r]={get:t,from:l,eager:!!n})},s=[];return"default"===t&&(u("@openmrs/esm-framework","4.0.1-pre.238",(()=>Promise.all([o.e(858),o.e(268)]).then((()=>()=>o(6858))))),u("react-dom","18.2.0",(()=>Promise.all([o.e(316),o.e(268)]).then((()=>()=>o(8316))))),u("react-i18next","11.18.4",(()=>Promise.all([o.e(709),o.e(268)]).then((()=>()=>o(709))))),u("react","18.2.0",(()=>o.e(784).then((()=>()=>o(2784)))))),e[t]=s.length?Promise.all(s).then((()=>e[t]=1)):1}}})(),(()=>{var e;o.g.importScripts&&(e=o.g.location+"");var r=o.g.document;if(!e&&r&&(r.currentScript&&(e=r.currentScript.src),!e)){var t=r.getElementsByTagName("script");t.length&&(e=t[t.length-1].src)}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),o.p=e})(),(()=>{var e=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},r=e=>{var t=e[0],n="";if(1===e.length)return"*";if(t+.5){n+=0==t?">=":-1==t?"<":1==t?"^":2==t?"~":t>0?"=":"!=";for(var o=1,a=1;a<e.length;a++)o--,n+="u"==(typeof(l=e[a]))[0]?"-":(o>0?".":"")+(o=2,l);return n}var i=[];for(a=1;a<e.length;a++){var l=e[a];i.push(0===l?"not("+u()+")":1===l?"("+u()+" || "+u()+")":2===l?i.pop()+" "+i.pop():r(l))}return u();function u(){return i.pop().replace(/^\((.+)\)$/,"$1")}},t=(r,n)=>{if(0 in r){n=e(n);var o=r[0],a=o<0;a&&(o=-o-1);for(var i=0,l=1,u=!0;;l++,i++){var s,p,f=l<r.length?(typeof r[l])[0]:"";if(i>=n.length||"o"==(p=(typeof(s=n[i]))[0]))return!u||("u"==f?l>o&&!a:""==f!=a);if("u"==p){if(!u||"u"!=f)return!1}else if(u)if(f==p)if(l<=o){if(s!=r[l])return!1}else{if(a?s>r[l]:s<r[l])return!1;s!=r[l]&&(u=!1)}else if("s"!=f&&"n"!=f){if(a||l<=o)return!1;u=!1,l--}else{if(l<=o||p<f!=a)return!1;u=!1}else"s"!=f&&"n"!=f&&(u=!1,l--)}}var c=[],d=c.pop.bind(c);for(i=1;i<r.length;i++){var h=r[i];c.push(1==h?d()|d():2==h?d()&d():h?t(h,n):!d())}return!!d()},n=(r,t)=>{var n=r[t];return Object.keys(n).reduce(((r,t)=>!r||!n[r].loaded&&((r,t)=>{r=e(r),t=e(t);for(var n=0;;){if(n>=r.length)return n<t.length&&"u"!=(typeof t[n])[0];var o=r[n],a=(typeof o)[0];if(n>=t.length)return"u"==a;var i=t[n],l=(typeof i)[0];if(a!=l)return"o"==a&&"n"==l||"s"==l||"u"==a;if("o"!=a&&"u"!=a&&o!=i)return o<i;n++}})(r,t)?t:r),0)},a=(e,o,a,l)=>{var u=n(e,a);return t(l,u)||"undefined"!=typeof console&&console.warn&&console.warn(((e,t,n,o)=>"Unsatisfied version "+n+" from "+(n&&e[t][n].from)+" of shared singleton module "+t+" (required "+r(o)+")")(e,a,u,l)),i(e[a][u])},i=e=>(e.loaded=1,e.get()),l=(e=>function(r,t,n,a){var i=o.I(r);return i&&i.then?i.then(e.bind(e,r,o.S[r],t,n,a)):e(r,o.S[r],t,n,a)})(((e,r,t,n,i)=>r&&o.o(r,t)?a(r,0,t,n):i())),u={},s={268:()=>l("default","react",[1,18],(()=>o.e(784).then((()=>()=>o(2784))))),1858:()=>l("default","react-dom",[1,18],(()=>o.e(316).then((()=>()=>o(8316))))),4924:()=>l("default","react-i18next",[1,11],(()=>o.e(709).then((()=>()=>o(709))))),906:()=>l("default","@openmrs/esm-framework",[1,4],(()=>Promise.all([o.e(858),o.e(268)]).then((()=>()=>o(6858)))))};[906].forEach((e=>{o.m[e]=r=>{u[e]=0,delete o.c[e];var t=s[e]();if("function"!=typeof t)throw new Error("Shared module is not available for eager consumption: "+e);r.exports=t()}}));var p={268:[268],452:[1858,4924]};o.f.consumes=(e,r)=>{o.o(p,e)&&p[e].forEach((e=>{if(o.o(u,e))return r.push(u[e]);var t=r=>{u[e]=0,o.m[e]=t=>{delete o.c[e],t.exports=r()}},n=r=>{delete u[e],o.m[e]=t=>{throw delete o.c[e],r}};try{var a=s[e]();a.then?r.push(u[e]=a.then(t).catch(n)):t(a)}catch(e){n(e)}}))}})(),(()=>{var e={179:0,862:0};o.f.j=(r,t)=>{var n=o.o(e,r)?e[r]:void 0;if(0!==n)if(n)t.push(n[2]);else if(268!=r){var a=new Promise(((t,o)=>n=e[r]=[t,o]));t.push(n[2]=a);var i=o.p+o.u(r),l=new Error;o.l(i,(t=>{if(o.o(e,r)&&(0!==(n=e[r])&&(e[r]=void 0),n)){var a=t&&("load"===t.type?"missing":t.type),i=t&&t.target&&t.target.src;l.message="Loading chunk "+r+" failed.\n("+a+": "+i+")",l.name="ChunkLoadError",l.type=a,l.request=i,n[1](l)}}),"chunk-"+r,r)}else e[r]=0};var r=(r,t)=>{var n,a,[i,l,u]=t,s=0;if(i.some((r=>0!==e[r]))){for(n in l)o.o(l,n)&&(o.m[n]=l[n]);u&&u(o)}for(r&&r(t);s<i.length;s++)a=i[s],o.o(e,a)&&e[a]&&e[a][0](),e[a]=0},t=self.webpackChunk_openmrs_esm_openconceptlab_app=self.webpackChunk_openmrs_esm_openconceptlab_app||[];t.forEach(r.bind(null,0)),t.push=r.bind(null,t.push.bind(t))})(),o.nc=void 0,o(4862)})();
@@ -0,0 +1 @@
1
+ var _openmrs_esm_openconceptlab_app;(()=>{function b(a){var c=h[a];if(void 0!==c)return c.exports;var d=h[a]={id:a,loaded:!1,exports:{}};return G[a].call(d.exports,d,d.exports,b),d.loaded=!0,d.exports}var j,k,q,v,w,x,y,z,A,B,C,D,E,F,G={3203:(b,c,d)=>{var f={"./start":()=>d.e(862).then(()=>()=>d(4862))},e=(a,b)=>(d.R=b,b=d.o(f,a)?f[a]():Promise.resolve().then(()=>{throw new Error("Module \""+a+"\" does not exist in container.")}),d.R=void 0,b),g=(a,b)=>{if(d.S){var c=d.S["default"];if(c&&c!==a)throw new Error("Container initialization failed as it has already been initialized with a different share scope");return d.S["default"]=a,d.I("default",b)}};d.d(c,{get:()=>e,init:()=>g})}},h={};b.m=G,b.c=h,b.n=a=>{var c=a&&a.__esModule?()=>a.default:()=>a;return b.d(c,{a:c}),c},b.d=(a,c)=>{for(var d in c)b.o(c,d)&&!b.o(a,d)&&Object.defineProperty(a,d,{enumerable:!0,get:c[d]})},b.f={},b.e=a=>Promise.all(Object.keys(b.f).reduce((c,d)=>(b.f[d](a,c),c),[])),b.u=a=>a+".js",b.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(a){if("object"==typeof window)return window}}(),b.o=(a,b)=>Object.prototype.hasOwnProperty.call(a,b),j={},k="@openmrs/esm-openconceptlab-app:",b.l=(a,d,e)=>{if(j[a])j[a].push(d);else{var g,h;if(void 0!==e)for(var m,n=document.getElementsByTagName("script"),o=0;o<n.length;o++)if(m=n[o],m.getAttribute("src")==a||m.getAttribute("data-webpack")==k+e){g=m;break}g||(h=!0,(g=document.createElement("script")).charset="utf-8",g.timeout=120,b.nc&&g.setAttribute("nonce",b.nc),g.setAttribute("data-webpack",k+e),g.src=a),j[a]=[d];var q=(b,c)=>{g.onerror=g.onload=null,clearTimeout(f);var d=j[a];if(delete j[a],g.parentNode&&g.parentNode.removeChild(g),d&&d.forEach(a=>a(c)),b)return b(c)},f=setTimeout(q.bind(null,void 0,{type:"timeout",target:g}),12e4);g.onerror=q.bind(null,g.onerror),g.onload=q.bind(null,g.onload),h&&document.head.appendChild(g)}},b.r=a=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(a,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(a,"__esModule",{value:!0})},b.nmd=a=>(a.paths=[],a.children||(a.children=[]),a),(()=>{b.S={};var c={},d={};b.I=(e,f)=>{f||(f=[]);var g=d[e];if(g||(g=d[e]={}),!(0<=f.indexOf(g))){if(f.push(g),c[e])return c[e];b.o(b.S,e)||(b.S[e]={});var h=b.S[e],a=(a,b,c,d)=>{var e=h[a]=h[a]||{},f=e[b];f&&(f.loaded||(!d==!f.eager?!("@openmrs/esm-openconceptlab-app">f.from):!d))||(e[b]={get:c,from:"@openmrs/esm-openconceptlab-app",eager:!!d})},i=[];return"default"===e&&(a("@openmrs/esm-framework","4.0.1-pre.238",()=>Promise.all([b.e(858),b.e(268)]).then(()=>()=>b(6858))),a("react-dom","18.2.0",()=>Promise.all([b.e(316),b.e(268)]).then(()=>()=>b(8316))),a("react-i18next","11.18.4",()=>Promise.all([b.e(709),b.e(268)]).then(()=>()=>b(709))),a("react","18.2.0",()=>b.e(784).then(()=>()=>b(2784)))),c[e]=i.length?Promise.all(i).then(()=>c[e]=1):1}}})(),(()=>{var a;b.g.importScripts&&(a=b.g.location+"");var c=b.g.document;if(!a&&c&&(c.currentScript&&(a=c.currentScript.src),!a)){var d=c.getElementsByTagName("script");d.length&&(a=d[d.length-1].src)}if(!a)throw new Error("Automatic publicPath is not supported in this browser");a=a.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),b.p=a})(),q=a=>{var b=a=>a.split(".").map(a=>+a==a?+a:a),c=/^([^-+]+)?(?:-([^+]+))?(?:\+(.+))?$/.exec(a),d=c[1]?b(c[1]):[];return c[2]&&(d.length++,d.push.apply(d,b(c[2]))),c[3]&&(d.push([]),d.push.apply(d,b(c[3]))),d},v=(b,c)=>{b=q(b),c=q(c);for(var d=0;;){if(d>=b.length)return d<c.length&&"u"!=(typeof c[d])[0];var f=b[d],g=(typeof f)[0];if(d>=c.length)return"u"==g;var a=c[d],h=(typeof a)[0];if(g!=h)return"o"==g&&"n"==h||"s"==h||"u"==g;if("o"!=g&&"u"!=g&&f!=a)return f<a;d++}},w=b=>{function c(){return h.pop().replace(/^\((.+)\)$/,"$1")}var d=b[0],e="";if(1===b.length)return"*";if(d+.5){e+=0==d?">=":-1==d?"<":1==d?"^":2==d?"~":0<d?"=":"!=";for(var f=1,g=1;g<b.length;g++)f--,e+="u"==(typeof(i=b[g]))[0]?"-":(0<f?".":"")+(f=2,i);return e}var h=[];for(g=1;g<b.length;g++){var i=b[g];h.push(0===i?"not("+c()+")":1===i?"("+c()+" || "+c()+")":2===i?h.pop()+" "+h.pop():w(i))}return c()},x=(a,b)=>{if(0 in a){b=q(b);var e=a[0],g=0>e;g&&(e=-e-1);for(var j=0,k=1,m=!0;;k++,j++){var o,t,v=k<a.length?(typeof a[k])[0]:"";if(j>=b.length||"o"==(t=(typeof(o=b[j]))[0]))return!m||("u"==v?k>e&&!g:""==v!=g);if("u"==t){if(!m||"u"!=v)return!1;}else if(!m)"s"!=v&&"n"!=v&&(m=!1,k--);else if(v==t){if(!(k<=e)){if(g?o>a[k]:o<a[k])return!1;o!=a[k]&&(m=!1)}else if(o!=a[k])return!1;}else if("s"!=v&&"n"!=v){if(g||k<=e)return!1;m=!1,k--}else{if(k<=e||t<v!=g)return!1;m=!1}}}var f=[],c=f.pop.bind(f);for(j=1;j<a.length;j++){var d=a[j];f.push(1==d?c()|c():2==d?c()&c():d?x(d,b):!c())}return!!c()},y=(a,b)=>{var c=a[b];return Object.keys(c).reduce((a,b)=>a&&(c[a].loaded||!v(a,b))?a:b,0)},z=(a,b,c,d)=>"Unsatisfied version "+c+" from "+(c&&a[b][c].from)+" of shared singleton module "+b+" (required "+w(d)+")",A=(a,b,c,d)=>{var e=y(a,c);return x(d,e)||"undefined"!=typeof console&&console.warn&&console.warn(z(a,c,e,d)),B(a[c][e])},B=a=>(a.loaded=1,a.get()),C=(c=>function(d,e,f,g){var h=b.I(d);return h&&h.then?h.then(c.bind(c,d,b.S[d],e,f,g)):c(0,b.S[d],e,f,g)})((a,c,d,e,f)=>c&&b.o(c,d)?A(c,0,d,e):f()),D={},E={268:()=>C("default","react",[1,18],()=>b.e(784).then(()=>()=>b(2784))),906:()=>C("default","@openmrs/esm-framework",[1,4],()=>Promise.all([b.e(858),b.e(268)]).then(()=>()=>b(6858))),1858:()=>C("default","react-dom",[1,18],()=>b.e(316).then(()=>()=>b(8316))),4924:()=>C("default","react-i18next",[1,11],()=>b.e(709).then(()=>()=>b(709)))},F={268:[268],452:[1858,4924],862:[906]},b.f.consumes=(a,c)=>{b.o(F,a)&&F[a].forEach(a=>{if(b.o(D,a))return c.push(D[a]);var d=c=>{D[a]=0,b.m[a]=d=>{delete b.c[a],d.exports=c()}},f=c=>{delete D[a],b.m[a]=()=>{throw delete b.c[a],c}};try{var e=E[a]();e.then?c.push(D[a]=e.then(d).catch(f)):d(e)}catch(a){f(a)}})},(()=>{var c={174:0};b.f.j=(d,e)=>{var f=b.o(c,d)?c[d]:void 0;if(0!==f)if(f)e.push(f[2]);else if(268!=d){var g=new Promise((a,b)=>f=c[d]=[a,b]);e.push(f[2]=g);var h=b.p+b.u(d),j=new Error;b.l(h,e=>{if(b.o(c,d)&&(0!==(f=c[d])&&(c[d]=void 0),f)){var g=e&&("load"===e.type?"missing":e.type),h=e&&e.target&&e.target.src;j.message="Loading chunk "+d+" failed.\n("+g+": "+h+")",j.name="ChunkLoadError",j.type=g,j.request=h,f[1](j)}},"chunk-"+d,d)}else c[d]=0};var a=(d,e)=>{var f,g,[h,a,i]=e,j=0;if(h.some(a=>0!==c[a])){for(f in a)b.o(a,f)&&(b.m[f]=a[f]);i&&i(b)}for(d&&d(e);j<h.length;j++)g=h[j],b.o(c,g)&&c[g]&&c[g][0](),c[g]=0},d=self.webpackChunk_openmrs_esm_openconceptlab_app=self.webpackChunk_openmrs_esm_openconceptlab_app||[];d.forEach(a.bind(null,0)),d.push=a.bind(null,d.push.bind(d))})(),b.nc=void 0;var m=b(3203);_openmrs_esm_openconceptlab_app=m})();
@@ -0,0 +1,265 @@
1
+ {
2
+ "chunks": [
3
+ {
4
+ "rendered": true,
5
+ "initial": true,
6
+ "entry": true,
7
+ "recorded": false,
8
+ "size": 19453,
9
+ "sizes": {
10
+ "javascript": 42,
11
+ "share-init": 168,
12
+ "runtime": 19243
13
+ },
14
+ "names": [
15
+ "@openmrs/esm-openconceptlab-app"
16
+ ],
17
+ "idHints": [],
18
+ "runtime": [
19
+ "@openmrs/esm-openconceptlab-app"
20
+ ],
21
+ "files": [
22
+ "openmrs-esm-openconceptlab-app.js"
23
+ ],
24
+ "auxiliaryFiles": [],
25
+ "hash": "b82fac69008cb7fc131f",
26
+ "childrenByOrder": {}
27
+ },
28
+ {
29
+ "rendered": true,
30
+ "initial": true,
31
+ "entry": true,
32
+ "recorded": false,
33
+ "size": 22076,
34
+ "sizes": {
35
+ "consume-shared": 42,
36
+ "javascript": 2256,
37
+ "share-init": 168,
38
+ "runtime": 19610
39
+ },
40
+ "names": [
41
+ "main"
42
+ ],
43
+ "idHints": [],
44
+ "runtime": [
45
+ "main"
46
+ ],
47
+ "files": [
48
+ "main.js"
49
+ ],
50
+ "auxiliaryFiles": [],
51
+ "hash": "740480108dd4faebe8c0",
52
+ "childrenByOrder": {}
53
+ },
54
+ {
55
+ "rendered": false,
56
+ "initial": false,
57
+ "entry": false,
58
+ "recorded": false,
59
+ "reason": "reused as split chunk (cache group: default)",
60
+ "size": 42,
61
+ "sizes": {
62
+ "consume-shared": 42
63
+ },
64
+ "names": [],
65
+ "idHints": [],
66
+ "runtime": [
67
+ "@openmrs/esm-openconceptlab-app",
68
+ "main"
69
+ ],
70
+ "files": [],
71
+ "auxiliaryFiles": [],
72
+ "hash": "db8ef61fa9ed16831608",
73
+ "childrenByOrder": {}
74
+ },
75
+ {
76
+ "rendered": true,
77
+ "initial": false,
78
+ "entry": false,
79
+ "recorded": false,
80
+ "reason": "reused as split chunk (cache group: defaultVendors)",
81
+ "size": 137533,
82
+ "sizes": {
83
+ "javascript": 137533
84
+ },
85
+ "names": [],
86
+ "idHints": [
87
+ "vendors"
88
+ ],
89
+ "runtime": [
90
+ "@openmrs/esm-openconceptlab-app",
91
+ "main"
92
+ ],
93
+ "files": [
94
+ "316.js"
95
+ ],
96
+ "auxiliaryFiles": [],
97
+ "hash": "03f0939e0125623d49c2",
98
+ "childrenByOrder": {}
99
+ },
100
+ {
101
+ "rendered": true,
102
+ "initial": false,
103
+ "entry": false,
104
+ "recorded": false,
105
+ "size": 76539,
106
+ "sizes": {
107
+ "javascript": 76455,
108
+ "consume-shared": 84
109
+ },
110
+ "names": [],
111
+ "idHints": [],
112
+ "runtime": [
113
+ "@openmrs/esm-openconceptlab-app",
114
+ "main"
115
+ ],
116
+ "files": [
117
+ "452.js"
118
+ ],
119
+ "auxiliaryFiles": [],
120
+ "hash": "7ec4531e95b95b56c432",
121
+ "childrenByOrder": {}
122
+ },
123
+ {
124
+ "rendered": true,
125
+ "initial": false,
126
+ "entry": false,
127
+ "recorded": false,
128
+ "size": 2380,
129
+ "sizes": {
130
+ "javascript": 2380
131
+ },
132
+ "names": [],
133
+ "idHints": [],
134
+ "runtime": [
135
+ "@openmrs/esm-openconceptlab-app",
136
+ "main"
137
+ ],
138
+ "files": [
139
+ "574.js"
140
+ ],
141
+ "auxiliaryFiles": [],
142
+ "hash": "1120dc2ccbdb807380f2",
143
+ "childrenByOrder": {}
144
+ },
145
+ {
146
+ "rendered": true,
147
+ "initial": false,
148
+ "entry": false,
149
+ "recorded": false,
150
+ "reason": "split chunk (cache group: defaultVendors)",
151
+ "size": 1799596,
152
+ "sizes": {
153
+ "javascript": 1799596
154
+ },
155
+ "names": [],
156
+ "idHints": [
157
+ "vendors"
158
+ ],
159
+ "runtime": [
160
+ "@openmrs/esm-openconceptlab-app",
161
+ "main"
162
+ ],
163
+ "files": [
164
+ "645.js"
165
+ ],
166
+ "auxiliaryFiles": [],
167
+ "hash": "ebc70c52b01ddb991d59",
168
+ "childrenByOrder": {}
169
+ },
170
+ {
171
+ "rendered": true,
172
+ "initial": false,
173
+ "entry": false,
174
+ "recorded": false,
175
+ "reason": "reused as split chunk (cache group: defaultVendors)",
176
+ "size": 39248,
177
+ "sizes": {
178
+ "javascript": 39248
179
+ },
180
+ "names": [],
181
+ "idHints": [
182
+ "vendors"
183
+ ],
184
+ "runtime": [
185
+ "@openmrs/esm-openconceptlab-app",
186
+ "main"
187
+ ],
188
+ "files": [
189
+ "709.js"
190
+ ],
191
+ "auxiliaryFiles": [],
192
+ "hash": "665a46c67c2239f85400",
193
+ "childrenByOrder": {}
194
+ },
195
+ {
196
+ "rendered": true,
197
+ "initial": false,
198
+ "entry": false,
199
+ "recorded": false,
200
+ "size": 7103,
201
+ "sizes": {
202
+ "javascript": 7103
203
+ },
204
+ "names": [],
205
+ "idHints": [],
206
+ "runtime": [
207
+ "@openmrs/esm-openconceptlab-app",
208
+ "main"
209
+ ],
210
+ "files": [
211
+ "784.js"
212
+ ],
213
+ "auxiliaryFiles": [],
214
+ "hash": "f3db8e4641ee765cf0b5",
215
+ "childrenByOrder": {}
216
+ },
217
+ {
218
+ "rendered": true,
219
+ "initial": false,
220
+ "entry": false,
221
+ "recorded": false,
222
+ "reason": "split chunk (cache group: defaultVendors)",
223
+ "size": 417361,
224
+ "sizes": {
225
+ "javascript": 417361
226
+ },
227
+ "names": [],
228
+ "idHints": [
229
+ "vendors"
230
+ ],
231
+ "runtime": [
232
+ "@openmrs/esm-openconceptlab-app",
233
+ "main"
234
+ ],
235
+ "files": [
236
+ "858.js"
237
+ ],
238
+ "auxiliaryFiles": [],
239
+ "hash": "e271e0f647458d8cfe84",
240
+ "childrenByOrder": {}
241
+ },
242
+ {
243
+ "rendered": true,
244
+ "initial": false,
245
+ "entry": false,
246
+ "recorded": false,
247
+ "size": 2298,
248
+ "sizes": {
249
+ "consume-shared": 42,
250
+ "javascript": 2256
251
+ },
252
+ "names": [],
253
+ "idHints": [],
254
+ "runtime": [
255
+ "@openmrs/esm-openconceptlab-app"
256
+ ],
257
+ "files": [
258
+ "862.js"
259
+ ],
260
+ "auxiliaryFiles": [],
261
+ "hash": "ddacffa676f9fe897be1",
262
+ "childrenByOrder": {}
263
+ }
264
+ ]
265
+ }
@@ -0,0 +1 @@
1
+ var _openmrs_esm_openconceptlab_app;(()=>{"use strict";var e,r,t,n,o,a,i,l,s,p,u,f,c,d,h={3203:(e,r,t)=>{var n={"./start":()=>t.e(862).then((()=>()=>t(4862)))},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})}},m={};function v(e){var r=m[e];if(void 0!==r)return r.exports;var t=m[e]={id:e,loaded:!1,exports:{}};return h[e].call(t.exports,t,t.exports,v),t.loaded=!0,t.exports}v.m=h,v.c=m,v.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return v.d(r,{a:r}),r},v.d=(e,r)=>{for(var t in r)v.o(r,t)&&!v.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},v.f={},v.e=e=>Promise.all(Object.keys(v.f).reduce(((r,t)=>(v.f[t](e,r),r)),[])),v.u=e=>e+".js",v.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),v.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),e={},r="@openmrs/esm-openconceptlab-app:",v.l=(t,n,o,a)=>{if(e[t])e[t].push(n);else{var i,l;if(void 0!==o)for(var s=document.getElementsByTagName("script"),p=0;p<s.length;p++){var u=s[p];if(u.getAttribute("src")==t||u.getAttribute("data-webpack")==r+o){i=u;break}}i||(l=!0,(i=document.createElement("script")).charset="utf-8",i.timeout=120,v.nc&&i.setAttribute("nonce",v.nc),i.setAttribute("data-webpack",r+o),i.src=t),e[t]=[n];var f=(r,n)=>{i.onerror=i.onload=null,clearTimeout(c);var o=e[t];if(delete e[t],i.parentNode&&i.parentNode.removeChild(i),o&&o.forEach((e=>e(n))),r)return r(n)},c=setTimeout(f.bind(null,void 0,{type:"timeout",target:i}),12e4);i.onerror=f.bind(null,i.onerror),i.onload=f.bind(null,i.onload),l&&document.head.appendChild(i)}},v.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},v.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),(()=>{v.S={};var e={},r={};v.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];v.o(v.S,t)||(v.S[t]={});var a=v.S[t],i="@openmrs/esm-openconceptlab-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","4.0.1-pre.238",(()=>Promise.all([v.e(858),v.e(268)]).then((()=>()=>v(6858))))),l("react-dom","18.2.0",(()=>Promise.all([v.e(316),v.e(268)]).then((()=>()=>v(8316))))),l("react-i18next","11.18.4",(()=>Promise.all([v.e(709),v.e(268)]).then((()=>()=>v(709))))),l("react","18.2.0",(()=>v.e(784).then((()=>()=>v(2784)))))),e[t]=s.length?Promise.all(s).then((()=>e[t]=1)):1}}})(),(()=>{var e;v.g.importScripts&&(e=v.g.location+"");var r=v.g.document;if(!e&&r&&(r.currentScript&&(e=r.currentScript.src),!e)){var t=r.getElementsByTagName("script");t.length&&(e=t[t.length-1].src)}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),v.p=e})(),t=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},n=(e,r)=>{e=t(e),r=t(r);for(var n=0;;){if(n>=e.length)return n<r.length&&"u"!=(typeof r[n])[0];var o=e[n],a=(typeof o)[0];if(n>=r.length)return"u"==a;var i=r[n],l=(typeof i)[0];if(a!=l)return"o"==a&&"n"==l||"s"==l||"u"==a;if("o"!=a&&"u"!=a&&o!=i)return o<i;n++}},o=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,a=1;a<e.length;a++)n--,t+="u"==(typeof(l=e[a]))[0]?"-":(n>0?".":"")+(n=2,l);return t}var i=[];for(a=1;a<e.length;a++){var l=e[a];i.push(0===l?"not("+s()+")":1===l?"("+s()+" || "+s()+")":2===l?i.pop()+" "+i.pop():o(l))}return s();function s(){return i.pop().replace(/^\((.+)\)$/,"$1")}},a=(e,r)=>{if(0 in e){r=t(r);var n=e[0],o=n<0;o&&(n=-n-1);for(var i=0,l=1,s=!0;;l++,i++){var p,u,f=l<e.length?(typeof e[l])[0]:"";if(i>=r.length||"o"==(u=(typeof(p=r[i]))[0]))return!s||("u"==f?l>n&&!o:""==f!=o);if("u"==u){if(!s||"u"!=f)return!1}else if(s)if(f==u)if(l<=n){if(p!=e[l])return!1}else{if(o?p>e[l]:p<e[l])return!1;p!=e[l]&&(s=!1)}else if("s"!=f&&"n"!=f){if(o||l<=n)return!1;s=!1,l--}else{if(l<=n||u<f!=o)return!1;s=!1}else"s"!=f&&"n"!=f&&(s=!1,l--)}}var c=[],d=c.pop.bind(c);for(i=1;i<e.length;i++){var h=e[i];c.push(1==h?d()|d():2==h?d()&d():h?a(h,r):!d())}return!!d()},i=(e,r)=>{var t=e[r];return Object.keys(t).reduce(((e,r)=>!e||!t[e].loaded&&n(e,r)?r:e),0)},l=(e,r,t,n)=>"Unsatisfied version "+t+" from "+(t&&e[r][t].from)+" of shared singleton module "+r+" (required "+o(n)+")",s=(e,r,t,n)=>{var o=i(e,t);return a(n,o)||"undefined"!=typeof console&&console.warn&&console.warn(l(e,t,o,n)),p(e[t][o])},p=e=>(e.loaded=1,e.get()),u=(e=>function(r,t,n,o){var a=v.I(r);return a&&a.then?a.then(e.bind(e,r,v.S[r],t,n,o)):e(0,v.S[r],t,n,o)})(((e,r,t,n,o)=>r&&v.o(r,t)?s(r,0,t,n):o())),f={},c={268:()=>u("default","react",[1,18],(()=>v.e(784).then((()=>()=>v(2784))))),906:()=>u("default","@openmrs/esm-framework",[1,4],(()=>Promise.all([v.e(858),v.e(268)]).then((()=>()=>v(6858))))),1858:()=>u("default","react-dom",[1,18],(()=>v.e(316).then((()=>()=>v(8316))))),4924:()=>u("default","react-i18next",[1,11],(()=>v.e(709).then((()=>()=>v(709)))))},d={268:[268],452:[1858,4924],862:[906]},v.f.consumes=(e,r)=>{v.o(d,e)&&d[e].forEach((e=>{if(v.o(f,e))return r.push(f[e]);var t=r=>{f[e]=0,v.m[e]=t=>{delete v.c[e],t.exports=r()}},n=r=>{delete f[e],v.m[e]=t=>{throw delete v.c[e],r}};try{var o=c[e]();o.then?r.push(f[e]=o.then(t).catch(n)):t(o)}catch(e){n(e)}}))},(()=>{var e={174:0};v.f.j=(r,t)=>{var n=v.o(e,r)?e[r]:void 0;if(0!==n)if(n)t.push(n[2]);else if(268!=r){var o=new Promise(((t,o)=>n=e[r]=[t,o]));t.push(n[2]=o);var a=v.p+v.u(r),i=new Error;v.l(a,(t=>{if(v.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)v.o(i,n)&&(v.m[n]=i[n]);l&&l(v)}for(r&&r(t);s<a.length;s++)o=a[s],v.o(e,o)&&e[o]&&e[o][0](),e[o]=0},t=self.webpackChunk_openmrs_esm_openconceptlab_app=self.webpackChunk_openmrs_esm_openconceptlab_app||[];t.forEach(r.bind(null,0)),t.push=r.bind(null,t.push.bind(t))})(),v.nc=void 0;var g=v(3203);_openmrs_esm_openconceptlab_app=g})();
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "@openmrs/esm-openconceptlab-app",
3
+ "version": "3.0.1-pre.10",
4
+ "license": "MPL-2.0",
5
+ "description": "An app to manage the openconceptlab module",
6
+ "browser": "dist/openmrs-esm-openconceptlab-app.js",
7
+ "main": "src/index.ts",
8
+ "source": true,
9
+ "scripts": {
10
+ "start": "openmrs develop",
11
+ "serve": "webpack serve --mode=development",
12
+ "build": "webpack --mode production",
13
+ "analyze": "webpack --mode=production --env.analyze=true",
14
+ "lint": "eslint src --ext js,jsx,ts,tsx",
15
+ "typescript": "tsc",
16
+ "extract-translations": "i18next 'src/**/*.component.tsx' --config ../../tools/i18next-parser.config.js"
17
+ },
18
+ "browserslist": [
19
+ "extends browserslist-config-openmrs"
20
+ ],
21
+ "keywords": [
22
+ "openmrs",
23
+ "openconceptlab",
24
+ "OCL",
25
+ "medical terminology"
26
+ ],
27
+ "repository": {
28
+ "type": "git",
29
+ "url": "git+https://github.com/openmrs/openmrs-esm-admin-tools.git"
30
+ },
31
+ "homepage": "https://github.com/openmrs/openmrs-esm-admin-tools#readme",
32
+ "publishConfig": {
33
+ "access": "public"
34
+ },
35
+ "bugs": {
36
+ "url": "https://github.com/openmrs/openmrs-esm-admin-tools/issues"
37
+ },
38
+ "dependencies": {
39
+ "@carbon/react": "^1.8.0",
40
+ "lodash-es": "^4.17.15",
41
+ "swr": "^1.3.0"
42
+ },
43
+ "peerDependencies": {
44
+ "@openmrs/esm-framework": "4.x",
45
+ "dayjs": "1.x",
46
+ "react": "18.x",
47
+ "react-dom": "18.x",
48
+ "react-i18next": "11.x",
49
+ "react-router-dom": "6.x",
50
+ "rxjs": "6.x"
51
+ },
52
+ "gitHead": "d87e746ab7f51798a6210f46716f07e0a20e5dea"
53
+ }
@@ -0,0 +1,5 @@
1
+ import { Type, validator } from '@openmrs/esm-framework';
2
+
3
+ export const configSchema = {};
4
+
5
+ export type Config = {};
@@ -0,0 +1,2 @@
1
+ declare module '*.css';
2
+ declare module '*.scss';
@@ -0,0 +1,27 @@
1
+ @use "@carbon/styles/scss/spacing";
2
+ @use "@carbon/styles/scss/type";
3
+ @import "~@openmrs/esm-styleguide/src/vars";
4
+
5
+ .grid {
6
+ margin-left: 0;
7
+ margin-right: 0;
8
+ padding-left: 0;
9
+ padding-right: 0;
10
+ }
11
+
12
+ .productiveHeading03 {
13
+ @include type.type-style('productive-heading-03');
14
+ margin-bottom: spacing.$spacing-03;
15
+ }
16
+
17
+ .form {
18
+ margin-top: spacing.$spacing-07;
19
+ }
20
+
21
+ .formText {
22
+ padding-bottom: spacing.$spacing-05;
23
+ }
24
+
25
+ .fileUploaderDropContainer {
26
+ margin-bottom: spacing.$spacing-06;
27
+ }
@@ -0,0 +1,190 @@
1
+ import { showNotification } from '@openmrs/esm-framework';
2
+ import {
3
+ Button,
4
+ ButtonSkeleton,
5
+ Column,
6
+ FileUploaderDropContainer,
7
+ FileUploaderItem,
8
+ FileUploaderSkeleton,
9
+ Form,
10
+ Grid,
11
+ SkeletonText,
12
+ } from '@carbon/react';
13
+ import React, { useCallback, useEffect, useState } from 'react';
14
+ import { useTranslation } from 'react-i18next';
15
+ import styles from './import.component.scss';
16
+ import { startImportWithFile, startImportWithSubscription, useSubscription } from './import.resource';
17
+
18
+ const Import: React.FC = () => {
19
+ const { t } = useTranslation();
20
+ const [isSubscriptionAvailable, setIsSubscriptionAvailable] = useState(false);
21
+ const [file, setFile] = useState<File>();
22
+
23
+ const { data: subscription, isLoading, isError } = useSubscription();
24
+
25
+ useEffect(() => {
26
+ if (!isLoading && !isError) {
27
+ setIsSubscriptionAvailable(!!subscription);
28
+ }
29
+ }, [isLoading, isError, subscription]);
30
+
31
+ const onAddFiles = useCallback(
32
+ (evt: React.DragEvent<HTMLInputElement>, { addedFiles }) => {
33
+ const fileToUpload: File = addedFiles[0];
34
+ if (fileToUpload.type !== 'application/zip') {
35
+ showNotification({
36
+ kind: 'error',
37
+ description: t('fileFormatError', 'Only .zip files are allowed'),
38
+ });
39
+ } else {
40
+ setFile(fileToUpload);
41
+ }
42
+ },
43
+ [t],
44
+ );
45
+
46
+ const handleFileUploaderItemClick = useCallback(() => {
47
+ setFile(null);
48
+ }, []);
49
+
50
+ const handleImportWithSubscription = useCallback(
51
+ async (evt: React.FormEvent<HTMLFormElement>) => {
52
+ evt.preventDefault();
53
+ evt.stopPropagation();
54
+
55
+ if (!isSubscriptionAvailable) {
56
+ showNotification({
57
+ kind: 'error',
58
+ description: t('noSubscriptionError', 'No saved subscription'),
59
+ });
60
+ return;
61
+ }
62
+
63
+ const abortController = new AbortController();
64
+ const response = await startImportWithSubscription(abortController);
65
+
66
+ if (response.status === 201) {
67
+ showNotification({
68
+ kind: 'success',
69
+ description: t('importSuccess', 'Import started successfully'),
70
+ });
71
+ } else {
72
+ showNotification({
73
+ kind: 'error',
74
+ description: t('importFailed', 'Import failed'),
75
+ });
76
+ }
77
+ },
78
+ [isSubscriptionAvailable, t],
79
+ );
80
+
81
+ const handleImportWithFile = useCallback(
82
+ async (evt: React.FormEvent<HTMLFormElement>) => {
83
+ evt.preventDefault();
84
+ evt.stopPropagation();
85
+
86
+ if (!file) {
87
+ showNotification({
88
+ kind: 'error',
89
+ description: t('noFileSelected', 'No file selected'),
90
+ });
91
+ return;
92
+ }
93
+
94
+ const abortController = new AbortController();
95
+ const response = await startImportWithFile(file, abortController);
96
+
97
+ if (response.status === 201) {
98
+ setFile(null);
99
+ showNotification({
100
+ kind: 'success',
101
+ description: t('importSuccess', 'Import started successfully'),
102
+ });
103
+ } else {
104
+ showNotification({
105
+ kind: 'error',
106
+ description: t('importFailed', 'Import failed'),
107
+ });
108
+ }
109
+ },
110
+ [file, t],
111
+ );
112
+
113
+ if (isLoading) {
114
+ return (
115
+ <Grid className={styles.grid}>
116
+ <Column sm={4} md={8} lg={10}>
117
+ <Form>
118
+ <SkeletonText className={styles.productiveHeading03} heading={true} />
119
+ <SkeletonText className={styles.formText} paragraph={true} lineCount={2} />
120
+ <ButtonSkeleton />
121
+ </Form>
122
+
123
+ <Form className={styles.form}>
124
+ <SkeletonText className={styles.productiveHeading03} heading={true} />
125
+ <SkeletonText className={styles.formText} />
126
+ <FileUploaderSkeleton style={{ marginBottom: '1.5rem' }} />
127
+ <ButtonSkeleton />
128
+ </Form>
129
+ </Column>
130
+ </Grid>
131
+ );
132
+ }
133
+
134
+ if (isError) {
135
+ showNotification({
136
+ kind: 'error',
137
+ description: t('subscriptionError', 'Error occured while fetching the subscription'),
138
+ });
139
+ }
140
+
141
+ return (
142
+ <Grid className={styles.grid}>
143
+ <Column sm={4} md={8} lg={10}>
144
+ <Form onSubmit={handleImportWithSubscription}>
145
+ <h3 className={styles.productiveHeading03}>{t('importConcepts', 'Import Concepts')}</h3>
146
+ <p className={styles.formText}>
147
+ {t(
148
+ 'importInstructions',
149
+ 'Avoid importing during data entry hours, because the operation may significantly slow down the system. You can either use the subscription or a zip file to import concepts.',
150
+ )}
151
+ </p>
152
+ <Button kind="primary" type="submit" disabled={!isSubscriptionAvailable}>
153
+ {t('importFromSubscription', 'Import from Subscription')}
154
+ </Button>
155
+ </Form>
156
+
157
+ <Form className={styles.form} onSubmit={handleImportWithFile}>
158
+ <h3 className={styles.productiveHeading03}>{t('importFromFileHeading', 'Import from file (Offline)')}</h3>
159
+ <p className={styles.formText}>
160
+ {t('importFromFileInfo', 'You can import data without setting up a subscription by using this option.')}
161
+ </p>
162
+ {file ? (
163
+ <FileUploaderItem
164
+ key={file.name}
165
+ name={file.name}
166
+ size="default"
167
+ status="edit"
168
+ iconDescription={t('fileAdded', 'File Added')}
169
+ onDelete={handleFileUploaderItemClick}
170
+ style={{ backgroundColor: '#e0e0e0' }}
171
+ />
172
+ ) : (
173
+ <FileUploaderDropContainer
174
+ accept={['application/zip']}
175
+ multiple
176
+ labelText={t('importFromFileDragInfo', 'Drag and drop file here or click to upload')}
177
+ onAddFiles={onAddFiles}
178
+ style={{ marginBottom: '1.5rem' }}
179
+ />
180
+ )}
181
+ <Button kind="primary" type="submit">
182
+ {t('importFromFile', 'Import from file')}
183
+ </Button>
184
+ </Form>
185
+ </Column>
186
+ </Grid>
187
+ );
188
+ };
189
+
190
+ export default Import;
@@ -0,0 +1,40 @@
1
+ import { openmrsFetch } from '@openmrs/esm-framework';
2
+ import useSWR from 'swr';
3
+ import { Import, Subscription } from '../types';
4
+
5
+ export function useSubscription() {
6
+ const { data, error, isValidating } = useSWR<{ data: { results: Subscription[] } }, Error>(
7
+ '/ws/rest/v1/openconceptlab/subscription?v=full',
8
+ openmrsFetch,
9
+ );
10
+
11
+ return {
12
+ data: data?.data?.results[0],
13
+ isLoading: !data && !error,
14
+ isError: error,
15
+ isValidating,
16
+ };
17
+ }
18
+
19
+ export async function startImportWithSubscription(abortController?: AbortController) {
20
+ const url = '/ws/rest/v1/openconceptlab/import';
21
+ return openmrsFetch<Import>(url, {
22
+ method: 'POST',
23
+ body: {},
24
+ headers: {
25
+ 'Content-Type': 'application/json',
26
+ },
27
+ signal: abortController?.signal,
28
+ });
29
+ }
30
+
31
+ export async function startImportWithFile(file: File, abortController?: AbortController) {
32
+ const url = '/ws/rest/v1/openconceptlab/import';
33
+ const formData: FormData = new FormData();
34
+ formData.append('file', file);
35
+ return openmrsFetch<Import>(url, {
36
+ method: 'POST',
37
+ body: formData,
38
+ signal: abortController?.signal,
39
+ });
40
+ }