@openmrs/esm-stock-management-app 1.0.1-pre.334 → 1.0.1-pre.336

Sign up to get free protection for your applications and to get access to all the features.
@@ -112,10 +112,10 @@
112
112
  "initial": true,
113
113
  "entry": true,
114
114
  "recorded": false,
115
- "size": 4355568,
115
+ "size": 4353955,
116
116
  "sizes": {
117
117
  "consume-shared": 252,
118
- "javascript": 4333620,
118
+ "javascript": 4332007,
119
119
  "share-init": 252,
120
120
  "runtime": 21444
121
121
  },
@@ -132,7 +132,7 @@
132
132
  "auxiliaryFiles": [
133
133
  "main.js.map"
134
134
  ],
135
- "hash": "4421563f3b87f2aa",
135
+ "hash": "4a8146752fae697f",
136
136
  "childrenByOrder": {}
137
137
  },
138
138
  {
@@ -140,9 +140,9 @@
140
140
  "initial": false,
141
141
  "entry": false,
142
142
  "recorded": false,
143
- "size": 918771,
143
+ "size": 917158,
144
144
  "sizes": {
145
- "javascript": 918561,
145
+ "javascript": 916948,
146
146
  "consume-shared": 210
147
147
  },
148
148
  "names": [],
@@ -156,7 +156,7 @@
156
156
  "auxiliaryFiles": [
157
157
  "220.js.map"
158
158
  ],
159
- "hash": "71dd66264f583d31",
159
+ "hash": "56ec62cd710fb270",
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.2.0","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.334"}
1
+ {"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"fhir2":"^1.2.0","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.336"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openmrs/esm-stock-management-app",
3
- "version": "1.0.1-pre.334",
3
+ "version": "1.0.1-pre.336",
4
4
  "license": "MPL-2.0",
5
5
  "description": "Stock management microfrontend for OpenMRS 3.x",
6
6
  "browser": "dist/openmrs-esm-stock-management-app.js",
@@ -18,7 +18,7 @@ const StockHomeReceivingCard = () => {
18
18
 
19
19
  if (isLoading) return <></>;
20
20
 
21
- if (items.length === 0) {
21
+ if (items?.length === 0) {
22
22
  return (
23
23
  <>
24
24
  <p className={styles.content}>
@@ -1,7 +1,7 @@
1
- import React, { ReactNode, useState } from "react";
1
+ import React, { ReactNode, useMemo, useState } from "react";
2
2
  import { Control, Controller, FieldValues } from "react-hook-form";
3
3
  import { StockItemPackagingUOMDTO } from "../../../core/api/types/stockItem/StockItemPackagingUOM";
4
- import { Select, SelectItem, SelectSkeleton } from "@carbon/react";
4
+ import { ComboBox, SelectSkeleton } from "@carbon/react";
5
5
 
6
6
  interface DispensingPackageMeasurementProps<T> {
7
7
  dispensingUnitPackagingUoMUuid?: string;
@@ -24,52 +24,48 @@ interface DispensingPackageMeasurementProps<T> {
24
24
  const DispensingPackageMeasurement = <T,>(
25
25
  props: DispensingPackageMeasurementProps<T>
26
26
  ) => {
27
- const [item, setItem] = useState("");
27
+ const initialSelectedItem = useMemo<StockItemPackagingUOMDTO | null>(
28
+ () => (props?.packagingUnits.length > 0 ? props?.packagingUnits[0] : null),
29
+ [props?.packagingUnits]
30
+ );
28
31
 
29
32
  if (props.isLoading) return <SelectSkeleton />;
30
33
 
31
- if (!(props.packagingUnits && props.packagingUnits.length > 0)) return <></>;
34
+ if (!(props?.packagingUnits && props?.packagingUnits.length > 0))
35
+ return <></>;
32
36
  return (
33
- <Controller
34
- name={props.controllerName}
35
- control={props.control}
36
- render={({ field: { onChange, value, ref } }) => (
37
- <Select
38
- labelText={props.title}
39
- name={props.name}
40
- control={props.control}
41
- controllerName={props.controllerName}
42
- id={props.name}
43
- size={"md"}
44
- onChange={(data: { selectedItem?: StockItemPackagingUOMDTO }) => {
45
- props.onDispensingUnitPackagingUoMUuidChange?.(data?.selectedItem);
46
- onChange(data?.selectedItem?.uuid);
47
- setItem(data?.selectedItem?.uuid);
48
- }}
49
- ref={ref}
50
- value={item}
51
- invalid={props.invalid}
52
- invalidText={props.invalidText}
53
- >
54
- {!item ? (
55
- <SelectItem disabled hidden value={null} text={props.placeholder} />
56
- ) : (
57
- ""
58
- )}
59
- {props.packagingUnits?.map((uom, index) => {
60
- return (
61
- <SelectItem
62
- key={`${index}-${uom.uuid}`}
63
- value={uom.uuid}
64
- text={uom.packagingUomName}
65
- >
66
- {uom?.packagingUomName}
67
- </SelectItem>
68
- );
69
- })}
70
- </Select>
71
- )}
72
- />
37
+ <div>
38
+ <Controller
39
+ name={props.controllerName}
40
+ control={props.control}
41
+ defaultValue={initialSelectedItem.uuid ?? ""}
42
+ render={({ field: { onChange, ref } }) => (
43
+ <ComboBox
44
+ titleText={props.title}
45
+ name={props.name}
46
+ control={props.control}
47
+ controllerName={props.controllerName}
48
+ id={props.name}
49
+ size={"sm"}
50
+ items={props.packagingUnits ?? []}
51
+ onChange={(data: { selectedItem?: StockItemPackagingUOMDTO }) => {
52
+ props.onDispensingUnitPackagingUoMUuidChange?.(
53
+ data?.selectedItem
54
+ );
55
+ onChange(data?.selectedItem?.uuid);
56
+ }}
57
+ initialSelectedItem={initialSelectedItem}
58
+ itemToString={(s: StockItemPackagingUOMDTO) =>
59
+ s.packagingUomName ?? ""
60
+ }
61
+ placeholder={props.placeholder}
62
+ invalid={props.invalid}
63
+ invalidText={props.invalidText}
64
+ ref={ref}
65
+ />
66
+ )}
67
+ />
68
+ </div>
73
69
  );
74
70
  };
75
71