@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,151 @@
|
|
1
|
+
import React, { useEffect, useMemo } from "react";
|
2
|
+
import { ResourceRepresentation } from "../../../core/api/api";
|
3
|
+
import { useStockItemsTransactions } from "./transactions.resource";
|
4
|
+
import { DataTableSkeleton, Link, Tile } from "@carbon/react";
|
5
|
+
import { formatDisplayDate } from "../../../core/utils/datetimeUtils";
|
6
|
+
import { ArrowLeft } from "@carbon/react/icons";
|
7
|
+
import DataList from "../../../core/components/table/table.component";
|
8
|
+
import styles from "../../stock-items-table.scss";
|
9
|
+
import { URL_STOCK_OPERATION } from "../../../constants";
|
10
|
+
import { StockOperationType } from "../../../core/api/types/stockOperation/StockOperationType";
|
11
|
+
import EditStockOperationActionMenu from "../../../stock-operations/edit-stock-operation/edit-stock-operation-action-menu.component";
|
12
|
+
|
13
|
+
interface TransactionsProps {
|
14
|
+
onSubmit?: () => void;
|
15
|
+
stockItemUuid: string;
|
16
|
+
}
|
17
|
+
|
18
|
+
const Transactions: React.FC<TransactionsProps> = ({ stockItemUuid }) => {
|
19
|
+
const {
|
20
|
+
isLoading,
|
21
|
+
items,
|
22
|
+
tableHeaders,
|
23
|
+
|
24
|
+
totalCount,
|
25
|
+
setCurrentPage,
|
26
|
+
setStockItemUuid,
|
27
|
+
} = useStockItemsTransactions(ResourceRepresentation.Default);
|
28
|
+
|
29
|
+
useEffect(() => {
|
30
|
+
setStockItemUuid(stockItemUuid);
|
31
|
+
}, [stockItemUuid, setStockItemUuid]);
|
32
|
+
|
33
|
+
let operations: StockOperationType[] | null | undefined;
|
34
|
+
const tableRows = useMemo(() => {
|
35
|
+
return items?.map((stockItemTransaction) => ({
|
36
|
+
...stockItemTransaction,
|
37
|
+
id: stockItemTransaction?.uuid,
|
38
|
+
key: `key-${stockItemTransaction?.uuid}`,
|
39
|
+
uuid: `${stockItemTransaction?.uuid}`,
|
40
|
+
date: formatDisplayDate(stockItemTransaction?.dateCreated),
|
41
|
+
location:
|
42
|
+
stockItemTransaction.operationSourcePartyName &&
|
43
|
+
stockItemTransaction.operationDestinationPartyName ? (
|
44
|
+
stockItemTransaction.operationSourcePartyName ===
|
45
|
+
stockItemTransaction?.partyName ? (
|
46
|
+
stockItemTransaction.quantity > 0 ? (
|
47
|
+
<>
|
48
|
+
<span className="transaction-location">
|
49
|
+
{stockItemTransaction.operationSourcePartyName}
|
50
|
+
</span>
|
51
|
+
<ArrowLeft size={16} />{" "}
|
52
|
+
{stockItemTransaction.operationDestinationPartyName}
|
53
|
+
</>
|
54
|
+
) : (
|
55
|
+
<>
|
56
|
+
<span className="transaction-location">
|
57
|
+
{stockItemTransaction.operationSourcePartyName}
|
58
|
+
</span>
|
59
|
+
<ArrowLeft size={16} />{" "}
|
60
|
+
{stockItemTransaction.operationDestinationPartyName}
|
61
|
+
</>
|
62
|
+
)
|
63
|
+
) : stockItemTransaction.operationDestinationPartyName ===
|
64
|
+
stockItemTransaction?.partyName ? (
|
65
|
+
stockItemTransaction.quantity > 0 ? (
|
66
|
+
<>
|
67
|
+
<span className="transaction-location">
|
68
|
+
{stockItemTransaction.operationDestinationPartyName}
|
69
|
+
</span>
|
70
|
+
<ArrowLeft size={16} />{" "}
|
71
|
+
{stockItemTransaction.operationSourcePartyName}
|
72
|
+
</>
|
73
|
+
) : (
|
74
|
+
<>
|
75
|
+
<span className="transaction-location">
|
76
|
+
{stockItemTransaction.operationDestinationPartyName}
|
77
|
+
</span>
|
78
|
+
<ArrowLeft size={16} />{" "}
|
79
|
+
{stockItemTransaction.operationSourcePartyName}
|
80
|
+
</>
|
81
|
+
)
|
82
|
+
) : (
|
83
|
+
stockItemTransaction?.partyName
|
84
|
+
)
|
85
|
+
) : (
|
86
|
+
stockItemTransaction?.partyName
|
87
|
+
),
|
88
|
+
transaction: stockItemTransaction?.isPatientTransaction
|
89
|
+
? "Patient Dispense"
|
90
|
+
: stockItemTransaction.stockOperationTypeName,
|
91
|
+
quantity: `${stockItemTransaction?.quantity?.toLocaleString()} ${
|
92
|
+
stockItemTransaction?.packagingUomName ?? ""
|
93
|
+
}`,
|
94
|
+
batch: stockItemTransaction.stockBatchNo
|
95
|
+
? `${stockItemTransaction.stockBatchNo}${
|
96
|
+
stockItemTransaction.expiration
|
97
|
+
? ` (${formatDisplayDate(stockItemTransaction.expiration)})`
|
98
|
+
: ""
|
99
|
+
}`
|
100
|
+
: "",
|
101
|
+
reference: stockItemTransaction?.stockOperationUuid ? (
|
102
|
+
<EditStockOperationActionMenu
|
103
|
+
operationUuid={stockItemTransaction?.stockOperationUuid}
|
104
|
+
operationNumber={stockItemTransaction?.stockOperationNumber}
|
105
|
+
operations={operations}
|
106
|
+
/>
|
107
|
+
) : (
|
108
|
+
<></>
|
109
|
+
),
|
110
|
+
status: stockItemTransaction?.stockOperationStatus ?? "",
|
111
|
+
in:
|
112
|
+
stockItemTransaction?.quantity >= 0
|
113
|
+
? `${stockItemTransaction?.quantity?.toLocaleString()} ${
|
114
|
+
stockItemTransaction?.packagingUomName ?? ""
|
115
|
+
}`
|
116
|
+
: "",
|
117
|
+
out:
|
118
|
+
stockItemTransaction?.quantity < 0
|
119
|
+
? `${(-1 * stockItemTransaction?.quantity)?.toLocaleString()} ${
|
120
|
+
stockItemTransaction?.packagingUomName ?? ""
|
121
|
+
}`
|
122
|
+
: "",
|
123
|
+
}));
|
124
|
+
}, [items, operations]);
|
125
|
+
|
126
|
+
if (isLoading) {
|
127
|
+
return <DataTableSkeleton role="progressbar" />;
|
128
|
+
}
|
129
|
+
|
130
|
+
if (items?.length != undefined) {
|
131
|
+
return (
|
132
|
+
<DataList
|
133
|
+
columns={tableHeaders}
|
134
|
+
data={tableRows}
|
135
|
+
totalItems={totalCount}
|
136
|
+
goToPage={setCurrentPage}
|
137
|
+
hasToolbar={false}
|
138
|
+
/>
|
139
|
+
);
|
140
|
+
}
|
141
|
+
|
142
|
+
return (
|
143
|
+
<div className={styles.tileContainer}>
|
144
|
+
<Tile className={styles.tile}>
|
145
|
+
<p className={styles.content}>No transactions to display</p>
|
146
|
+
</Tile>
|
147
|
+
</div>
|
148
|
+
);
|
149
|
+
};
|
150
|
+
|
151
|
+
export default Transactions;
|
@@ -0,0 +1,109 @@
|
|
1
|
+
import { ResourceRepresentation } from "../../../core/api/api";
|
2
|
+
import { useEffect, useMemo, useState } from "react";
|
3
|
+
import {
|
4
|
+
StockItemInventoryFilter,
|
5
|
+
useStockItemTransactions,
|
6
|
+
} from "../../stock-items.resource";
|
7
|
+
|
8
|
+
export function useStockItemsTransactions(v?: ResourceRepresentation) {
|
9
|
+
const [stockItemFilter, setStockItemFilter] =
|
10
|
+
useState<StockItemInventoryFilter>({
|
11
|
+
startIndex: 0,
|
12
|
+
v: v || ResourceRepresentation.Default,
|
13
|
+
limit: 10,
|
14
|
+
q: null,
|
15
|
+
totalCount: true,
|
16
|
+
});
|
17
|
+
|
18
|
+
const pageSizes = [10, 20, 30, 40, 50];
|
19
|
+
const [currentPageSize, setPageSize] = useState(10);
|
20
|
+
const [searchString, setSearchString] = useState(null);
|
21
|
+
|
22
|
+
const [currentPage, setCurrentPage] = useState(1);
|
23
|
+
|
24
|
+
const [stockItemUuid, setStockItemUuid] = useState<string | null>();
|
25
|
+
const [partyUuid, setPartyUuid] = useState<string | null>();
|
26
|
+
const [locationUuid, setLocationUuid] = useState<string | null>();
|
27
|
+
const [stockBatchUuid, setStockBatchUuid] = useState<string | null>();
|
28
|
+
|
29
|
+
useEffect(() => {
|
30
|
+
setStockItemFilter({
|
31
|
+
startIndex: currentPage - 1,
|
32
|
+
v: ResourceRepresentation.Default,
|
33
|
+
limit: currentPageSize,
|
34
|
+
q: searchString,
|
35
|
+
totalCount: true,
|
36
|
+
stockItemUuid: stockItemUuid,
|
37
|
+
partyUuid: partyUuid,
|
38
|
+
locationUuid: locationUuid,
|
39
|
+
stockBatchUuid: stockBatchUuid,
|
40
|
+
});
|
41
|
+
}, [
|
42
|
+
searchString,
|
43
|
+
currentPage,
|
44
|
+
currentPageSize,
|
45
|
+
stockItemUuid,
|
46
|
+
partyUuid,
|
47
|
+
locationUuid,
|
48
|
+
stockBatchUuid,
|
49
|
+
]);
|
50
|
+
|
51
|
+
const { items, isLoading, isError } =
|
52
|
+
useStockItemTransactions(stockItemFilter);
|
53
|
+
|
54
|
+
const tableHeaders = useMemo(
|
55
|
+
() => [
|
56
|
+
{
|
57
|
+
key: "date",
|
58
|
+
header: "Date",
|
59
|
+
},
|
60
|
+
{
|
61
|
+
key: "location",
|
62
|
+
header: "Location",
|
63
|
+
},
|
64
|
+
{
|
65
|
+
key: "transaction",
|
66
|
+
header: "Transaction",
|
67
|
+
},
|
68
|
+
{
|
69
|
+
key: "in",
|
70
|
+
header: "IN",
|
71
|
+
},
|
72
|
+
{
|
73
|
+
key: "out",
|
74
|
+
header: "OUT",
|
75
|
+
},
|
76
|
+
{
|
77
|
+
key: "batch",
|
78
|
+
header: "Batch",
|
79
|
+
},
|
80
|
+
{
|
81
|
+
key: "reference",
|
82
|
+
header: "Reference",
|
83
|
+
},
|
84
|
+
{
|
85
|
+
key: "status",
|
86
|
+
header: "Status",
|
87
|
+
},
|
88
|
+
],
|
89
|
+
[]
|
90
|
+
);
|
91
|
+
|
92
|
+
return {
|
93
|
+
items: items.results,
|
94
|
+
totalCount: items.totalCount,
|
95
|
+
currentPage,
|
96
|
+
currentPageSize,
|
97
|
+
setCurrentPage,
|
98
|
+
setPageSize,
|
99
|
+
pageSizes,
|
100
|
+
isLoading,
|
101
|
+
isError,
|
102
|
+
setSearchString,
|
103
|
+
tableHeaders,
|
104
|
+
setStockItemUuid,
|
105
|
+
setLocationUuid,
|
106
|
+
setPartyUuid,
|
107
|
+
setStockBatchUuid,
|
108
|
+
};
|
109
|
+
}
|
File without changes
|
@@ -0,0 +1,28 @@
|
|
1
|
+
import React from "react";
|
2
|
+
import { RadioButton, RadioButtonGroup } from "@carbon/react";
|
3
|
+
import styles from "./filter-stock-items.scss";
|
4
|
+
|
5
|
+
interface FilterStockItemsProps {
|
6
|
+
filterType: string;
|
7
|
+
changeFilterType: React.Dispatch<React.SetStateAction<string>>;
|
8
|
+
}
|
9
|
+
|
10
|
+
const FilterStockItems: React.FC<FilterStockItemsProps> = ({
|
11
|
+
filterType,
|
12
|
+
changeFilterType,
|
13
|
+
}) => {
|
14
|
+
return (
|
15
|
+
<RadioButtonGroup
|
16
|
+
name="is-drug"
|
17
|
+
defaultSelected={filterType}
|
18
|
+
onChange={changeFilterType}
|
19
|
+
className={styles.spacing}
|
20
|
+
>
|
21
|
+
<RadioButton labelText="All" value="" id="is-drug-all" />
|
22
|
+
<RadioButton labelText="Drugs" value="true" id="is-drug-drug" />
|
23
|
+
<RadioButton labelText="Other" value="false" id="is-drug-other" />
|
24
|
+
</RadioButtonGroup>
|
25
|
+
);
|
26
|
+
};
|
27
|
+
|
28
|
+
export default FilterStockItems;
|
File without changes
|
@@ -0,0 +1,30 @@
|
|
1
|
+
import React from "react";
|
2
|
+
import { Button } from "@carbon/react";
|
3
|
+
import { useTranslation } from "react-i18next";
|
4
|
+
import { StockItemDTO } from "../../core/api/types/stockItem/StockItem";
|
5
|
+
import { launchAddOrEditDialog } from "../stock-item.utils";
|
6
|
+
|
7
|
+
interface EditStockItemActionsMenuProps {
|
8
|
+
data: StockItemDTO;
|
9
|
+
}
|
10
|
+
|
11
|
+
const EditStockItemActionsMenu: React.FC<EditStockItemActionsMenuProps> = ({
|
12
|
+
data,
|
13
|
+
}) => {
|
14
|
+
const { t } = useTranslation();
|
15
|
+
|
16
|
+
return (
|
17
|
+
<Button
|
18
|
+
kind="ghost"
|
19
|
+
size="md"
|
20
|
+
onClick={() => {
|
21
|
+
data.isDrug = !!data.drugUuid;
|
22
|
+
launchAddOrEditDialog(data, true);
|
23
|
+
}}
|
24
|
+
iconDescription={t("editStockItem", "Edit Stock Item")}
|
25
|
+
>
|
26
|
+
{`${data?.drugName ?? data.conceptName}`}
|
27
|
+
</Button>
|
28
|
+
);
|
29
|
+
};
|
30
|
+
export default EditStockItemActionsMenu;
|
@@ -0,0 +1,62 @@
|
|
1
|
+
import { closeOverlay, launchOverlay } from "../core/components/overlay/hook";
|
2
|
+
import { StockItemDTO } from "../core/api/types/stockItem/StockItem";
|
3
|
+
import React from "react";
|
4
|
+
import AddEditStockItem from "./add-stock-item/add-stock-item.component";
|
5
|
+
import {
|
6
|
+
FetchResponse,
|
7
|
+
showNotification,
|
8
|
+
showToast,
|
9
|
+
} from "@openmrs/esm-framework";
|
10
|
+
import { createStockItem, updateStockItem } from "./stock-items.resource";
|
11
|
+
|
12
|
+
export const addOrEditStockItem = async (
|
13
|
+
stockItem: StockItemDTO,
|
14
|
+
isEditing = false
|
15
|
+
) => {
|
16
|
+
try {
|
17
|
+
const response: FetchResponse<StockItemDTO> = await (isEditing
|
18
|
+
? updateStockItem
|
19
|
+
: createStockItem)(stockItem);
|
20
|
+
|
21
|
+
if (response?.data) {
|
22
|
+
showToast({
|
23
|
+
critical: true,
|
24
|
+
title: `${isEditing ? "Edit" : "Add"} Stock Item`,
|
25
|
+
kind: "success",
|
26
|
+
description: `Stock Item ${
|
27
|
+
isEditing ? "Edited" : "Added"
|
28
|
+
} Successfully`,
|
29
|
+
});
|
30
|
+
|
31
|
+
if (!isEditing) {
|
32
|
+
closeOverlay();
|
33
|
+
|
34
|
+
// launch edit dialog
|
35
|
+
const item = response.data;
|
36
|
+
item.isDrug = !!item.drugUuid;
|
37
|
+
launchAddOrEditDialog(item, true);
|
38
|
+
}
|
39
|
+
}
|
40
|
+
} catch (error) {
|
41
|
+
showNotification({
|
42
|
+
title: `Error ${isEditing ? "edit" : "add"}ing a stock item`,
|
43
|
+
kind: "error",
|
44
|
+
critical: true,
|
45
|
+
description: error?.responseBody?.error?.message,
|
46
|
+
});
|
47
|
+
}
|
48
|
+
};
|
49
|
+
|
50
|
+
export const launchAddOrEditDialog = (
|
51
|
+
stockItem: StockItemDTO,
|
52
|
+
isEditing = false
|
53
|
+
) => {
|
54
|
+
launchOverlay(
|
55
|
+
`${isEditing ? "Edit" : "Add"} ${stockItem?.drugName || ""}`,
|
56
|
+
<AddEditStockItem
|
57
|
+
model={stockItem}
|
58
|
+
onSave={(stockItem) => addOrEditStockItem(stockItem, isEditing)}
|
59
|
+
isEditing={isEditing}
|
60
|
+
/>
|
61
|
+
);
|
62
|
+
};
|
@@ -0,0 +1,266 @@
|
|
1
|
+
import {
|
2
|
+
Button,
|
3
|
+
TabPanel,
|
4
|
+
DataTable,
|
5
|
+
DataTableSkeleton,
|
6
|
+
Pagination,
|
7
|
+
Table,
|
8
|
+
TableBatchActions,
|
9
|
+
TableBody,
|
10
|
+
TableCell,
|
11
|
+
TableContainer,
|
12
|
+
TableHead,
|
13
|
+
TableHeader,
|
14
|
+
TableRow,
|
15
|
+
TableToolbar,
|
16
|
+
TableToolbarContent,
|
17
|
+
TableToolbarSearch,
|
18
|
+
Tile,
|
19
|
+
Tooltip,
|
20
|
+
} from "@carbon/react";
|
21
|
+
import { Edit } from "@carbon/react/icons";
|
22
|
+
import { isDesktop } from "@openmrs/esm-framework";
|
23
|
+
import React, { useMemo } from "react";
|
24
|
+
import { useTranslation } from "react-i18next";
|
25
|
+
import { ResourceRepresentation } from "../core/api/api";
|
26
|
+
import AddStockItemActionButton from "./add-stock-item/add-stock-action-button.component";
|
27
|
+
import FilterStockItems from "./components/filter-stock-items/filter-stock-items.component";
|
28
|
+
import { launchAddOrEditDialog } from "./stock-item.utils";
|
29
|
+
import { useStockItemsPages } from "./stock-items-table.resource";
|
30
|
+
import styles from "./stock-items-table.scss";
|
31
|
+
import AddStockItemsBulktImportActionButton from "./add-bulk-stock-item/add-stock-items-bulk-import-action-button.component";
|
32
|
+
import EditStockItemActionsMenu from "./edit-stock-item/edit-stock-item-action-menu.component";
|
33
|
+
|
34
|
+
interface StockItemsTableProps {
|
35
|
+
from?: string;
|
36
|
+
}
|
37
|
+
|
38
|
+
const StockItemsTableComponent: React.FC<StockItemsTableProps> = () => {
|
39
|
+
const { t } = useTranslation();
|
40
|
+
|
41
|
+
const {
|
42
|
+
isLoading,
|
43
|
+
items,
|
44
|
+
totalCount,
|
45
|
+
currentPageSize,
|
46
|
+
pageSizes,
|
47
|
+
currentPage,
|
48
|
+
setCurrentPage,
|
49
|
+
isDrug,
|
50
|
+
setDrug,
|
51
|
+
} = useStockItemsPages(ResourceRepresentation.Full);
|
52
|
+
|
53
|
+
const tableHeaders = useMemo(
|
54
|
+
() => [
|
55
|
+
{
|
56
|
+
id: 0,
|
57
|
+
header: t("type", "Type"),
|
58
|
+
key: "type",
|
59
|
+
},
|
60
|
+
{
|
61
|
+
id: 1,
|
62
|
+
header: t("genericName", "Generic Name"),
|
63
|
+
key: "genericName",
|
64
|
+
},
|
65
|
+
{
|
66
|
+
id: 2,
|
67
|
+
header: t("commonName", "Common Name"),
|
68
|
+
key: "commonName",
|
69
|
+
},
|
70
|
+
{
|
71
|
+
id: 3,
|
72
|
+
header: t("tradeName", "Trade Name"),
|
73
|
+
key: "tradeName",
|
74
|
+
},
|
75
|
+
{
|
76
|
+
id: 4,
|
77
|
+
header: t("dispensingUnitName", "Dispensing UoM"),
|
78
|
+
key: "dispensingUnitName",
|
79
|
+
},
|
80
|
+
{
|
81
|
+
id: 5,
|
82
|
+
header: t("defaultStockOperationsUoMName", "Bulk Packaging"),
|
83
|
+
key: "defaultStockOperationsUoMName",
|
84
|
+
},
|
85
|
+
{
|
86
|
+
id: 6,
|
87
|
+
header: t("reorderLevel", "Reorder Level"),
|
88
|
+
key: "reorderLevel",
|
89
|
+
},
|
90
|
+
{
|
91
|
+
id: 7,
|
92
|
+
key: "actions",
|
93
|
+
header: "Actions",
|
94
|
+
},
|
95
|
+
],
|
96
|
+
[t]
|
97
|
+
);
|
98
|
+
|
99
|
+
const tableRows = useMemo(() => {
|
100
|
+
return items?.map((stockItem, index) => ({
|
101
|
+
...stockItem,
|
102
|
+
id: stockItem?.uuid,
|
103
|
+
key: `key-${stockItem?.uuid}`,
|
104
|
+
uuid: `${stockItem?.uuid}`,
|
105
|
+
type: stockItem?.drugUuid ? t("drug", "Drug") : t("other", "Other"),
|
106
|
+
genericName: <EditStockItemActionsMenu data={items[index]} />,
|
107
|
+
commonName: stockItem?.commonName,
|
108
|
+
tradeName: stockItem?.drugUuid ? stockItem?.conceptName : "",
|
109
|
+
preferredVendorName: stockItem?.preferredVendorName,
|
110
|
+
dispensingUoM: stockItem?.defaultStockOperationsUoMName,
|
111
|
+
dispensingUnitName: stockItem?.dispensingUnitName,
|
112
|
+
defaultStockOperationsUoMName: stockItem?.defaultStockOperationsUoMName,
|
113
|
+
reorderLevel:
|
114
|
+
stockItem?.reorderLevelUoMName && stockItem?.reorderLevel
|
115
|
+
? `${stockItem?.reorderLevel?.toLocaleString()} ${
|
116
|
+
stockItem?.reorderLevelUoMName
|
117
|
+
}`
|
118
|
+
: "",
|
119
|
+
actions: (
|
120
|
+
<Tooltip align="bottom" label="Edit Stock Item">
|
121
|
+
<Button
|
122
|
+
kind="ghost"
|
123
|
+
size="md"
|
124
|
+
onClick={() => {
|
125
|
+
stockItem.isDrug = !!stockItem.drugUuid;
|
126
|
+
launchAddOrEditDialog(stockItem, true);
|
127
|
+
}}
|
128
|
+
iconDescription={t("editStockItem", "Edit Stock Item")}
|
129
|
+
renderIcon={(props) => <Edit size={16} {...props} />}
|
130
|
+
></Button>
|
131
|
+
</Tooltip>
|
132
|
+
),
|
133
|
+
}));
|
134
|
+
}, [items, t]);
|
135
|
+
|
136
|
+
if (isLoading) {
|
137
|
+
return <DataTableSkeleton role="progressbar" />;
|
138
|
+
}
|
139
|
+
|
140
|
+
return (
|
141
|
+
<>
|
142
|
+
<TabPanel>
|
143
|
+
{t(
|
144
|
+
"panelDescription",
|
145
|
+
"Drugs and other stock items managed by the system."
|
146
|
+
)}
|
147
|
+
</TabPanel>
|
148
|
+
|
149
|
+
<DataTable
|
150
|
+
rows={tableRows}
|
151
|
+
headers={tableHeaders}
|
152
|
+
isSortable
|
153
|
+
useZebraStyles
|
154
|
+
render={({
|
155
|
+
rows,
|
156
|
+
headers,
|
157
|
+
getHeaderProps,
|
158
|
+
getTableProps,
|
159
|
+
getRowProps,
|
160
|
+
getBatchActionProps,
|
161
|
+
onInputChange,
|
162
|
+
}) => (
|
163
|
+
<TableContainer>
|
164
|
+
<TableToolbar
|
165
|
+
style={{
|
166
|
+
position: "static",
|
167
|
+
overflow: "visible",
|
168
|
+
backgroundColor: "color",
|
169
|
+
}}
|
170
|
+
>
|
171
|
+
<TableBatchActions {...getBatchActionProps()}></TableBatchActions>
|
172
|
+
<TableToolbarContent
|
173
|
+
style={{
|
174
|
+
display: "flex",
|
175
|
+
alignItems: "center",
|
176
|
+
}}
|
177
|
+
>
|
178
|
+
<TableToolbarSearch persistent onChange={onInputChange} />
|
179
|
+
<FilterStockItems
|
180
|
+
filterType={isDrug}
|
181
|
+
changeFilterType={setDrug}
|
182
|
+
/>
|
183
|
+
<AddStockItemsBulktImportActionButton />
|
184
|
+
<AddStockItemActionButton />
|
185
|
+
</TableToolbarContent>
|
186
|
+
</TableToolbar>
|
187
|
+
<Table {...getTableProps()}>
|
188
|
+
<TableHead>
|
189
|
+
<TableRow>
|
190
|
+
{headers.map(
|
191
|
+
(header) =>
|
192
|
+
header.key !== "details" && (
|
193
|
+
<TableHeader
|
194
|
+
{...getHeaderProps({
|
195
|
+
header,
|
196
|
+
isSortable: header.isSortable,
|
197
|
+
})}
|
198
|
+
className={
|
199
|
+
isDesktop
|
200
|
+
? styles.desktopHeader
|
201
|
+
: styles.tabletHeader
|
202
|
+
}
|
203
|
+
key={`${header.key}`}
|
204
|
+
isSortable={header.key !== "name"}
|
205
|
+
>
|
206
|
+
{header.header?.content ?? header.header}
|
207
|
+
</TableHeader>
|
208
|
+
)
|
209
|
+
)}
|
210
|
+
<TableHeader></TableHeader>
|
211
|
+
</TableRow>
|
212
|
+
</TableHead>
|
213
|
+
<TableBody>
|
214
|
+
{rows.map((row) => {
|
215
|
+
return (
|
216
|
+
<React.Fragment key={row.id}>
|
217
|
+
<TableRow
|
218
|
+
className={
|
219
|
+
isDesktop ? styles.desktopRow : styles.tabletRow
|
220
|
+
}
|
221
|
+
{...getRowProps({ row })}
|
222
|
+
key={row.id}
|
223
|
+
>
|
224
|
+
{row.cells.map(
|
225
|
+
(cell) =>
|
226
|
+
cell?.info?.header !== "details" && (
|
227
|
+
<TableCell key={cell.id}>{cell.value}</TableCell>
|
228
|
+
)
|
229
|
+
)}
|
230
|
+
</TableRow>
|
231
|
+
</React.Fragment>
|
232
|
+
);
|
233
|
+
})}
|
234
|
+
</TableBody>
|
235
|
+
</Table>
|
236
|
+
{rows.length === 0 ? (
|
237
|
+
<div className={styles.tileContainer}>
|
238
|
+
<Tile className={styles.tile}>
|
239
|
+
<div className={styles.tileContent}>
|
240
|
+
<p className={styles.content}>
|
241
|
+
{t("noItemsToDisplay", "No Stock Items to display")}
|
242
|
+
</p>
|
243
|
+
<p className={styles.helper}>
|
244
|
+
{t("checkFilters", "Check the filters above")}
|
245
|
+
</p>
|
246
|
+
</div>
|
247
|
+
</Tile>
|
248
|
+
</div>
|
249
|
+
) : null}
|
250
|
+
</TableContainer>
|
251
|
+
)}
|
252
|
+
></DataTable>
|
253
|
+
|
254
|
+
<Pagination
|
255
|
+
page={currentPage}
|
256
|
+
pageSize={currentPageSize}
|
257
|
+
pageSizes={pageSizes}
|
258
|
+
totalItems={totalCount}
|
259
|
+
onChange={({ page }) => setCurrentPage(page)}
|
260
|
+
className={styles.paginationOverride}
|
261
|
+
/>
|
262
|
+
</>
|
263
|
+
);
|
264
|
+
};
|
265
|
+
|
266
|
+
export default StockItemsTableComponent;
|