@openmrs/esm-stock-management-app 1.0.1-pre.473 → 1.0.1-pre.476
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/components/tabs/vertical-tabs.scss +2 -3
- 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
@@ -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
|
)
|
package/src/stock-user-role-scopes/add-stock-user-scope/add-stock-user-role-scope.component.tsx
CHANGED
@@ -28,12 +28,7 @@ import { closeOverlay } from "../../core/components/overlay/hook";
|
|
28
28
|
import { useTranslation } from "react-i18next";
|
29
29
|
import { UserRoleScope } from "../../core/api/types/identity/UserRoleScope";
|
30
30
|
import { createOrUpdateUserRoleScope } from "../stock-user-role-scopes.resource";
|
31
|
-
import {
|
32
|
-
restBaseUrl,
|
33
|
-
showNotification,
|
34
|
-
showToast,
|
35
|
-
useSession,
|
36
|
-
} from "@openmrs/esm-framework";
|
31
|
+
import { restBaseUrl, showSnackbar, useSession } from "@openmrs/esm-framework";
|
37
32
|
import { UserRoleScopeOperationType } from "../../core/api/types/identity/UserRoleScopeOperationType";
|
38
33
|
import { UserRoleScopeLocation } from "../../core/api/types/identity/UserRoleScopeLocation";
|
39
34
|
import {
|
@@ -69,7 +64,6 @@ const AddStockUserRoleScope: React.FC<AddStockUserRoleScopeProps> = ({
|
|
69
64
|
|
70
65
|
const [roles, setRoles] = useState<Role[]>([]);
|
71
66
|
|
72
|
-
const [showItems, setShowItems] = useState(false);
|
73
67
|
const loggedInUserUuid = currentUser?.user?.uuid;
|
74
68
|
|
75
69
|
// operation types
|
@@ -79,37 +73,28 @@ const AddStockUserRoleScope: React.FC<AddStockUserRoleScopeProps> = ({
|
|
79
73
|
} = useStockOperationTypes();
|
80
74
|
|
81
75
|
// get users
|
82
|
-
const {
|
83
|
-
|
84
|
-
|
85
|
-
isLoading: loadingUsers,
|
86
|
-
} = useUsers({ v: ResourceRepresentation.Default });
|
76
|
+
const { items: users, isLoading: loadingUsers } = useUsers({
|
77
|
+
v: ResourceRepresentation.Default,
|
78
|
+
});
|
87
79
|
|
88
80
|
const [selectedUserUuid, setSelectedUserUuid] = useState<string | null>(null);
|
89
|
-
const { data: user
|
81
|
+
const { data: user } = useUser(selectedUserUuid);
|
90
82
|
|
91
83
|
// get roles
|
92
|
-
const {
|
84
|
+
const { isLoading: loadingRoles } = useRoles({
|
93
85
|
v: ResourceRepresentation.Default,
|
94
86
|
});
|
95
87
|
|
96
88
|
/* Only load locations tagged to perform stock related activities.
|
97
89
|
Unless a location is tag as main store, main pharmacy or dispensing, it will not be listed here.
|
98
|
-
|
99
90
|
*/
|
100
91
|
const { stockLocations } = useStockTagLocations();
|
101
|
-
const onEnabledChanged = (
|
102
|
-
cvt: React.ChangeEvent<HTMLInputElement>,
|
103
|
-
data: { checked: boolean; id: string }
|
104
|
-
): void => {
|
92
|
+
const onEnabledChanged = (): void => {
|
105
93
|
const isEnabled = !formModel?.enabled;
|
106
94
|
setFormModel({ ...formModel, enabled: isEnabled });
|
107
95
|
};
|
108
96
|
|
109
|
-
const onPermanentChanged = (
|
110
|
-
cvt: React.ChangeEvent<HTMLInputElement>,
|
111
|
-
data: { checked: boolean; id: string }
|
112
|
-
): void => {
|
97
|
+
const onPermanentChanged = (): void => {
|
113
98
|
const isPermanent = !formModel?.permanent;
|
114
99
|
setFormModel({
|
115
100
|
...formModel,
|
@@ -119,16 +104,12 @@ const AddStockUserRoleScope: React.FC<AddStockUserRoleScopeProps> = ({
|
|
119
104
|
});
|
120
105
|
};
|
121
106
|
|
122
|
-
const [
|
123
|
-
const [filteredItems, setFilteredItems] = useState<any[]>([]);
|
107
|
+
const [filteredItems, setFilteredItems] = useState<unknown[]>([]);
|
124
108
|
|
125
109
|
const usersResults = users?.results ?? [];
|
126
110
|
|
127
111
|
const filterItems = (query: string) => {
|
128
|
-
if (query.trim()
|
129
|
-
setShowItems(false);
|
130
|
-
} else {
|
131
|
-
setShowItems(true);
|
112
|
+
if (query && query.trim() !== "") {
|
132
113
|
const filtered = usersResults
|
133
114
|
.filter((item: any) => item.uuid !== loggedInUserUuid)
|
134
115
|
.filter((item: any) => {
|
@@ -145,13 +126,10 @@ const AddStockUserRoleScope: React.FC<AddStockUserRoleScopeProps> = ({
|
|
145
126
|
}, [model]);
|
146
127
|
|
147
128
|
const handleSearchQueryChange = (query: string) => {
|
148
|
-
setSearchQuery(query);
|
149
129
|
filterItems(query);
|
150
130
|
};
|
151
131
|
const onStockOperationTypeChanged = (
|
152
|
-
event: React.ChangeEvent<HTMLInputElement
|
153
|
-
uuid: string,
|
154
|
-
isChecked: boolean
|
132
|
+
event: React.ChangeEvent<HTMLInputElement>
|
155
133
|
): void => {
|
156
134
|
const operationType = formModel?.operationTypes?.find(
|
157
135
|
(x) => x.operationTypeUuid === event?.target?.value
|
@@ -179,8 +157,7 @@ const AddStockUserRoleScope: React.FC<AddStockUserRoleScopeProps> = ({
|
|
179
157
|
};
|
180
158
|
|
181
159
|
const onLocationCheckBoxChanged = (
|
182
|
-
event: ChangeEvent<HTMLInputElement
|
183
|
-
id: string
|
160
|
+
event: ChangeEvent<HTMLInputElement>
|
184
161
|
): void => {
|
185
162
|
const selectedLocation = formModel?.locations?.find(
|
186
163
|
(x) => x.locationUuid === event?.target?.value
|
@@ -253,28 +230,6 @@ const AddStockUserRoleScope: React.FC<AddStockUserRoleScopeProps> = ({
|
|
253
230
|
});
|
254
231
|
};
|
255
232
|
|
256
|
-
const onEnableDescendantsChanged = (event: ChangeEvent<HTMLInputElement>) => {
|
257
|
-
const selectedLocation = formModel?.locations?.find(
|
258
|
-
(x) => x.locationUuid === event?.target?.value
|
259
|
-
);
|
260
|
-
if (selectedLocation) {
|
261
|
-
const enableDescendants = !(selectedLocation.enableDescendants === true);
|
262
|
-
const newModifiedLocation = {
|
263
|
-
...selectedLocation,
|
264
|
-
enableDescendants: enableDescendants,
|
265
|
-
};
|
266
|
-
setFormModel({
|
267
|
-
...formModel,
|
268
|
-
locations: [
|
269
|
-
...(formModel?.locations?.filter(
|
270
|
-
(x) => x.locationUuid !== selectedLocation?.locationUuid
|
271
|
-
) ?? []),
|
272
|
-
newModifiedLocation,
|
273
|
-
],
|
274
|
-
});
|
275
|
-
}
|
276
|
-
};
|
277
|
-
|
278
233
|
const isOperationChecked = (operationType: StockOperationType) => {
|
279
234
|
return (
|
280
235
|
formModel?.operationTypes?.filter(
|
@@ -289,11 +244,11 @@ const AddStockUserRoleScope: React.FC<AddStockUserRoleScopeProps> = ({
|
|
289
244
|
createOrUpdateUserRoleScope(formModel).then(
|
290
245
|
(res) => {
|
291
246
|
handleMutate(`${restBaseUrl}/stockmanagement/userrolescope`);
|
292
|
-
|
293
|
-
|
247
|
+
showSnackbar({
|
248
|
+
isLowContrast: true,
|
294
249
|
title: t("addUserRole", "Add User role"),
|
295
250
|
kind: "success",
|
296
|
-
|
251
|
+
subtitle: t(
|
297
252
|
"successfullysaved",
|
298
253
|
`You have successfully saved user role scope `
|
299
254
|
),
|
@@ -301,13 +256,13 @@ const AddStockUserRoleScope: React.FC<AddStockUserRoleScopeProps> = ({
|
|
301
256
|
closeOverlay();
|
302
257
|
},
|
303
258
|
(err) => {
|
304
|
-
|
259
|
+
showSnackbar({
|
305
260
|
title: t(
|
306
261
|
`errorSaving user role scope', 'Error Saving user role scope`
|
307
262
|
),
|
308
263
|
kind: "error",
|
309
|
-
|
310
|
-
|
264
|
+
isLowContrast: true,
|
265
|
+
subtitle: err?.message,
|
311
266
|
});
|
312
267
|
|
313
268
|
closeOverlay();
|
@@ -465,13 +420,7 @@ const AddStockUserRoleScope: React.FC<AddStockUserRoleScopeProps> = ({
|
|
465
420
|
value={type.uuid}
|
466
421
|
checked={isOperationChecked(type)}
|
467
422
|
className={styles.checkbox}
|
468
|
-
onChange={(event) =>
|
469
|
-
onStockOperationTypeChanged(
|
470
|
-
event,
|
471
|
-
type.uuid,
|
472
|
-
isOperationChecked(type)
|
473
|
-
)
|
474
|
-
}
|
423
|
+
onChange={(event) => onStockOperationTypeChanged(event)}
|
475
424
|
labelText={type.name}
|
476
425
|
id={type.uuid}
|
477
426
|
/>
|
@@ -520,9 +469,7 @@ const AddStockUserRoleScope: React.FC<AddStockUserRoleScopeProps> = ({
|
|
520
469
|
key={`chk-loc-child-key-${type.id}`}
|
521
470
|
id={`chk-loc-child-${type.id}`}
|
522
471
|
value={type.id}
|
523
|
-
onChange={(event) =>
|
524
|
-
onLocationCheckBoxChanged(event, type.id)
|
525
|
-
}
|
472
|
+
onChange={(event) => onLocationCheckBoxChanged(event)}
|
526
473
|
className={styles.checkbox}
|
527
474
|
labelText={type.name}
|
528
475
|
checked={checkedLocation != null}
|
package/src/stock-user-role-scopes/delete-stock-user-scope/delete-stock-user-scope.component.tsx
CHANGED
@@ -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 { deleteUserRoleScopes } from "../stock-user-role-scopes.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 StockUserScopDeleteActionMenuProps {
|
@@ -34,11 +29,11 @@ const StockUserScopeDeleteActionMenu: React.FC<
|
|
34
29
|
() => {
|
35
30
|
handleMutate(`${restBaseUrl}/stockmanagement/userrolescope`);
|
36
31
|
setDeletingUserScope(false);
|
37
|
-
|
38
|
-
|
32
|
+
showSnackbar({
|
33
|
+
isLowContrast: true,
|
39
34
|
title: t("deletingstockUserScope", "Delete Stock User Scope"),
|
40
35
|
kind: "success",
|
41
|
-
|
36
|
+
subtitle: t(
|
42
37
|
"stockuserscopedeletedsuccessfully",
|
43
38
|
"Stock User Scope Deleted Successfully"
|
44
39
|
),
|
@@ -46,13 +41,13 @@ const StockUserScopeDeleteActionMenu: React.FC<
|
|
46
41
|
},
|
47
42
|
(error) => {
|
48
43
|
setDeletingUserScope(false);
|
49
|
-
|
44
|
+
showSnackbar({
|
50
45
|
title: t(
|
51
46
|
`errorDeletingUserScope', 'error deleting a user scope`
|
52
47
|
),
|
53
48
|
kind: "error",
|
54
|
-
|
55
|
-
|
49
|
+
isLowContrast: true,
|
50
|
+
subtitle: error?.message,
|
56
51
|
});
|
57
52
|
}
|
58
53
|
)
|
package/src/utils.ts
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
import {
|
1
|
+
import { showSnackbar } from "@openmrs/esm-framework";
|
2
2
|
import { mutate } from "swr";
|
3
3
|
|
4
4
|
export function errorAlert(msg: string, error?: Error) {
|
5
|
-
|
5
|
+
showSnackbar({
|
6
6
|
title: msg,
|
7
7
|
kind: "error",
|
8
|
-
|
9
|
-
|
8
|
+
isLowContrast: true,
|
9
|
+
subtitle: error?.message,
|
10
10
|
});
|
11
11
|
}
|
12
12
|
|