@openmrs/esm-stock-management-app 1.0.1-pre.473 → 1.0.1-pre.475
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/474.js +1 -1
- package/dist/474.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 +6 -6
- package/dist/routes.json +1 -1
- package/package.json +1 -1
- package/src/core/utils/alert.ts +4 -4
- package/src/stock-items/add-bulk-stock-item/stock-items-bulk-import.component.tsx +9 -17
- package/src/stock-items/add-stock-item/packaging-units/packaging-units-delete-modal.component.tsx +7 -7
- package/src/stock-items/add-stock-item/stock-item-references/stock-item-references.component.tsx +3 -14
- package/src/stock-items/add-stock-item/stock-item-rules/add-stock-rules.component.tsx +11 -22
- package/src/stock-items/add-stock-item/stock-item-rules/stock-rules-delete.component.tsx +7 -7
- package/src/stock-items/stock-item.utils.tsx +7 -13
- package/src/stock-locations/add-locations-form.component.tsx +7 -7
- package/src/stock-locations/stock-locations-table.resource.tsx +11 -14
- package/src/stock-operations/add-stock-operation/add-stock-operation.component.tsx +1 -6
- package/src/stock-operations/stock-operation.utils.tsx +7 -8
- package/src/stock-sources/add-stock-sources/add-stock-sources.component.tsx +8 -12
- package/src/stock-sources/stock-sources-delete/stock-sources-delete.component.tsx +7 -12
- package/src/stock-user-role-scopes/add-stock-user-scope/add-stock-user-role-scope.component.tsx +20 -73
- package/src/stock-user-role-scopes/delete-stock-user-scope/delete-stock-user-scope.component.tsx +7 -12
- package/src/utils.ts +4 -4
@@ -86,10 +86,10 @@
|
|
86
86
|
"initial": true,
|
87
87
|
"entry": true,
|
88
88
|
"recorded": false,
|
89
|
-
"size":
|
89
|
+
"size": 4767329,
|
90
90
|
"sizes": {
|
91
91
|
"consume-shared": 252,
|
92
|
-
"javascript":
|
92
|
+
"javascript": 4745380,
|
93
93
|
"share-init": 252,
|
94
94
|
"runtime": 21445
|
95
95
|
},
|
@@ -106,7 +106,7 @@
|
|
106
106
|
"auxiliaryFiles": [
|
107
107
|
"main.js.map"
|
108
108
|
],
|
109
|
-
"hash": "
|
109
|
+
"hash": "2dd0d0b605a58141",
|
110
110
|
"childrenByOrder": {}
|
111
111
|
},
|
112
112
|
{
|
@@ -138,9 +138,9 @@
|
|
138
138
|
"initial": false,
|
139
139
|
"entry": false,
|
140
140
|
"recorded": false,
|
141
|
-
"size":
|
141
|
+
"size": 1095617,
|
142
142
|
"sizes": {
|
143
|
-
"javascript":
|
143
|
+
"javascript": 1095407,
|
144
144
|
"consume-shared": 210
|
145
145
|
},
|
146
146
|
"names": [],
|
@@ -154,7 +154,7 @@
|
|
154
154
|
"auxiliaryFiles": [
|
155
155
|
"474.js.map"
|
156
156
|
],
|
157
|
-
"hash": "
|
157
|
+
"hash": "d3138f8f9dbb47a0",
|
158
158
|
"childrenByOrder": {}
|
159
159
|
},
|
160
160
|
{
|
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.
|
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.475"}
|
package/package.json
CHANGED
package/src/core/utils/alert.ts
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
import {
|
1
|
+
import { showSnackbar } from "@openmrs/esm-framework";
|
2
2
|
|
3
3
|
export function errorAlert(title: string, msg: string) {
|
4
|
-
|
5
|
-
|
4
|
+
showSnackbar({
|
5
|
+
isLowContrast: true,
|
6
6
|
title: title,
|
7
7
|
kind: "error",
|
8
|
-
|
8
|
+
subtitle: msg,
|
9
9
|
});
|
10
10
|
}
|
@@ -9,7 +9,7 @@ import {
|
|
9
9
|
FileUploader,
|
10
10
|
} from "@carbon/react";
|
11
11
|
import { UploadStockItems } from "./stock-items-bulk-import.resource";
|
12
|
-
import {
|
12
|
+
import { showSnackbar } from "@openmrs/esm-framework";
|
13
13
|
|
14
14
|
export interface ImportDialogPopupProps {
|
15
15
|
closeModal: () => void;
|
@@ -20,8 +20,6 @@ const ImportDialogPopup: React.FC<ImportDialogPopupProps> = ({
|
|
20
20
|
}) => {
|
21
21
|
const { t } = useTranslation();
|
22
22
|
const [selectedFile, setSelectedFile] = useState<any>();
|
23
|
-
const [hasHeader, setHasHeader] = useState(true);
|
24
|
-
const [fileNotSelected, setFileNotSelected] = useState(true);
|
25
23
|
|
26
24
|
const onConfirmUpload = () => {
|
27
25
|
if (!selectedFile) {
|
@@ -30,15 +28,15 @@ const ImportDialogPopup: React.FC<ImportDialogPopupProps> = ({
|
|
30
28
|
const formData = new FormData();
|
31
29
|
if (selectedFile) {
|
32
30
|
formData.append("file", selectedFile, "Import_Stock_Items.csv");
|
33
|
-
formData.append("hasHeader",
|
31
|
+
formData.append("hasHeader", "true");
|
34
32
|
}
|
35
33
|
UploadStockItems(formData).then(
|
36
|
-
(
|
37
|
-
|
38
|
-
|
34
|
+
() => {
|
35
|
+
showSnackbar({
|
36
|
+
isLowContrast: true,
|
39
37
|
title: t("rejectOrder", "Uploaded Order"),
|
40
38
|
kind: "success",
|
41
|
-
|
39
|
+
subtitle: t(
|
42
40
|
"Successfully uploaded",
|
43
41
|
`You have successfully uploaded stock items`
|
44
42
|
),
|
@@ -46,13 +44,13 @@ const ImportDialogPopup: React.FC<ImportDialogPopupProps> = ({
|
|
46
44
|
closeModal();
|
47
45
|
},
|
48
46
|
(err) => {
|
49
|
-
|
47
|
+
showSnackbar({
|
50
48
|
title: t(
|
51
49
|
`errorUploadingItems', 'An error occurred uploading stock items`
|
52
50
|
),
|
53
51
|
kind: "error",
|
54
|
-
|
55
|
-
|
52
|
+
isLowContrast: true,
|
53
|
+
subtitle: err?.message,
|
56
54
|
});
|
57
55
|
}
|
58
56
|
);
|
@@ -62,16 +60,11 @@ const ImportDialogPopup: React.FC<ImportDialogPopupProps> = ({
|
|
62
60
|
const file = event?.target?.files?.[0];
|
63
61
|
if (file) {
|
64
62
|
setSelectedFile(file);
|
65
|
-
setFileNotSelected(false);
|
66
63
|
} else {
|
67
64
|
event.preventDefault();
|
68
65
|
}
|
69
66
|
};
|
70
67
|
|
71
|
-
const onFileDeleted = () => {
|
72
|
-
setFileNotSelected(true);
|
73
|
-
};
|
74
|
-
|
75
68
|
return (
|
76
69
|
<div>
|
77
70
|
<Form>
|
@@ -90,7 +83,6 @@ const ImportDialogPopup: React.FC<ImportDialogPopupProps> = ({
|
|
90
83
|
labelTitle=""
|
91
84
|
size="small"
|
92
85
|
onChange={onFileChanged}
|
93
|
-
onDelete={onFileDeleted}
|
94
86
|
/>
|
95
87
|
</ModalBody>
|
96
88
|
<ModalFooter>
|
package/src/stock-items/add-stock-item/packaging-units/packaging-units-delete-modal.component.tsx
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import React, { useState, useEffect } from "react";
|
2
|
-
import {
|
2
|
+
import { showSnackbar } from "@openmrs/esm-framework";
|
3
3
|
import {
|
4
4
|
Button,
|
5
5
|
ModalHeader,
|
@@ -42,25 +42,25 @@ const DeletePackagingUnit: React.FC<DeletePackagingUnitProps> = ({
|
|
42
42
|
() => {
|
43
43
|
mutate();
|
44
44
|
closeModal();
|
45
|
-
|
46
|
-
|
45
|
+
showSnackbar({
|
46
|
+
isLowContrast: true,
|
47
47
|
title: t("deletePackagingUnitTitle", `Delete packing item `),
|
48
48
|
kind: "success",
|
49
|
-
|
49
|
+
subtitle: t(
|
50
50
|
"deletePackagingUnitMesaage",
|
51
51
|
`Stock Item packing unit deleted Successfully`
|
52
52
|
),
|
53
53
|
});
|
54
54
|
},
|
55
55
|
(error) => {
|
56
|
-
|
56
|
+
showSnackbar({
|
57
57
|
title: t(
|
58
58
|
"deletePackingUnitErrorTitle",
|
59
59
|
`Error Deleting a stock item packing unit`
|
60
60
|
),
|
61
61
|
kind: "error",
|
62
|
-
|
63
|
-
|
62
|
+
isLowContrast: true,
|
63
|
+
subtitle: error?.message,
|
64
64
|
});
|
65
65
|
}
|
66
66
|
);
|
package/src/stock-items/add-stock-item/stock-item-references/stock-item-references.component.tsx
CHANGED
@@ -26,12 +26,7 @@ import {
|
|
26
26
|
createStockItemReference,
|
27
27
|
deleteStockItemReference,
|
28
28
|
} from "../../stock-items.resource";
|
29
|
-
import {
|
30
|
-
restBaseUrl,
|
31
|
-
showNotification,
|
32
|
-
showSnackbar,
|
33
|
-
showToast,
|
34
|
-
} from "@openmrs/esm-framework";
|
29
|
+
import { restBaseUrl, showSnackbar } from "@openmrs/esm-framework";
|
35
30
|
import { extractErrorMessagesFromResponse } from "../../../constants";
|
36
31
|
import { handleMutate } from "../../../utils";
|
37
32
|
|
@@ -41,10 +36,7 @@ interface StockReferencesProps {
|
|
41
36
|
stockItemUuid: string;
|
42
37
|
}
|
43
38
|
|
44
|
-
const StockReferences: React.FC<StockReferencesProps> = ({
|
45
|
-
isEditing,
|
46
|
-
stockItemUuid,
|
47
|
-
}) => {
|
39
|
+
const StockReferences: React.FC<StockReferencesProps> = ({ stockItemUuid }) => {
|
48
40
|
const { t } = useTranslation();
|
49
41
|
|
50
42
|
// get stock item references
|
@@ -189,10 +181,7 @@ const StockReferencesRow: React.FC<{
|
|
189
181
|
}> = ({ isEditing, row, key }) => {
|
190
182
|
const { t } = useTranslation();
|
191
183
|
|
192
|
-
const {
|
193
|
-
control,
|
194
|
-
formState: { errors },
|
195
|
-
} = useFormContext();
|
184
|
+
const { control } = useFormContext();
|
196
185
|
|
197
186
|
const handleDelete = (e) => {
|
198
187
|
e.preventDefault();
|
@@ -19,7 +19,7 @@ import {
|
|
19
19
|
} from "../../../stock-lookups/stock-lookups.resource";
|
20
20
|
import { createOrUpdateStockRule } from "./stock-rules.resource";
|
21
21
|
import { StockRule } from "../../../core/api/types/stockItem/StockRule";
|
22
|
-
import {
|
22
|
+
import { showSnackbar } from "@openmrs/esm-framework";
|
23
23
|
import { useTranslation } from "react-i18next";
|
24
24
|
import { closeOverlay } from "../../../core/components/overlay/hook";
|
25
25
|
import { ResourceRepresentation } from "../../../core/api/api";
|
@@ -61,11 +61,7 @@ const StockRulesAddOrUpdate: React.FC<AddStockRuleProps> = ({
|
|
61
61
|
const { stockLocations } = useStockTagLocations();
|
62
62
|
|
63
63
|
//Roles
|
64
|
-
const {
|
65
|
-
items: rolesData,
|
66
|
-
isError: rolesError,
|
67
|
-
isLoading: loadingRoles,
|
68
|
-
} = useRoles({ v: ResourceRepresentation.Default });
|
64
|
+
const { items: rolesData } = useRoles({ v: ResourceRepresentation.Default });
|
69
65
|
|
70
66
|
const [formModel, setFormModel] = useState<StockRule>({
|
71
67
|
enabled: true,
|
@@ -75,8 +71,7 @@ const StockRulesAddOrUpdate: React.FC<AddStockRuleProps> = ({
|
|
75
71
|
useEffect(() => {
|
76
72
|
if (model != null && Object.keys(model).length != 0) {
|
77
73
|
// To prevent editing properties like date created
|
78
|
-
const {
|
79
|
-
model;
|
74
|
+
const { ...rest } = model;
|
80
75
|
const tmpFormModel = { ...rest };
|
81
76
|
setFormModel(tmpFormModel);
|
82
77
|
}
|
@@ -143,18 +138,12 @@ const StockRulesAddOrUpdate: React.FC<AddStockRuleProps> = ({
|
|
143
138
|
setFormModel({ ...formModel, mailRole: selectedMailRole.display });
|
144
139
|
};
|
145
140
|
|
146
|
-
const onEnabledChanged = (
|
147
|
-
cvt: React.ChangeEvent<HTMLInputElement>,
|
148
|
-
data: { checked: boolean; id: string }
|
149
|
-
): void => {
|
141
|
+
const onEnabledChanged = (): void => {
|
150
142
|
const isEnabled = !formModel?.enabled;
|
151
143
|
setFormModel({ ...formModel, enabled: isEnabled });
|
152
144
|
};
|
153
145
|
|
154
|
-
const onAppliesToChildrenChanged = (
|
155
|
-
cvt: React.ChangeEvent<HTMLInputElement>,
|
156
|
-
data: { checked: boolean; id: string }
|
157
|
-
): void => {
|
146
|
+
const onAppliesToChildrenChanged = (): void => {
|
158
147
|
const enableDescendants = !formModel?.enableDescendants;
|
159
148
|
setFormModel({ ...formModel, enableDescendants: enableDescendants });
|
160
149
|
};
|
@@ -171,11 +160,11 @@ const StockRulesAddOrUpdate: React.FC<AddStockRuleProps> = ({
|
|
171
160
|
createOrUpdateStockRule(formModel)
|
172
161
|
.then(
|
173
162
|
() => {
|
174
|
-
|
175
|
-
|
163
|
+
showSnackbar({
|
164
|
+
isLowContrast: true,
|
176
165
|
title: t("addedRule", "Add Rule"),
|
177
166
|
kind: "success",
|
178
|
-
|
167
|
+
subtitle: t(
|
179
168
|
"stockruleaddedsuccessfully",
|
180
169
|
"Stock Rule Added Successfully"
|
181
170
|
),
|
@@ -183,11 +172,11 @@ const StockRulesAddOrUpdate: React.FC<AddStockRuleProps> = ({
|
|
183
172
|
closeOverlay();
|
184
173
|
},
|
185
174
|
(error) => {
|
186
|
-
|
175
|
+
showSnackbar({
|
187
176
|
title: t(`errorAddingRule', 'error adding a rule`),
|
188
177
|
kind: "error",
|
189
|
-
|
190
|
-
|
178
|
+
isLowContrast: true,
|
179
|
+
subtitle: error?.message,
|
191
180
|
});
|
192
181
|
}
|
193
182
|
)
|
@@ -3,7 +3,7 @@ import { Button, InlineLoading } from "@carbon/react";
|
|
3
3
|
import { useTranslation } from "react-i18next";
|
4
4
|
import { TrashCan } from "@carbon/react/icons";
|
5
5
|
import { deleteStockRule } from "../../stock-items.resource";
|
6
|
-
import { showModal,
|
6
|
+
import { showModal, showSnackbar } from "@openmrs/esm-framework";
|
7
7
|
|
8
8
|
interface StockRulesDeleteActionMenuProps {
|
9
9
|
uuid: string;
|
@@ -25,11 +25,11 @@ const StockRulesDeleteActionMenu: React.FC<StockRulesDeleteActionMenuProps> = ({
|
|
25
25
|
.then(
|
26
26
|
() => {
|
27
27
|
setDeletingRule(false);
|
28
|
-
|
29
|
-
|
28
|
+
showSnackbar({
|
29
|
+
isLowContrast: true,
|
30
30
|
title: t("deletingRule", "Delete Rule"),
|
31
31
|
kind: "success",
|
32
|
-
|
32
|
+
subtitle: t(
|
33
33
|
"stockruledeletedsuccessfully",
|
34
34
|
"Stock Rule Deleted Successfully"
|
35
35
|
),
|
@@ -37,11 +37,11 @@ const StockRulesDeleteActionMenu: React.FC<StockRulesDeleteActionMenuProps> = ({
|
|
37
37
|
},
|
38
38
|
(error) => {
|
39
39
|
setDeletingRule(false);
|
40
|
-
|
40
|
+
showSnackbar({
|
41
41
|
title: t(`errorDeletingRule', 'error deleting a rule`),
|
42
42
|
kind: "error",
|
43
|
-
|
44
|
-
|
43
|
+
isLowContrast: true,
|
44
|
+
subtitle: error?.message,
|
45
45
|
});
|
46
46
|
}
|
47
47
|
)
|
@@ -2,11 +2,7 @@ import { closeOverlay, launchOverlay } from "../core/components/overlay/hook";
|
|
2
2
|
import { StockItemDTO } from "../core/api/types/stockItem/StockItem";
|
3
3
|
import React from "react";
|
4
4
|
import AddEditStockItem from "./add-stock-item/add-stock-item.component";
|
5
|
-
import {
|
6
|
-
FetchResponse,
|
7
|
-
showNotification,
|
8
|
-
showToast,
|
9
|
-
} from "@openmrs/esm-framework";
|
5
|
+
import { FetchResponse, showSnackbar } from "@openmrs/esm-framework";
|
10
6
|
import { createStockItem, updateStockItem } from "./stock-items.resource";
|
11
7
|
|
12
8
|
export const addOrEditStockItem = async (
|
@@ -19,13 +15,11 @@ export const addOrEditStockItem = async (
|
|
19
15
|
: createStockItem)(stockItem);
|
20
16
|
|
21
17
|
if (response?.data) {
|
22
|
-
|
23
|
-
|
18
|
+
showSnackbar({
|
19
|
+
isLowContrast: true,
|
24
20
|
title: `${isEditing ? "Edit" : "Add"} Stock Item`,
|
25
21
|
kind: "success",
|
26
|
-
|
27
|
-
isEditing ? "Edited" : "Added"
|
28
|
-
} Successfully`,
|
22
|
+
subtitle: `Stock Item ${isEditing ? "Edited" : "Added"} Successfully`,
|
29
23
|
});
|
30
24
|
|
31
25
|
if (!isEditing) {
|
@@ -38,11 +32,11 @@ export const addOrEditStockItem = async (
|
|
38
32
|
}
|
39
33
|
}
|
40
34
|
} catch (error) {
|
41
|
-
|
35
|
+
showSnackbar({
|
42
36
|
title: `Error ${isEditing ? "edit" : "add"}ing a stock item`,
|
43
37
|
kind: "error",
|
44
|
-
|
45
|
-
|
38
|
+
isLowContrast: true,
|
39
|
+
subtitle: error?.responseBody?.error?.message,
|
46
40
|
});
|
47
41
|
}
|
48
42
|
};
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import React, { useCallback } from "react";
|
2
2
|
import { useTranslation } from "react-i18next";
|
3
|
-
import {
|
3
|
+
import { showSnackbar } from "@openmrs/esm-framework";
|
4
4
|
import { saveLocation } from "./stock-locations-table.resource";
|
5
5
|
import { locationData, LocationMutator } from "../stock-items/types";
|
6
6
|
import LocationAdministrationForm from "./location-admin-form.component";
|
@@ -35,22 +35,22 @@ const NewLocationForm: React.FC<LocationFormProps> = ({
|
|
35
35
|
};
|
36
36
|
saveLocation({ locationPayload: locationbject })
|
37
37
|
.then(() => {
|
38
|
-
|
38
|
+
showSnackbar({
|
39
39
|
title: t("formCreated", "Add Location"),
|
40
40
|
kind: "success",
|
41
|
-
|
42
|
-
|
41
|
+
isLowContrast: true,
|
42
|
+
subtitle: t(`Location ${name} was created successfully.`),
|
43
43
|
});
|
44
44
|
|
45
45
|
mutate();
|
46
46
|
onModalChange(false);
|
47
47
|
})
|
48
48
|
.catch((error) => {
|
49
|
-
|
49
|
+
showSnackbar({
|
50
50
|
title: t("errorCreatingForm", "Error creating location"),
|
51
51
|
kind: "error",
|
52
|
-
|
53
|
-
|
52
|
+
isLowContrast: true,
|
53
|
+
subtitle: error?.message,
|
54
54
|
});
|
55
55
|
onModalChange(false);
|
56
56
|
});
|
@@ -1,18 +1,15 @@
|
|
1
|
-
import { StockOperationFilter } from "../stock-operations/stock-operations.resource";
|
2
1
|
import { useMemo, useState } from "react";
|
2
|
+
import useSWR from "swr";
|
3
3
|
import {
|
4
4
|
FetchResponse,
|
5
5
|
openmrsFetch,
|
6
6
|
restBaseUrl,
|
7
|
-
|
7
|
+
showSnackbar,
|
8
8
|
usePagination,
|
9
9
|
} from "@openmrs/esm-framework";
|
10
10
|
import { useTranslation } from "react-i18next";
|
11
|
-
import {
|
12
|
-
|
13
|
-
useStockTagLocations,
|
14
|
-
} from "../stock-lookups/stock-lookups.resource";
|
15
|
-
import useSWR from "swr";
|
11
|
+
import { StockOperationFilter } from "../stock-operations/stock-operations.resource";
|
12
|
+
import { useStockTagLocations } from "../stock-lookups/stock-lookups.resource";
|
16
13
|
import { extractErrorMessagesFromResponse } from "../constants";
|
17
14
|
|
18
15
|
export function useStockLocationPages(filter: StockOperationFilter) {
|
@@ -89,10 +86,10 @@ export const useLocationTags = () => {
|
|
89
86
|
const url = `${restBaseUrl}/locationtag/`;
|
90
87
|
|
91
88
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
92
|
-
const { data,
|
93
|
-
|
94
|
-
|
95
|
-
|
89
|
+
const { data, isLoading, mutate } = useSWR<{ data }, Error>(
|
90
|
+
url,
|
91
|
+
openmrsFetch
|
92
|
+
);
|
96
93
|
const results = data?.data?.results ? data?.data?.results : [];
|
97
94
|
return {
|
98
95
|
locationTagList: results,
|
@@ -118,11 +115,11 @@ export async function saveLocation({
|
|
118
115
|
return response;
|
119
116
|
} catch (error) {
|
120
117
|
const errorMessages = extractErrorMessagesFromResponse(error);
|
121
|
-
|
122
|
-
|
118
|
+
showSnackbar({
|
119
|
+
subtitle: errorMessages.join(", "),
|
123
120
|
title: "Error on saving form",
|
124
121
|
kind: "error",
|
125
|
-
|
122
|
+
isLowContrast: true,
|
126
123
|
});
|
127
124
|
}
|
128
125
|
}
|
@@ -22,12 +22,7 @@ import StockOperationApproveDispatchButton from "../stock-operations-dialog/stoc
|
|
22
22
|
import StockOperationCompleteDispatchButton from "../stock-operations-dialog/stock-operations-completed-dispatch-button.component";
|
23
23
|
import StockOperationIssueStockButton from "../stock-operations-dialog/stock-operations-issue-stock-button.component";
|
24
24
|
import { StockOperation } from "./stock-operation-context/useStockOperationContext";
|
25
|
-
import {
|
26
|
-
formatDate,
|
27
|
-
parseDate,
|
28
|
-
showSnackbar,
|
29
|
-
showToast,
|
30
|
-
} from "@openmrs/esm-framework";
|
25
|
+
import { formatDate, parseDate, showSnackbar } from "@openmrs/esm-framework";
|
31
26
|
import {
|
32
27
|
OperationType,
|
33
28
|
StockOperationType,
|
@@ -4,8 +4,7 @@ import {
|
|
4
4
|
FetchResponse,
|
5
5
|
restBaseUrl,
|
6
6
|
showModal,
|
7
|
-
|
8
|
-
showToast,
|
7
|
+
showSnackbar,
|
9
8
|
} from "@openmrs/esm-framework";
|
10
9
|
import { StockOperationDTO } from "../core/api/types/stockOperation/StockOperationDTO";
|
11
10
|
import {
|
@@ -49,11 +48,11 @@ export const addOrEditStockOperation = async (
|
|
49
48
|
|
50
49
|
if (response?.data) {
|
51
50
|
handleMutate(`${restBaseUrl}/stockmanagement/stockoperation`);
|
52
|
-
|
53
|
-
|
51
|
+
showSnackbar({
|
52
|
+
isLowContrast: true,
|
54
53
|
title: `${isEditing ? "Edit" : "Add"} Stock Operation`,
|
55
54
|
kind: "success",
|
56
|
-
|
55
|
+
subtitle: `Stock Operation ${
|
57
56
|
isEditing ? "Edited" : "Added"
|
58
57
|
} Successfully`,
|
59
58
|
});
|
@@ -63,11 +62,11 @@ export const addOrEditStockOperation = async (
|
|
63
62
|
}
|
64
63
|
} catch (error) {
|
65
64
|
const errorMessages = extractErrorMessagesFromResponse(error);
|
66
|
-
|
67
|
-
|
65
|
+
showSnackbar({
|
66
|
+
subtitle: errorMessages.join(", "),
|
68
67
|
title: "Error on saving form",
|
69
68
|
kind: "error",
|
70
|
-
|
69
|
+
isLowContrast: true,
|
71
70
|
});
|
72
71
|
}
|
73
72
|
};
|
@@ -13,12 +13,7 @@ import styles from "./add-stock-sources.scss";
|
|
13
13
|
import { useConcept } from "../../stock-lookups/stock-lookups.resource";
|
14
14
|
import { StockSource } from "../../core/api/types/stockOperation/StockSource";
|
15
15
|
import { createOrUpdateStockSource } from "../stock-sources.resource";
|
16
|
-
import {
|
17
|
-
restBaseUrl,
|
18
|
-
showNotification,
|
19
|
-
showToast,
|
20
|
-
useConfig,
|
21
|
-
} from "@openmrs/esm-framework";
|
16
|
+
import { restBaseUrl, showSnackbar, useConfig } from "@openmrs/esm-framework";
|
22
17
|
import { useTranslation } from "react-i18next";
|
23
18
|
import { closeOverlay } from "../../core/components/overlay/hook";
|
24
19
|
import { type ConfigObject } from "../../config-schema";
|
@@ -63,14 +58,15 @@ const StockSourcesAddOrUpdate: React.FC<AddStockSourceProps> = ({ model }) => {
|
|
63
58
|
createOrUpdateStockSource(formModel)
|
64
59
|
.then(
|
65
60
|
() => {
|
66
|
-
|
67
|
-
|
61
|
+
showSnackbar({
|
62
|
+
isLowContrast: true,
|
68
63
|
title: t("addedSource", "Add Source"),
|
69
64
|
kind: "success",
|
70
|
-
|
65
|
+
subtitle: t(
|
71
66
|
"stocksourceaddedsuccessfully",
|
72
67
|
"Stock Source Added Successfully"
|
73
68
|
),
|
69
|
+
timeoutInMs: 5000,
|
74
70
|
});
|
75
71
|
|
76
72
|
handleMutate(`${restBaseUrl}/stockmanagement/stocksource`);
|
@@ -78,11 +74,11 @@ const StockSourcesAddOrUpdate: React.FC<AddStockSourceProps> = ({ model }) => {
|
|
78
74
|
closeOverlay();
|
79
75
|
},
|
80
76
|
(error) => {
|
81
|
-
|
77
|
+
showSnackbar({
|
82
78
|
title: t(`errorAddingSource', 'error adding a source`),
|
83
79
|
kind: "error",
|
84
|
-
|
85
|
-
|
80
|
+
isLowContrast: true,
|
81
|
+
subtitle: error?.message,
|
86
82
|
});
|
87
83
|
}
|
88
84
|
)
|
@@ -3,12 +3,7 @@ import { Button, InlineLoading } from "@carbon/react";
|
|
3
3
|
import { useTranslation } from "react-i18next";
|
4
4
|
import { TrashCan } from "@carbon/react/icons";
|
5
5
|
import { deleteStockSource } from "../stock-sources.resource";
|
6
|
-
import {
|
7
|
-
restBaseUrl,
|
8
|
-
showModal,
|
9
|
-
showNotification,
|
10
|
-
showToast,
|
11
|
-
} from "@openmrs/esm-framework";
|
6
|
+
import { restBaseUrl, showModal, showSnackbar } from "@openmrs/esm-framework";
|
12
7
|
import { handleMutate } from "../../utils";
|
13
8
|
|
14
9
|
interface StockSourcesDeleteActionMenuProps {
|
@@ -35,11 +30,11 @@ const StockSourcesDeleteActionMenu: React.FC<
|
|
35
30
|
setDeletingSource(false);
|
36
31
|
|
37
32
|
handleMutate(`${restBaseUrl}/stockmanagement/stocksource`);
|
38
|
-
|
39
|
-
|
33
|
+
showSnackbar({
|
34
|
+
isLowContrast: true,
|
40
35
|
title: t("deletingSource", "Delete Source"),
|
41
36
|
kind: "success",
|
42
|
-
|
37
|
+
subtitle: t(
|
43
38
|
"stocksourcedeletedsuccessfully",
|
44
39
|
"Stock Source Deleted Successfully"
|
45
40
|
),
|
@@ -47,11 +42,11 @@ const StockSourcesDeleteActionMenu: React.FC<
|
|
47
42
|
},
|
48
43
|
(error) => {
|
49
44
|
setDeletingSource(false);
|
50
|
-
|
45
|
+
showSnackbar({
|
51
46
|
title: t(`errorDeletingSource', 'error deleting a source`),
|
52
47
|
kind: "error",
|
53
|
-
|
54
|
-
|
48
|
+
isLowContrast: true,
|
49
|
+
subtitle: error?.message,
|
55
50
|
});
|
56
51
|
}
|
57
52
|
)
|