@openmrs/esm-stock-management-app 1.0.1-pre.489 → 1.0.1-pre.491

Sign up to get free protection for your applications and to get access to all the features.
@@ -85,10 +85,10 @@
85
85
  "initial": true,
86
86
  "entry": true,
87
87
  "recorded": false,
88
- "size": 5389111,
88
+ "size": 5392001,
89
89
  "sizes": {
90
90
  "consume-shared": 252,
91
- "javascript": 5367161,
91
+ "javascript": 5370051,
92
92
  "share-init": 252,
93
93
  "runtime": 21446
94
94
  },
@@ -105,7 +105,7 @@
105
105
  "auxiliaryFiles": [
106
106
  "main.js.map"
107
107
  ],
108
- "hash": "b5f7a57f4ae4fe98",
108
+ "hash": "52b48e58a757b55c",
109
109
  "childrenByOrder": {}
110
110
  },
111
111
  {
@@ -273,9 +273,9 @@
273
273
  "initial": false,
274
274
  "entry": false,
275
275
  "recorded": false,
276
- "size": 1720684,
276
+ "size": 1723574,
277
277
  "sizes": {
278
- "javascript": 1720474,
278
+ "javascript": 1723364,
279
279
  "consume-shared": 210
280
280
  },
281
281
  "names": [],
@@ -289,7 +289,7 @@
289
289
  "auxiliaryFiles": [
290
290
  "647.js.map"
291
291
  ],
292
- "hash": "95af224be149a64e",
292
+ "hash": "7121aa7f458a52da",
293
293
  "childrenByOrder": {}
294
294
  },
