@openmrs/esm-stock-management-app 3.0.1-pre.805 → 3.0.1-pre.826

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (196) hide show
  1. package/.eslintrc +10 -1
  2. package/dist/10.js +1 -0
  3. package/dist/10.js.map +1 -0
  4. package/dist/165.js +1 -1
  5. package/dist/165.js.map +1 -1
  6. package/dist/20.js +1 -1
  7. package/dist/20.js.map +1 -1
  8. package/dist/606.js.map +1 -1
  9. package/dist/642.js +1 -0
  10. package/dist/642.js.map +1 -0
  11. package/dist/675.js +1 -0
  12. package/dist/675.js.map +1 -0
  13. package/dist/{880.js → 727.js} +1 -1
  14. package/dist/727.js.map +1 -0
  15. package/dist/780.js +1 -0
  16. package/dist/780.js.map +1 -0
  17. package/dist/793.js +1 -1
  18. package/dist/793.js.map +1 -1
  19. package/dist/main.js +1 -1
  20. package/dist/main.js.map +1 -1
  21. package/dist/openmrs-esm-stock-management-app.js +1 -1
  22. package/dist/openmrs-esm-stock-management-app.js.buildmanifest.json +132 -59
  23. package/dist/openmrs-esm-stock-management-app.js.map +1 -1
  24. package/dist/routes.json +1 -1
  25. package/package.json +3 -2
  26. package/src/core/api/api.ts +1 -1
  27. package/src/core/api/types/Auditable.ts +2 -2
  28. package/src/core/api/types/BaseOpenmrsData.ts +2 -2
  29. package/src/core/api/types/BaseOpenmrsMetadata.ts +2 -2
  30. package/src/core/api/types/BaseOpenmrsObject.ts +1 -1
  31. package/src/core/api/types/BatchJob.ts +1 -1
  32. package/src/core/api/types/LocationTree.ts +1 -1
  33. package/src/core/api/types/OpenmrsData.ts +3 -3
  34. package/src/core/api/types/OpenmrsMetadata.ts +3 -3
  35. package/src/core/api/types/Retireable.ts +2 -2
  36. package/src/core/api/types/Voidable.ts +2 -2
  37. package/src/core/api/types/concept/Concept.ts +4 -4
  38. package/src/core/api/types/concept/ConceptName.ts +2 -2
  39. package/src/core/api/types/concept/Drug.ts +2 -2
  40. package/src/core/api/types/identity/Patient.ts +1 -1
  41. package/src/core/api/types/identity/Privilege.ts +1 -1
  42. package/src/core/api/types/identity/Session.ts +3 -3
  43. package/src/core/api/types/identity/User.ts +2 -2
  44. package/src/core/api/types/identity/UserRoleScope.ts +3 -3
  45. package/src/core/api/types/identity/UserRoleScopeLocation.ts +1 -1
  46. package/src/core/api/types/identity/UserRoleScopeOperationType.ts +1 -1
  47. package/src/core/api/types/stockItem/StockBatch.ts +2 -2
  48. package/src/core/api/types/stockItem/StockItem.ts +6 -6
  49. package/src/core/api/types/stockItem/StockItemPackagingUOM.ts +3 -3
  50. package/src/core/api/types/stockItem/StockItemReference.ts +3 -3
  51. package/src/core/api/types/stockItem/StockItemTransaction.ts +1 -1
  52. package/src/core/api/types/stockItem/StockRule.ts +1 -1
  53. package/src/core/api/types/stockOperation/StockOperation.ts +8 -8
  54. package/src/core/api/types/stockOperation/StockOperationDTO.ts +3 -3
  55. package/src/core/api/types/stockOperation/StockOperationItem.ts +5 -5
  56. package/src/core/api/types/stockOperation/StockOperationItemDTO.ts +2 -2
  57. package/src/core/api/types/stockOperation/StockOperationType.ts +2 -2
  58. package/src/core/api/types/stockOperation/StockSource.ts +2 -2
  59. package/src/core/components/carbon/controlled-combo-box/controlled-combo-box.component.tsx +1 -1
  60. package/src/core/components/carbon/controlled-dropdown/controlled-dropdown.component.tsx +2 -2
  61. package/src/core/components/carbon/controlled-number-input/controlled-number-input.component.tsx +3 -3
  62. package/src/core/components/carbon/controlled-radio-button-group/controlled-radio-button-group.component.tsx +3 -3
  63. package/src/core/components/carbon/controlled-text-area/controlled-text-area.component.tsx +3 -3
  64. package/src/core/components/carbon/controlled-text-input/controlled-text-input.component.tsx +3 -3
  65. package/src/core/components/carbon/types.ts +1 -1
  66. package/src/core/components/side-nav/side-nav.component.tsx +1 -1
  67. package/src/core/components/table/table.component.tsx +1 -1
  68. package/src/core/components/table/types.ts +1 -1
  69. package/src/core/components/tabs/types.ts +1 -1
  70. package/src/core/components/tabs/vertical-tabs.component.tsx +1 -1
  71. package/src/core/print/PrintTemplate.ts +1 -1
  72. package/src/core/utils/utils.ts +1 -1
  73. package/src/index.ts +8 -0
  74. package/src/routes.json +14 -0
  75. package/src/stock-batch/stock-batch.resource.ts +4 -4
  76. package/src/stock-home/stock-home-inventory-expiry.resource.tsx +1 -1
  77. package/src/stock-home/stock-home-inventory-items.resource.tsx +1 -1
  78. package/src/stock-home/stock-home-issuing.resource.tsx +1 -1
  79. package/src/stock-home/stock-home-metrics.tsx +1 -1
  80. package/src/stock-home/stock-home-receiving.resource.tsx +1 -1
  81. package/src/stock-home/useDisposalList.tsx +1 -1
  82. package/src/stock-items/add-stock-item/add-stock-action-button.component.tsx +2 -3
  83. package/src/stock-items/add-stock-item/add-stock-item.component.tsx +30 -21
  84. package/src/stock-items/add-stock-item/add-stock-item.resource.tsx +1 -1
  85. package/src/stock-items/add-stock-item/add-stock-item.scss +22 -3
  86. package/src/stock-items/add-stock-item/add-stock-item.test.tsx +12 -12
  87. package/src/stock-items/add-stock-item/batch-information/batch-information-locations/batch-information-locations-filter.component.tsx +2 -2
  88. package/src/stock-items/add-stock-item/batch-information/batch-information.component.tsx +1 -1
  89. package/src/stock-items/add-stock-item/batch-information/batch-information.resource.tsx +1 -1
  90. package/src/stock-items/add-stock-item/concepts-selector/concepts-selector.component.tsx +3 -3
  91. package/src/stock-items/add-stock-item/dispensing-package-measurement/dispensing-package-measurement.component.tsx +3 -3
  92. package/src/stock-items/add-stock-item/dispensing-unit-selector/dispensing-unit-selector.component.tsx +3 -3
  93. package/src/stock-items/add-stock-item/drug-selector/drug-selector.component.tsx +3 -3
  94. package/src/stock-items/add-stock-item/drug-selector/drug-selector.resource.tsx +1 -1
  95. package/src/stock-items/add-stock-item/packaging-units/packaging-units-delete-modal-button.component.tsx +1 -1
  96. package/src/stock-items/add-stock-item/packaging-units/packaging-units-delete-modal.component.tsx +1 -1
  97. package/src/stock-items/add-stock-item/packaging-units/packaging-units.component.tsx +10 -11
  98. package/src/stock-items/add-stock-item/packaging-units/packaging-units.resource.tsx +2 -2
  99. package/src/stock-items/add-stock-item/packaging-units-concept-selector/packaging-units-concept-selector.component.tsx +4 -4
  100. package/src/stock-items/add-stock-item/preferred-vendor-selector/preferred-vendor-selector.component.tsx +4 -4
  101. package/src/stock-items/add-stock-item/quantities/quantities.resource.tsx +1 -1
  102. package/src/stock-items/add-stock-item/stock-item-category-selector/stock-item-category-selector.component.tsx +3 -3
  103. package/src/stock-items/add-stock-item/stock-item-details/stock-item-details.component.tsx +226 -214
  104. package/src/stock-items/add-stock-item/stock-item-details/stock-item-details.resource.tsx +7 -2
  105. package/src/stock-items/add-stock-item/stock-item-references/stock-item-references.component.tsx +2 -2
  106. package/src/stock-items/add-stock-item/stock-item-references/stock-item-references.resource.ts +1 -1
  107. package/src/stock-items/add-stock-item/stock-item-references/stock-references-selector.component.tsx +4 -4
  108. package/src/stock-items/add-stock-item/stock-item-rules/add-stock-rule-button.component.tsx +6 -4
  109. package/src/stock-items/add-stock-item/stock-item-rules/add-stock-rules.component.tsx +163 -167
  110. package/src/stock-items/add-stock-item/stock-item-rules/add-stock-rules.scss +19 -11
  111. package/src/stock-items/add-stock-item/stock-item-rules/edit-stock-rule.component.tsx +9 -6
  112. package/src/stock-items/add-stock-item/stock-item-rules/stock-item-rules.component.tsx +1 -1
  113. package/src/stock-items/add-stock-item/stock-item-rules/stock-item-rules.resource.tsx +1 -1
  114. package/src/stock-items/add-stock-item/stock-item-rules/stock-rules.resource.ts +3 -3
  115. package/src/stock-items/add-stock-item/stock-item-units-edit/stock-item-units-edit.component.tsx +2 -2
  116. package/src/stock-items/add-stock-item/transactions/printout/transactions-print-action.component.tsx +2 -3
  117. package/src/stock-items/add-stock-item/transactions/transaction-filters/transaction-locations-filter.component.tsx +2 -2
  118. package/src/stock-items/add-stock-item/transactions/transactions.component.tsx +1 -1
  119. package/src/stock-items/add-stock-item/transactions/transactions.resource.tsx +1 -1
  120. package/src/stock-items/edit-stock-item/edit-stock-item-action-menu.component.tsx +3 -3
  121. package/src/stock-items/stock-item.utils.tsx +7 -50
  122. package/src/stock-items/stock-items-table.component.tsx +2 -2
  123. package/src/stock-items/stock-items-table.resource.ts +1 -1
  124. package/src/stock-items/stock-items-table.test.tsx +28 -23
  125. package/src/stock-items/stock-items.resource.ts +17 -15
  126. package/src/stock-items/types.ts +3 -3
  127. package/src/stock-locations/add-locations-form.component.tsx +1 -1
  128. package/src/stock-locations/location-admin-form.component.tsx +1 -1
  129. package/src/stock-locations/stock-locations-table.resource.tsx +2 -2
  130. package/src/stock-lookups/stock-lookups.resource.ts +13 -13
  131. package/src/stock-operations/add-stock-operation/stock-operations-expanded-row/stock-items-table.tsx +1 -1
  132. package/src/stock-operations/add-stock-operation/stock-operations-expanded-row/stock-operation-expanded-row.component.tsx +1 -1
  133. package/src/stock-operations/edit-stock-operation/edit-stock-operation-action-menu.component.tsx +1 -1
  134. package/src/stock-operations/stock-operation-actions.component.tsx +2 -2
  135. package/src/stock-operations/stock-operation-links.component.tsx +2 -2
  136. package/src/stock-operations/stock-operation-status/stock-operation-status-row.tsx +1 -1
  137. package/src/stock-operations/stock-operation-types-selector/stock-operation-types-selector.component.tsx +1 -1
  138. package/src/stock-operations/stock-operation.utils.tsx +3 -3
  139. package/src/stock-operations/stock-operations-dialog/stock-operations-approve-button.component.tsx +1 -1
  140. package/src/stock-operations/stock-operations-dialog/stock-operations-approve-dispatch-button.component.tsx +1 -1
  141. package/src/stock-operations/stock-operations-dialog/stock-operations-cancel-button.component.tsx +1 -1
  142. package/src/stock-operations/stock-operations-dialog/stock-operations-complete-button.component.tsx +1 -1
  143. package/src/stock-operations/stock-operations-dialog/stock-operations-completed-dispatch-button.component.tsx +1 -1
  144. package/src/stock-operations/stock-operations-dialog/stock-operations-dialog.component.tsx +5 -2
  145. package/src/stock-operations/stock-operations-dialog/stock-operations-issue-stock-button.component.tsx +1 -1
  146. package/src/stock-operations/stock-operations-dialog/stock-operations-print-button.component.tsx +5 -6
  147. package/src/stock-operations/stock-operations-dialog/stock-operations-reject-button.component.tsx +1 -1
  148. package/src/stock-operations/stock-operations-dialog/stock-operations-return-button.component.tsx +1 -1
  149. package/src/stock-operations/stock-operations-forms/hooks/useFilterableStockItems.ts +2 -2
  150. package/src/stock-operations/stock-operations-forms/hooks/useOperationTypePermisions.ts +1 -1
  151. package/src/stock-operations/stock-operations-forms/hooks/useParties.ts +3 -3
  152. package/src/stock-operations/stock-operations-forms/hooks/useSearchUser.ts +5 -1
  153. package/src/stock-operations/stock-operations-forms/hooks/useStockItemBatchNumbers.ts +1 -1
  154. package/src/stock-operations/stock-operations-forms/hooks/useStockOperationLinks.ts +2 -2
  155. package/src/stock-operations/stock-operations-forms/input-components/batch-no-selector.component.tsx +1 -1
  156. package/src/stock-operations/stock-operations-forms/input-components/batch-no-selector.test.tsx +1 -1
  157. package/src/stock-operations/stock-operations-forms/input-components/quantity-uom-selector.component.tsx +1 -1
  158. package/src/stock-operations/stock-operations-forms/input-components/stock-item-search.component.tsx +2 -2
  159. package/src/stock-operations/stock-operations-forms/input-components/stock-operation-reason-selector.component.tsx +2 -2
  160. package/src/stock-operations/stock-operations-forms/input-components/unique-batch-no-entry-input.component.tsx +2 -3
  161. package/src/stock-operations/stock-operations-forms/input-components/users-selector.component.tsx +2 -4
  162. package/src/stock-operations/stock-operations-forms/step2.test.tsx +3 -4
  163. package/src/stock-operations/stock-operations-forms/step3.test.tsx +1 -2
  164. package/src/stock-operations/stock-operations-forms/steps/base-operation-details-form-step.tsx +16 -7
  165. package/src/stock-operations/stock-operations-forms/steps/received-items.component.tsx +1 -1
  166. package/src/stock-operations/stock-operations-forms/steps/stock-operation-item-batch-no-cell.component.tsx +1 -1
  167. package/src/stock-operations/stock-operations-forms/steps/stock-operation-item-cell.component.tsx +1 -1
  168. package/src/stock-operations/stock-operations-forms/steps/stock-operation-item-expiry-cell.component.tsx +1 -1
  169. package/src/stock-operations/stock-operations-forms/steps/stock-operation-items-form-step.component.tsx +3 -3
  170. package/src/stock-operations/stock-operations-forms/steps/stock-operation-submission-form-step.component.tsx +4 -4
  171. package/src/stock-operations/stock-operations-forms/stock-issue-form-initializer-with-related-requisition-operation.component.tsx +2 -2
  172. package/src/stock-operations/stock-operations-forms/stock-item-form/stock-item-form.workspace.tsx +7 -4
  173. package/src/stock-operations/stock-operations-forms/stock-operation-form.component.tsx +9 -9
  174. package/src/stock-operations/stock-operations-forms/stock-operation-stepper/stock-operation-stepper.component.tsx +1 -0
  175. package/src/stock-operations/stock-operations-forms/stock-operations-form-utils.ts +1 -1
  176. package/src/stock-operations/stock-operations-table.component.tsx +1 -1
  177. package/src/stock-operations/stock-operations-table.resource.tsx +1 -1
  178. package/src/stock-operations/stock-operations.resource.ts +9 -9
  179. package/src/stock-operations/stock-print-reports/GoodsReceivedNote.tsx +1 -1
  180. package/src/stock-operations/stock-print-reports/RequisitionDocument.tsx +1 -1
  181. package/src/stock-operations/stock-print-reports/StockOperationReport.tsx +4 -4
  182. package/src/stock-operations/stock-print-reports/StockTransferDocument.tsx +1 -1
  183. package/src/stock-reports/generate-report/create-stock-report.component.tsx +3 -3
  184. package/src/stock-reports/stock-reports.resource.ts +1 -1
  185. package/src/stock-sources/add-stock-sources/add-stock-sources.component.tsx +2 -2
  186. package/src/stock-sources/add-stock-sources/add-stock-sources.test.tsx +2 -2
  187. package/src/stock-sources/edit-stock-source/edit-stock-source.component.tsx +1 -1
  188. package/src/stock-sources/stock-sources-items-table.resource.ts +1 -1
  189. package/src/stock-sources/stock-sources.resource.ts +3 -3
  190. package/src/stock-user-role-scopes/add-stock-user-scope/add-stock-user-role-scope.component.tsx +7 -7
  191. package/src/stock-user-role-scopes/edit-stock-user-scope/edit-stock-user-scope-action-menu.component.tsx +1 -1
  192. package/src/stock-user-role-scopes/stock-user-role-scopes-items-table.resource.ts +1 -1
  193. package/src/stock-user-role-scopes/stock-user-role-scopes.resource.ts +3 -3
  194. package/dist/600.js +0 -1
  195. package/dist/600.js.map +0 -1
  196. package/dist/880.js.map +0 -1
