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