295
295
  {
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-nav-menu","slot":"stock-sidebar-slot","component":"stockNavMenu","online":true,"offline":true},{"name":"overview-db-link","slot":"stock-page-dashboard-slot","component":"stockOverviewLink","meta":{"name":"overview","slot":"overview-dashboard-slot","title":"overview"},"order":0,"online":true,"offline":true},{"name":"stock-overview-db","slot":"overview-dashboard-slot","component":"stockOverview"},{"name":"operations-db-link","slot":"stock-page-dashboard-slot","component":"stockOperationsLink","meta":{"name":"operations","slot":"operations-dashboard-slot","title":"operations"},"order":2,"online":true,"offline":true},{"name":"stock-operations-db","slot":"operations-dashboard-slot","component":"stockOperations"},{"name":"items-db-link","slot":"stock-page-dashboard-slot","component":"stockItemsLink","meta":{"name":"items","slot":"items-dashboard-slot","title":"items"},"order":1,"online":true,"offline":true},{"name":"stock-items-db","slot":"items-dashboard-slot","component":"stockItems"},{"name":"user-scopes-db-link","slot":"stock-page-dashboard-slot","component":"stockUserScopesLink","meta":{"name":"user-scopes","slot":"user-scopes-dashboard-slot","title":"user-scopes"},"order":3,"online":true,"offline":true},{"name":"stock-user-scopes-db","slot":"user-scopes-dashboard-slot","component":"stockUserScopes"},{"name":"sources-db-link","slot":"stock-page-dashboard-slot","component":"stockSourcesLink","meta":{"name":"sources","slot":"sources-dashboard-slot","title":"Sources"},"order":2,"online":true,"offline":true},{"name":"stock-sources-db","slot":"sources-dashboard-slot","component":"stockSources"},{"name":"locations-db-link","slot":"stock-page-dashboard-slot","component":"stockLocationsLink","meta":{"name":"locations","slot":"locations-dashboard-slot","title":"Locations"},"order":4,"online":true,"offline":true},{"name":"stock-locations-db","slot":"locations-dashboard-slot","component":"stockLocations"},{"name":"reports-db-link","slot":"stock-page-dashboard-slot","component":"stockReportsLink","meta":{"name":"reports","slot":"reports-dashboard-slot","title":"Reports"},"order":5,"online":true,"offline":true},{"name":"stock-reports-db","slot":"reports-dashboard-slot","component":"stockReports"},{"name":"settings-db-link","slot":"stock-page-dashboard-slot","component":"stockSettingsLink","meta":{"name":"settings","slot":"settings-dashboard-slot","title":"Settings"},"order":6,"online":true,"offline":true},{"name":"stock-settings-db","slot":"settings-dashboard-slot","component":"stockSettings"},{"name":"stock-management-admin-card-link","slot":"system-admin-page-card-link-slot","component":"stockManagementAdminCardLink"},{"name":"stock-operation-dialog","component":"stockOperationDialog"},{"name":"import-bulk-stock-items","component":"importBulkStockItemsDialog"},{"name":"delete-stock-modal","component":"deleteStockModal"},{"name":"delete-stock-user-scope-modal","component":"deleteUserScopeModal"},{"name":"stock-management-app-menu-item","component":"stockManagementAppMenuItem","slot":"app-menu-item-slot","meta":{"name":" Stock Management"}},{"name":"delete-stock-rule-modal","component":"deleteStockRuleModal"},{"name":"delete-packaging-unit-modal","component":"deletePackagingUnitModal"},{"name":"delete-packaging-unit-button","component":"deletePackagingUnitButton"}],"pages":[{"component":"root","route":"stock-management"}],"version":"1.0.1-pre.489"}
1
+ {"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"fhir2":">=1.2","webservices.rest":"^2.24.0"},"extensions":[{"name":"stock-nav-menu","slot":"stock-sidebar-slot","component":"stockNavMenu","online":true,"offline":true},{"name":"overview-db-link","slot":"stock-page-dashboard-slot","component":"stockOverviewLink","meta":{"name":"overview","slot":"overview-dashboard-slot","title":"overview"},"order":0,"online":true,"offline":true},{"name":"stock-overview-db","slot":"overview-dashboard-slot","component":"stockOverview"},{"name":"operations-db-link","slot":"stock-page-dashboard-slot","component":"stockOperationsLink","meta":{"name":"operations","slot":"operations-dashboard-slot","title":"operations"},"order":2,"online":true,"offline":true},{"name":"stock-operations-db","slot":"operations-dashboard-slot","component":"stockOperations"},{"name":"items-db-link","slot":"stock-page-dashboard-slot","component":"stockItemsLink","meta":{"name":"items","slot":"items-dashboard-slot","title":"items"},"order":1,"online":true,"offline":true},{"name":"stock-items-db","slot":"items-dashboard-slot","component":"stockItems"},{"name":"user-scopes-db-link","slot":"stock-page-dashboard-slot","component":"stockUserScopesLink","meta":{"name":"user-scopes","slot":"user-scopes-dashboard-slot","title":"user-scopes"},"order":3,"online":true,"offline":true},{"name":"stock-user-scopes-db","slot":"user-scopes-dashboard-slot","component":"stockUserScopes"},{"name":"sources-db-link","slot":"stock-page-dashboard-slot","component":"stockSourcesLink","meta":{"name":"sources","slot":"sources-dashboard-slot","title":"Sources"},"order":2,"online":true,"offline":true},{"name":"stock-sources-db","slot":"sources-dashboard-slot","component":"stockSources"},{"name":"locations-db-link","slot":"stock-page-dashboard-slot","component":"stockLocationsLink","meta":{"name":"locations","slot":"locations-dashboard-slot","title":"Locations"},"order":4,"online":true,"offline":true},{"name":"stock-locations-db","slot":"locations-dashboard-slot","component":"stockLocations"},{"name":"reports-db-link","slot":"stock-page-dashboard-slot","component":"stockReportsLink","meta":{"name":"reports","slot":"reports-dashboard-slot","title":"Reports"},"order":5,"online":true,"offline":true},{"name":"stock-reports-db","slot":"reports-dashboard-slot","component":"stockReports"},{"name":"settings-db-link","slot":"stock-page-dashboard-slot","component":"stockSettingsLink","meta":{"name":"settings","slot":"settings-dashboard-slot","title":"Settings"},"order":6,"online":true,"offline":true},{"name":"stock-settings-db","slot":"settings-dashboard-slot","component":"stockSettings"},{"name":"stock-management-admin-card-link","slot":"system-admin-page-card-link-slot","component":"stockManagementAdminCardLink"},{"name":"stock-operation-dialog","component":"stockOperationDialog"},{"name":"import-bulk-stock-items","component":"importBulkStockItemsDialog"},{"name":"delete-stock-modal","component":"deleteStockModal"},{"name":"delete-stock-user-scope-modal","component":"deleteUserScopeModal"},{"name":"stock-management-app-menu-item","component":"stockManagementAppMenuItem","slot":"app-menu-item-slot","meta":{"name":" Stock Management"}},{"name":"delete-stock-rule-modal","component":"deleteStockRuleModal"},{"name":"delete-packaging-unit-modal","component":"deletePackagingUnitModal"},{"name":"delete-packaging-unit-button","component":"deletePackagingUnitButton"}],"pages":[{"component":"root","route":"stock-management"}],"version":"1.0.1-pre.491"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openmrs/esm-stock-management-app",
3
- "version": "1.0.1-pre.489",
3
+ "version": "1.0.1-pre.491",
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",
@@ -194,7 +194,10 @@ const StockItemsAdditionRow: React.FC<StockItemsAdditionRowProps> = ({
194
194
  <BatchNoSelector
195
195
  batchUuid={row?.stockBatchUuid}
196
196
  onBatchNoChanged={(item) => {
197
- setValue(`stockItems.${index}.batchNo`, item?.batchNo);
197
+ setValue(
198
+ `stockItems.${index}.batchNo`,
199
+ item?.batchNo ?? ""
200
+ );
198
201
  setValue(
199
202
  `stockItems.${index}.expiration`,
200
203
  item?.expiration
@@ -207,6 +210,7 @@ const StockItemsAdditionRow: React.FC<StockItemsAdditionRowProps> = ({
207
210
  controllerName={`stockItems.${index}.stockBatchUuid`}
208
211
  name={`stockItems.${index}.stockBatchUuid`}
209
212
  stockItemUuid={row.stockItemUuid}
213
+ selectedItem={stockItemUuid}
210
214
  />
211
215
  )}
212
216
  {!(
@@ -1,10 +1,10 @@
1
- import React, { ReactNode, useEffect, useMemo } from "react";
1
+ import React, { ReactNode, useEffect, useMemo, useState } from "react";
2
2
  import { Control, Controller, FieldValues } from "react-hook-form";
3
3
  import { ComboBox, InlineLoading } from "@carbon/react";
4
4
  import { useStockItemBatchNos } from "./batch-no-selector.resource";
5
5
  import { StockBatchDTO } from "../../core/api/types/stockItem/StockBatchDTO";
6
6
  import { useStockItemBatchInformationHook } from "../../stock-items/add-stock-item/batch-information/batch-information.resource";
7
- import { ResourceRepresentation } from "../../core/api/api";
7
+ import { useTranslation } from "react-i18next";
8
8
 
9
9
  interface BatchNoSelectorProps<T> {
10
10
  placeholder?: string;
@@ -14,6 +14,7 @@ interface BatchNoSelectorProps<T> {
14
14
  title?: string;
15
15
  invalid?: boolean;
16
16
  invalidText?: ReactNode;
17
+ selectedItem?: string;
17
18
 
18
19
  // Control
19
20
  controllerName: string;
@@ -25,6 +26,12 @@ const BatchNoSelector = <T,>(props: BatchNoSelectorProps<T>) => {
25
26
  const { isLoading, stockItemBatchNos } = useStockItemBatchNos(
26
27
  props.stockItemUuid
27
28
  );
29
+ const [validationMessage, setValidationMessage] = useState<string | null>(
30
+ null
31
+ );
32
+ const [selectedItem, setSelectedItem] = useState<StockBatchDTO | null>(null);
33
+ const { t } = useTranslation();
34
+
28
35
  const initialSelectedItem = useMemo(
29
36
  () =>
30
37
  stockItemBatchNos?.find(
@@ -52,23 +59,31 @@ const BatchNoSelector = <T,>(props: BatchNoSelectorProps<T>) => {
52
59
  return item;
53
60
  });
54
61
 
62
+ useEffect(() => {
63
+ if (
64
+ !isLoading &&
65
+ stockItemBatchNos &&
66
+ props.selectedItem &&
67
+ stockItemBatchNos.length === 0
68
+ ) {
69
+ setValidationMessage(
70
+ "No stock batch numbers defined. Do a initial/receipt stock operation first."
71
+ );
72
+ } else {
73
+ setValidationMessage(null);
74
+ }
75
+ }, [isLoading, stockItemBatchNos, props.selectedItem]);
76
+
55
77
  if (isLoading) return <InlineLoading status="active" />;
56
78
 
57
79
  return (
58
- <div
59
- style={{
60
- display: "flex",
61
- flexDirection: "row",
62
- }}
63
- >
80
+ <div style={{ display: "flex", flexDirection: "column" }}>
64
81
  <Controller
65
82
  name={props.controllerName}
66
83
  control={props.control}
67
84
  render={({ field: { onChange, ref } }) => (
68
85
  <ComboBox
69
- style={{
70
- flexGrow: "1",
71
- }}
86
+ style={{ flexGrow: "1" }}
72
87
  titleText={props.title}
73
88
  name={props.name}
74
89
  control={props.control}
@@ -77,6 +92,7 @@ const BatchNoSelector = <T,>(props: BatchNoSelectorProps<T>) => {
77
92
  size={"sm"}
78
93
  items={stockItemBatchesInfo || []}
79
94
  onChange={(data: { selectedItem?: StockBatchDTO }) => {
95
+ setSelectedItem(data.selectedItem || null);
80
96
  props.onBatchNoChanged?.(data.selectedItem);
81
97
  onChange(data.selectedItem?.uuid);
82
98
  }}
@@ -92,6 +108,11 @@ const BatchNoSelector = <T,>(props: BatchNoSelectorProps<T>) => {
92
108
  )}
93
109
  />
94
110
  {isLoading && <InlineLoading status="active" />}
111
+ {validationMessage && (
112
+ <div style={{ color: "red", marginTop: "8px" }}>
113
+ {t(validationMessage)}
114
+ </div>
115
+ )}
95
116
  </div>
96
117
  );
97
118
  };