@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,74 @@
|
|
1
|
+
import React, { ReactNode } from "react";
|
2
|
+
import { Control, Controller, FieldValues } from "react-hook-form";
|
3
|
+
import { ComboBox, InlineLoading } from "@carbon/react";
|
4
|
+
import { StockItemDTO } from "../../core/api/types/stockItem/StockItem";
|
5
|
+
import { useStockItems } from "./stock-item-selector.resource";
|
6
|
+
import { useDebounce } from "../../core/hooks/debounce-hook";
|
7
|
+
|
8
|
+
interface StockItemSelectorProps<T> {
|
9
|
+
placeholder?: string;
|
10
|
+
stockItemUuid?: string;
|
11
|
+
onStockItemChanged?: (item: StockItemDTO) => void;
|
12
|
+
title?: string;
|
13
|
+
invalid?: boolean;
|
14
|
+
invalidText?: ReactNode;
|
15
|
+
|
16
|
+
// Control
|
17
|
+
controllerName: string;
|
18
|
+
name: string;
|
19
|
+
control: Control<FieldValues, T>;
|
20
|
+
}
|
21
|
+
|
22
|
+
const StockItemSelector = <T,>(props: StockItemSelectorProps<T>) => {
|
23
|
+
const { isLoading, stockItemsList, setSearchString } = useStockItems({});
|
24
|
+
|
25
|
+
const debouncedSearch = useDebounce((query: string) => {
|
26
|
+
setSearchString(query);
|
27
|
+
}, 500);
|
28
|
+
|
29
|
+
return (
|
30
|
+
<div>
|
31
|
+
<Controller
|
32
|
+
name={props.controllerName}
|
33
|
+
control={props.control}
|
34
|
+
render={({ field: { onChange, value, ref } }) => (
|
35
|
+
<ComboBox
|
36
|
+
titleText={props.title}
|
37
|
+
name={props.name}
|
38
|
+
control={props.control}
|
39
|
+
controllerName={props.controllerName}
|
40
|
+
id={props.name}
|
41
|
+
size={"sm"}
|
42
|
+
items={stockItemsList || []}
|
43
|
+
onChange={(data: { selectedItem: StockItemDTO }) => {
|
44
|
+
props.onStockItemChanged?.(data.selectedItem);
|
45
|
+
onChange(data.selectedItem?.uuid);
|
46
|
+
}}
|
47
|
+
initialSelectedItem={
|
48
|
+
stockItemsList?.find((p) => p.uuid === props.stockItemUuid) ?? ""
|
49
|
+
}
|
50
|
+
itemToString={stockItemName}
|
51
|
+
onInputChange={debouncedSearch}
|
52
|
+
placeholder={props.placeholder}
|
53
|
+
invalid={props.invalid}
|
54
|
+
invalidText={props.invalidText}
|
55
|
+
ref={ref}
|
56
|
+
/>
|
57
|
+
)}
|
58
|
+
/>
|
59
|
+
{isLoading && (
|
60
|
+
<InlineLoading
|
61
|
+
status="active"
|
62
|
+
iconDescription="Searching"
|
63
|
+
description="Searching..."
|
64
|
+
/>
|
65
|
+
)}
|
66
|
+
</div>
|
67
|
+
);
|
68
|
+
};
|
69
|
+
|
70
|
+
function stockItemName(item: StockItemDTO): string {
|
71
|
+
return item.drugName || item.conceptName;
|
72
|
+
}
|
73
|
+
|
74
|
+
export default StockItemSelector;
|
@@ -0,0 +1,47 @@
|
|
1
|
+
import { UserFilterCriteria } from "../../stock-lookups/stock-lookups.resource";
|
2
|
+
import { useEffect, useState } from "react";
|
3
|
+
import { ResourceRepresentation } from "../../core/api/api";
|
4
|
+
import {
|
5
|
+
StockItemFilter,
|
6
|
+
useStockItems as useStockItemsData,
|
7
|
+
} from "../../stock-items/stock-items.resource";
|
8
|
+
|
9
|
+
export function useStockItems(filter?: StockItemFilter) {
|
10
|
+
const [conceptFilter, setConceptFilter] = useState<UserFilterCriteria>(
|
11
|
+
filter || {
|
12
|
+
v: ResourceRepresentation.Default,
|
13
|
+
limit: 10,
|
14
|
+
startIndex: 0,
|
15
|
+
}
|
16
|
+
);
|
17
|
+
|
18
|
+
const {
|
19
|
+
items: { results: stockItemsList },
|
20
|
+
isLoading,
|
21
|
+
} = useStockItemsData(conceptFilter);
|
22
|
+
|
23
|
+
const [searchString, setSearchString] = useState(null);
|
24
|
+
|
25
|
+
// Drug filter type
|
26
|
+
const [limit, setLimit] = useState(filter?.limit || 10);
|
27
|
+
const [representation, setRepresentation] = useState(
|
28
|
+
filter?.v || ResourceRepresentation.Default
|
29
|
+
);
|
30
|
+
|
31
|
+
useEffect(() => {
|
32
|
+
setConceptFilter({
|
33
|
+
startIndex: 0,
|
34
|
+
v: representation,
|
35
|
+
limit: limit,
|
36
|
+
q: searchString,
|
37
|
+
});
|
38
|
+
}, [searchString, limit, representation]);
|
39
|
+
|
40
|
+
return {
|
41
|
+
stockItemsList,
|
42
|
+
setLimit,
|
43
|
+
setRepresentation,
|
44
|
+
setSearchString,
|
45
|
+
isLoading,
|
46
|
+
};
|
47
|
+
}
|
File without changes
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import React from "react";
|
2
|
+
|
3
|
+
import { render, cleanup } from "@testing-library/react";
|
4
|
+
import StockItemSelector from "./stock-item-selector.component";
|
5
|
+
|
6
|
+
describe("Test the stock item selector", () => {
|
7
|
+
afterEach(cleanup);
|
8
|
+
it(`renders without dying`, () => {
|
9
|
+
// render(<StockItemSelector />);
|
10
|
+
});
|
11
|
+
});
|
@@ -0,0 +1,27 @@
|
|
1
|
+
import styles from "./stock-operation-operations-filter.scss";
|
2
|
+
import { Dropdown, DropdownSkeleton } from "@carbon/react";
|
3
|
+
import React from "react";
|
4
|
+
import { useStockOperationTypes } from "../../stock-lookups/stock-lookups.resource";
|
5
|
+
|
6
|
+
const StockOperationOperationsFilter: React.FC = () => {
|
7
|
+
// get stock sources
|
8
|
+
const { types, isLoading, isError } = useStockOperationTypes();
|
9
|
+
if (isLoading || isError) {
|
10
|
+
return <DropdownSkeleton />;
|
11
|
+
}
|
12
|
+
return (
|
13
|
+
<>
|
14
|
+
<div className={styles.filterContainer}>
|
15
|
+
<Dropdown
|
16
|
+
id="stockOperationOperationsFiter"
|
17
|
+
items={types.results}
|
18
|
+
itemToString={(item) => (item ? item.name : "Not Set")}
|
19
|
+
type="inline"
|
20
|
+
size="sm"
|
21
|
+
/>
|
22
|
+
</div>
|
23
|
+
</>
|
24
|
+
);
|
25
|
+
};
|
26
|
+
|
27
|
+
export default StockOperationOperationsFilter;
|
@@ -0,0 +1,65 @@
|
|
1
|
+
import React, { ReactNode } from "react";
|
2
|
+
import { Control, Controller, FieldValues } from "react-hook-form";
|
3
|
+
import { Concept } from "../../core/api/types/concept/Concept";
|
4
|
+
import { ComboBox, SelectSkeleton } from "@carbon/react";
|
5
|
+
import { useConceptById } from "../../stock-lookups/stock-lookups.resource";
|
6
|
+
import { STOCK_ADJUSTMENT_REASON_CODED_CONCEPT_ID } from "../../constants";
|
7
|
+
|
8
|
+
interface StockOperationReasonSelectorProps<T> {
|
9
|
+
reasonUuid?: string;
|
10
|
+
onReasonChange?: (reason: Concept) => void;
|
11
|
+
title?: string;
|
12
|
+
placeholder?: string;
|
13
|
+
invalid?: boolean;
|
14
|
+
invalidText?: ReactNode;
|
15
|
+
|
16
|
+
// Control
|
17
|
+
controllerName: string;
|
18
|
+
name: string;
|
19
|
+
control: Control<FieldValues, T>;
|
20
|
+
}
|
21
|
+
|
22
|
+
const StockOperationReasonSelector = <T,>(
|
23
|
+
props: StockOperationReasonSelectorProps<T>
|
24
|
+
) => {
|
25
|
+
const {
|
26
|
+
isLoading,
|
27
|
+
isError,
|
28
|
+
items: { answers: reasons },
|
29
|
+
} = useConceptById(STOCK_ADJUSTMENT_REASON_CODED_CONCEPT_ID);
|
30
|
+
|
31
|
+
if (isLoading || isError) return <SelectSkeleton />;
|
32
|
+
|
33
|
+
return (
|
34
|
+
<Controller
|
35
|
+
name={props.controllerName}
|
36
|
+
control={props.control}
|
37
|
+
render={({ field: { onChange, ref } }) => (
|
38
|
+
<ComboBox
|
39
|
+
labelText={props.title}
|
40
|
+
placeholder={props.placeholder}
|
41
|
+
name={props.name}
|
42
|
+
controllerName={props.controllerName}
|
43
|
+
id={props.name}
|
44
|
+
size={"md"}
|
45
|
+
items={reasons}
|
46
|
+
initialSelectedItem={
|
47
|
+
reasons?.find((p) => p.uuid === props.reasonUuid) || {}
|
48
|
+
}
|
49
|
+
itemToString={(item?: Concept) =>
|
50
|
+
item && item?.display ? `${item?.display}` : ""
|
51
|
+
}
|
52
|
+
onChange={(data: { selectedItem?: Concept }) => {
|
53
|
+
props.onReasonChange?.(data?.selectedItem);
|
54
|
+
onChange(data?.selectedItem?.uuid);
|
55
|
+
}}
|
56
|
+
ref={ref}
|
57
|
+
invalid={props.invalid}
|
58
|
+
invalidText={props.invalidText}
|
59
|
+
/>
|
60
|
+
)}
|
61
|
+
/>
|
62
|
+
);
|
63
|
+
};
|
64
|
+
|
65
|
+
export default StockOperationReasonSelector;
|
@@ -0,0 +1,30 @@
|
|
1
|
+
import styles from "./stock-operation-sources-filter.scss";
|
2
|
+
import { Dropdown, DropdownSkeleton } from "@carbon/react";
|
3
|
+
import React from "react";
|
4
|
+
import { STOCK_SOURCE_TYPE_CODED_CONCEPT_ID } from "../../constants";
|
5
|
+
import { useConceptById } from "../../stock-lookups/stock-lookups.resource";
|
6
|
+
|
7
|
+
const StockOperationSourcesFilter: React.FC = () => {
|
8
|
+
// get stock sources
|
9
|
+
const { items, isLoading, isError } = useConceptById(
|
10
|
+
STOCK_SOURCE_TYPE_CODED_CONCEPT_ID
|
11
|
+
);
|
12
|
+
if (isLoading || isError) {
|
13
|
+
return <DropdownSkeleton />;
|
14
|
+
}
|
15
|
+
return (
|
16
|
+
<>
|
17
|
+
<div className={styles.filterContainer}>
|
18
|
+
<Dropdown
|
19
|
+
id="stockOperationSourcesFiter"
|
20
|
+
items={[...items.answers]}
|
21
|
+
itemToString={(item) => (item ? item.display : "Not Set")}
|
22
|
+
type="inline"
|
23
|
+
size="sm"
|
24
|
+
/>
|
25
|
+
</div>
|
26
|
+
</>
|
27
|
+
);
|
28
|
+
};
|
29
|
+
|
30
|
+
export default StockOperationSourcesFilter;
|
@@ -0,0 +1,32 @@
|
|
1
|
+
import styles from "./stock-operation-statuses-filter.scss";
|
2
|
+
import { Dropdown } from "@carbon/react";
|
3
|
+
import React from "react";
|
4
|
+
const StockOperationStatusesFilter: React.FC = () => {
|
5
|
+
// get stock sources
|
6
|
+
|
7
|
+
const items = [
|
8
|
+
"SUBMITTED",
|
9
|
+
"NEW",
|
10
|
+
"RETURNED",
|
11
|
+
"CANCELLED",
|
12
|
+
"DISPATCHED",
|
13
|
+
"COMPLETED",
|
14
|
+
"REJECTED",
|
15
|
+
];
|
16
|
+
|
17
|
+
return (
|
18
|
+
<>
|
19
|
+
<div className={styles.filterContainer}>
|
20
|
+
<Dropdown
|
21
|
+
id="stockOperationStatusesFiter"
|
22
|
+
items={items}
|
23
|
+
itemToString={(item) => (item ? item : "Not Set")}
|
24
|
+
type="inline"
|
25
|
+
size="sm"
|
26
|
+
/>
|
27
|
+
</div>
|
28
|
+
</>
|
29
|
+
);
|
30
|
+
};
|
31
|
+
|
32
|
+
export default StockOperationStatusesFilter;
|
@@ -0,0 +1,80 @@
|
|
1
|
+
import React, { useEffect, useMemo } from "react";
|
2
|
+
import { ButtonSkeleton, OverflowMenu, OverflowMenuItem } from "@carbon/react";
|
3
|
+
import { OverflowMenuVertical } from "@carbon/react/icons";
|
4
|
+
import {
|
5
|
+
useStockOperationTypes,
|
6
|
+
useUserRoles,
|
7
|
+
} from "../../stock-lookups/stock-lookups.resource";
|
8
|
+
import { StockOperationType } from "../../core/api/types/stockOperation/StockOperationType";
|
9
|
+
|
10
|
+
interface StockOperationTypesSelectorProps {
|
11
|
+
onOperationTypeSelected?: (operation: StockOperationType) => void;
|
12
|
+
onOperationLoaded?: (operation: StockOperationType[]) => void;
|
13
|
+
}
|
14
|
+
|
15
|
+
const StockOperationTypesSelector: React.FC<
|
16
|
+
StockOperationTypesSelectorProps
|
17
|
+
> = ({ onOperationTypeSelected, onOperationLoaded }) => {
|
18
|
+
const {
|
19
|
+
types: { results: createOperationTypes },
|
20
|
+
isLoading,
|
21
|
+
isError,
|
22
|
+
} = useStockOperationTypes();
|
23
|
+
const { userRoles } = useUserRoles();
|
24
|
+
|
25
|
+
const filterOperationTypes = useMemo(() => {
|
26
|
+
const applicablePrivilegeScopes =
|
27
|
+
userRoles?.operationTypes?.map((p) => p.operationTypeUuid) || [];
|
28
|
+
const uniqueApplicablePrivilegeScopes = [
|
29
|
+
...new Set(applicablePrivilegeScopes),
|
30
|
+
];
|
31
|
+
|
32
|
+
return (
|
33
|
+
createOperationTypes?.filter((p) =>
|
34
|
+
uniqueApplicablePrivilegeScopes.includes(p.uuid)
|
35
|
+
) || []
|
36
|
+
);
|
37
|
+
}, [createOperationTypes, userRoles]);
|
38
|
+
|
39
|
+
useEffect(() => {
|
40
|
+
onOperationLoaded?.(filterOperationTypes);
|
41
|
+
}, [filterOperationTypes, onOperationLoaded]);
|
42
|
+
|
43
|
+
if (isLoading || isError) return <ButtonSkeleton />;
|
44
|
+
|
45
|
+
return (
|
46
|
+
<OverflowMenu
|
47
|
+
renderIcon={() => (
|
48
|
+
<>
|
49
|
+
Start New
|
50
|
+
<OverflowMenuVertical size={16} />
|
51
|
+
</>
|
52
|
+
)}
|
53
|
+
menuOffset={{ right: "-100px" }}
|
54
|
+
style={{
|
55
|
+
backgroundColor: "#007d79",
|
56
|
+
backgroundImage: "none",
|
57
|
+
color: "#fff",
|
58
|
+
minHeight: "1rem",
|
59
|
+
padding: ".95rem !important",
|
60
|
+
width: "8rem",
|
61
|
+
marginRight: "0.5rem",
|
62
|
+
whiteSpace: "nowrap",
|
63
|
+
}}
|
64
|
+
>
|
65
|
+
{filterOperationTypes
|
66
|
+
.sort((a, b) => a.name.localeCompare(b.name))
|
67
|
+
.map((operation) => (
|
68
|
+
<OverflowMenuItem
|
69
|
+
key={operation.uuid}
|
70
|
+
itemText={operation.name}
|
71
|
+
onClick={() => {
|
72
|
+
onOperationTypeSelected?.(operation);
|
73
|
+
}}
|
74
|
+
/>
|
75
|
+
))}
|
76
|
+
</OverflowMenu>
|
77
|
+
);
|
78
|
+
};
|
79
|
+
|
80
|
+
export default StockOperationTypesSelector;
|
@@ -0,0 +1,106 @@
|
|
1
|
+
import { closeOverlay, launchOverlay } from "../core/components/overlay/hook";
|
2
|
+
import React from "react";
|
3
|
+
import {
|
4
|
+
FetchResponse,
|
5
|
+
showModal,
|
6
|
+
showNotification,
|
7
|
+
showToast,
|
8
|
+
} from "@openmrs/esm-framework";
|
9
|
+
import { StockOperationDTO } from "../core/api/types/stockOperation/StockOperationDTO";
|
10
|
+
import {
|
11
|
+
createStockOperation,
|
12
|
+
updateStockOperation,
|
13
|
+
} from "./stock-operations.resource";
|
14
|
+
import AddStockOperation from "./add-stock-operation/add-stock-operation.component";
|
15
|
+
import { StockOperationType } from "../core/api/types/stockOperation/StockOperationType";
|
16
|
+
import { useLocation } from "react-router-dom";
|
17
|
+
import { extractErrorMessagesFromResponse } from "../constants";
|
18
|
+
import { handleMutate } from "./swr-revalidation";
|
19
|
+
export const addOrEditStockOperation = async (
|
20
|
+
stockOperation: StockOperationDTO,
|
21
|
+
isEditing: boolean,
|
22
|
+
operation?: StockOperationType,
|
23
|
+
operations?: StockOperationType[],
|
24
|
+
canPrint?: boolean
|
25
|
+
) => {
|
26
|
+
const payload = stockOperation;
|
27
|
+
try {
|
28
|
+
if (operation.operationType === "requisition") {
|
29
|
+
delete payload.destinationName;
|
30
|
+
}
|
31
|
+
const response: FetchResponse<StockOperationDTO> = await (isEditing
|
32
|
+
? updateStockOperation
|
33
|
+
: createStockOperation)(payload);
|
34
|
+
|
35
|
+
if (response?.data) {
|
36
|
+
handleMutate("ws/rest/v1/stockmanagement/stockoperation");
|
37
|
+
showToast({
|
38
|
+
critical: true,
|
39
|
+
title: `${isEditing ? "Edit" : "Add"} Stock Operation`,
|
40
|
+
kind: "success",
|
41
|
+
description: `Stock Operation ${
|
42
|
+
isEditing ? "Edited" : "Added"
|
43
|
+
} Successfully`,
|
44
|
+
});
|
45
|
+
|
46
|
+
// Close overlay and open edit overlay
|
47
|
+
closeOverlay();
|
48
|
+
}
|
49
|
+
} catch (error) {
|
50
|
+
const errorMessages = extractErrorMessagesFromResponse(error);
|
51
|
+
showNotification({
|
52
|
+
description: errorMessages.join(", "),
|
53
|
+
title: "Error on saving form",
|
54
|
+
kind: "error",
|
55
|
+
critical: true,
|
56
|
+
});
|
57
|
+
}
|
58
|
+
};
|
59
|
+
|
60
|
+
export const launchAddOrEditDialog = (
|
61
|
+
stockOperation: StockOperationDTO,
|
62
|
+
isEditing: boolean,
|
63
|
+
operation?: StockOperationType,
|
64
|
+
operations?: StockOperationType[],
|
65
|
+
canPrint?: boolean
|
66
|
+
) => {
|
67
|
+
launchOverlay(
|
68
|
+
`${isEditing ? "Edit" : "New: "} ${
|
69
|
+
isEditing ? stockOperation?.operationTypeName : operation?.name
|
70
|
+
}`,
|
71
|
+
<AddStockOperation
|
72
|
+
model={stockOperation}
|
73
|
+
onSave={(so) =>
|
74
|
+
addOrEditStockOperation(so, isEditing, operation, operations, canPrint)
|
75
|
+
}
|
76
|
+
isEditing={isEditing}
|
77
|
+
operation={operation}
|
78
|
+
canEdit={
|
79
|
+
isEditing ? (stockOperation?.status === "NEW" ? true : false) : true
|
80
|
+
}
|
81
|
+
/>
|
82
|
+
);
|
83
|
+
};
|
84
|
+
|
85
|
+
export const useUrlQueryParams = () => {
|
86
|
+
return new URLSearchParams(useLocation().search);
|
87
|
+
};
|
88
|
+
|
89
|
+
export function getStockOperationUniqueId() {
|
90
|
+
return `${new Date().getTime()}-${Math.random()
|
91
|
+
.toString(36)
|
92
|
+
.substring(2, 16)}`;
|
93
|
+
}
|
94
|
+
|
95
|
+
export const showActionDialogButton = async (
|
96
|
+
title: string,
|
97
|
+
requireReason: boolean,
|
98
|
+
operation: StockOperationDTO
|
99
|
+
) => {
|
100
|
+
const dispose = showModal("stock-operation-dialog", {
|
101
|
+
title: title,
|
102
|
+
operation: operation,
|
103
|
+
requireReason: requireReason,
|
104
|
+
closeModal: () => dispose(),
|
105
|
+
});
|
106
|
+
};
|
package/src/stock-operations/stock-operations-dialog/stock-operations-approve-button.component.tsx
ADDED
@@ -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 { CheckmarkOutline } from "@carbon/react/icons";
|
7
|
+
import { StockOperationDTO } from "../../core/api/types/stockOperation/StockOperationDTO";
|
8
|
+
|
9
|
+
interface StockOperationApprovalButtonProps {
|
10
|
+
operation: StockOperationDTO;
|
11
|
+
}
|
12
|
+
|
13
|
+
const StockOperationApprovalButton: React.FC<
|
14
|
+
StockOperationApprovalButtonProps
|
15
|
+
> = ({ operation }) => {
|
16
|
+
const { t } = useTranslation();
|
17
|
+
const launchApprovalModal = useCallback(() => {
|
18
|
+
const dispose = showModal("stock-operation-dialog", {
|
19
|
+
title: "Approve",
|
20
|
+
operation: operation,
|
21
|
+
requireReason: false,
|
22
|
+
closeModal: () => dispose(),
|
23
|
+
});
|
24
|
+
}, [operation]);
|
25
|
+
|
26
|
+
return (
|
27
|
+
<Button
|
28
|
+
onClick={launchApprovalModal}
|
29
|
+
renderIcon={(props) => <CheckmarkOutline size={16} {...props} />}
|
30
|
+
>
|
31
|
+
{t("approve", "Approve ")}
|
32
|
+
</Button>
|
33
|
+
);
|
34
|
+
};
|
35
|
+
|
36
|
+
export default StockOperationApprovalButton;
|
@@ -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 { Departure } from "@carbon/react/icons";
|
7
|
+
import { StockOperationDTO } from "../../core/api/types/stockOperation/StockOperationDTO";
|
8
|
+
|
9
|
+
interface StockOperationApproveDispatchButtonProps {
|
10
|
+
operation: StockOperationDTO;
|
11
|
+
}
|
12
|
+
|
13
|
+
const StockOperationApproveDispatchButton: React.FC<
|
14
|
+
StockOperationApproveDispatchButtonProps
|
15
|
+
> = ({ operation }) => {
|
16
|
+
const { t } = useTranslation();
|
17
|
+
const launchApproveDispatchModal = useCallback(() => {
|
18
|
+
const dispose = showModal("stock-operation-dialog", {
|
19
|
+
title: "Dispatch",
|
20
|
+
operation: operation,
|
21
|
+
requireReason: true,
|
22
|
+
closeModal: () => dispose(),
|
23
|
+
});
|
24
|
+
}, [operation]);
|
25
|
+
|
26
|
+
return (
|
27
|
+
<Button
|
28
|
+
onClick={launchApproveDispatchModal}
|
29
|
+
renderIcon={(props) => <Departure size={16} {...props} />}
|
30
|
+
>
|
31
|
+
{t("approve", "Dispatch")}
|
32
|
+
</Button>
|
33
|
+
);
|
34
|
+
};
|
35
|
+
|
36
|
+
export default StockOperationApproveDispatchButton;
|
package/src/stock-operations/stock-operations-dialog/stock-operations-cancel-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 { Error } from "@carbon/react/icons";
|
7
|
+
import { StockOperationDTO } from "../../core/api/types/stockOperation/StockOperationDTO";
|
8
|
+
|
9
|
+
interface StockOperationCancelButtonProps {
|
10
|
+
operation: StockOperationDTO;
|
11
|
+
}
|
12
|
+
|
13
|
+
const StockOperationCancelButton: React.FC<StockOperationCancelButtonProps> = ({
|
14
|
+
operation,
|
15
|
+
}) => {
|
16
|
+
const { t } = useTranslation();
|
17
|
+
const launchCancelModal = useCallback(() => {
|
18
|
+
const dispose = showModal("stock-operation-dialog", {
|
19
|
+
title: "Cancel",
|
20
|
+
operation: operation,
|
21
|
+
requireReason: true,
|
22
|
+
closeModal: () => dispose(),
|
23
|
+
});
|
24
|
+
}, [operation]);
|
25
|
+
|
26
|
+
return (
|
27
|
+
<Button
|
28
|
+
onClick={launchCancelModal}
|
29
|
+
kind="danger--ghost"
|
30
|
+
renderIcon={(props) => <Error size={16} {...props} />}
|
31
|
+
>
|
32
|
+
{t("cancel", "Cancel ")}
|
33
|
+
</Button>
|
34
|
+
);
|
35
|
+
};
|
36
|
+
|
37
|
+
export default StockOperationCancelButton;
|
package/src/stock-operations/stock-operations-dialog/stock-operations-complete-button.component.tsx
ADDED
@@ -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 { CheckmarkOutline } from "@carbon/react/icons";
|
7
|
+
import { StockOperationDTO } from "../../core/api/types/stockOperation/StockOperationDTO";
|
8
|
+
|
9
|
+
interface StockOperationCompleteButtonProps {
|
10
|
+
operation: StockOperationDTO;
|
11
|
+
}
|
12
|
+
|
13
|
+
const StockOperationCompleteButton: React.FC<
|
14
|
+
StockOperationCompleteButtonProps
|
15
|
+
> = ({ operation }) => {
|
16
|
+
const { t } = useTranslation();
|
17
|
+
const launchCompleteModal = useCallback(() => {
|
18
|
+
const dispose = showModal("stock-operation-dialog", {
|
19
|
+
title: "Complete",
|
20
|
+
operation: operation,
|
21
|
+
requireReason: true,
|
22
|
+
closeModal: () => dispose(),
|
23
|
+
});
|
24
|
+
}, [operation]);
|
25
|
+
|
26
|
+
return (
|
27
|
+
<Button
|
28
|
+
onClick={launchCompleteModal}
|
29
|
+
renderIcon={(props) => <CheckmarkOutline size={16} {...props} />}
|
30
|
+
>
|
31
|
+
{t("complete", "Complete")}
|
32
|
+
</Button>
|
33
|
+
);
|
34
|
+
};
|
35
|
+
|
36
|
+
export default StockOperationCompleteButton;
|