@openmrs/esm-stock-management-app 3.0.1-pre.853 → 3.0.1-pre.855
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/.husky/pre-commit +1 -4
- package/__mocks__/react-i18next.js +9 -8
- package/dist/10.js +1 -1
- package/dist/10.js.map +1 -1
- package/dist/119.js +1 -1
- package/dist/119.js.map +1 -1
- package/dist/14.js +1 -1
- package/dist/14.js.map +1 -1
- package/dist/172.js +1 -1
- package/dist/172.js.map +1 -1
- package/dist/20.js +1 -1
- package/dist/20.js.map +1 -1
- package/dist/290.js +1 -1
- package/dist/290.js.map +1 -1
- package/dist/467.js +1 -1
- package/dist/467.js.map +1 -1
- package/dist/574.js +1 -1
- package/dist/606.js +1 -1
- package/dist/606.js.map +1 -1
- package/dist/627.js +1 -0
- package/dist/627.js.map +1 -0
- package/dist/642.js +1 -1
- package/dist/642.js.map +1 -1
- package/dist/675.js +1 -1
- package/dist/675.js.map +1 -1
- package/dist/727.js +1 -1
- package/dist/727.js.map +1 -1
- package/dist/842.js +1 -1
- package/dist/842.js.map +1 -1
- package/dist/93.js +1 -1
- package/dist/93.js.map +1 -1
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/openmrs-esm-stock-management-app.js.buildmanifest.json +70 -70
- package/dist/routes.json +1 -1
- package/jest.config.js +3 -6
- package/package.json +1 -1
- package/src/core/components/table/table.component.tsx +2 -2
- package/src/index.ts +5 -5
- package/src/stock-items/add-bulk-stock-item/add-stock-items-bulk-import-action-button.component.tsx +3 -3
- package/src/stock-items/add-bulk-stock-item/{stock-items-bulk-import.modal.tsx → stock-items-bulk-import.component.tsx} +19 -20
- package/src/stock-items/add-bulk-stock-item/stock-items-bulk-import.resource.ts +1 -1
- package/src/stock-items/add-bulk-stock-item/stock-items-bulk-import.test.tsx +59 -59
- package/src/stock-items/add-stock-item/add-stock-action-button.component.tsx +6 -6
- package/src/stock-items/add-stock-item/add-stock-item.component.tsx +4 -6
- package/src/stock-items/add-stock-item/add-stock-item.scss +0 -5
- package/src/stock-items/add-stock-item/add-stock-item.test.tsx +43 -28
- package/src/stock-items/add-stock-item/packaging-units/packaging-units-delete-modal.component.tsx +4 -3
- package/src/stock-items/add-stock-item/packaging-units/packaging-units.component.tsx +10 -9
- package/src/stock-items/add-stock-item/packaging-units/packaging-units.scss +4 -4
- package/src/stock-items/add-stock-item/stock-item-details/stock-item-details.component.tsx +19 -27
- package/src/stock-items/add-stock-item/stock-item-references/stock-item-references.scss +4 -4
- package/src/stock-items/add-stock-item/stock-item-rules/add-stock-rules.component.tsx +9 -15
- package/src/stock-items/add-stock-item/stock-item-rules/add-stock-rules.scss +0 -1
- package/src/stock-items/add-stock-item/stock-item-rules/delete-stock-rule-modal.component.tsx +1 -2
- package/src/stock-items/add-stock-item/stock-item-rules/stock-item-rules.component.tsx +16 -14
- package/src/stock-items/add-stock-item/stock-item-rules/stock-item-rules.scss +3 -7
- package/src/stock-items/add-stock-item/transactions/printout/transactions-print-bincard-preview.modal.tsx +6 -14
- package/src/stock-items/add-stock-item/transactions/printout/transactions-print-stockcard-preview.modal.tsx +8 -14
- package/src/stock-items/edit-stock-item/edit-stock-item-action-menu.component.tsx +2 -2
- package/src/stock-items/stock-item.utils.tsx +5 -3
- package/src/stock-items/stock-items-table.component.tsx +45 -47
- package/src/stock-items/stock-items-table.resource.ts +2 -2
- package/src/stock-items/stock-items-table.scss +1 -5
- package/src/stock-items/stock-items-table.test.tsx +65 -106
- package/src/stock-locations/location-admin-form.component.tsx +4 -5
- package/src/stock-locations/stock-locations-table.component.tsx +8 -10
- package/src/stock-lookups/stock-lookups.resource.ts +2 -3
- package/src/stock-operations/stock-operations-dialog/stock-operations-dialog.component.tsx +2 -2
- package/src/stock-operations/stock-operations-forms/input-components/batch-no-selector.component.tsx +11 -11
- package/src/stock-operations/stock-operations-forms/input-components/batch-no-selector.test.tsx +25 -115
- package/src/stock-operations/stock-operations-forms/input-components/qty-uim-selector.test.tsx +65 -107
- package/src/stock-operations/stock-operations-forms/input-components/quantity-uom-selector.component.tsx +9 -9
- package/src/stock-operations/stock-operations-forms/input-components/stock-operation-reason-selector.test.tsx +153 -35
- package/src/stock-operations/stock-operations-forms/input-components/user-selector.test.tsx +29 -82
- package/src/stock-operations/stock-operations-forms/step1.test.tsx +69 -204
- package/src/stock-operations/stock-operations-forms/step2.test.tsx +63 -140
- package/src/stock-operations/stock-operations-forms/step3.test.tsx +60 -79
- package/src/stock-operations/stock-operations-forms/steps/stock-operation-items-form-step.component.tsx +5 -6
- package/src/stock-operations/stock-operations-forms/steps/stock-operation-submission-form-step.component.tsx +11 -12
- package/src/stock-operations/stock-operations-forms/stock-item-form/stock-item-form.scss +0 -1
- package/src/stock-operations/stock-operations-forms/stock-item-form/stock-item-form.workspace.tsx +12 -20
- package/src/stock-operations/stock-operations-forms/stock-operation-form.scss +0 -1
- package/src/stock-operations/stock-operations-forms/stock-operation-stepper/stepper.scss +3 -1
- package/src/stock-operations/stock-operations-forms/stock-operation-stepper/stock-operation-stepper.component.tsx +1 -2
- package/src/stock-reports/generate-report/create-stock-report.scss +2 -3
- package/src/stock-reports/generate-report/create-stock-report.workspace.tsx +25 -32
- package/src/stock-reports/report-list/stock-report-parameters.component.tsx +1 -1
- package/src/stock-reports/report-list/stock-report-status.component.tsx +1 -1
- package/src/stock-reports/report-list/stock-reports.component.tsx +25 -24
- package/src/stock-reports/report-list/stock-reports.scss +2 -10
- package/src/stock-sources/add-stock-sources/add-stock-sources.scss +4 -11
- package/src/stock-sources/add-stock-sources/add-stock-sources.test.tsx +36 -38
- package/src/stock-sources/add-stock-sources/add-stock-sources.workspace.tsx +30 -35
- package/src/stock-sources/delete-stock-modal.component.tsx +1 -2
- package/src/stock-sources/stock-sources-delete/stock-sources-delete.test.tsx +36 -27
- package/src/stock-sources/stock-sources-filter/stock-sources-filter.component.tsx +21 -33
- package/src/stock-sources/stock-sources-items-table.component.tsx +17 -16
- package/src/stock-sources/stock-sources-items-table.resource.ts +6 -8
- package/src/stock-sources/stock-sources-items-table.test.tsx +37 -60
- package/src/stock-sources/stock-sources.scss +2 -6
- package/src/stock-user-role-scopes/add-stock-user-scope/add-stock-user-role-scope.scss +13 -5
- package/src/stock-user-role-scopes/add-stock-user-scope/add-stock-user-role-scope.workspace.tsx +2 -2
- package/src/stock-user-role-scopes/delete-stock-user-scope-modal.component.tsx +1 -2
- package/translations/en.json +6 -5
- package/tsconfig.json +0 -4
- package/dist/33.js +0 -1
- package/dist/33.js.map +0 -1
@@ -1,22 +1,20 @@
|
|
1
|
+
import { Button, Form, Select, TextInput, SelectItem, ButtonSet } from '@carbon/react';
|
1
2
|
import React, { type ChangeEvent, useCallback, useState } from 'react';
|
2
|
-
import
|
3
|
-
import {
|
4
|
-
import {
|
5
|
-
import {
|
3
|
+
import styles from './add-stock-sources.scss';
|
4
|
+
import { useConcept } from '../../stock-lookups/stock-lookups.resource';
|
5
|
+
import { type StockSource } from '../../core/api/types/stockOperation/StockSource';
|
6
|
+
import { createOrUpdateStockSource } from '../stock-sources.resource';
|
6
7
|
import {
|
7
|
-
|
8
|
+
type DefaultWorkspaceProps,
|
8
9
|
restBaseUrl,
|
9
10
|
showSnackbar,
|
10
|
-
type DefaultWorkspaceProps,
|
11
11
|
useConfig,
|
12
|
-
|
12
|
+
getCoreTranslation,
|
13
13
|
} from '@openmrs/esm-framework';
|
14
|
-
import {
|
15
|
-
import { type StockSource } from '../../core/api/types/stockOperation/StockSource';
|
16
|
-
import { createOrUpdateStockSource } from '../stock-sources.resource';
|
14
|
+
import { useTranslation } from 'react-i18next';
|
17
15
|
import { type ConfigObject } from '../../config-schema';
|
18
16
|
import { handleMutate } from '../../utils';
|
19
|
-
import
|
17
|
+
import { Save } from '@carbon/react/icons';
|
20
18
|
|
21
19
|
type AddStockSourceProps = DefaultWorkspaceProps & {
|
22
20
|
model?: StockSource;
|
@@ -24,7 +22,6 @@ type AddStockSourceProps = DefaultWorkspaceProps & {
|
|
24
22
|
|
25
23
|
const StockSourcesAddOrUpdate: React.FC<AddStockSourceProps> = ({ model, closeWorkspace }) => {
|
26
24
|
const { t } = useTranslation();
|
27
|
-
const isTablet = useLayoutType() === 'tablet';
|
28
25
|
const { stockSourceTypeUUID } = useConfig<ConfigObject>();
|
29
26
|
|
30
27
|
// get stock sources
|
@@ -50,11 +47,9 @@ const StockSourcesAddOrUpdate: React.FC<AddStockSourceProps> = ({ model, closeWo
|
|
50
47
|
const handleSave = useCallback(
|
51
48
|
(event) => {
|
52
49
|
event.preventDefault();
|
53
|
-
|
54
50
|
if (model) {
|
55
51
|
formModel.uuid = model.uuid;
|
56
52
|
}
|
57
|
-
|
58
53
|
createOrUpdateStockSource(formModel)
|
59
54
|
.then(
|
60
55
|
() => {
|
@@ -87,51 +82,51 @@ const StockSourcesAddOrUpdate: React.FC<AddStockSourceProps> = ({ model, closeWo
|
|
87
82
|
return (
|
88
83
|
<div className={styles.formContainer}>
|
89
84
|
<div className={styles.body}>
|
90
|
-
<
|
85
|
+
<section className={styles.section}>
|
91
86
|
<TextInput
|
92
87
|
id="fullname"
|
93
|
-
labelText={t('fullName', 'Full name')}
|
94
|
-
onChange={onNameChanged}
|
95
|
-
placeholder="e.g National Medical Stores"
|
96
|
-
size="md"
|
97
88
|
type="text"
|
89
|
+
labelText={t('fullName', 'Full Name')}
|
90
|
+
size="md"
|
91
|
+
onChange={onNameChanged}
|
98
92
|
value={model?.name}
|
93
|
+
placeholder="e.g National Medical Stores"
|
99
94
|
/>
|
95
|
+
</section>
|
96
|
+
<section className={styles.section}>
|
100
97
|
<TextInput
|
101
98
|
id="acronym"
|
102
|
-
labelText={t('acronymOrCode', 'Acronym/Code')}
|
103
|
-
onChange={onAcronymChanged}
|
104
|
-
placeholder="e.g NMS"
|
105
|
-
size="md"
|
106
99
|
type="text"
|
100
|
+
size="md"
|
101
|
+
placeholder="e.g NMS"
|
102
|
+
onChange={onAcronymChanged}
|
107
103
|
value={model?.acronym}
|
104
|
+
labelText={t('acronym', 'Acronym/Code')}
|
108
105
|
/>
|
106
|
+
</section>
|
107
|
+
<section className={styles.section}>
|
109
108
|
<Select
|
109
|
+
name="sourceType"
|
110
110
|
className="select-field"
|
111
|
-
id="sourceType"
|
112
111
|
labelText={t('sourceType', 'Source Type')}
|
113
|
-
|
114
|
-
onChange={onSourceTypeChange}
|
112
|
+
id="sourceType"
|
115
113
|
value={formModel?.sourceType ? formModel.sourceType.uuid : ''}
|
114
|
+
onChange={onSourceTypeChange}
|
116
115
|
>
|
117
116
|
<SelectItem disabled hidden value="" text={t('chooseSourceType', 'Choose a source type')} />
|
118
117
|
{items?.answers?.map((sourceType) => (
|
119
118
|
<SelectItem key={sourceType.uuid} value={sourceType.uuid} text={sourceType.display} />
|
120
119
|
))}
|
121
120
|
</Select>
|
122
|
-
</
|
121
|
+
</section>
|
123
122
|
</div>
|
124
|
-
|
125
|
-
|
126
|
-
[styles.tablet]: isTablet,
|
127
|
-
[styles.desktop]: !isTablet,
|
128
|
-
})}
|
129
|
-
>
|
123
|
+
|
124
|
+
<ButtonSet className={styles.buttonSet}>
|
130
125
|
<Button kind="secondary" onClick={closeWorkspace} className={styles.button}>
|
131
|
-
{getCoreTranslation('cancel')}
|
126
|
+
{getCoreTranslation('cancel', 'Cancel')}
|
132
127
|
</Button>
|
133
128
|
<Button type="submit" className={styles.button} onClick={handleSave} kind="primary" renderIcon={Save}>
|
134
|
-
{getCoreTranslation('save')}
|
129
|
+
{getCoreTranslation('save', 'Save')}
|
135
130
|
</Button>
|
136
131
|
</ButtonSet>
|
137
132
|
</div>
|
@@ -1,7 +1,6 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import { useTranslation } from 'react-i18next';
|
3
3
|
import { Button, ModalHeader, ModalBody, ModalFooter } from '@carbon/react';
|
4
|
-
import { getCoreTranslation } from '@openmrs/esm-framework';
|
5
4
|
import styles from './delete-stock-modal.scss';
|
6
5
|
|
7
6
|
interface DeleteConfirmationProps {
|
@@ -29,7 +28,7 @@ const DeleteConfirmation: React.FC<DeleteConfirmationProps> = ({ close, onConfir
|
|
29
28
|
</ModalBody>
|
30
29
|
<ModalFooter>
|
31
30
|
<Button size="lg" kind="secondary" onClick={handleCancel}>
|
32
|
-
{
|
31
|
+
{t('cancel', 'Cancel')}
|
33
32
|
</Button>
|
34
33
|
<Button autoFocus kind="danger" onClick={handleDelete} size="lg">
|
35
34
|
{t('delete', 'Delete')}
|
@@ -1,16 +1,24 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import userEvent from '@testing-library/user-event';
|
3
3
|
import { render, screen } from '@testing-library/react';
|
4
|
-
import
|
4
|
+
import '@testing-library/jest-dom/extend-expect';
|
5
|
+
import { showModal, showSnackbar } from '@openmrs/esm-framework';
|
5
6
|
import { deleteStockSource } from '../stock-sources.resource';
|
6
|
-
import { handleMutate } from '../../utils';
|
7
|
-
import DeleteConfirmation from '../../stock-user-role-scopes/delete-stock-user-scope-modal.component';
|
8
7
|
import StockSourcesDeleteActionMenu from './stock-sources-delete.component';
|
8
|
+
import DeleteConfirmation from '../../stock-user-role-scopes/delete-stock-user-scope-modal.component';
|
9
|
+
import { handleMutate } from '../../utils';
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
jest.mock('react-i18next', () => ({
|
12
|
+
useTranslation: () => ({
|
13
|
+
t: (key) => key,
|
14
|
+
}),
|
15
|
+
}));
|
16
|
+
|
17
|
+
jest.mock('@openmrs/esm-framework', () => ({
|
18
|
+
showModal: jest.fn(),
|
19
|
+
showSnackbar: jest.fn(),
|
20
|
+
restBaseUrl: 'http://localhost:8080',
|
21
|
+
}));
|
14
22
|
|
15
23
|
jest.mock('../stock-sources.resource', () => ({
|
16
24
|
deleteStockSource: jest.fn(),
|
@@ -26,8 +34,7 @@ describe('StockSourcesDeleteActionMenu', () => {
|
|
26
34
|
|
27
35
|
it('renders the delete button correctly', () => {
|
28
36
|
render(<StockSourcesDeleteActionMenu uuid={uuid} />);
|
29
|
-
|
30
|
-
const button = screen.getByRole('button', { name: /delete source/i });
|
37
|
+
const button = screen.getByRole('button', { name: 'deleteSource' });
|
31
38
|
expect(button).toBeInTheDocument();
|
32
39
|
});
|
33
40
|
|
@@ -35,10 +42,9 @@ describe('StockSourcesDeleteActionMenu', () => {
|
|
35
42
|
const user = userEvent.setup();
|
36
43
|
render(<StockSourcesDeleteActionMenu uuid={uuid} />);
|
37
44
|
|
38
|
-
const button = screen.getByRole('button', { name:
|
45
|
+
const button = screen.getByRole('button', { name: 'deleteSource' });
|
39
46
|
await user.click(button);
|
40
|
-
|
41
|
-
expect(mockShowModal).toHaveBeenCalledWith(
|
47
|
+
expect(showModal).toHaveBeenCalledWith(
|
42
48
|
'delete-stock-modal',
|
43
49
|
expect.objectContaining({
|
44
50
|
close: expect.any(Function),
|
@@ -55,9 +61,9 @@ describe('StockSourcesDeleteActionMenu', () => {
|
|
55
61
|
|
56
62
|
render(<DeleteConfirmation close={mockClose} onConfirmation={mockOnConfirmation} />);
|
57
63
|
|
58
|
-
expect(screen.getByText(/
|
64
|
+
expect(screen.getByText(/deleteStockUserScope/i)).toBeInTheDocument();
|
59
65
|
|
60
|
-
const deleteButton = screen.getByRole('button', { name: /
|
66
|
+
const deleteButton = screen.getByRole('button', { name: /delete/i });
|
61
67
|
await user.click(deleteButton);
|
62
68
|
|
63
69
|
expect(mockOnConfirmation).toHaveBeenCalledTimes(1);
|
@@ -79,7 +85,7 @@ describe('StockSourcesDeleteActionMenu', () => {
|
|
79
85
|
/>,
|
80
86
|
);
|
81
87
|
|
82
|
-
const deleteButton = screen.getByRole('button', { name: /
|
88
|
+
const deleteButton = screen.getByRole('button', { name: /delete/i });
|
83
89
|
await user.click(deleteButton);
|
84
90
|
|
85
91
|
expect(mockOnConfirmation).toHaveBeenCalledTimes(1);
|
@@ -88,7 +94,7 @@ describe('StockSourcesDeleteActionMenu', () => {
|
|
88
94
|
|
89
95
|
it('calls handleMutate with the correct URL on successful deletion', async () => {
|
90
96
|
const user = userEvent.setup();
|
91
|
-
|
97
|
+
(deleteStockSource as jest.Mock).mockResolvedValueOnce({});
|
92
98
|
|
93
99
|
const mockOnConfirmation = jest.fn();
|
94
100
|
const mockClose = jest.fn();
|
@@ -103,17 +109,18 @@ describe('StockSourcesDeleteActionMenu', () => {
|
|
103
109
|
/>,
|
104
110
|
);
|
105
111
|
|
106
|
-
const deleteButton = screen.getByRole('button', { name: /
|
112
|
+
const deleteButton = screen.getByRole('button', { name: /delete/i });
|
107
113
|
await user.click(deleteButton);
|
108
114
|
|
109
|
-
expect(
|
110
|
-
expect(
|
115
|
+
expect(deleteStockSource).toHaveBeenCalledWith([uuid]);
|
116
|
+
expect(handleMutate).toHaveBeenCalledWith('/openmrs/ws/rest/v1/stocksource');
|
111
117
|
});
|
112
118
|
|
113
119
|
it('calls showSnackbar with the correct parameters on deletion error', async () => {
|
114
120
|
const user = userEvent.setup();
|
115
|
-
|
121
|
+
(deleteStockSource as jest.Mock).mockRejectedValueOnce(new Error('Deletion failed'));
|
116
122
|
|
123
|
+
const mockOnConfirmation = jest.fn();
|
117
124
|
const mockClose = jest.fn();
|
118
125
|
|
119
126
|
render(
|
@@ -132,11 +139,11 @@ describe('StockSourcesDeleteActionMenu', () => {
|
|
132
139
|
/>,
|
133
140
|
);
|
134
141
|
|
135
|
-
const deleteButton = screen.getByRole('button', { name: /
|
142
|
+
const deleteButton = screen.getByRole('button', { name: /delete/i });
|
136
143
|
await user.click(deleteButton);
|
137
144
|
|
138
|
-
expect(
|
139
|
-
expect(
|
145
|
+
expect(deleteStockSource).toHaveBeenCalledWith([uuid]);
|
146
|
+
expect(showSnackbar).toHaveBeenCalledWith({
|
140
147
|
title: 'stockSourceDeleteError',
|
141
148
|
kind: 'error',
|
142
149
|
});
|
@@ -144,8 +151,9 @@ describe('StockSourcesDeleteActionMenu', () => {
|
|
144
151
|
|
145
152
|
it('handles the error state correctly when the delete action fails', async () => {
|
146
153
|
const user = userEvent.setup();
|
147
|
-
|
154
|
+
(deleteStockSource as jest.Mock).mockRejectedValueOnce(new Error('Deletion failed'));
|
148
155
|
|
156
|
+
const mockOnConfirmation = jest.fn();
|
149
157
|
const mockClose = jest.fn();
|
150
158
|
|
151
159
|
render(
|
@@ -164,11 +172,12 @@ describe('StockSourcesDeleteActionMenu', () => {
|
|
164
172
|
/>,
|
165
173
|
);
|
166
174
|
|
167
|
-
const deleteButton = screen.getByRole('button', { name: /
|
175
|
+
const deleteButton = screen.getByRole('button', { name: /delete/i });
|
168
176
|
await user.click(deleteButton);
|
169
177
|
|
170
|
-
expect(
|
171
|
-
|
178
|
+
expect(deleteStockSource).toHaveBeenCalledWith([uuid]);
|
179
|
+
|
180
|
+
expect(showSnackbar).toHaveBeenCalledWith({
|
172
181
|
title: 'stockSourceDeleteError',
|
173
182
|
kind: 'error',
|
174
183
|
});
|
@@ -1,46 +1,34 @@
|
|
1
|
-
import
|
1
|
+
import styles from './stock-sources-filter.scss';
|
2
2
|
import { Dropdown, DropdownSkeleton } from '@carbon/react';
|
3
|
-
import
|
4
|
-
import { type ConfigObject } from '../../config-schema';
|
3
|
+
import React from 'react';
|
5
4
|
import { useConcept } from '../../stock-lookups/stock-lookups.resource';
|
6
|
-
import
|
5
|
+
import { type ConfigObject } from '../../config-schema';
|
6
|
+
import { useConfig } from '@openmrs/esm-framework';
|
7
7
|
|
8
8
|
const StockSourcesFilter: React.FC<{
|
9
9
|
onFilterChange: (selectedSourceType: string) => void;
|
10
10
|
}> = ({ onFilterChange }) => {
|
11
11
|
const { stockSourceTypeUUID } = useConfig<ConfigObject>();
|
12
|
-
|
12
|
+
// get stock sources
|
13
13
|
const { items, isLoading, error } = useConcept(stockSourceTypeUUID);
|
14
|
-
|
15
|
-
|
16
|
-
return <DropdownSkeleton size="sm" />;
|
17
|
-
}
|
18
|
-
|
19
|
-
if (error) {
|
20
|
-
showSnackbar({
|
21
|
-
title: 'Error fetching stock sources',
|
22
|
-
kind: 'error',
|
23
|
-
isLowContrast: true,
|
24
|
-
});
|
14
|
+
if (isLoading || error) {
|
15
|
+
return <DropdownSkeleton />;
|
25
16
|
}
|
26
|
-
|
27
|
-
if (!items) {
|
28
|
-
return null;
|
29
|
-
}
|
30
|
-
|
31
17
|
return (
|
32
|
-
|
33
|
-
<
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
18
|
+
<>
|
19
|
+
<div className={styles.filterContainer}>
|
20
|
+
<Dropdown
|
21
|
+
id="stockSourcesFiter"
|
22
|
+
items={[...items.answers]}
|
23
|
+
initialSelectedItem={items.answers[0]}
|
24
|
+
itemToString={(item) => (item ? item.display : 'Not Set')}
|
25
|
+
titleText="Filter: "
|
26
|
+
type="inline"
|
27
|
+
size="sm"
|
28
|
+
onChange={({ selectedItem }) => onFilterChange(selectedItem?.display)}
|
29
|
+
/>
|
30
|
+
</div>
|
31
|
+
</>
|
44
32
|
);
|
45
33
|
};
|
46
34
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import React, { useMemo } from 'react';
|
2
2
|
import {
|
3
|
+
TabPanel,
|
3
4
|
DataTable,
|
4
|
-
DataTableSkeleton,
|
5
5
|
Pagination,
|
6
6
|
Table,
|
7
7
|
TableBody,
|
@@ -11,23 +11,23 @@ import {
|
|
11
11
|
TableHeader,
|
12
12
|
TableRow,
|
13
13
|
TableToolbar,
|
14
|
-
TableToolbarAction,
|
15
14
|
TableToolbarContent,
|
16
|
-
TableToolbarMenu,
|
17
|
-
TableToolbarSearch,
|
18
|
-
TabPanel,
|
19
15
|
Tile,
|
16
|
+
DataTableSkeleton,
|
17
|
+
TableToolbarSearch,
|
18
|
+
TableToolbarMenu,
|
19
|
+
TableToolbarAction,
|
20
20
|
} from '@carbon/react';
|
21
|
-
import { useTranslation } from 'react-i18next';
|
22
21
|
import { isDesktop, restBaseUrl } from '@openmrs/esm-framework';
|
23
|
-
import { handleMutate } from '../utils';
|
24
|
-
import { ResourceRepresentation } from '../core/api/api';
|
25
22
|
import useStockSourcesPage from './stock-sources-items-table.resource';
|
23
|
+
import { ResourceRepresentation } from '../core/api/api';
|
26
24
|
import AddStockSourceActionButton from './add-stock-source-button.component';
|
27
|
-
import EditStockSourceActionsMenu from './edit-stock-source/edit-stock-source.component';
|
28
|
-
import StockSourcesDeleteActionMenu from './stock-sources-delete/stock-sources-delete.component';
|
29
25
|
import StockSourcesFilter from './stock-sources-filter/stock-sources-filter.component';
|
30
26
|
import styles from './stock-sources.scss';
|
27
|
+
import { useTranslation } from 'react-i18next';
|
28
|
+
import StockSourcesDeleteActionMenu from './stock-sources-delete/stock-sources-delete.component';
|
29
|
+
import EditStockSourceActionsMenu from './edit-stock-source/edit-stock-source.component';
|
30
|
+
import { handleMutate } from '../utils';
|
31
31
|
|
32
32
|
const StockSourcesItems: React.FC = () => {
|
33
33
|
const { t } = useTranslation();
|
@@ -81,12 +81,15 @@ const StockSourcesItems: React.FC = () => {
|
|
81
81
|
return (
|
82
82
|
<div className={styles.tableOverride}>
|
83
83
|
<TabPanel>{t('panelDescription', 'List of partners who provide stock to the facility.')}</TabPanel>
|
84
|
-
|
84
|
+
<div id="table-tool-bar">
|
85
|
+
<div></div>
|
86
|
+
<div className="right-filters"></div>
|
87
|
+
</div>
|
85
88
|
<DataTable
|
86
89
|
rows={filteredTableRows}
|
87
90
|
headers={tableHeaders}
|
88
|
-
isSortable
|
89
|
-
useZebraStyles
|
91
|
+
isSortable={true}
|
92
|
+
useZebraStyles={true}
|
90
93
|
render={({ rows, headers, getHeaderProps, getTableProps, getRowProps, onInputChange }) => (
|
91
94
|
<TableContainer>
|
92
95
|
<TableToolbar
|
@@ -107,9 +110,7 @@ const StockSourcesItems: React.FC = () => {
|
|
107
110
|
<StockSourcesFilter onFilterChange={handleFilterChange} />
|
108
111
|
</div>
|
109
112
|
<TableToolbarMenu>
|
110
|
-
<TableToolbarAction
|
111
|
-
{t('refresh', 'Refresh')}
|
112
|
-
</TableToolbarAction>
|
113
|
+
<TableToolbarAction onClick={handleRefresh}>Refresh</TableToolbarAction>
|
113
114
|
</TableToolbarMenu>
|
114
115
|
|
115
116
|
<AddStockSourceActionButton />
|
@@ -1,11 +1,9 @@
|
|
1
|
+
import { useStockSources } from './stock-sources.resource';
|
1
2
|
import { useMemo, useState } from 'react';
|
2
|
-
import { useTranslation } from 'react-i18next';
|
3
3
|
import { usePagination } from '@openmrs/esm-framework';
|
4
|
-
import { useStockSources } from './stock-sources.resource';
|
5
4
|
import { type StockOperationFilter } from '../stock-operations/stock-operations.resource';
|
6
5
|
|
7
6
|
export default function useStockSourcesPage(filter: StockOperationFilter) {
|
8
|
-
const { t } = useTranslation();
|
9
7
|
const { items, isLoading, error } = useStockSources(filter);
|
10
8
|
|
11
9
|
const pageSizes = [10, 20, 30, 40, 50];
|
@@ -16,26 +14,26 @@ export default function useStockSourcesPage(filter: StockOperationFilter) {
|
|
16
14
|
() => [
|
17
15
|
{
|
18
16
|
id: 1,
|
19
|
-
header:
|
17
|
+
header: 'Name',
|
20
18
|
key: 'name',
|
21
19
|
},
|
22
20
|
{
|
23
21
|
id: 2,
|
24
|
-
header:
|
22
|
+
header: 'Acronym',
|
25
23
|
key: 'acronym',
|
26
24
|
},
|
27
25
|
{
|
28
26
|
id: 3,
|
29
|
-
header:
|
27
|
+
header: 'Source Type',
|
30
28
|
key: 'sourceType',
|
31
29
|
},
|
32
30
|
{
|
33
31
|
id: 4,
|
34
|
-
header:
|
32
|
+
header: 'actions',
|
35
33
|
key: 'actions',
|
36
34
|
},
|
37
35
|
],
|
38
|
-
[
|
36
|
+
[],
|
39
37
|
);
|
40
38
|
|
41
39
|
return {
|