@openmrs/esm-stock-management-app 1.0.1-pre.377 → 1.0.1-pre.380

Sign up to get free protection for your applications and to get access to all the features.
@@ -59,9 +59,9 @@
59
59
  "initial": false,
60
60
  "entry": false,
61
61
  "recorded": false,
62
- "size": 1024662,
62
+ "size": 1027049,
63
63
  "sizes": {
64
- "javascript": 1024452,
64
+ "javascript": 1026839,
65
65
  "consume-shared": 210
66
66
  },
67
67
  "names": [],
@@ -75,7 +75,7 @@
75
75
  "auxiliaryFiles": [
76
76
  "56.js.map"
77
77
  ],
78
- "hash": "4ee3259f79d57dc5",
78
+ "hash": "3e1478879e180635",
79
79
  "childrenByOrder": {}
80
80
  },
81
81
  {
@@ -110,10 +110,10 @@
110
110
  "initial": true,
111
111
  "entry": true,
112
112
  "recorded": false,
113
- "size": 4773711,
113
+ "size": 4776098,
114
114
  "sizes": {
115
115
  "consume-shared": 252,
116
- "javascript": 4751763,
116
+ "javascript": 4754150,
117
117
  "share-init": 252,
118
118
  "runtime": 21444
119
119
  },
@@ -130,7 +130,7 @@
130
130
  "auxiliaryFiles": [
131
131
  "main.js.map"
132
132
  ],
133
- "hash": "b5fe33bc3d4cadc9",
133
+ "hash": "7d2a0b9a180a3088",
134
134
  "childrenByOrder": {}
135
135
  },
136
136
  {
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.377"}
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.380"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openmrs/esm-stock-management-app",
3
- "version": "1.0.1-pre.377",
3
+ "version": "1.0.1-pre.380",
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",
@@ -20,7 +20,7 @@ import {
20
20
  } from "@carbon/react";
21
21
  import { Edit } from "@carbon/react/icons";
22
22
  import { isDesktop } from "@openmrs/esm-framework";
23
- import React, { useMemo } from "react";
23
+ import React, { useMemo, useState, useEffect } from "react";
24
24
  import { useTranslation } from "react-i18next";
25
25
  import { ResourceRepresentation } from "../core/api/api";
26
26
  import AddStockItemActionButton from "./add-stock-item/add-stock-action-button.component";
@@ -30,6 +30,7 @@ import { useStockItemsPages } from "./stock-items-table.resource";
30
30
  import styles from "./stock-items-table.scss";
31
31
  import AddStockItemsBulktImportActionButton from "./add-bulk-stock-item/add-stock-items-bulk-import-action-button.component";
32
32
  import EditStockItemActionsMenu from "./edit-stock-item/edit-stock-item-action-menu.component";
33
+ import { useDebounce } from "../core/hooks/debounce-hook";
33
34
 
34
35
  interface StockItemsTableProps {
35
36
  from?: string;
@@ -37,6 +38,7 @@ interface StockItemsTableProps {
37
38
 
38
39
  const StockItemsTableComponent: React.FC<StockItemsTableProps> = () => {
39
40
  const { t } = useTranslation();
41
+ const [searchInput, setSearchInput] = useState("");
40
42
 
41
43
  const {
42
44
  isLoading,
@@ -48,8 +50,21 @@ const StockItemsTableComponent: React.FC<StockItemsTableProps> = () => {
48
50
  setCurrentPage,
49
51
  isDrug,
50
52
  setDrug,
53
+ setSearchString,
51
54
  } = useStockItemsPages(ResourceRepresentation.Full);
52
55
 
56
+ const handleSearch = (query: string) => {
57
+ setSearchInput(query);
58
+ };
59
+
60
+ const debouncedSearch = useDebounce((query: string) => {
61
+ setSearchString(query);
62
+ }, 1000);
63
+
64
+ useEffect(() => {
65
+ debouncedSearch(searchInput);
66
+ }, [searchInput, debouncedSearch]);
67
+
53
68
  const tableHeaders = useMemo(
54
69
  () => [
55
70
  {
@@ -158,7 +173,6 @@ const StockItemsTableComponent: React.FC<StockItemsTableProps> = () => {
158
173
  getTableProps,
159
174
  getRowProps,
160
175
  getBatchActionProps,
161
- onInputChange,
162
176
  }) => (
163
177
  <TableContainer>
164
178
  <TableToolbar
@@ -175,7 +189,12 @@ const StockItemsTableComponent: React.FC<StockItemsTableProps> = () => {
175
189
  alignItems: "center",
176
190
  }}
177
191
  >
178
- <TableToolbarSearch persistent onChange={onInputChange} />
192
+ <TableToolbarSearch
193
+ persistent
194
+ value={searchInput}
195
+ onChange={(e) => handleSearch(e.target.value)}
196
+ />
197
+
179
198
  <FilterStockItems
180
199
  filterType={isDrug}
181
200
  changeFilterType={setDrug}