@openmrs/esm-stock-management-app 1.0.1-pre.327
Sign up to get free protection for your applications and to get access to all the features.
- package/.editorconfig +12 -0
- package/.eslintignore +2 -0
- package/.eslintrc +39 -0
- package/.husky/pre-commit +4 -0
- package/.husky/pre-push +6 -0
- package/.prettierignore +14 -0
- package/.turbo.json +18 -0
- package/.yarn/plugins/@yarnpkg/plugin-outdated.cjs +35 -0
- package/LICENSE +401 -0
- package/README.md +3 -0
- package/__mocks__/react-i18next.js +55 -0
- package/dist/26.js +2 -0
- package/dist/26.js.LICENSE.txt +32 -0
- package/dist/26.js.map +1 -0
- package/dist/294.js +2 -0
- package/dist/294.js.LICENSE.txt +9 -0
- package/dist/294.js.map +1 -0
- package/dist/375.js +2 -0
- package/dist/375.js.LICENSE.txt +40 -0
- package/dist/375.js.map +1 -0
- package/dist/46.js +1 -0
- package/dist/46.js.map +1 -0
- package/dist/484.js +1 -0
- package/dist/484.js.map +1 -0
- package/dist/574.js +1 -0
- package/dist/629.js +1 -0
- package/dist/629.js.map +1 -0
- package/dist/707.js +1 -0
- package/dist/707.js.map +1 -0
- package/dist/800.js +2 -0
- package/dist/800.js.LICENSE.txt +3 -0
- package/dist/800.js.map +1 -0
- package/dist/935.js +2 -0
- package/dist/935.js.LICENSE.txt +19 -0
- package/dist/935.js.map +1 -0
- package/dist/979.js +1 -0
- package/dist/979.js.map +1 -0
- package/dist/main.js +2 -0
- package/dist/main.js.LICENSE.txt +60 -0
- package/dist/main.js.map +1 -0
- package/dist/openmrs-esm-stock-management-app.js +1 -0
- package/dist/openmrs-esm-stock-management-app.js.buildmanifest.json +356 -0
- package/dist/openmrs-esm-stock-management-app.js.map +1 -0
- package/dist/routes.json +1 -0
- package/i18next-parser.config.js +89 -0
- package/jest.config.js +25 -0
- package/package.json +116 -0
- package/src/config-schema.ts +18 -0
- package/src/constants.ts +214 -0
- package/src/core/api/api.ts +34 -0
- package/src/core/api/types/Auditable.ts +9 -0
- package/src/core/api/types/BaseOpenmrsData.ts +4 -0
- package/src/core/api/types/BaseOpenmrsMetadata.ts +6 -0
- package/src/core/api/types/BaseOpenmrsObject.ts +3 -0
- package/src/core/api/types/BatchJob.ts +121 -0
- package/src/core/api/types/DashboardExtension.ts +8 -0
- package/src/core/api/types/Location.ts +16 -0
- package/src/core/api/types/LocationTree.ts +7 -0
- package/src/core/api/types/OpenmrsData.ts +5 -0
- package/src/core/api/types/OpenmrsMetadata.ts +8 -0
- package/src/core/api/types/OpenmrsObject.ts +3 -0
- package/src/core/api/types/PageableResult.ts +15 -0
- package/src/core/api/types/Party.ts +8 -0
- package/src/core/api/types/RecordPermission.ts +9 -0
- package/src/core/api/types/Retireable.ts +9 -0
- package/src/core/api/types/Voidable.ts +9 -0
- package/src/core/api/types/concept/Concept.ts +24 -0
- package/src/core/api/types/concept/ConceptName.ts +14 -0
- package/src/core/api/types/concept/Drug.ts +14 -0
- package/src/core/api/types/identity/Credentials.ts +4 -0
- package/src/core/api/types/identity/Patient.ts +3 -0
- package/src/core/api/types/identity/Person.ts +4 -0
- package/src/core/api/types/identity/PriviledgeScope.ts +9 -0
- package/src/core/api/types/identity/Privilege.ts +5 -0
- package/src/core/api/types/identity/Role.ts +5 -0
- package/src/core/api/types/identity/Session.ts +16 -0
- package/src/core/api/types/identity/User.ts +19 -0
- package/src/core/api/types/identity/UserRoleScope.ts +17 -0
- package/src/core/api/types/identity/UserRoleScopeLocation.ts +7 -0
- package/src/core/api/types/identity/UserRoleScopeOperationType.ts +6 -0
- package/src/core/api/types/stockItem/ImportResult.ts +9 -0
- package/src/core/api/types/stockItem/StockBatch.ts +8 -0
- package/src/core/api/types/stockItem/StockBatchDTO.ts +8 -0
- package/src/core/api/types/stockItem/StockItem.ts +63 -0
- package/src/core/api/types/stockItem/StockItemInventory.ts +10 -0
- package/src/core/api/types/stockItem/StockItemPackagingUOM.ts +20 -0
- package/src/core/api/types/stockItem/StockItemTransaction.ts +22 -0
- package/src/core/api/types/stockItem/StockRule.ts +28 -0
- package/src/core/api/types/stockOperation/LocationType.ts +4 -0
- package/src/core/api/types/stockOperation/StockOperation.ts +36 -0
- package/src/core/api/types/stockOperation/StockOperationAction.ts +24 -0
- package/src/core/api/types/stockOperation/StockOperationDTO.ts +64 -0
- package/src/core/api/types/stockOperation/StockOperationItem.ts +13 -0
- package/src/core/api/types/stockOperation/StockOperationItemCost.ts +14 -0
- package/src/core/api/types/stockOperation/StockOperationItemDTO.ts +29 -0
- package/src/core/api/types/stockOperation/StockOperationLinkDTO.ts +13 -0
- package/src/core/api/types/stockOperation/StockOperationStatus.ts +18 -0
- package/src/core/api/types/stockOperation/StockOperationType.ts +162 -0
- package/src/core/api/types/stockOperation/StockSource.ts +8 -0
- package/src/core/components/carbon/controlled-combo-box/controlled-combo-box.component.tsx +37 -0
- package/src/core/components/carbon/controlled-combo-box/controlled-combo-box.resource.tsx +0 -0
- package/src/core/components/carbon/controlled-combo-box/controlled-combo-box.scss +0 -0
- package/src/core/components/carbon/controlled-combo-box/controlled-combo-box.test.tsx +8 -0
- package/src/core/components/carbon/controlled-dropdown/controlled-dropdown.component.tsx +40 -0
- package/src/core/components/carbon/controlled-dropdown/controlled-dropdown.resource.tsx +0 -0
- package/src/core/components/carbon/controlled-dropdown/controlled-dropdown.scss +0 -0
- package/src/core/components/carbon/controlled-dropdown/controlled-dropdown.test.tsx +8 -0
- package/src/core/components/carbon/controlled-number-input/controlled-number-input.component.tsx +44 -0
- package/src/core/components/carbon/controlled-number-input/controlled-number-input.resource.tsx +0 -0
- package/src/core/components/carbon/controlled-number-input/controlled-number-input.scss +0 -0
- package/src/core/components/carbon/controlled-number-input/controlled-number-input.test.tsx +8 -0
- package/src/core/components/carbon/controlled-radio-button-group/controlled-radio-button-group.component.tsx +54 -0
- package/src/core/components/carbon/controlled-radio-button-group/controlled-radio-button-group.resource.tsx +0 -0
- package/src/core/components/carbon/controlled-radio-button-group/controlled-radio-button-group.scss +0 -0
- package/src/core/components/carbon/controlled-radio-button-group/controlled-radio-button-group.test.tsx +8 -0
- package/src/core/components/carbon/controlled-text-area/controlled-text-area.component.tsx +37 -0
- package/src/core/components/carbon/controlled-text-area/controlled-text-area.resource.tsx +0 -0
- package/src/core/components/carbon/controlled-text-area/controlled-text-area.scss +0 -0
- package/src/core/components/carbon/controlled-text-area/controlled-text-area.test.tsx +11 -0
- package/src/core/components/carbon/controlled-text-input/controlled-text-input.component.tsx +37 -0
- package/src/core/components/carbon/controlled-text-input/controlled-text-input.resource.tsx +0 -0
- package/src/core/components/carbon/controlled-text-input/controlled-text-input.scss +0 -0
- package/src/core/components/carbon/controlled-text-input/controlled-text-input.test.tsx +8 -0
- package/src/core/components/carbon/types.ts +7 -0
- package/src/core/components/card/metrics-card-component.tsx +102 -0
- package/src/core/components/card/metrics-card.scss +78 -0
- package/src/core/components/overlay/hook.ts +47 -0
- package/src/core/components/overlay/overlay.component.tsx +52 -0
- package/src/core/components/overlay/overlay.scss +97 -0
- package/src/core/components/side-nav/side-nav.component.tsx +62 -0
- package/src/core/components/side-nav/side-nav.scss +126 -0
- package/src/core/components/side-nav/types.ts +6 -0
- package/src/core/components/table/table.component.tsx +239 -0
- package/src/core/components/table/table.scss +173 -0
- package/src/core/components/table/types.ts +8 -0
- package/src/core/components/tabs/types.ts +7 -0
- package/src/core/components/tabs/vertical-tabs.component.tsx +53 -0
- package/src/core/components/tabs/vertical-tabs.scss +126 -0
- package/src/core/hooks/debounce-hook.ts +35 -0
- package/src/core/print/PrintStyles.ts +774 -0
- package/src/core/print/PrintTemplate.ts +65 -0
- package/src/core/print/printUtils.ts +19 -0
- package/src/core/utils/alert.ts +10 -0
- package/src/core/utils/datetimeUtils.ts +84 -0
- package/src/core/utils/debounce.ts +21 -0
- package/src/core/utils/imageUtils.ts +82 -0
- package/src/core/utils/stringUtils.ts +27 -0
- package/src/core/utils/utils.ts +70 -0
- package/src/createDashboardLink.tsx +43 -0
- package/src/dashboard/stock-management-dashboard-side-nav.component.tsx +50 -0
- package/src/dashboard/stock-management-dashboard.component.tsx +41 -0
- package/src/dashboard/stock-management-dashboard.scss +8 -0
- package/src/dashboard.meta.ts +5 -0
- package/src/declarations.d.ts +6 -0
- package/src/index.ts +64 -0
- package/src/root.component.tsx +12 -0
- package/src/root.scss +174 -0
- package/src/routes.json +53 -0
- package/src/setup-tests.ts +1 -0
- package/src/stock-app-menu-item/item.component.tsx +21 -0
- package/src/stock-app-menu-item/item.resource.ts +0 -0
- package/src/stock-app-menu-item/item.scss +17 -0
- package/src/stock-batch/stock-batch.resource.ts +79 -0
- package/src/stock-home/stock-home-detail-card.scss +211 -0
- package/src/stock-home/stock-home-detail-cards.component.tsx +62 -0
- package/src/stock-home/stock-home-inventory-card.component.tsx +80 -0
- package/src/stock-home/stock-home-inventory-expiry.resource.tsx +32 -0
- package/src/stock-home/stock-home-inventory-items.resource.tsx +28 -0
- package/src/stock-home/stock-home-issuing-card.component.tsx +84 -0
- package/src/stock-home/stock-home-issuing.resource.tsx +18 -0
- package/src/stock-home/stock-home-landing-page-component.tsx +14 -0
- package/src/stock-home/stock-home-metrics.tsx +112 -0
- package/src/stock-home/stock-home-receiving-card.component.tsx +66 -0
- package/src/stock-home/stock-home-receiving.resource.tsx +17 -0
- package/src/stock-home/stock-home.scss +13 -0
- package/src/stock-home/useDisposalList.tsx +18 -0
- package/src/stock-home/useStockList.tsx +36 -0
- package/src/stock-items/add-bulk-stock-item/add-stock-items-bulk-import-action-button.component.tsx +26 -0
- package/src/stock-items/add-bulk-stock-item/stock-items-bulk-import.component.tsx +109 -0
- package/src/stock-items/add-bulk-stock-item/stock-items-bulk-import.resource.ts +14 -0
- package/src/stock-items/add-bulk-stock-item/stock-items-bulk-import.scss +0 -0
- package/src/stock-items/add-stock-item/add-stock-action-button.component.tsx +21 -0
- package/src/stock-items/add-stock-item/add-stock-item.component.tsx +84 -0
- package/src/stock-items/add-stock-item/add-stock-item.resource.tsx +36 -0
- package/src/stock-items/add-stock-item/add-stock-item.scss +5 -0
- package/src/stock-items/add-stock-item/batch-information/batch-information.component.tsx +98 -0
- package/src/stock-items/add-stock-item/batch-information/batch-information.resource.tsx +71 -0
- package/src/stock-items/add-stock-item/batch-information/batch-information.scss +0 -0
- package/src/stock-items/add-stock-item/concepts-selector/concepts-selector.component.tsx +79 -0
- package/src/stock-items/add-stock-item/concepts-selector/concepts-selector.resource.tsx +0 -0
- package/src/stock-items/add-stock-item/concepts-selector/concepts-selector.scss +0 -0
- package/src/stock-items/add-stock-item/concepts-selector/concepts-selector.test.tsx +8 -0
- package/src/stock-items/add-stock-item/dispensing-package-measurement/dispensing-package-measurement.component.tsx +76 -0
- package/src/stock-items/add-stock-item/dispensing-unit-selector/dispensing-unit-selector.component.tsx +66 -0
- package/src/stock-items/add-stock-item/dispensing-unit-selector/dispensing-unit-selector.resource.tsx +0 -0
- package/src/stock-items/add-stock-item/dispensing-unit-selector/dispensing-unit-selector.scss +0 -0
- package/src/stock-items/add-stock-item/dispensing-unit-selector/dispensing-unit-selector.test.tsx +8 -0
- package/src/stock-items/add-stock-item/drug-selector/drug-selector.component.tsx +83 -0
- package/src/stock-items/add-stock-item/drug-selector/drug-selector.resource.tsx +50 -0
- package/src/stock-items/add-stock-item/drug-selector/drug-selector.scss +0 -0
- package/src/stock-items/add-stock-item/packaging-units/packaging-units.component.tsx +255 -0
- package/src/stock-items/add-stock-item/packaging-units/packaging-units.resource.tsx +38 -0
- package/src/stock-items/add-stock-item/packaging-units/packaging-units.scss +21 -0
- package/src/stock-items/add-stock-item/packaging-units/validationSchema.ts +14 -0
- package/src/stock-items/add-stock-item/packaging-units-concept-selector/packaging-units-concept-selector.component.tsx +95 -0
- package/src/stock-items/add-stock-item/preferred-vendor-selector/preferred-vendor-selector.component.tsx +70 -0
- package/src/stock-items/add-stock-item/preferred-vendor-selector/preferred-vendor-selector.resource.tsx +0 -0
- package/src/stock-items/add-stock-item/preferred-vendor-selector/preferred-vendor-selector.scss +0 -0
- package/src/stock-items/add-stock-item/preferred-vendor-selector/preferred-vendor-selector.test.tsx +8 -0
- package/src/stock-items/add-stock-item/quantities/quantities.component.tsx +83 -0
- package/src/stock-items/add-stock-item/quantities/quantities.resource.tsx +69 -0
- package/src/stock-items/add-stock-item/quantities/quantities.scss +0 -0
- package/src/stock-items/add-stock-item/stock-item-category-selector/stock-item-category-selector.component.tsx +67 -0
- package/src/stock-items/add-stock-item/stock-item-category-selector/stock-item-category-selector.resource.tsx +0 -0
- package/src/stock-items/add-stock-item/stock-item-category-selector/stock-item-category-selector.scss +0 -0
- package/src/stock-items/add-stock-item/stock-item-category-selector/stock-item-category-selector.test.tsx +8 -0
- package/src/stock-items/add-stock-item/stock-item-details/stock-item-details.component.tsx +239 -0
- package/src/stock-items/add-stock-item/stock-item-details/stock-item-details.resource.tsx +14 -0
- package/src/stock-items/add-stock-item/stock-item-details/stock-item-details.scss +13 -0
- package/src/stock-items/add-stock-item/stock-item-rules/add-stock-rule-button.component.tsx +30 -0
- package/src/stock-items/add-stock-item/stock-item-rules/add-stock-rules.component.tsx +424 -0
- package/src/stock-items/add-stock-item/stock-item-rules/add-stock-rules.scss +18 -0
- package/src/stock-items/add-stock-item/stock-item-rules/delete-stock-rule-modal.component.tsx +47 -0
- package/src/stock-items/add-stock-item/stock-item-rules/edit-stock-rule.component.tsx +37 -0
- package/src/stock-items/add-stock-item/stock-item-rules/edit-stock-rule.scss +0 -0
- package/src/stock-items/add-stock-item/stock-item-rules/stock-item-rules.component.tsx +222 -0
- package/src/stock-items/add-stock-item/stock-item-rules/stock-item-rules.resource.tsx +72 -0
- package/src/stock-items/add-stock-item/stock-item-rules/stock-item-rules.scss +13 -0
- package/src/stock-items/add-stock-item/stock-item-rules/stock-rules-delete.component.tsx +67 -0
- package/src/stock-items/add-stock-item/stock-item-rules/stock-rules-delete.scss +0 -0
- package/src/stock-items/add-stock-item/stock-item-rules/stock-rules-filter.component.tsx +38 -0
- package/src/stock-items/add-stock-item/stock-item-rules/stock-rules-filter.scss +13 -0
- package/src/stock-items/add-stock-item/stock-item-rules/stock-rules.resource.ts +79 -0
- package/src/stock-items/add-stock-item/stock-item-units-edit/stock-item-units-edit.component.tsx +132 -0
- package/src/stock-items/add-stock-item/stock-rules/stock-rules.component.tsx +16 -0
- package/src/stock-items/add-stock-item/stock-rules/stock-rules.resource.tsx +0 -0
- package/src/stock-items/add-stock-item/stock-rules/stock-rules.scss +0 -0
- package/src/stock-items/add-stock-item/transactions/transactions.component.tsx +151 -0
- package/src/stock-items/add-stock-item/transactions/transactions.resource.tsx +109 -0
- package/src/stock-items/add-stock-item/transactions/transactions.scss +0 -0
- package/src/stock-items/components/filter-stock-items/filter-stock-items.component.tsx +28 -0
- package/src/stock-items/components/filter-stock-items/filter-stock-items.resource.tsx +0 -0
- package/src/stock-items/components/filter-stock-items/filter-stock-items.scss +3 -0
- package/src/stock-items/edit-stock-item/edit-stock-item-action-menu.component.tsx +30 -0
- package/src/stock-items/stock-item.utils.tsx +62 -0
- package/src/stock-items/stock-items-table.component.tsx +266 -0
- package/src/stock-items/stock-items-table.resource.ts +58 -0
- package/src/stock-items/stock-items-table.scss +66 -0
- package/src/stock-items/stock-items.component.tsx +12 -0
- package/src/stock-items/stock-items.resource.ts +365 -0
- package/src/stock-items/types.ts +8 -0
- package/src/stock-items/validationSchema.ts +67 -0
- package/src/stock-locations/stock-locations-table.component.tsx +69 -0
- package/src/stock-locations/stock-locations-table.resource.tsx +73 -0
- package/src/stock-locations/stock-locations-table.scss +0 -0
- package/src/stock-locations/stock-locations.component.tsx +12 -0
- package/src/stock-locations/stock-locations.resource.ts +0 -0
- package/src/stock-lookups/stock-lookups.resource.ts +306 -0
- package/src/stock-management-admin-card-link.component.tsx +29 -0
- package/src/stock-management-header/stock-management-Illustration.tsx +35 -0
- package/src/stock-management-header/stock-management-header.component.tsx +37 -0
- package/src/stock-management-header/stock-management-header.scss +58 -0
- package/src/stock-management.component.tsx +6 -0
- package/src/stock-operations/add-stock-operation/add-stock-operation.component.tsx +491 -0
- package/src/stock-operations/add-stock-operation/add-stock-operation.resource.tsx +33 -0
- package/src/stock-operations/add-stock-operation/add-stock-operation.scss +44 -0
- package/src/stock-operations/add-stock-operation/add-stock-operation.utils.tsx +241 -0
- package/src/stock-operations/add-stock-operation/add-stock-utils.ts +110 -0
- package/src/stock-operations/add-stock-operation/base-operation-details.component.tsx +352 -0
- package/src/stock-operations/add-stock-operation/stock-items-addition-row.component.tsx +347 -0
- package/src/stock-operations/add-stock-operation/stock-items-addition-row.resource.tsx +0 -0
- package/src/stock-operations/add-stock-operation/stock-items-addition-row.scss +0 -0
- package/src/stock-operations/add-stock-operation/stock-items-addition-row.test.tsx +11 -0
- package/src/stock-operations/add-stock-operation/stock-items-addition.component.scss +5 -0
- package/src/stock-operations/add-stock-operation/stock-items-addition.component.tsx +272 -0
- package/src/stock-operations/add-stock-operation/stock-operation-context/useStockOperationContext.tsx +22 -0
- package/src/stock-operations/add-stock-operation/stock-operation-submission.component.tsx +188 -0
- package/src/stock-operations/add-stock-operation/types.ts +55 -0
- package/src/stock-operations/add-stock-operation/validationSchema.ts +45 -0
- package/src/stock-operations/batch-no-selector/batch-no-selector.component.tsx +100 -0
- package/src/stock-operations/batch-no-selector/batch-no-selector.resource.tsx +46 -0
- package/src/stock-operations/batch-no-selector/batch-no-selector.scss +0 -0
- package/src/stock-operations/batch-no-selector/batch-no-selector.test.tsx +11 -0
- package/src/stock-operations/edit-stock-operation/edit-stock-operation-action-menu.component.tsx +73 -0
- package/src/stock-operations/party-selector/party-selector.component.tsx +58 -0
- package/src/stock-operations/qty-uom-selector/qty-uom-selector.component.tsx +65 -0
- package/src/stock-operations/qty-uom-selector/qty-uom-selector.resource.tsx +0 -0
- package/src/stock-operations/qty-uom-selector/qty-uom-selector.scss +0 -0
- package/src/stock-operations/qty-uom-selector/qty-uom-selector.test.tsx +11 -0
- package/src/stock-operations/stock-item-selector/stock-item-selector.component.tsx +74 -0
- package/src/stock-operations/stock-item-selector/stock-item-selector.resource.tsx +47 -0
- package/src/stock-operations/stock-item-selector/stock-item-selector.scss +0 -0
- package/src/stock-operations/stock-item-selector/stock-item-selector.test.tsx +11 -0
- package/src/stock-operations/stock-operation-operations-filter/stock-operation-operations-filter.component.tsx +27 -0
- package/src/stock-operations/stock-operation-operations-filter/stock-operation-operations-filter.scss +13 -0
- package/src/stock-operations/stock-operation-reason-selector/stock-operation-reason-selector.component.tsx +65 -0
- package/src/stock-operations/stock-operation-sources-filter/stock-operation-sources-filter.component.tsx +30 -0
- package/src/stock-operations/stock-operation-sources-filter/stock-operation-sources-filter.scss +13 -0
- package/src/stock-operations/stock-operation-statuses-filter/stock-operation-statuses-filter.component.tsx +32 -0
- package/src/stock-operations/stock-operation-statuses-filter/stock-operation-statuses-filter.scss +13 -0
- package/src/stock-operations/stock-operation-types-selector/stock-operation-types-selector.component.tsx +80 -0
- package/src/stock-operations/stock-operation.utils.tsx +106 -0
- package/src/stock-operations/stock-operations-dialog/stock-operations-approve-button.component.tsx +36 -0
- package/src/stock-operations/stock-operations-dialog/stock-operations-approve-dispatch-button.component.tsx +36 -0
- package/src/stock-operations/stock-operations-dialog/stock-operations-cancel-button.component.tsx +37 -0
- package/src/stock-operations/stock-operations-dialog/stock-operations-complete-button.component.tsx +36 -0
- package/src/stock-operations/stock-operations-dialog/stock-operations-completed-dispatch-button.component.tsx +36 -0
- package/src/stock-operations/stock-operations-dialog/stock-operations-dialog.component.tsx +167 -0
- package/src/stock-operations/stock-operations-dialog/stock-operations-dialog.scss +14 -0
- package/src/stock-operations/stock-operations-dialog/stock-operations-issue-stock-button.component.tsx +58 -0
- package/src/stock-operations/stock-operations-dialog/stock-operations-print-button.component.tsx +160 -0
- package/src/stock-operations/stock-operations-dialog/stock-operations-reject-button.component.tsx +37 -0
- package/src/stock-operations/stock-operations-dialog/stock-operations-return-button.component.tsx +37 -0
- package/src/stock-operations/stock-operations-table.component.tsx +524 -0
- package/src/stock-operations/stock-operations-table.resource.tsx +77 -0
- package/src/stock-operations/stock-operations-table.scss +0 -0
- package/src/stock-operations/stock-operations.component.tsx +12 -0
- package/src/stock-operations/stock-operations.resource.ts +238 -0
- package/src/stock-operations/stock-print-reports/GoodsReceivedNote.tsx +147 -0
- package/src/stock-operations/stock-print-reports/RequisitionDocument.tsx +153 -0
- package/src/stock-operations/stock-print-reports/StockOperationReport.tsx +133 -0
- package/src/stock-operations/stock-print-reports/StockTransferDocument.tsx +161 -0
- package/src/stock-operations/swr-revalidation.ts +7 -0
- package/src/stock-operations/users-selector/users-selector.component.tsx +77 -0
- package/src/stock-operations/users-selector/users-selector.resource.tsx +47 -0
- package/src/stock-operations/validation-schema.ts +195 -0
- package/src/stock-reports/ReportType.ts +63 -0
- package/src/stock-reports/stock-reports.component.tsx +0 -0
- package/src/stock-reports/stock-reports.resource.ts +0 -0
- package/src/stock-settings/stock-settings.component.tsx +11 -0
- package/src/stock-settings/stock-settings.resource.ts +0 -0
- package/src/stock-sources/add-stock-source-button.component.tsx +21 -0
- package/src/stock-sources/add-stock-sources/add-stock-sources.component.tsx +152 -0
- package/src/stock-sources/add-stock-sources/add-stock-sources.scss +18 -0
- package/src/stock-sources/delete-stock-modal.component.tsx +47 -0
- package/src/stock-sources/edit-stock-source/edit-stock-source.component.tsx +35 -0
- package/src/stock-sources/edit-stock-source/edit-stock-source.scss +0 -0
- package/src/stock-sources/stock-sources-delete/stock-sources-delate.scss +0 -0
- package/src/stock-sources/stock-sources-delete/stock-sources-delete.component.tsx +72 -0
- package/src/stock-sources/stock-sources-filter/stock-sources-filter.component.tsx +35 -0
- package/src/stock-sources/stock-sources-filter/stock-sources-filter.scss +13 -0
- package/src/stock-sources/stock-sources-items-table.component.tsx +213 -0
- package/src/stock-sources/stock-sources-items-table.resource.ts +56 -0
- package/src/stock-sources/stock-sources.component.tsx +12 -0
- package/src/stock-sources/stock-sources.resource.ts +80 -0
- package/src/stock-sources/stock-sources.scss +220 -0
- package/src/stock-sources/swr-revalidation.ts +7 -0
- package/src/stock-tabs/commodity-tabs.component.tsx +43 -0
- package/src/stock-tabs/commodity-tabs.scss +0 -0
- package/src/stock-user-role-scopes/add-stock-user-role-scope-button.component.tsx +21 -0
- package/src/stock-user-role-scopes/add-stock-user-scope/add-stock-user-role-scope.component.tsx +525 -0
- package/src/stock-user-role-scopes/add-stock-user-scope/add-stock-user-role-scope.scss +37 -0
- package/src/stock-user-role-scopes/delete-stock-user-scope/delete-stock-user-scope.component.tsx +73 -0
- package/src/stock-user-role-scopes/delete-stock-user-scope/delete-stock-user-scope.scss +0 -0
- package/src/stock-user-role-scopes/delete-stock-user-scope-modal.component.tsx +47 -0
- package/src/stock-user-role-scopes/edit-stock-user-scope/edit-stock-user-scope-action-menu.component.tsx +35 -0
- package/src/stock-user-role-scopes/stock-user-role-scopes-items-table.component.tsx +284 -0
- package/src/stock-user-role-scopes/stock-user-role-scopes-items-table.resource.ts +31 -0
- package/src/stock-user-role-scopes/stock-user-role-scopes.component.tsx +12 -0
- package/src/stock-user-role-scopes/stock-user-role-scopes.resource.ts +76 -0
- package/src/stock-user-role-scopes/stock-user-role-scopes.scss +61 -0
- package/src/stock-user-role-scopes/swr-revalidation.ts +7 -0
- package/src/utils.ts +10 -0
- package/translations/en.json +24 -0
- package/tsconfig.json +23 -0
- package/webpack.config.js +1 -0
@@ -0,0 +1,36 @@
|
|
1
|
+
import React, { useCallback } from "react";
|
2
|
+
|
3
|
+
import { Button } from "@carbon/react";
|
4
|
+
import { showModal } from "@openmrs/esm-framework";
|
5
|
+
import { useTranslation } from "react-i18next";
|
6
|
+
import { Arrival } from "@carbon/react/icons";
|
7
|
+
import { StockOperationDTO } from "../../core/api/types/stockOperation/StockOperationDTO";
|
8
|
+
|
9
|
+
interface StockOperationCompleteDispatchButtonProps {
|
10
|
+
operation: StockOperationDTO;
|
11
|
+
}
|
12
|
+
|
13
|
+
const StockOperationCompleteDispatchButton: React.FC<
|
14
|
+
StockOperationCompleteDispatchButtonProps
|
15
|
+
> = ({ operation }) => {
|
16
|
+
const { t } = useTranslation();
|
17
|
+
const launchcompletedDispatchModal = useCallback(() => {
|
18
|
+
const dispose = showModal("stock-operation-dialog", {
|
19
|
+
title: "Complete Dispatch",
|
20
|
+
operation: operation,
|
21
|
+
requireReason: false,
|
22
|
+
closeModal: () => dispose(),
|
23
|
+
});
|
24
|
+
}, [operation]);
|
25
|
+
|
26
|
+
return (
|
27
|
+
<Button
|
28
|
+
onClick={launchcompletedDispatchModal}
|
29
|
+
renderIcon={(props) => <Arrival size={16} {...props} />}
|
30
|
+
>
|
31
|
+
{t("complete", "Complete Dispatch ")}
|
32
|
+
</Button>
|
33
|
+
);
|
34
|
+
};
|
35
|
+
|
36
|
+
export default StockOperationCompleteDispatchButton;
|
@@ -0,0 +1,167 @@
|
|
1
|
+
import React, { useState } from "react";
|
2
|
+
import { useTranslation } from "react-i18next";
|
3
|
+
import { StockOperationDTO } from "../../core/api/types/stockOperation/StockOperationDTO";
|
4
|
+
import {
|
5
|
+
Button,
|
6
|
+
Form,
|
7
|
+
ModalBody,
|
8
|
+
ModalFooter,
|
9
|
+
ModalHeader,
|
10
|
+
TextArea,
|
11
|
+
InlineLoading,
|
12
|
+
} from "@carbon/react";
|
13
|
+
import styles from "./stock-operations-dialog.scss";
|
14
|
+
import {
|
15
|
+
StopOperationAction,
|
16
|
+
StopOperationActionType,
|
17
|
+
} from "../../core/api/types/stockOperation/StockOperationAction";
|
18
|
+
import { executeStockOperationAction } from "../stock-operations.resource";
|
19
|
+
import { showNotification, showToast } from "@openmrs/esm-framework";
|
20
|
+
import { closeOverlay } from "../../core/components/overlay/hook";
|
21
|
+
import { extractErrorMessagesFromResponse } from "../../constants";
|
22
|
+
|
23
|
+
interface StockOperationDialogProps {
|
24
|
+
title: string;
|
25
|
+
requireReason: boolean;
|
26
|
+
operation: StockOperationDTO;
|
27
|
+
closeModal: () => void;
|
28
|
+
}
|
29
|
+
|
30
|
+
const StockOperationDialog: React.FC<StockOperationDialogProps> = ({
|
31
|
+
title,
|
32
|
+
requireReason,
|
33
|
+
operation,
|
34
|
+
closeModal,
|
35
|
+
}) => {
|
36
|
+
const confirmType = title.toLocaleLowerCase().trim();
|
37
|
+
|
38
|
+
const { t } = useTranslation();
|
39
|
+
|
40
|
+
const [notes, setNotes] = useState("");
|
41
|
+
|
42
|
+
const [isApproving, setIsApproving] = useState(false);
|
43
|
+
|
44
|
+
const handleClick = async (event) => {
|
45
|
+
event.preventDefault();
|
46
|
+
|
47
|
+
setIsApproving(true);
|
48
|
+
|
49
|
+
let actionName: StopOperationActionType | null = null;
|
50
|
+
|
51
|
+
switch (confirmType) {
|
52
|
+
case "submit":
|
53
|
+
actionName = "SUBMIT";
|
54
|
+
break;
|
55
|
+
case "dispatch":
|
56
|
+
actionName = "DISPATCH";
|
57
|
+
break;
|
58
|
+
case "complete":
|
59
|
+
actionName = "COMPLETE";
|
60
|
+
break;
|
61
|
+
case "completedispatch":
|
62
|
+
actionName = "COMPLETE";
|
63
|
+
break;
|
64
|
+
case "cancel":
|
65
|
+
actionName = "CANCEL";
|
66
|
+
break;
|
67
|
+
case "reject":
|
68
|
+
actionName = "REJECT";
|
69
|
+
break;
|
70
|
+
case "return":
|
71
|
+
actionName = "RETURN";
|
72
|
+
break;
|
73
|
+
case "approve":
|
74
|
+
actionName = "APPROVE";
|
75
|
+
break;
|
76
|
+
case "dispatchapproval":
|
77
|
+
// messagePrefix = "dispatch";
|
78
|
+
actionName = "DISPATCH";
|
79
|
+
break;
|
80
|
+
}
|
81
|
+
if (!actionName) {
|
82
|
+
return;
|
83
|
+
}
|
84
|
+
|
85
|
+
const payload: StopOperationAction = {
|
86
|
+
name: actionName,
|
87
|
+
uuid: operation?.uuid,
|
88
|
+
reason: notes,
|
89
|
+
};
|
90
|
+
|
91
|
+
// submit action
|
92
|
+
executeStockOperationAction(payload).then(
|
93
|
+
() => {
|
94
|
+
setIsApproving(false);
|
95
|
+
showToast({
|
96
|
+
critical: true,
|
97
|
+
title: t("title", `${title} Operation`),
|
98
|
+
kind: "success",
|
99
|
+
description: t(
|
100
|
+
"successMessage",
|
101
|
+
`You have successfully ${title} operation `
|
102
|
+
),
|
103
|
+
});
|
104
|
+
closeModal();
|
105
|
+
closeOverlay();
|
106
|
+
},
|
107
|
+
(err) => {
|
108
|
+
setIsApproving(false);
|
109
|
+
const errorMessages = extractErrorMessagesFromResponse(err);
|
110
|
+
showNotification({
|
111
|
+
description: t("errorDescription", errorMessages.join(", ")),
|
112
|
+
title: t("errorDescriptionTitle", "Error on saving form"),
|
113
|
+
kind: "error",
|
114
|
+
critical: true,
|
115
|
+
});
|
116
|
+
closeModal();
|
117
|
+
closeOverlay();
|
118
|
+
}
|
119
|
+
);
|
120
|
+
};
|
121
|
+
|
122
|
+
return (
|
123
|
+
<div>
|
124
|
+
<Form onSubmit={handleClick}>
|
125
|
+
<ModalHeader
|
126
|
+
closeModal={closeModal}
|
127
|
+
title={t("title", `${title} Operation`)}
|
128
|
+
/>
|
129
|
+
<ModalBody>
|
130
|
+
<div className={styles.modalBody}>
|
131
|
+
<section className={styles.section}>
|
132
|
+
<h5 className={styles.section}>
|
133
|
+
Would you really like to {title} the operation ?
|
134
|
+
</h5>
|
135
|
+
</section>
|
136
|
+
<br />
|
137
|
+
{requireReason && (
|
138
|
+
<section className={styles.section}>
|
139
|
+
<TextArea
|
140
|
+
labelText={t("notes", "Please explain the reason:")}
|
141
|
+
id="nextNotes"
|
142
|
+
name="nextNotes"
|
143
|
+
invalidText="Required"
|
144
|
+
maxCount={500}
|
145
|
+
enableCounter
|
146
|
+
onChange={(e) => setNotes(e.target.value)}
|
147
|
+
/>
|
148
|
+
</section>
|
149
|
+
)}
|
150
|
+
</div>
|
151
|
+
</ModalBody>
|
152
|
+
<ModalFooter>
|
153
|
+
<Button kind="secondary" onClick={closeModal}>
|
154
|
+
{t("cancel", "Cancel")}
|
155
|
+
</Button>
|
156
|
+
{isApproving ? (
|
157
|
+
<InlineLoading />
|
158
|
+
) : (
|
159
|
+
<Button type="submit">{t("submit", "Submit")}</Button>
|
160
|
+
)}
|
161
|
+
</ModalFooter>
|
162
|
+
</Form>
|
163
|
+
</div>
|
164
|
+
);
|
165
|
+
};
|
166
|
+
|
167
|
+
export default StockOperationDialog;
|
@@ -0,0 +1,58 @@
|
|
1
|
+
import React from "react";
|
2
|
+
|
3
|
+
import { Button } from "@carbon/react";
|
4
|
+
import { useTranslation } from "react-i18next";
|
5
|
+
import { DeliveryTruck } from "@carbon/react/icons";
|
6
|
+
import { StockOperationDTO } from "../../core/api/types/stockOperation/StockOperationDTO";
|
7
|
+
import { StockOperationType } from "../../core/api/types/stockOperation/StockOperationType";
|
8
|
+
import { launchAddOrEditDialog } from "../stock-operation.utils";
|
9
|
+
|
10
|
+
interface StockOperationIssueStockButtonProps {
|
11
|
+
operation: StockOperationDTO;
|
12
|
+
operations: StockOperationType[];
|
13
|
+
}
|
14
|
+
|
15
|
+
const StockOperationIssueStockButton: React.FC<
|
16
|
+
StockOperationIssueStockButtonProps
|
17
|
+
> = ({ operation, operations }) => {
|
18
|
+
const { t } = useTranslation();
|
19
|
+
const type: StockOperationType = {
|
20
|
+
uuid: "",
|
21
|
+
name: "Stock Issue",
|
22
|
+
description: "",
|
23
|
+
operationType: "",
|
24
|
+
hasSource: false,
|
25
|
+
sourceType: "Location",
|
26
|
+
hasDestination: false,
|
27
|
+
destinationType: "Location",
|
28
|
+
hasRecipient: false,
|
29
|
+
recipientRequired: false,
|
30
|
+
availableWhenReserved: false,
|
31
|
+
allowExpiredBatchNumbers: false,
|
32
|
+
stockOperationTypeLocationScopes: [],
|
33
|
+
creator: undefined,
|
34
|
+
dateCreated: undefined,
|
35
|
+
changedBy: undefined,
|
36
|
+
dateChanged: undefined,
|
37
|
+
dateVoided: undefined,
|
38
|
+
voidedBy: undefined,
|
39
|
+
voidReason: "",
|
40
|
+
voided: false,
|
41
|
+
};
|
42
|
+
|
43
|
+
const handleButtonClick = () => {
|
44
|
+
launchAddOrEditDialog(operation, false, type, operations, false);
|
45
|
+
};
|
46
|
+
|
47
|
+
return (
|
48
|
+
<Button
|
49
|
+
onClick={handleButtonClick}
|
50
|
+
kind="tertiary"
|
51
|
+
renderIcon={(props) => <DeliveryTruck size={16} {...props} />}
|
52
|
+
>
|
53
|
+
{t("issueStock", "Issue Stock ")}
|
54
|
+
</Button>
|
55
|
+
);
|
56
|
+
};
|
57
|
+
|
58
|
+
export default StockOperationIssueStockButton;
|
package/src/stock-operations/stock-operations-dialog/stock-operations-print-button.component.tsx
ADDED
@@ -0,0 +1,160 @@
|
|
1
|
+
import React from "react";
|
2
|
+
|
3
|
+
import { Button } from "@carbon/react";
|
4
|
+
import { useConfig } from "@openmrs/esm-framework";
|
5
|
+
import { useTranslation } from "react-i18next";
|
6
|
+
import { Printer } from "@carbon/react/icons";
|
7
|
+
import { StockOperationDTO } from "../../core/api/types/stockOperation/StockOperationDTO";
|
8
|
+
import { StockOperationItemCost } from "../../core/api/types/stockOperation/StockOperationItemCost";
|
9
|
+
import { StockItemInventory } from "../../core/api/types/stockItem/StockItemInventory";
|
10
|
+
|
11
|
+
import { StockItemInventoryFilter } from "../../stock-items/stock-items.resource";
|
12
|
+
import { ResourceRepresentation } from "../../core/api/api";
|
13
|
+
import { BuildStockOperationData } from "../stock-print-reports/StockOperationReport";
|
14
|
+
import { PrintGoodsReceivedNoteStockOperation } from "../stock-print-reports/GoodsReceivedNote";
|
15
|
+
import { PrintTransferOutStockOperation } from "../stock-print-reports/StockTransferDocument";
|
16
|
+
import { PrintRequisitionStockOperation } from "../stock-print-reports/RequisitionDocument";
|
17
|
+
import {
|
18
|
+
getStockItemInventory,
|
19
|
+
getStockOperation,
|
20
|
+
getStockOperationItemsCost,
|
21
|
+
} from "../stock-operations.resource";
|
22
|
+
|
23
|
+
interface StockOperationCancelButtonProps {
|
24
|
+
operation: StockOperationDTO;
|
25
|
+
}
|
26
|
+
|
27
|
+
const StockOperationPrintButton: React.FC<StockOperationCancelButtonProps> = ({
|
28
|
+
operation,
|
29
|
+
}) => {
|
30
|
+
const { t } = useTranslation();
|
31
|
+
|
32
|
+
const { config } = useConfig();
|
33
|
+
|
34
|
+
// const { printItemCost, printBalanceOnHand } = config;
|
35
|
+
|
36
|
+
// on print stock operation
|
37
|
+
const onPrintStockOperation = async () => {
|
38
|
+
try {
|
39
|
+
let parentOperation: StockOperationDTO | null | undefined;
|
40
|
+
let itemsCost: StockOperationItemCost[] | null | undefined = null;
|
41
|
+
let itemInventory: StockItemInventory[] | null | undefined = null;
|
42
|
+
|
43
|
+
if (operation.requisitionStockOperationUuid) {
|
44
|
+
// get stock operation
|
45
|
+
getStockOperation(operation.requisitionStockOperationUuid)
|
46
|
+
.then((payload: any) => {
|
47
|
+
if ((payload as any).error) {
|
48
|
+
return;
|
49
|
+
}
|
50
|
+
parentOperation = payload;
|
51
|
+
})
|
52
|
+
.catch((error: any) => {
|
53
|
+
if ((error as any).error) {
|
54
|
+
return;
|
55
|
+
}
|
56
|
+
return;
|
57
|
+
});
|
58
|
+
if (!parentOperation) {
|
59
|
+
return null;
|
60
|
+
}
|
61
|
+
}
|
62
|
+
|
63
|
+
if (
|
64
|
+
parentOperation ||
|
65
|
+
parentOperation?.operationType === "stockissue" ||
|
66
|
+
parentOperation?.operationType === "transferout"
|
67
|
+
) {
|
68
|
+
const enableOperationPrintCosts = true;
|
69
|
+
if (enableOperationPrintCosts) {
|
70
|
+
const inventoryFilter: StockItemInventoryFilter = {};
|
71
|
+
if (operation?.uuid) {
|
72
|
+
inventoryFilter.stockOperationUuid = operation.uuid;
|
73
|
+
}
|
74
|
+
getStockOperationItemsCost(inventoryFilter)
|
75
|
+
.then((payload: any) => {
|
76
|
+
if ((payload as any).error) {
|
77
|
+
return;
|
78
|
+
}
|
79
|
+
itemsCost = payload?.results;
|
80
|
+
})
|
81
|
+
.catch((error: any) => {
|
82
|
+
if ((error as any).error) {
|
83
|
+
return;
|
84
|
+
}
|
85
|
+
return;
|
86
|
+
});
|
87
|
+
}
|
88
|
+
}
|
89
|
+
const enableBalance = true;
|
90
|
+
if (
|
91
|
+
enableBalance &&
|
92
|
+
(parentOperation || parentOperation?.operationType === "requisition")
|
93
|
+
) {
|
94
|
+
const inventoryFilter: StockItemInventoryFilter = {};
|
95
|
+
if (operation?.uuid) {
|
96
|
+
inventoryFilter.locationUuid = operation.atLocationUuid;
|
97
|
+
inventoryFilter.stockOperationUuid = operation.uuid;
|
98
|
+
} else {
|
99
|
+
inventoryFilter.locationUuid = operation.atLocationUuid;
|
100
|
+
inventoryFilter.stockOperationUuid = operation.uuid;
|
101
|
+
}
|
102
|
+
inventoryFilter.v = ResourceRepresentation.Default;
|
103
|
+
inventoryFilter.groupBy = "LocationStockItem";
|
104
|
+
inventoryFilter.includeStockItemName = "true";
|
105
|
+
|
106
|
+
inventoryFilter.date = JSON.stringify(
|
107
|
+
parentOperation?.dateCreated ?? operation?.dateCreated
|
108
|
+
);
|
109
|
+
|
110
|
+
// get stock item inventory
|
111
|
+
getStockItemInventory(inventoryFilter)
|
112
|
+
.then((payload: any) => {
|
113
|
+
if ((payload as any).error) {
|
114
|
+
return;
|
115
|
+
}
|
116
|
+
itemInventory = payload?.results;
|
117
|
+
})
|
118
|
+
.catch((error: any) => {
|
119
|
+
if ((error as any).error) {
|
120
|
+
return;
|
121
|
+
}
|
122
|
+
return;
|
123
|
+
});
|
124
|
+
}
|
125
|
+
|
126
|
+
const data = await BuildStockOperationData(
|
127
|
+
operation,
|
128
|
+
operation.stockOperationItems,
|
129
|
+
parentOperation,
|
130
|
+
itemsCost,
|
131
|
+
itemInventory
|
132
|
+
);
|
133
|
+
if (data) {
|
134
|
+
if (operation?.operationType === "receipt") {
|
135
|
+
await PrintGoodsReceivedNoteStockOperation(data);
|
136
|
+
} else if (operation?.operationType === "transferout") {
|
137
|
+
await PrintTransferOutStockOperation(data);
|
138
|
+
} else {
|
139
|
+
await PrintRequisitionStockOperation(data);
|
140
|
+
}
|
141
|
+
} else {
|
142
|
+
console.info(data);
|
143
|
+
}
|
144
|
+
} catch (e) {
|
145
|
+
console.info(e);
|
146
|
+
}
|
147
|
+
};
|
148
|
+
|
149
|
+
return (
|
150
|
+
<Button
|
151
|
+
onClick={onPrintStockOperation}
|
152
|
+
kind="tertiary"
|
153
|
+
renderIcon={(props) => <Printer size={16} {...props} />}
|
154
|
+
>
|
155
|
+
{t("print", "Print ")}
|
156
|
+
</Button>
|
157
|
+
);
|
158
|
+
};
|
159
|
+
|
160
|
+
export default StockOperationPrintButton;
|
package/src/stock-operations/stock-operations-dialog/stock-operations-reject-button.component.tsx
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
import React, { useCallback } from "react";
|
2
|
+
|
3
|
+
import { Button } from "@carbon/react";
|
4
|
+
import { showModal } from "@openmrs/esm-framework";
|
5
|
+
import { useTranslation } from "react-i18next";
|
6
|
+
import { Repeat } from "@carbon/react/icons";
|
7
|
+
import { StockOperationDTO } from "../../core/api/types/stockOperation/StockOperationDTO";
|
8
|
+
|
9
|
+
interface StockOperationRejectButtonProps {
|
10
|
+
operation: StockOperationDTO;
|
11
|
+
}
|
12
|
+
|
13
|
+
const StockOperationRejectButton: React.FC<StockOperationRejectButtonProps> = ({
|
14
|
+
operation,
|
15
|
+
}) => {
|
16
|
+
const { t } = useTranslation();
|
17
|
+
const launchRejectModal = useCallback(() => {
|
18
|
+
const dispose = showModal("stock-operation-dialog", {
|
19
|
+
title: "Reject",
|
20
|
+
operation: operation,
|
21
|
+
requireReason: true,
|
22
|
+
closeModal: () => dispose(),
|
23
|
+
});
|
24
|
+
}, [operation]);
|
25
|
+
|
26
|
+
return (
|
27
|
+
<Button
|
28
|
+
onClick={launchRejectModal}
|
29
|
+
kind=""
|
30
|
+
renderIcon={(props) => <Repeat size={16} {...props} />}
|
31
|
+
>
|
32
|
+
{t("reject", "Reject ")}
|
33
|
+
</Button>
|
34
|
+
);
|
35
|
+
};
|
36
|
+
|
37
|
+
export default StockOperationRejectButton;
|
package/src/stock-operations/stock-operations-dialog/stock-operations-return-button.component.tsx
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
import React, { useCallback } from "react";
|
2
|
+
|
3
|
+
import { Button } from "@carbon/react";
|
4
|
+
import { showModal } from "@openmrs/esm-framework";
|
5
|
+
import { useTranslation } from "react-i18next";
|
6
|
+
import { CloseOutline } from "@carbon/react/icons";
|
7
|
+
import { StockOperationDTO } from "../../core/api/types/stockOperation/StockOperationDTO";
|
8
|
+
|
9
|
+
interface StockOperationReturnButtonProps {
|
10
|
+
operation: StockOperationDTO;
|
11
|
+
}
|
12
|
+
|
13
|
+
const StockOperationReturnButton: React.FC<StockOperationReturnButtonProps> = ({
|
14
|
+
operation,
|
15
|
+
}) => {
|
16
|
+
const { t } = useTranslation();
|
17
|
+
const launchReturnModal = useCallback(() => {
|
18
|
+
const dispose = showModal("stock-operation-dialog", {
|
19
|
+
title: "Return",
|
20
|
+
operation: operation,
|
21
|
+
requireReason: true,
|
22
|
+
closeModal: () => dispose(),
|
23
|
+
});
|
24
|
+
}, [operation]);
|
25
|
+
|
26
|
+
return (
|
27
|
+
<Button
|
28
|
+
onClick={launchReturnModal}
|
29
|
+
kind="tertiary"
|
30
|
+
renderIcon={(props) => <CloseOutline size={16} {...props} />}
|
31
|
+
>
|
32
|
+
{t("return", "Return ")}
|
33
|
+
</Button>
|
34
|
+
);
|
35
|
+
};
|
36
|
+
|
37
|
+
export default StockOperationReturnButton;
|