@openmrs/esm-stock-management-app 3.0.1-pre.818 → 3.0.1-pre.826
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.
- package/dist/10.js +1 -0
- package/dist/10.js.map +1 -0
- package/dist/165.js +1 -1
- package/dist/165.js.map +1 -1
- package/dist/20.js +1 -1
- package/dist/20.js.map +1 -1
- package/dist/642.js +1 -0
- package/dist/642.js.map +1 -0
- package/dist/675.js +1 -0
- package/dist/675.js.map +1 -0
- package/dist/{880.js → 727.js} +1 -1
- package/dist/727.js.map +1 -0
- package/dist/780.js +1 -0
- package/dist/780.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 +129 -56
- package/dist/openmrs-esm-stock-management-app.js.map +1 -1
- package/dist/routes.json +1 -1
- package/package.json +1 -1
- package/src/index.ts +8 -0
- package/src/routes.json +14 -0
- package/src/stock-items/add-stock-item/add-stock-action-button.component.tsx +2 -3
- package/src/stock-items/add-stock-item/add-stock-item.component.tsx +29 -20
- package/src/stock-items/add-stock-item/add-stock-item.scss +22 -3
- package/src/stock-items/add-stock-item/add-stock-item.test.tsx +11 -11
- package/src/stock-items/add-stock-item/packaging-units/packaging-units.component.tsx +9 -10
- package/src/stock-items/add-stock-item/packaging-units/packaging-units.resource.tsx +1 -1
- package/src/stock-items/add-stock-item/stock-item-details/stock-item-details.component.tsx +226 -214
- package/src/stock-items/add-stock-item/stock-item-details/stock-item-details.resource.tsx +7 -2
- package/src/stock-items/add-stock-item/stock-item-rules/add-stock-rule-button.component.tsx +6 -4
- package/src/stock-items/add-stock-item/stock-item-rules/add-stock-rules.component.tsx +162 -166
- package/src/stock-items/add-stock-item/stock-item-rules/add-stock-rules.scss +19 -11
- package/src/stock-items/add-stock-item/stock-item-rules/edit-stock-rule.component.tsx +8 -5
- package/src/stock-items/edit-stock-item/edit-stock-item-action-menu.component.tsx +2 -2
- package/src/stock-items/stock-item.utils.tsx +7 -50
- package/src/stock-items/stock-items-table.component.tsx +2 -2
- package/src/stock-items/stock-items-table.test.tsx +28 -23
- package/src/stock-items/stock-items.resource.ts +7 -5
- package/src/stock-operations/stock-operations-forms/stock-operation-stepper/stock-operation-stepper.component.tsx +1 -0
- package/dist/600.js +0 -1
- package/dist/600.js.map +0 -1
- package/dist/880.js.map +0 -1
@@ -4,7 +4,7 @@ import userEvent from '@testing-library/user-event';
|
|
4
4
|
import StockItemsTableComponent from './stock-items-table.component';
|
5
5
|
import { useStockItemsPages } from './stock-items-table.resource';
|
6
6
|
import { handleMutate } from '../utils';
|
7
|
-
import {
|
7
|
+
import { launchAddOrStockItemWorkspace } from './stock-item.utils';
|
8
8
|
|
9
9
|
jest.mock('./stock-items-table.resource', () => ({
|
10
10
|
useStockItemsPages: jest.fn(),
|
@@ -15,7 +15,7 @@ jest.mock('../utils', () => ({
|
|
15
15
|
}));
|
16
16
|
|
17
17
|
jest.mock('./stock-item.utils', () => ({
|
18
|
-
|
18
|
+
launchAddOrStockItemWorkspace: jest.fn(),
|
19
19
|
}));
|
20
20
|
|
21
21
|
jest.mock('react-i18next', () => ({
|
@@ -27,16 +27,18 @@ jest.mock('react-i18next', () => ({
|
|
27
27
|
describe('StockItemsTableComponent', () => {
|
28
28
|
const mockUseStockItemsPages = {
|
29
29
|
isLoading: false,
|
30
|
-
items: Array(25)
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
30
|
+
items: Array(25)
|
31
|
+
.fill(null)
|
32
|
+
.map((_, index) => ({
|
33
|
+
uuid: `item-${index}`,
|
34
|
+
commonName: `Test Item ${index}`,
|
35
|
+
drugUuid: index % 2 === 0 ? `drug-${index}` : null,
|
36
|
+
conceptName: `Concept ${index}`,
|
37
|
+
dispensingUnitName: `Unit ${index}`,
|
38
|
+
defaultStockOperationsUoMName: `UoM ${index}`,
|
39
|
+
reorderLevel: index * 10,
|
40
|
+
reorderLevelUoMName: 'Units',
|
41
|
+
})),
|
40
42
|
totalCount: 25,
|
41
43
|
currentPageSize: 10,
|
42
44
|
setPageSize: jest.fn(),
|
@@ -57,13 +59,13 @@ describe('StockItemsTableComponent', () => {
|
|
57
59
|
render(<StockItemsTableComponent />);
|
58
60
|
expect(screen.getByText('panelDescription')).toBeInTheDocument();
|
59
61
|
expect(screen.getByRole('searchbox')).toBeInTheDocument();
|
60
|
-
|
62
|
+
|
61
63
|
const user = userEvent.setup();
|
62
64
|
const menuButton = screen.getByTestId('stock-items-menu');
|
63
65
|
await user.click(menuButton);
|
64
|
-
|
66
|
+
|
65
67
|
await screen.findByText('Refresh');
|
66
|
-
|
68
|
+
|
67
69
|
expect(screen.getByText('type')).toBeInTheDocument();
|
68
70
|
expect(screen.getByText('genericName')).toBeInTheDocument();
|
69
71
|
expect(screen.getByText('commonName')).toBeInTheDocument();
|
@@ -87,9 +89,12 @@ describe('StockItemsTableComponent', () => {
|
|
87
89
|
const user = userEvent.setup();
|
88
90
|
const searchInput = screen.getByRole('searchbox');
|
89
91
|
await user.type(searchInput, 'test search');
|
90
|
-
await waitFor(
|
91
|
-
|
92
|
-
|
92
|
+
await waitFor(
|
93
|
+
() => {
|
94
|
+
expect(mockUseStockItemsPages.setSearchString).toHaveBeenCalledWith('test search');
|
95
|
+
},
|
96
|
+
{ timeout: 2000 },
|
97
|
+
);
|
93
98
|
});
|
94
99
|
|
95
100
|
it('updates pagination when page or page size changes', async () => {
|
@@ -106,12 +111,12 @@ describe('StockItemsTableComponent', () => {
|
|
106
111
|
|
107
112
|
it('triggers handleRefresh when refresh button is clicked', async () => {
|
108
113
|
render(<StockItemsTableComponent />);
|
109
|
-
|
114
|
+
|
110
115
|
const user = userEvent.setup();
|
111
116
|
const menuButton = screen.getByTestId('stock-items-menu');
|
112
117
|
expect(menuButton).toBeInTheDocument();
|
113
118
|
await user.click(menuButton);
|
114
|
-
|
119
|
+
|
115
120
|
const refreshButton = await screen.findByText('Refresh');
|
116
121
|
expect(refreshButton).toBeInTheDocument();
|
117
122
|
await user.click(refreshButton);
|
@@ -125,10 +130,10 @@ describe('StockItemsTableComponent', () => {
|
|
125
130
|
const user = userEvent.setup();
|
126
131
|
const editButtons = screen.getAllByLabelText('Edit Stock Item');
|
127
132
|
await user.click(editButtons[0]);
|
128
|
-
|
133
|
+
|
134
|
+
expect(launchAddOrStockItemWorkspace).toHaveBeenCalledWith(
|
129
135
|
expect.any(Function),
|
130
136
|
expect.objectContaining({ uuid: 'item-0' }),
|
131
|
-
true
|
132
137
|
);
|
133
138
|
});
|
134
|
-
});
|
139
|
+
});
|
@@ -10,6 +10,8 @@ import { type StockItemReference, type StockItemReferenceDTO } from '../core/api
|
|
10
10
|
import { type StockItemTransactionDTO } from '../core/api/types/stockItem/StockItemTransaction';
|
11
11
|
import { type StockRule } from '../core/api/types/stockItem/StockRule';
|
12
12
|
import { type StockOperationItemCost } from '../core/api/types/stockOperation/StockOperationItemCost';
|
13
|
+
import { z } from 'zod';
|
14
|
+
import { stockItemDetailsSchema, type StockItemFormData } from './validationSchema';
|
13
15
|
|
14
16
|
export interface StockItemFilter extends ResourceFilterCriteria {
|
15
17
|
isDrug?: string | null | undefined;
|
@@ -227,11 +229,11 @@ export function deleteStockItemPackagingUnit(id: string) {
|
|
227
229
|
}
|
228
230
|
|
229
231
|
// createStockItem
|
230
|
-
export function createStockItem(item:
|
232
|
+
export function createStockItem(item: StockItemFormData) {
|
231
233
|
const apiUrl = `${restBaseUrl}/stockmanagement/stockitem`;
|
232
234
|
const abortController = new AbortController();
|
233
235
|
delete item.isDrug;
|
234
|
-
return openmrsFetch(apiUrl, {
|
236
|
+
return openmrsFetch<StockItemDTO>(apiUrl, {
|
235
237
|
method: 'POST',
|
236
238
|
headers: {
|
237
239
|
'Content-Type': 'application/json',
|
@@ -242,12 +244,12 @@ export function createStockItem(item: StockItemDTO) {
|
|
242
244
|
}
|
243
245
|
|
244
246
|
// updateStockItem
|
245
|
-
export function updateStockItem(item:
|
246
|
-
const apiUrl = `${restBaseUrl}/stockmanagement/stockitem/${
|
247
|
+
export function updateStockItem(stockItemUuid: string, item: StockItemFormData) {
|
248
|
+
const apiUrl = `${restBaseUrl}/stockmanagement/stockitem/${stockItemUuid}`;
|
247
249
|
const abortController = new AbortController();
|
248
250
|
delete item.isDrug;
|
249
251
|
delete item.dateCreated;
|
250
|
-
return openmrsFetch(apiUrl, {
|
252
|
+
return openmrsFetch<StockItemDTO>(apiUrl, {
|
251
253
|
method: 'POST',
|
252
254
|
headers: {
|
253
255
|
'Content-Type': 'application/json',
|
@@ -35,6 +35,7 @@ const StockOperationStepper: React.FC<StockOperationStepperProps> = ({
|
|
35
35
|
className={`${styles.stepperItem} ${active ? styles.stepperItemActive : ''}`}
|
36
36
|
key={index}
|
37
37
|
onClick={!disabled ? () => onChange?.(index) : undefined}
|
38
|
+
aria-disabled={disabled}
|
38
39
|
>
|
39
40
|
<p className={styles.title}>{title}</p>
|
40
41
|
</li>
|