@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,32 @@
|
|
1
|
+
import { ResourceRepresentation } from "../core/api/api";
|
2
|
+
import { useEffect, useMemo, useState } from "react";
|
3
|
+
import {
|
4
|
+
StockBatchFilter,
|
5
|
+
StockItemInventoryFilter,
|
6
|
+
useStockBatches,
|
7
|
+
useStockItemInventory,
|
8
|
+
} from "../stock-items/stock-items.resource";
|
9
|
+
|
10
|
+
export function useStockInventory() {
|
11
|
+
const [stockItemFilter, setStockItemFilter] = useState<StockBatchFilter>({
|
12
|
+
startIndex: 0,
|
13
|
+
v: ResourceRepresentation.Default,
|
14
|
+
q: null,
|
15
|
+
includeStockItemName: "true",
|
16
|
+
});
|
17
|
+
|
18
|
+
useEffect(() => {
|
19
|
+
setStockItemFilter({
|
20
|
+
v: ResourceRepresentation.Default,
|
21
|
+
includeStockItemName: "true",
|
22
|
+
});
|
23
|
+
}, []);
|
24
|
+
|
25
|
+
const { items, isLoading, isError } = useStockBatches(stockItemFilter);
|
26
|
+
|
27
|
+
return {
|
28
|
+
items: items.results ?? [],
|
29
|
+
isLoading,
|
30
|
+
isError,
|
31
|
+
};
|
32
|
+
}
|
@@ -0,0 +1,28 @@
|
|
1
|
+
import {
|
2
|
+
StockItemFilter,
|
3
|
+
useStockItems,
|
4
|
+
} from "../stock-items/stock-items.resource";
|
5
|
+
import { useEffect, useState } from "react";
|
6
|
+
import { ResourceRepresentation } from "../core/api/api";
|
7
|
+
export function useStockInventoryItems(v?: ResourceRepresentation) {
|
8
|
+
const [stockItemFilter, setStockItemFilter] = useState<StockItemFilter>({
|
9
|
+
v: v || ResourceRepresentation.Default,
|
10
|
+
q: null,
|
11
|
+
totalCount: true,
|
12
|
+
});
|
13
|
+
|
14
|
+
const { items, isLoading, isError } = useStockItems(stockItemFilter);
|
15
|
+
|
16
|
+
useEffect(() => {
|
17
|
+
setStockItemFilter({
|
18
|
+
v: ResourceRepresentation.Default,
|
19
|
+
totalCount: true,
|
20
|
+
});
|
21
|
+
}, []);
|
22
|
+
|
23
|
+
return {
|
24
|
+
items: items?.results ?? [],
|
25
|
+
isLoading,
|
26
|
+
isError,
|
27
|
+
};
|
28
|
+
}
|
@@ -0,0 +1,84 @@
|
|
1
|
+
import React from "react";
|
2
|
+
import { useTranslation } from "react-i18next";
|
3
|
+
import { Button } from "@carbon/react";
|
4
|
+
import { navigate, useLayoutType } from "@openmrs/esm-framework";
|
5
|
+
import styles from "./stock-home-detail-card.scss";
|
6
|
+
import { ResourceRepresentation } from "../core/api/api";
|
7
|
+
import { DocumentImport } from "@carbon/react/icons";
|
8
|
+
import { useStockIssuing } from "./stock-home-issuing.resource";
|
9
|
+
|
10
|
+
const StockHomeIssuingCard = () => {
|
11
|
+
const { t } = useTranslation();
|
12
|
+
const isTablet = useLayoutType() === "tablet";
|
13
|
+
|
14
|
+
const { items, isLoading } = useStockIssuing({
|
15
|
+
v: ResourceRepresentation.Full,
|
16
|
+
totalCount: true,
|
17
|
+
});
|
18
|
+
|
19
|
+
if (isLoading) return <></>;
|
20
|
+
|
21
|
+
if (items.length === 0) {
|
22
|
+
return (
|
23
|
+
<>
|
24
|
+
<p className={styles.content}>
|
25
|
+
{t("issuingNull", "No issued to display")}
|
26
|
+
</p>
|
27
|
+
</>
|
28
|
+
);
|
29
|
+
}
|
30
|
+
|
31
|
+
const itemsToDisplay = items.map((item, index) => {
|
32
|
+
// Assuming you are using 'stockOperationItems' from each 'item'
|
33
|
+
const stockItems = item?.stockOperationItems || [];
|
34
|
+
|
35
|
+
// Assuming you are using some properties from 'stock' in your code
|
36
|
+
const formattedStockItems = stockItems.map((stock, stockIndex) => ({
|
37
|
+
status: item?.status,
|
38
|
+
sourceName: item?.sourceName,
|
39
|
+
destinationName: item?.destinationName,
|
40
|
+
stockItemName: stock?.stockItemName,
|
41
|
+
stockItemPackagingUOMName: stock?.stockItemPackagingUOMName,
|
42
|
+
quantity: stock?.quantity,
|
43
|
+
key: `${index}-${stockIndex}`,
|
44
|
+
}));
|
45
|
+
|
46
|
+
return formattedStockItems;
|
47
|
+
});
|
48
|
+
|
49
|
+
const flattenedItemsToDisplay = itemsToDisplay.flat().slice(0, 10);
|
50
|
+
|
51
|
+
return (
|
52
|
+
<>
|
53
|
+
{flattenedItemsToDisplay.map((item, index) => (
|
54
|
+
<div className={styles.card} key={index}>
|
55
|
+
<div className={styles.colorLineGreen} />
|
56
|
+
<div className={styles.icon}>
|
57
|
+
<DocumentImport size={40} color={"#198038"} />
|
58
|
+
</div>
|
59
|
+
<div className={styles.cardText}>
|
60
|
+
<p>
|
61
|
+
{item?.status} · {item?.sourceName} · {item?.destinationName}
|
62
|
+
</p>
|
63
|
+
<p>
|
64
|
+
<strong>{item?.stockItemName}</strong>{" "}
|
65
|
+
{item?.stockItemPackagingUOMName}, {item?.quantity}
|
66
|
+
</p>
|
67
|
+
</div>
|
68
|
+
</div>
|
69
|
+
))}
|
70
|
+
<Button
|
71
|
+
onClick={() => {
|
72
|
+
navigate({
|
73
|
+
to: `${window.getOpenmrsSpaBase()}stock-management/requisitions`,
|
74
|
+
});
|
75
|
+
}}
|
76
|
+
kind="ghost"
|
77
|
+
>
|
78
|
+
View All
|
79
|
+
</Button>
|
80
|
+
</>
|
81
|
+
);
|
82
|
+
};
|
83
|
+
|
84
|
+
export default StockHomeIssuingCard;
|
@@ -0,0 +1,18 @@
|
|
1
|
+
import {
|
2
|
+
StockOperationFilter,
|
3
|
+
useStockOperations,
|
4
|
+
} from "../stock-operations/stock-operations.resource";
|
5
|
+
|
6
|
+
export function useStockIssuing(filter: StockOperationFilter) {
|
7
|
+
const { items, isLoading, isError } = useStockOperations(filter);
|
8
|
+
|
9
|
+
const receivedItems = items?.results?.filter(
|
10
|
+
(item) =>
|
11
|
+
item?.operationType === "stockissue" && item?.status !== "COMPLETED"
|
12
|
+
);
|
13
|
+
return {
|
14
|
+
items: receivedItems,
|
15
|
+
isLoading,
|
16
|
+
isError,
|
17
|
+
};
|
18
|
+
}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import React from "react";
|
2
|
+
import { StockManagementHeader } from "../stock-management-header/stock-management-header.component";
|
3
|
+
import StockManagementMetrics from "./stock-home-metrics";
|
4
|
+
import StockHomeDetailCards from "./stock-home-detail-cards.component";
|
5
|
+
|
6
|
+
export default function StockHomeLandingPage() {
|
7
|
+
const basePath = `${window.getOpenmrsSpaBase()}stock-management`;
|
8
|
+
return (
|
9
|
+
<div style={{ backgroundColor: "white" }}>
|
10
|
+
<StockManagementMetrics />
|
11
|
+
<StockHomeDetailCards />
|
12
|
+
</div>
|
13
|
+
);
|
14
|
+
}
|
@@ -0,0 +1,112 @@
|
|
1
|
+
import React from "react";
|
2
|
+
import { useTranslation } from "react-i18next";
|
3
|
+
import { InlineLoading } from "@carbon/react";
|
4
|
+
import { ErrorState } from "@openmrs/esm-framework";
|
5
|
+
import styles from "./stock-home.scss";
|
6
|
+
import MetricsCard from "../core/components/card/metrics-card-component";
|
7
|
+
import useStockList from "./useStockList";
|
8
|
+
|
9
|
+
import { StockOperationFilter } from "../stock-operations/stock-operations.resource";
|
10
|
+
import { useDisposalList } from "./useDisposalList";
|
11
|
+
import { ResourceRepresentation } from "../core/api/api";
|
12
|
+
import { useStockInventoryItems } from "./stock-home-inventory-items.resource";
|
13
|
+
import { useStockInventory } from "./stock-home-inventory-expiry.resource";
|
14
|
+
|
15
|
+
const StockManagementMetrics: React.FC = (filter: StockOperationFilter) => {
|
16
|
+
const { t } = useTranslation();
|
17
|
+
|
18
|
+
const { stockList: allStocks, isLoading, error } = useStockList();
|
19
|
+
|
20
|
+
const { items: expiryItems, isLoading: inventoryLoading } =
|
21
|
+
useStockInventory();
|
22
|
+
const { items: stockItems } = useStockInventoryItems();
|
23
|
+
|
24
|
+
const currentDate: any = new Date();
|
25
|
+
let mergedArray: any[] = expiryItems.map((batch) => {
|
26
|
+
const matchingItem = stockItems?.find(
|
27
|
+
(item2) => batch?.stockItemUuid === item2.uuid
|
28
|
+
);
|
29
|
+
return { ...batch, ...matchingItem };
|
30
|
+
});
|
31
|
+
mergedArray = mergedArray.filter((item) => item.hasExpiration);
|
32
|
+
const filteredData = mergedArray.filter((item) => {
|
33
|
+
const expiryNotice = item.expiryNotice || 0;
|
34
|
+
const expirationDate: any = new Date(item.expiration);
|
35
|
+
const differenceInDays = Math.ceil(
|
36
|
+
(expirationDate - currentDate) / (1000 * 60 * 60 * 24)
|
37
|
+
);
|
38
|
+
|
39
|
+
return differenceInDays <= expiryNotice || differenceInDays < 0;
|
40
|
+
});
|
41
|
+
|
42
|
+
const { items } = useDisposalList({
|
43
|
+
v: ResourceRepresentation.Full,
|
44
|
+
totalCount: true,
|
45
|
+
});
|
46
|
+
|
47
|
+
if (isLoading) {
|
48
|
+
return (
|
49
|
+
<InlineLoading
|
50
|
+
role="progressbar"
|
51
|
+
description={t("loading", "Loading...")}
|
52
|
+
/>
|
53
|
+
);
|
54
|
+
}
|
55
|
+
if (error) {
|
56
|
+
return <ErrorState headerTitle={t("errorStockMetric")} error={error} />;
|
57
|
+
}
|
58
|
+
|
59
|
+
const sevenDaysExpiryStocks = allStocks.filter(
|
60
|
+
(stock) => stock.hasExpiration && stock.ExpiryNotice <= 7
|
61
|
+
);
|
62
|
+
const thirtyDaysExpiryStocks = allStocks.filter(
|
63
|
+
(stock) => stock.hasExpiration && stock.ExpiryNotice <= 30
|
64
|
+
);
|
65
|
+
|
66
|
+
const filteredItems =
|
67
|
+
items &&
|
68
|
+
items.filter(
|
69
|
+
(item) =>
|
70
|
+
item.reasonName === "Drug not available due to expired medication"
|
71
|
+
);
|
72
|
+
const filteredItemsPoorquality =
|
73
|
+
items && items.filter((item) => item.reasonName === "Poor Quality");
|
74
|
+
|
75
|
+
return (
|
76
|
+
<>
|
77
|
+
<div className={styles.cardContainer}>
|
78
|
+
<MetricsCard
|
79
|
+
label={t("stocks", "Expiring stock")}
|
80
|
+
value={filteredData?.length || 0}
|
81
|
+
headerLabel={t("expiringStock", "Expiring Stock")}
|
82
|
+
view="items"
|
83
|
+
count={{
|
84
|
+
expiry7days: sevenDaysExpiryStocks,
|
85
|
+
expiry30days: thirtyDaysExpiryStocks,
|
86
|
+
}}
|
87
|
+
/>
|
88
|
+
<MetricsCard
|
89
|
+
label={t("outofstock", "Out of Stock")}
|
90
|
+
value={allStocks?.length}
|
91
|
+
headerLabel={t("highestServiceVolume", "Out of Stock ")}
|
92
|
+
view="items"
|
93
|
+
outofstockCount={{
|
94
|
+
itemsbelowmin: sevenDaysExpiryStocks,
|
95
|
+
itemsabovemax: thirtyDaysExpiryStocks,
|
96
|
+
}}
|
97
|
+
/>
|
98
|
+
<MetricsCard
|
99
|
+
label={t("disposedstock", "Disposed Stock")}
|
100
|
+
value={items?.length || 0}
|
101
|
+
headerLabel={t("providersAvailableToday", "Disposed Stock ")}
|
102
|
+
view="items"
|
103
|
+
disposedCount={{
|
104
|
+
expired: filteredItems,
|
105
|
+
poorquality: filteredItemsPoorquality,
|
106
|
+
}}
|
107
|
+
/>
|
108
|
+
</div>
|
109
|
+
</>
|
110
|
+
);
|
111
|
+
};
|
112
|
+
export default StockManagementMetrics;
|
@@ -0,0 +1,66 @@
|
|
1
|
+
import React from "react";
|
2
|
+
import { useTranslation } from "react-i18next";
|
3
|
+
import { Button } from "@carbon/react";
|
4
|
+
import { navigate, useLayoutType } from "@openmrs/esm-framework";
|
5
|
+
import styles from "./stock-home-detail-card.scss";
|
6
|
+
import { Delivery } from "@carbon/react/icons";
|
7
|
+
import { ResourceRepresentation } from "../core/api/api";
|
8
|
+
import { useStockReceiving } from "./stock-home-receiving.resource";
|
9
|
+
|
10
|
+
const StockHomeReceivingCard = () => {
|
11
|
+
const { t } = useTranslation();
|
12
|
+
const isTablet = useLayoutType() === "tablet";
|
13
|
+
|
14
|
+
const { items, isLoading } = useStockReceiving({
|
15
|
+
v: ResourceRepresentation.Full,
|
16
|
+
totalCount: true,
|
17
|
+
});
|
18
|
+
|
19
|
+
if (isLoading) return <></>;
|
20
|
+
|
21
|
+
if (items.length === 0) {
|
22
|
+
return (
|
23
|
+
<>
|
24
|
+
<p className={styles.content}>
|
25
|
+
{t("receivedNull", "No received to display")}
|
26
|
+
</p>
|
27
|
+
</>
|
28
|
+
);
|
29
|
+
}
|
30
|
+
|
31
|
+
return (
|
32
|
+
<>
|
33
|
+
{items.map((item, index) =>
|
34
|
+
item?.stockOperationItems.map((stock) => (
|
35
|
+
<div className={styles.card} key={index}>
|
36
|
+
<div className={styles.colorLineBlue} />
|
37
|
+
<div className={styles.icon}>
|
38
|
+
<Delivery size={40} color={"#0F62FE"} />
|
39
|
+
</div>
|
40
|
+
<div className={styles.cardText}>
|
41
|
+
<p>
|
42
|
+
{item?.status} · {item?.sourceName} · {item?.destinationName}
|
43
|
+
</p>
|
44
|
+
<p>
|
45
|
+
<strong>{stock?.stockItemName}</strong>{" "}
|
46
|
+
{stock?.stockItemPackagingUOMName}, {stock?.quantity}
|
47
|
+
</p>
|
48
|
+
</div>
|
49
|
+
</div>
|
50
|
+
))
|
51
|
+
)}
|
52
|
+
<Button
|
53
|
+
onClick={() => {
|
54
|
+
navigate({
|
55
|
+
to: `${window.getOpenmrsSpaBase()}stock-management/orders`,
|
56
|
+
});
|
57
|
+
}}
|
58
|
+
kind="ghost"
|
59
|
+
>
|
60
|
+
{t("receivedView", "View All")}
|
61
|
+
</Button>
|
62
|
+
</>
|
63
|
+
);
|
64
|
+
};
|
65
|
+
|
66
|
+
export default StockHomeReceivingCard;
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import {
|
2
|
+
StockOperationFilter,
|
3
|
+
useStockOperations,
|
4
|
+
} from "../stock-operations/stock-operations.resource";
|
5
|
+
|
6
|
+
export function useStockReceiving(filter: StockOperationFilter) {
|
7
|
+
const { items, isLoading, isError } = useStockOperations(filter);
|
8
|
+
|
9
|
+
const receivedItems = items?.results?.filter(
|
10
|
+
(item) => item?.operationType === "receipt" && item?.status !== "COMPLETED"
|
11
|
+
);
|
12
|
+
return {
|
13
|
+
items: receivedItems,
|
14
|
+
isLoading,
|
15
|
+
isError,
|
16
|
+
};
|
17
|
+
}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
@use '@carbon/styles/scss/spacing';
|
2
|
+
@use '@carbon/styles/scss/type';
|
3
|
+
@use '@carbon/colors';
|
4
|
+
@import '~@openmrs/esm-styleguide/src/vars';
|
5
|
+
.cardContainer {
|
6
|
+
background-color: colors.$white;
|
7
|
+
display: flex;
|
8
|
+
justify-content: space-between;
|
9
|
+
margin: 0 spacing.$spacing-05 0 spacing.$spacing-05;
|
10
|
+
flex-flow: row wrap;
|
11
|
+
column-gap: spacing.$spacing-05;
|
12
|
+
row-gap: spacing.$spacing-05;
|
13
|
+
}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
import {
|
2
|
+
StockOperationFilter,
|
3
|
+
useStockOperations,
|
4
|
+
} from "../stock-operations/stock-operations.resource";
|
5
|
+
|
6
|
+
export function useDisposalList(filter: StockOperationFilter) {
|
7
|
+
const { items, isLoading, isError } = useStockOperations(filter);
|
8
|
+
|
9
|
+
const receivedItems = items?.results?.filter(
|
10
|
+
(item) => item?.operationType === "disposed"
|
11
|
+
);
|
12
|
+
|
13
|
+
return {
|
14
|
+
items: receivedItems,
|
15
|
+
isLoading,
|
16
|
+
isError,
|
17
|
+
};
|
18
|
+
}
|
@@ -0,0 +1,36 @@
|
|
1
|
+
import useSWR from "swr";
|
2
|
+
import { openmrsFetch } from "@openmrs/esm-framework";
|
3
|
+
|
4
|
+
interface StockList {
|
5
|
+
uuid: string;
|
6
|
+
hasExpiration: boolean;
|
7
|
+
ExpiryNotice: number;
|
8
|
+
results: {
|
9
|
+
uuid: string;
|
10
|
+
hasExpiration: boolean;
|
11
|
+
ExpiryNotice: number;
|
12
|
+
};
|
13
|
+
}
|
14
|
+
|
15
|
+
const useStockList = () => {
|
16
|
+
const url = `/ws/rest/v1/stockmanagement/stockitem`;
|
17
|
+
|
18
|
+
const { data, error } = useSWR<{ data: { results: Array<StockList> } }>(
|
19
|
+
url,
|
20
|
+
openmrsFetch
|
21
|
+
);
|
22
|
+
|
23
|
+
const stocks = data?.data.results.map((stock) => ({
|
24
|
+
uuid: stock.uuid,
|
25
|
+
hasExpiration: stock.hasExpiration,
|
26
|
+
ExpiryNotice: stock.ExpiryNotice,
|
27
|
+
}));
|
28
|
+
|
29
|
+
return {
|
30
|
+
stockList: (stocks as Array<any>) ?? [],
|
31
|
+
isLoading: !data && !error,
|
32
|
+
error,
|
33
|
+
};
|
34
|
+
};
|
35
|
+
|
36
|
+
export default useStockList;
|
package/src/stock-items/add-bulk-stock-item/add-stock-items-bulk-import-action-button.component.tsx
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
import { Button } from "@carbon/react";
|
2
|
+
import React, { useCallback } from "react";
|
3
|
+
import { useTranslation } from "react-i18next";
|
4
|
+
import { showModal } from "@openmrs/esm-framework";
|
5
|
+
|
6
|
+
const AddStockItemsBulktImportActionButton: React.FC = () => {
|
7
|
+
const { t } = useTranslation();
|
8
|
+
|
9
|
+
const handleClick = useCallback(() => {
|
10
|
+
const dispose = showModal("import-bulk-stock-items", {
|
11
|
+
closeModal: () => dispose(),
|
12
|
+
});
|
13
|
+
}, []);
|
14
|
+
|
15
|
+
return (
|
16
|
+
<Button
|
17
|
+
kind="ghost"
|
18
|
+
onClick={handleClick}
|
19
|
+
iconDescription={t("import", "Import")}
|
20
|
+
>
|
21
|
+
{t("import", "Import")}
|
22
|
+
</Button>
|
23
|
+
);
|
24
|
+
};
|
25
|
+
|
26
|
+
export default AddStockItemsBulktImportActionButton;
|
@@ -0,0 +1,109 @@
|
|
1
|
+
import React, { useState } from "react";
|
2
|
+
import { useTranslation } from "react-i18next";
|
3
|
+
import {
|
4
|
+
Button,
|
5
|
+
Form,
|
6
|
+
ModalBody,
|
7
|
+
ModalFooter,
|
8
|
+
ModalHeader,
|
9
|
+
FileUploader,
|
10
|
+
} from "@carbon/react";
|
11
|
+
import { UploadStockItems } from "./stock-items-bulk-import.resource";
|
12
|
+
import { showNotification, showToast } from "@openmrs/esm-framework";
|
13
|
+
|
14
|
+
export interface ImportDialogPopupProps {
|
15
|
+
closeModal: () => void;
|
16
|
+
}
|
17
|
+
|
18
|
+
const ImportDialogPopup: React.FC<ImportDialogPopupProps> = ({
|
19
|
+
closeModal,
|
20
|
+
}) => {
|
21
|
+
const { t } = useTranslation();
|
22
|
+
const [selectedFile, setSelectedFile] = useState<any>();
|
23
|
+
const [hasHeader, setHasHeader] = useState(true);
|
24
|
+
const [fileNotSelected, setFileNotSelected] = useState(true);
|
25
|
+
|
26
|
+
const onConfirmUpload = () => {
|
27
|
+
if (!selectedFile) {
|
28
|
+
return;
|
29
|
+
}
|
30
|
+
const formData = new FormData();
|
31
|
+
if (selectedFile) {
|
32
|
+
formData.append("file", selectedFile, "Import_Stock_Items.csv");
|
33
|
+
formData.append("hasHeader", hasHeader ? "true" : "false");
|
34
|
+
}
|
35
|
+
UploadStockItems(formData).then(
|
36
|
+
(resp) => {
|
37
|
+
showToast({
|
38
|
+
critical: true,
|
39
|
+
title: t("rejectOrder", "Uploaded Order"),
|
40
|
+
kind: "success",
|
41
|
+
description: t(
|
42
|
+
"Successfully uploaded",
|
43
|
+
`You have successfully uploaded stock items`
|
44
|
+
),
|
45
|
+
});
|
46
|
+
closeModal();
|
47
|
+
},
|
48
|
+
(err) => {
|
49
|
+
showNotification({
|
50
|
+
title: t(
|
51
|
+
`errorUploadingItems', 'An error occurred uploading stock items`
|
52
|
+
),
|
53
|
+
kind: "error",
|
54
|
+
critical: true,
|
55
|
+
description: err?.message,
|
56
|
+
});
|
57
|
+
}
|
58
|
+
);
|
59
|
+
};
|
60
|
+
|
61
|
+
const onFileChanged = (event: React.ChangeEvent<HTMLInputElement>) => {
|
62
|
+
const file = event?.target?.files?.[0];
|
63
|
+
if (file) {
|
64
|
+
setSelectedFile(file);
|
65
|
+
setFileNotSelected(false);
|
66
|
+
} else {
|
67
|
+
event.preventDefault();
|
68
|
+
}
|
69
|
+
};
|
70
|
+
|
71
|
+
const onFileDeleted = () => {
|
72
|
+
setFileNotSelected(true);
|
73
|
+
};
|
74
|
+
|
75
|
+
return (
|
76
|
+
<div>
|
77
|
+
<Form>
|
78
|
+
<ModalHeader
|
79
|
+
closeModal={closeModal}
|
80
|
+
title={t("importStockItems", "Import Stock Items")}
|
81
|
+
/>
|
82
|
+
<ModalBody>
|
83
|
+
<FileUploader
|
84
|
+
accept={[".csv"]}
|
85
|
+
multiple={false}
|
86
|
+
name={"file"}
|
87
|
+
buttonLabel="Select file"
|
88
|
+
labelDescription="Only .csv files at 2mb or less"
|
89
|
+
filenameStatus="edit"
|
90
|
+
labelTitle=""
|
91
|
+
size="small"
|
92
|
+
onChange={onFileChanged}
|
93
|
+
onDelete={onFileDeleted}
|
94
|
+
/>
|
95
|
+
</ModalBody>
|
96
|
+
<ModalFooter>
|
97
|
+
<Button kind="secondary" onClick={closeModal}>
|
98
|
+
{t("cancel", "Cancel")}
|
99
|
+
</Button>
|
100
|
+
<Button type="button" onClick={onConfirmUpload}>
|
101
|
+
{t("uploadStockItems", "Upload StockItems")}
|
102
|
+
</Button>
|
103
|
+
</ModalFooter>
|
104
|
+
</Form>
|
105
|
+
</div>
|
106
|
+
);
|
107
|
+
};
|
108
|
+
|
109
|
+
export default ImportDialogPopup;
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import { openmrsFetch } from "@openmrs/esm-framework";
|
2
|
+
|
3
|
+
export async function UploadStockItems(body: any) {
|
4
|
+
const abortController = new AbortController();
|
5
|
+
|
6
|
+
return openmrsFetch(`/ws/rest/v1/stockmanagement/stockitemimport`, {
|
7
|
+
method: "POST",
|
8
|
+
// headers: {
|
9
|
+
// "Content-Type": "application/json",
|
10
|
+
// },
|
11
|
+
signal: abortController.signal,
|
12
|
+
body: body,
|
13
|
+
});
|
14
|
+
}
|
File without changes
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import { Button } from "@carbon/react";
|
2
|
+
import React, { useCallback } from "react";
|
3
|
+
import { useTranslation } from "react-i18next";
|
4
|
+
import { initialValues } from "./add-stock-item.resource";
|
5
|
+
import { launchAddOrEditDialog } from "../stock-item.utils";
|
6
|
+
|
7
|
+
const AddStockItemActionButton: React.FC = () => {
|
8
|
+
const { t } = useTranslation();
|
9
|
+
|
10
|
+
const handleClick = useCallback(() => {
|
11
|
+
launchAddOrEditDialog(initialValues, false);
|
12
|
+
}, []);
|
13
|
+
|
14
|
+
return (
|
15
|
+
<Button onClick={handleClick} size="md" kind="primary">
|
16
|
+
{t("stockmanagement.addnew", "Add New")}
|
17
|
+
</Button>
|
18
|
+
);
|
19
|
+
};
|
20
|
+
|
21
|
+
export default AddStockItemActionButton;
|