@@ -1,33 +1,30 @@
1
1
  import {
2
- ModalHeader,
3
- ModalBody,
4
- ModalFooter,
5
2
  Button,
3
+ ButtonSet,
4
+ Checkbox,
5
+ CheckboxGroup,
6
6
  Form,
7
+ FormGroup,
7
8
  Select,
8
- TextInput,
9
9
  SelectItem,
10
- FormGroup,
11
- Checkbox,
12
- CheckboxGroup,
10
+ TextInput,
13
11
  } from '@carbon/react';
14
- import React, { ChangeEvent, useCallback, useState, useEffect } from 'react';
15
- import styles from './add-stock-rules.scss';
16
- import { useRoles, useStockTagLocations } from '../../../stock-lookups/stock-lookups.resource';
17
- import { createOrUpdateStockRule } from './stock-rules.resource';
18
- import { StockRule } from '../../../core/api/types/stockItem/StockRule';
19
- import { showSnackbar } from '@openmrs/esm-framework';
12
+ import { type DefaultWorkspaceProps, showSnackbar } from '@openmrs/esm-framework';
13
+ import React, { type ChangeEvent, useCallback, useEffect, useState } from 'react';
20
14
  import { useTranslation } from 'react-i18next';
21
- import { closeOverlay } from '../../../core/components/overlay/hook';
22
15
  import { ResourceRepresentation } from '../../../core/api/api';
23
- import { StockItemInventoryFilter, useStockItemPackagingUOMs } from '../../stock-items.resource';
16
+ import { type StockRule } from '../../../core/api/types/stockItem/StockRule';
17
+ import { useRoles, useStockTagLocations } from '../../../stock-lookups/stock-lookups.resource';
18
+ import { type StockItemInventoryFilter, useStockItemPackagingUOMs } from '../../stock-items.resource';
19
+ import styles from './add-stock-rules.scss';
20
+ import { createOrUpdateStockRule } from './stock-rules.resource';
24
21
 
25
- interface AddStockRuleProps {
22
+ interface AddStockRuleProps extends Partial<DefaultWorkspaceProps> {
26
23
  model?: StockRule;
27
24
  stockItemUuid?: string;
28
25
  }
29
26
 
30
- const StockRulesAddOrUpdate: React.FC<AddStockRuleProps> = ({ model, stockItemUuid }) => {
27
+ const StockRulesAddOrUpdate: React.FC<AddStockRuleProps> = ({ model, stockItemUuid, closeWorkspace }) => {
31
28
  const { t } = useTranslation();
32
29
 
33
30
  const [stockItemFilter, setStockItemFilter] = useState<StockItemInventoryFilter>({
@@ -99,7 +96,7 @@ const StockRulesAddOrUpdate: React.FC<AddStockRuleProps> = ({ model, stockItemUu
99
96
  const selectedQuantityUnit = dispensingUnits?.results.find((x) => x.uuid === evt.target.value);
100
97
  setFormModel({
101
98
  ...formModel,
102
- stockItemPackagingUOMUuid: selectedQuantityUnit.uuid,
99
+ stockItemPackagingUOMUuid: selectedQuantityUnit?.uuid,
103
100
  });
104
101
  };
105
102
 
@@ -142,7 +139,7 @@ const StockRulesAddOrUpdate: React.FC<AddStockRuleProps> = ({ model, stockItemUu
142
139
  kind: 'success',
143
140
  subtitle: t('stockRuleAddedSuccessfully', 'Stock Rule Added Successfully'),
144
141
  });
145
- closeOverlay();
142
+ closeWorkspace?.();
146
143
  },
147
144
  (error) => {
148
145
  showSnackbar({
@@ -155,179 +152,178 @@ const StockRulesAddOrUpdate: React.FC<AddStockRuleProps> = ({ model, stockItemUu
155
152
  )
156
153
  .catch();
157
154
  },
158
- [formModel, model, t, stockItemUuid],
155
+ [formModel, model, t, stockItemUuid, closeWorkspace],
159
156
  );
160
157
 
161
158
  return (
162
- <div>
163
- <Form onSubmit={onFormSubmit}>
164
- <ModalHeader />
165
- <ModalBody>
166
- <FormGroup>
167
- <section className={styles.section}>
168
- <section className={styles.section}>
169
- <Select
170
- name="location"
171
- className="select-field"
172
- labelText={t('location', 'Location')}
173
- id="location"
174
- value={formModel?.locationUuid ? formModel.locationUuid : ''}
175
- onChange={onLocationChange}
176
- >
177
- <SelectItem disabled hidden value="" text={t('chooseLocation', 'Choose the location')} />
178
- {stockLocations?.map((location) => {
179
- return <SelectItem key={location.id} value={location.id} text={location.name} />;
180
- })}
181
- </Select>
182
- </section>
183
-
184
- <section className={styles.section}>
185
- <TextInput
186
- id="name"
187
- type="text"
188
- labelText={t('name', 'Rule Name')}
189
- size="md"
190
- onChange={onNameChanged}
191
- value={model?.name}
192
- placeholder="e.g Panado Alert"
193
- />
194
- </section>
195
-
196
- <section className={styles.section}>
197
- <Select
198
- name="quantityUnit"
199
- className="select-field"
200
- labelText={t('quantityUnit', 'Quantity Unit')}
201
- id="quantityUnit"
202
- value={formModel?.stockItemPackagingUOMUuid ? formModel.stockItemPackagingUOMUuid : ''}
203
- onChange={onQuantityUnitChange}
204
- >
205
- <SelectItem disabled hidden value="" text={t('chooseQuantityUnit', 'Choose the Unit of Quantity')} />
206
- {dispensingUnits?.results.map((stockItemPackagingUOMUuid) => {
207
- return (
208
- <SelectItem
209
- key={stockItemPackagingUOMUuid.uuid}
210
- value={stockItemPackagingUOMUuid.uuid}
211
- text={stockItemPackagingUOMUuid.packagingUomName}
212
- />
213
- );
214
- })}
215
- </Select>
216
- </section>
217
-
218
- <section className={styles.section}>
219
- <TextInput
220
- id="quantity"
221
- type="number"
222
- labelText={t('quantity', 'Quantity Threshold')}
223
- size="md"
224
- onChange={onQuantityChanged}
225
- value={model?.quantity}
226
- placeholder="e.g 30 Boxes"
227
- />
228
- </section>
229
- </section>
230
- </FormGroup>
231
-
232
- <FormGroup>
159
+ <Form onSubmit={onFormSubmit} className={styles.formContainer}>
160
+ <div>
161
+ <FormGroup>
162
+ <section className={styles.section}>
233
163
  <section className={styles.section}>
234
164
  <Select
235
- name="alertRole"
165
+ name="location"
236
166
  className="select-field"
237
- labelText={t('alertRole', 'Alert Role')}
238
- id="alertRole"
239
- value={formModel?.alertRole ? formModel.alertRole : ''}
240
- onChange={onAlertRoleChange}
167
+ labelText={t('location', 'Location')}
168
+ id="location"
169
+ value={formModel?.locationUuid ? formModel.locationUuid : ''}
170
+ onChange={onLocationChange}
241
171
  >
242
- <SelectItem disabled hidden value="" text={t('chooseAlertRole', 'Choose an Alert Role')} />
243
- {rolesData?.results?.map((alertRole) => {
244
- return <SelectItem key={alertRole.display} value={alertRole.display} text={alertRole.display} />;
172
+ <SelectItem disabled hidden value="" text={t('chooseLocation', 'Choose the location')} />
173
+ {stockLocations?.map((location) => {
174
+ return <SelectItem key={location.id} value={location.id} text={location.name} />;
245
175
  })}
246
176
  </Select>
247
177
  </section>
178
+
179
+ <section className={styles.section}>
180
+ <TextInput
181
+ id="name"
182
+ type="text"
183
+ labelText={t('name', 'Rule Name')}
184
+ size="md"
185
+ onChange={onNameChanged}
186
+ value={model?.name}
187
+ placeholder="e.g Panado Alert"
188
+ />
189
+ </section>
190
+
248
191
  <section className={styles.section}>
249
192
  <Select
250
- name="mailRole"
193
+ name="quantityUnit"
251
194
  className="select-field"
252
- labelText={t('mailRole', 'Mail Role')}
253
- id="mailRole"
254
- value={formModel?.mailRole ? formModel.mailRole : ''}
255
- onChange={onMailRoleChange}
195
+ labelText={t('quantityUnit', 'Quantity Unit')}
196
+ id="quantityUnit"
197
+ value={formModel?.stockItemPackagingUOMUuid ? formModel.stockItemPackagingUOMUuid : ''}
198
+ onChange={onQuantityUnitChange}
256
199
  >
257
- <SelectItem disabled hidden value="" text={t('chooseMailRole', 'Choose a Mail Role')} />
258
- {rolesData?.results?.map((mailRole) => {
259
- return <SelectItem key={mailRole.display} value={mailRole.display} text={mailRole.display} />;
200
+ <SelectItem disabled hidden value="" text={t('chooseQuantityUnit', 'Choose the Unit of Quantity')} />
201
+ {dispensingUnits?.results?.map((stockItemPackagingUOMUuid) => {
202
+ return (
203
+ <SelectItem
204
+ key={stockItemPackagingUOMUuid.uuid}
205
+ value={stockItemPackagingUOMUuid.uuid}
206
+ text={stockItemPackagingUOMUuid.packagingUomName}
207
+ />
208
+ );
260
209
  })}
261
210
  </Select>
262
211
  </section>
212
+
263
213
  <section className={styles.section}>
264
214
  <TextInput
265
- id="evaluationFrequency"
215
+ id="quantity"
266
216
  type="number"
267
- labelText={t('evaluationFrequency', 'Frequency Check (Minutes)')}
217
+ labelText={t('quantity', 'Quantity Threshold')}
268
218
  size="md"
269
- onChange={onEvaluationFrequencyChanged}
270
- value={model?.evaluationFrequency}
271
- placeholder="e.g 30 Minutes"
272
- />
273
- <TextInput
274
- id="actionFrequency"
275
- type="number"
276
- labelText={t('actionFrequency', 'Notification Frequency (Minutes)')}
277
- size="md"
278
- onChange={onActionFrequencyChanged}
279
- value={model?.actionFrequency}
280
- placeholder="e.g 3600 Minutes"
219
+ onChange={onQuantityChanged}
220
+ value={model?.quantity}
221
+ placeholder="e.g 30 Boxes"
281
222
  />
282
223
  </section>
283
- </FormGroup>
224
+ </section>
225
+ </FormGroup>
226
+
227
+ <FormGroup>
228
+ <section className={styles.section}>
229
+ <Select
230
+ name="alertRole"
231
+ className="select-field"
232
+ labelText={t('alertRole', 'Alert Role')}
233
+ id="alertRole"
234
+ value={formModel?.alertRole ? formModel.alertRole : ''}
235
+ onChange={onAlertRoleChange}
236
+ >
237
+ <SelectItem disabled hidden value="" text={t('chooseAlertRole', 'Choose an Alert Role')} />
238
+ {rolesData?.results?.map((alertRole) => {
239
+ return <SelectItem key={alertRole.display} value={alertRole.display} text={alertRole.display} />;
240
+ })}
241
+ </Select>
242
+ </section>
243
+ <section className={styles.section}>
244
+ <Select
245
+ name="mailRole"
246
+ className="select-field"
247
+ labelText={t('mailRole', 'Mail Role')}
248
+ id="mailRole"
249
+ value={formModel?.mailRole ? formModel.mailRole : ''}
250
+ onChange={onMailRoleChange}
251
+ >
252
+ <SelectItem disabled hidden value="" text={t('chooseMailRole', 'Choose a Mail Role')} />
253
+ {rolesData?.results?.map((mailRole) => {
254
+ return <SelectItem key={mailRole.display} value={mailRole.display} text={mailRole.display} />;
255
+ })}
256
+ </Select>
257
+ </section>
258
+ <section className={styles.section}>
259
+ <TextInput
260
+ id="evaluationFrequency"
261
+ type="number"
262
+ labelText={t('evaluationFrequency', 'Frequency Check (Minutes)')}
263
+ size="md"
264
+ onChange={onEvaluationFrequencyChanged}
265
+ value={model?.evaluationFrequency}
266
+ placeholder="e.g 30 Minutes"
267
+ />
268
+ <TextInput
269
+ id="actionFrequency"
270
+ type="number"
271
+ labelText={t('actionFrequency', 'Notification Frequency (Minutes)')}
272
+ size="md"
273
+ onChange={onActionFrequencyChanged}
274
+ value={model?.actionFrequency}
275
+ placeholder="e.g 3600 Minutes"
276
+ />
277
+ </section>
278
+ </FormGroup>
284
279
 
285
- <div
286
- style={{
287
- display: 'grid',
288
- gridTemplateColumns: '1fr 1fr',
289
- justifyContent: 'center',
290
- }}
291
- >
292
- <FormGroup className="clear-margin-bottom">
293
- <CheckboxGroup className={styles.checkboxGrid}>
294
- <Checkbox
295
- onChange={onEnabledChanged}
296
- checked={formModel?.enabled}
297
- labelText={`Enabled ?`}
298
- value={model?.enabled}
299
- id="chk-ruleEnabled"
300
- />
301
- </CheckboxGroup>
302
- </FormGroup>
303
- <FormGroup className="clear-margin-bottom">
304
- <CheckboxGroup className={styles.checkboxGrid}>
305
- <Checkbox
306
- onChange={onAppliesToChildrenChanged}
307
- name="appliesToChildren"
308
- checked={formModel?.enableDescendants}
309
- value={model?.enableDescendants}
310
- labelText={`Applies to child locations?`}
311
- id="chk-ruleAppliesToChildren"
312
- />
313
- </CheckboxGroup>
314
- </FormGroup>
315
- </div>
280
+ <div
281
+ style={{
282
+ display: 'grid',
283
+ gridTemplateColumns: '1fr 1fr',
284
+ justifyContent: 'center',
285
+ }}
286
+ >
287
+ <FormGroup className="clear-margin-bottom">
288
+ <CheckboxGroup className={styles.checkboxGrid}>
289
+ <Checkbox
290
+ onChange={onEnabledChanged}
291
+ checked={formModel?.enabled}
292
+ labelText={`Enabled ?`}
293
+ value={model?.enabled}
294
+ id="chk-ruleEnabled"
295
+ />
296
+ </CheckboxGroup>
297
+ </FormGroup>
298
+ <FormGroup className="clear-margin-bottom">
299
+ <CheckboxGroup className={styles.checkboxGrid}>
300
+ <Checkbox
301
+ onChange={onAppliesToChildrenChanged}
302
+ name="appliesToChildren"
303
+ checked={formModel?.enableDescendants}
304
+ value={model?.enableDescendants}
305
+ labelText={`Applies to child locations?`}
306
+ id="chk-ruleAppliesToChildren"
307
+ />
308
+ </CheckboxGroup>
309
+ </FormGroup>
310
+ </div>
316
311
 
317
- <div>
318
- This stock rule will be evaluated by checking if the stock quantities have lowered to the threshold or below
319
- and a notification will be sent to the personnel with the specified role in the given location. The
320
- notification will only be sent once per specified notification frequency.
321
- </div>
322
- </ModalBody>
323
- <ModalFooter>
324
- <Button kind="secondary" onClick={closeOverlay}>
325
- {t('cancel', 'Cancel')}
326
- </Button>
327
- <Button type="submit">{t('save', 'Save')}</Button>
328
- </ModalFooter>
329
- </Form>
330
- </div>
312
+ <div>
313
+ This stock rule will be evaluated by checking if the stock quantities have lowered to the threshold or below
314
+ and a notification will be sent to the personnel with the specified role in the given location. The
315
+ notification will only be sent once per specified notification frequency.
316
+ </div>
317
+ </div>
318
+ <ButtonSet className={styles.buttonSet}>
319
+ <Button kind="secondary" onClick={closeWorkspace} className={styles.button}>
320
+ {t('cancel', 'Cancel')}
321
+ </Button>
322
+ <Button type="submit" className={styles.button}>
323
+ {t('save', 'Save')}
324
+ </Button>
325
+ </ButtonSet>
326
+ </Form>
331
327
  );
332
328
  };
333
329
 
@@ -1,17 +1,25 @@
1
- @use '@carbon/styles/scss/spacing';
2
- @use '@carbon/styles/scss/type';
3
- @use '@openmrs/esm-styleguide/src/vars' as *;
1
+ @use '@carbon/type';
2
+ @use '@carbon/layout';
3
+ @use '@carbon/colors';
4
4
 
5
- .section {
6
- margin: spacing.$spacing-03;
5
+ .formContainer {
6
+ display: flex;
7
+ flex-direction: column;
8
+ justify-content: space-between;
9
+ width: 100%;
10
+ height: 100%;
11
+ padding: layout.$spacing-03;
7
12
  }
8
13
 
9
- .sectionTitle {
10
- @include type.type-style('heading-compact-02');
11
- color: $text-02;
12
- margin-bottom: spacing.$spacing-04;
14
+ .button {
15
+ display: flex;
16
+ align-content: flex-start;
17
+ align-items: baseline;
18
+ min-width: 50%;
13
19
  }
14
20
 
15
- .modalBody {
16
- padding-bottom: spacing.$spacing-05;
21
+ .buttonSet {
22
+ display: flex;
23
+ justify-content: space-between;
24
+ width: 100%;
17
25
  }
@@ -1,11 +1,10 @@
1
- import React, { useCallback } from 'react';
2
1
  import { Button } from '@carbon/react';
3
2
  import { Edit } from '@carbon/react/icons';
3
+ import React, { useCallback } from 'react';
4
4
 
5
+ import { launchWorkspace } from '@openmrs/esm-framework';
5
6
  import { useTranslation } from 'react-i18next';
6
- import { launchOverlay } from '../../../core/components/overlay/hook';
7
- import StockRulesAddOrUpdate from './add-stock-rules.component';
8
- import { StockRule } from '../../../core/api/types/stockItem/StockRule';
7
+ import { type StockRule } from '../../../core/api/types/stockItem/StockRule';
9
8
 
10
9
  interface EditStockRulesActionMenuProps {
11
10
  data?: StockRule;
@@ -15,8 +14,12 @@ interface EditStockRulesActionMenuProps {
15
14
  const EditStockRuleActionsMenu: React.FC<EditStockRulesActionMenuProps> = ({ data, stockItemUuid }) => {
16
15
  const { t } = useTranslation();
17
16
  const handleClick = useCallback(() => {
18
- launchOverlay('Edit Stock Rule', <StockRulesAddOrUpdate model={data} stockItemUuid={data.stockItemUuid} />);
19
- }, [data]);
17
+ launchWorkspace('stock-item-rules-form-workspace', {
18
+ workspaceTitle: t('editStockRule', 'Edit Stock Rule'),
19
+ stockItemUuid,
20
+ model: data,
21
+ });
22
+ }, [data, t, stockItemUuid]);
20
23
 
21
24
  return (
22
25
  <Button
@@ -21,7 +21,7 @@ import {
21
21
  } from '@carbon/react';
22
22
  import { formatDisplayDate } from '../../../core/utils/datetimeUtils';
23
23
  import styles from '../../stock-items-table.scss';
24
- import { StockRule } from '../../../core/api/types/stockItem/StockRule';
24
+ import { type StockRule } from '../../../core/api/types/stockItem/StockRule';
25
25
  import AddStockRuleActionButton from './add-stock-rule-button.component';
26
26
  import { isDesktop } from '@openmrs/esm-framework';
27
27
  import StockRulesFilter from './stock-rules-filter.component';
@@ -1,5 +1,5 @@
1
1
  import { useMemo, useState } from 'react';
2
- import { StockRuleFilter, useStockRules } from '../../stock-items.resource';
2
+ import { type StockRuleFilter, useStockRules } from '../../stock-items.resource';
3
3
  import { usePagination } from '@openmrs/esm-framework';
4
4
 
5
5
  export function useStockItemRules(filter: StockRuleFilter) {
@@ -1,8 +1,8 @@
1
1
  import { openmrsFetch, restBaseUrl } from '@openmrs/esm-framework';
2
- import { ResourceFilterCriteria, toQueryParams } from '../../../core/api/api';
2
+ import { type ResourceFilterCriteria, toQueryParams } from '../../../core/api/api';
3
3
  import useSWR from 'swr';
4
- import { PageableResult } from '../../../core/api/types/PageableResult';
5
- import { StockRule } from '../../../core/api/types/stockItem/StockRule';
4
+ import { type PageableResult } from '../../../core/api/types/PageableResult';
5
+ import { type StockRule } from '../../../core/api/types/stockItem/StockRule';
6
6
 
7
7
  export interface StockSourceFilter extends ResourceFilterCriteria {
8
8
  stockItemUuid?: string | null;
@@ -2,8 +2,8 @@ import React from 'react';
2
2
  import { useTranslation } from 'react-i18next';
3
3
  import { useStockItem } from '../../stock-items.resource';
4
4
  import DispensingPackageMeasurement from '../dispensing-package-measurement/dispensing-package-measurement.component';
5
- import { Control, FormState } from 'react-hook-form';
6
- import { StockItemFormData } from '../../validationSchema';
5
+ import { type Control, type FormState } from 'react-hook-form';
6
+ import { type StockItemFormData } from '../../validationSchema';
7
7
  import ControlledNumberInput from '../../../core/components/carbon/controlled-number-input/controlled-number-input.component';
8
8
  import { NumberInputSkeleton } from '@carbon/react';
9
9
 
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { useEffect, useMemo, useState } from 'react';
2
2
  import { Button, Stack, ComboButton, MenuItem } from '@carbon/react';
3
3
  import { Printer } from '@carbon/react/icons';
4
4
  import { useTranslation } from 'react-i18next';
@@ -6,8 +6,7 @@ import { useStockItem } from '../../../stock-items.resource';
6
6
  import { showModal, useConfig } from '@openmrs/esm-framework';
7
7
  import { type ConfigObject } from '../../../../config-schema';
8
8
  import styles from './printable-transaction.scss';
9
- import { useEffect, useMemo, useState } from 'react';
10
- import { StockItemInventoryFilter, useStockItemTransactions } from '../../../stock-items.resource';
9
+ import { type StockItemInventoryFilter, useStockItemTransactions } from '../../../stock-items.resource';
11
10
  import { ResourceRepresentation } from '../../../../core/api/api';
12
11
 
13
12
  type Props = {
@@ -1,6 +1,6 @@
1
- import React, { ReactNode } from 'react';
1
+ import React, { type ReactNode } from 'react';
2
2
  import { ComboBox } from '@carbon/react';
3
- import { Control, Controller, FieldValues } from 'react-hook-form';
3
+ import { type Control, Controller, type FieldValues } from 'react-hook-form';
4
4
  import { useTranslation } from 'react-i18next';
5
5
  import { useStockTagLocations } from '../../../../stock-lookups/stock-lookups.resource';
6
6
 
@@ -5,7 +5,7 @@ import { useForm } from 'react-hook-form';
5
5
  import { useTranslation } from 'react-i18next';
6
6
  import DataList from '../../../core/components/table/table.component';
7
7
  import { formatDisplayDate } from '../../../core/utils/datetimeUtils';
8
- import { StockItemInventoryFilter } from '../../stock-items.resource';
8
+ import { type StockItemInventoryFilter } from '../../stock-items.resource';
9
9
  import TransactionsPrintAction from './printout/transactions-print-action.component';
10
10
  import TransactionsLocationsFilter from './transaction-filters/transaction-locations-filter.component';
11
11
  import { useStockItemsTransactions } from './transactions.resource';
@@ -1,6 +1,6 @@
1
1
  import { ResourceRepresentation } from '../../../core/api/api';
2
2
  import { useEffect, useMemo, useState } from 'react';
3
- import { StockItemInventoryFilter, useStockItemTransactions } from '../../stock-items.resource';
3
+ import { type StockItemInventoryFilter, useStockItemTransactions } from '../../stock-items.resource';
4
4
 
5
5
  export function useStockItemsTransactions(filter?: StockItemInventoryFilter) {
6
6
  const [stockItemFilter, setStockItemFilter] = useState<StockItemInventoryFilter>({
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
2
  import { Button } from '@carbon/react';
3
3
  import { useTranslation } from 'react-i18next';
4
- import { StockItemDTO } from '../../core/api/types/stockItem/StockItem';
5
- import { launchAddOrEditDialog } from '../stock-item.utils';
4
+ import { type StockItemDTO } from '../../core/api/types/stockItem/StockItem';
5
+ import { launchAddOrStockItemWorkspace } from '../stock-item.utils';
6
6
 
7
7
  interface EditStockItemActionsMenuProps {
8
8
  data: StockItemDTO;
@@ -17,7 +17,7 @@ const EditStockItemActionsMenu: React.FC<EditStockItemActionsMenuProps> = ({ dat
17
17
  size="md"
18
18
  onClick={() => {
19
19
  data.isDrug = !!data.drugUuid;
20
- launchAddOrEditDialog(t, data, true);
20
+ launchAddOrStockItemWorkspace(t, data);
21
21
  }}
22
22
  iconDescription={t('editStockItem', 'Edit Stock Item')}
23
23
  >
@@ -1,57 +1,14 @@
1
- import React from 'react';
2
- import { closeOverlay, launchOverlay } from '../core/components/overlay/hook';
3
- import { StockItemDTO } from '../core/api/types/stockItem/StockItem';
1
+ import { launchWorkspace } from '@openmrs/esm-framework';
4
2
  import { type TFunction } from 'react-i18next';
5
- import AddEditStockItem from './add-stock-item/add-stock-item.component';
6
- import { FetchResponse, showSnackbar } from '@openmrs/esm-framework';
7
- import { createStockItem, updateStockItem } from './stock-items.resource';
3
+ import { type StockItemDTO } from '../core/api/types/stockItem/StockItem';
8
4
 
9
- export const addOrEditStockItem = async (t: TFunction, stockItem: StockItemDTO, isEditing = false) => {
10
- try {
11
- const response: FetchResponse<StockItemDTO> = await (isEditing ? updateStockItem : createStockItem)(stockItem);
12
-
13
- if (response?.data) {
14
- showSnackbar({
15
- isLowContrast: true,
16
- title: isEditing ? `${t('editStockItem', 'Edit Stock Item')}` : `${t('addStockItem', 'Add Stock Item')}`,
17
- kind: 'success',
18
- subtitle: isEditing
19
- ? `${t('stockItemEdited', 'Stock Item Edited Successfully')}`
20
- : `${t('stockItemAdded', 'Stock Item Added Successfully')}`,
21
- });
22
-
23
- if (!isEditing) {
24
- closeOverlay();
25
-
26
- // launch edit dialog
27
- const item = response.data;
28
- item.isDrug = !!item.drugUuid;
29
- launchAddOrEditDialog(t, item, true);
30
- }
31
- }
32
- } catch (error) {
33
- showSnackbar({
34
- title: isEditing
35
- ? t('errorEditingStockItem', 'Error editing a stock Item')
36
- : t('errorAddingStockItem', 'Error adding a stock Item'),
37
- kind: 'error',
38
- isLowContrast: true,
39
- subtitle: error?.responseBody?.error?.message,
40
- });
41
- }
42
- };
43
-
44
- export const launchAddOrEditDialog = (t: TFunction, stockItem: StockItemDTO, isEditing = false) => {
45
- launchOverlay(
46
- isEditing
5
+ export const launchAddOrStockItemWorkspace = (t: TFunction, stockItem?: StockItemDTO) => {
6
+ launchWorkspace('stock-item-form-workspace', {
7
+ workspaceTitle: stockItem
47
8
  ? `${t('editItem', 'Edit {{name}}', {
48
9
  name: stockItem?.drugName || stockItem.conceptName || '',
49
10
  })} ${stockItem.isDrug ? '(Drug)' : '(Non Drug)'}`
50
11
  : t('addItem', 'Add stock item'),
51
- <AddEditStockItem
52
- model={stockItem}
53
- onSave={(stockItem) => addOrEditStockItem(t, stockItem, isEditing)}
54
- isEditing={isEditing}
55
- />,
56
- );
12
+ stockItem,
13
+ });
57
14
  };