@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,152 @@
|
|
1
|
+
import {
|
2
|
+
ModalHeader,
|
3
|
+
ModalBody,
|
4
|
+
ModalFooter,
|
5
|
+
Button,
|
6
|
+
Form,
|
7
|
+
Select,
|
8
|
+
TextInput,
|
9
|
+
SelectItem,
|
10
|
+
} from "@carbon/react";
|
11
|
+
import React, { ChangeEvent, useCallback, useState } from "react";
|
12
|
+
import { handleMutate } from "../swr-revalidation";
|
13
|
+
import styles from "./add-stock-sources.scss";
|
14
|
+
import { useConceptById } from "../../stock-lookups/stock-lookups.resource";
|
15
|
+
import { STOCK_SOURCE_TYPE_CODED_CONCEPT_ID } from "../../constants";
|
16
|
+
import { StockSource } from "../../core/api/types/stockOperation/StockSource";
|
17
|
+
import { createOrUpdateStockSource } from "../stock-sources.resource";
|
18
|
+
import { showNotification, showToast } from "@openmrs/esm-framework";
|
19
|
+
import { useTranslation } from "react-i18next";
|
20
|
+
import { closeOverlay } from "../../core/components/overlay/hook";
|
21
|
+
|
22
|
+
interface AddStockSourceProps {
|
23
|
+
model?: StockSource;
|
24
|
+
}
|
25
|
+
|
26
|
+
const StockSourcesAddOrUpdate: React.FC<AddStockSourceProps> = ({ model }) => {
|
27
|
+
const { t } = useTranslation();
|
28
|
+
|
29
|
+
// get stock sources
|
30
|
+
const { items } = useConceptById(STOCK_SOURCE_TYPE_CODED_CONCEPT_ID);
|
31
|
+
|
32
|
+
const [formModel, setFormModel] = useState<StockSource>({ ...model });
|
33
|
+
|
34
|
+
const onNameChanged = (evt: React.ChangeEvent<HTMLInputElement>): void => {
|
35
|
+
model ? (model.name = evt.target.value) : "";
|
36
|
+
setFormModel({ ...formModel, name: evt.target.value });
|
37
|
+
};
|
38
|
+
|
39
|
+
const onAcronymChanged = (evt: React.ChangeEvent<HTMLInputElement>): void => {
|
40
|
+
model ? (model.acronym = evt.target.value) : "";
|
41
|
+
setFormModel({ ...formModel, acronym: evt.target.value });
|
42
|
+
};
|
43
|
+
|
44
|
+
const onSourceTypeChange = (evt: ChangeEvent<HTMLSelectElement>) => {
|
45
|
+
const selectedSourceType = items?.answers.find(
|
46
|
+
(x) => x.uuid === evt.target.value
|
47
|
+
);
|
48
|
+
setFormModel({ ...formModel, sourceType: selectedSourceType });
|
49
|
+
};
|
50
|
+
|
51
|
+
const onFormSubmit = useCallback(
|
52
|
+
(event) => {
|
53
|
+
event.preventDefault();
|
54
|
+
if (model) {
|
55
|
+
formModel.uuid = model.uuid;
|
56
|
+
}
|
57
|
+
createOrUpdateStockSource(formModel)
|
58
|
+
.then(
|
59
|
+
() => {
|
60
|
+
showToast({
|
61
|
+
critical: true,
|
62
|
+
title: t("addedSource", "Add Source"),
|
63
|
+
kind: "success",
|
64
|
+
description: t(
|
65
|
+
"stocksourceaddedsuccessfully",
|
66
|
+
"Stock Source Added Successfully"
|
67
|
+
),
|
68
|
+
});
|
69
|
+
|
70
|
+
handleMutate("ws/rest/v1/stockmanagement/stocksource");
|
71
|
+
|
72
|
+
closeOverlay();
|
73
|
+
},
|
74
|
+
(error) => {
|
75
|
+
showNotification({
|
76
|
+
title: t(`errorAddingSource', 'error adding a source`),
|
77
|
+
kind: "error",
|
78
|
+
critical: true,
|
79
|
+
description: error?.message,
|
80
|
+
});
|
81
|
+
}
|
82
|
+
)
|
83
|
+
.catch();
|
84
|
+
},
|
85
|
+
[formModel, model, t]
|
86
|
+
);
|
87
|
+
return (
|
88
|
+
<div>
|
89
|
+
<Form onSubmit={onFormSubmit}>
|
90
|
+
<ModalHeader />
|
91
|
+
<ModalBody>
|
92
|
+
<section className={styles.section}>
|
93
|
+
<TextInput
|
94
|
+
id="fullname"
|
95
|
+
type="text"
|
96
|
+
labelText={t("fullName", "Full Name")}
|
97
|
+
size="md"
|
98
|
+
onChange={onNameChanged}
|
99
|
+
value={model?.name}
|
100
|
+
placeholder="e.g National Medical Stores"
|
101
|
+
/>
|
102
|
+
</section>
|
103
|
+
<section className={styles.section}>
|
104
|
+
<TextInput
|
105
|
+
id="acronym"
|
106
|
+
type="text"
|
107
|
+
size="md"
|
108
|
+
placeholder="e.g NMS"
|
109
|
+
onChange={onAcronymChanged}
|
110
|
+
value={model?.acronym}
|
111
|
+
labelText={t("acronym", "Acronym/Code")}
|
112
|
+
/>
|
113
|
+
</section>
|
114
|
+
<section className={styles.section}>
|
115
|
+
<Select
|
116
|
+
name="sourceType"
|
117
|
+
className="select-field"
|
118
|
+
labelText={t("sourceType", "Source Type")}
|
119
|
+
id="sourceType"
|
120
|
+
value={formModel?.sourceType ? formModel.sourceType.uuid : ""}
|
121
|
+
onChange={onSourceTypeChange}
|
122
|
+
>
|
123
|
+
<SelectItem
|
124
|
+
disabled
|
125
|
+
hidden
|
126
|
+
value=""
|
127
|
+
text={t("chooseSourceType", "Choose a source type")}
|
128
|
+
/>
|
129
|
+
{items?.answers?.map((sourceType) => {
|
130
|
+
return (
|
131
|
+
<SelectItem
|
132
|
+
key={sourceType.uuid}
|
133
|
+
value={sourceType.uuid}
|
134
|
+
text={sourceType.display}
|
135
|
+
/>
|
136
|
+
);
|
137
|
+
})}
|
138
|
+
</Select>
|
139
|
+
</section>
|
140
|
+
</ModalBody>
|
141
|
+
<ModalFooter>
|
142
|
+
<Button kind="secondary" onClick={closeOverlay}>
|
143
|
+
{t("cancel", "Cancel")}
|
144
|
+
</Button>
|
145
|
+
<Button type="submit">{t("save", "Save")}</Button>
|
146
|
+
</ModalFooter>
|
147
|
+
</Form>
|
148
|
+
</div>
|
149
|
+
);
|
150
|
+
};
|
151
|
+
|
152
|
+
export default StockSourcesAddOrUpdate;
|
@@ -0,0 +1,18 @@
|
|
1
|
+
@use '@carbon/styles/scss/spacing';
|
2
|
+
@use '@carbon/styles/scss/type';
|
3
|
+
@import '~@openmrs/esm-styleguide/src/vars';
|
4
|
+
|
5
|
+
section {
|
6
|
+
margin: spacing.$spacing-03;
|
7
|
+
}
|
8
|
+
|
9
|
+
.sectionTitle {
|
10
|
+
@include type.type-style('heading-compact-02');
|
11
|
+
color: $text-02;
|
12
|
+
margin-bottom: spacing.$spacing-04;
|
13
|
+
}
|
14
|
+
|
15
|
+
.modalBody {
|
16
|
+
padding-bottom: spacing.$spacing-05;
|
17
|
+
}
|
18
|
+
|
@@ -0,0 +1,47 @@
|
|
1
|
+
import React from "react";
|
2
|
+
import { useTranslation } from "react-i18next";
|
3
|
+
import { Button, ModalHeader, ModalBody, ModalFooter } from "@carbon/react";
|
4
|
+
import styles from "../root.scss";
|
5
|
+
|
6
|
+
interface DeleteConfirmationProps {
|
7
|
+
uuid?: string;
|
8
|
+
close: () => void;
|
9
|
+
onConfirmation: () => void;
|
10
|
+
}
|
11
|
+
|
12
|
+
const DeleteConfirmation: React.FC<DeleteConfirmationProps> = ({
|
13
|
+
close,
|
14
|
+
onConfirmation,
|
15
|
+
uuid,
|
16
|
+
}) => {
|
17
|
+
const { t } = useTranslation();
|
18
|
+
const handleCancel = () => close();
|
19
|
+
const handleDelete = () => onConfirmation?.();
|
20
|
+
|
21
|
+
return (
|
22
|
+
<>
|
23
|
+
<ModalHeader closeModal={close} className={styles.productiveHeading03}>
|
24
|
+
{t("deleteStock", "Delete Stock source")}?
|
25
|
+
</ModalHeader>
|
26
|
+
<ModalBody>
|
27
|
+
<p className={styles.bodyLong01}>
|
28
|
+
{t(
|
29
|
+
"deleteConfirmationText",
|
30
|
+
`Are you sure you want to delete this source? This action can't be undone.`,
|
31
|
+
{ encounter: uuid }
|
32
|
+
)}
|
33
|
+
</p>
|
34
|
+
</ModalBody>
|
35
|
+
<ModalFooter>
|
36
|
+
<Button size="lg" kind="secondary" onClick={handleCancel}>
|
37
|
+
{t("cancel", "Cancel")}
|
38
|
+
</Button>
|
39
|
+
<Button autoFocus kind="danger" onClick={handleDelete} size="lg">
|
40
|
+
{t("delete", "Delete")}
|
41
|
+
</Button>
|
42
|
+
</ModalFooter>
|
43
|
+
</>
|
44
|
+
);
|
45
|
+
};
|
46
|
+
|
47
|
+
export default DeleteConfirmation;
|
@@ -0,0 +1,35 @@
|
|
1
|
+
import React, { useCallback } from "react";
|
2
|
+
import { Button } from "@carbon/react";
|
3
|
+
import { Edit } from "@carbon/react/icons";
|
4
|
+
|
5
|
+
import { useTranslation } from "react-i18next";
|
6
|
+
import { launchOverlay } from "../../core/components/overlay/hook";
|
7
|
+
import StockSourcesAddOrUpdate from "../add-stock-sources/add-stock-sources.component";
|
8
|
+
import { StockSource } from "../../core/api/types/stockOperation/StockSource";
|
9
|
+
|
10
|
+
interface EditStockSourcesActionMenuProps {
|
11
|
+
data?: StockSource;
|
12
|
+
}
|
13
|
+
|
14
|
+
const EditStockSourceActionsMenu: React.FC<EditStockSourcesActionMenuProps> = ({
|
15
|
+
data,
|
16
|
+
}) => {
|
17
|
+
const { t } = useTranslation();
|
18
|
+
const handleClick = useCallback(() => {
|
19
|
+
launchOverlay(
|
20
|
+
"Edit Stock Source",
|
21
|
+
<StockSourcesAddOrUpdate model={data} />
|
22
|
+
);
|
23
|
+
}, [data]);
|
24
|
+
|
25
|
+
return (
|
26
|
+
<Button
|
27
|
+
kind="ghost"
|
28
|
+
size="md"
|
29
|
+
onClick={() => handleClick()}
|
30
|
+
iconDescription={t("editStockItem", "Edit Stock Item")}
|
31
|
+
renderIcon={(props) => <Edit size={16} {...props} />}
|
32
|
+
/>
|
33
|
+
);
|
34
|
+
};
|
35
|
+
export default EditStockSourceActionsMenu;
|
File without changes
|
File without changes
|
@@ -0,0 +1,72 @@
|
|
1
|
+
import React, { useState } from "react";
|
2
|
+
import { handleMutate } from "../swr-revalidation";
|
3
|
+
import { Button, InlineLoading } from "@carbon/react";
|
4
|
+
import { useTranslation } from "react-i18next";
|
5
|
+
import { TrashCan } from "@carbon/react/icons";
|
6
|
+
import { deleteStockSource } from "../stock-sources.resource";
|
7
|
+
import { showModal, showNotification, showToast } from "@openmrs/esm-framework";
|
8
|
+
|
9
|
+
interface StockSourcesDeleteActionMenuProps {
|
10
|
+
uuid: string;
|
11
|
+
}
|
12
|
+
|
13
|
+
const StockSourcesDeleteActionMenu: React.FC<
|
14
|
+
StockSourcesDeleteActionMenuProps
|
15
|
+
> = ({ uuid }) => {
|
16
|
+
const { t } = useTranslation();
|
17
|
+
|
18
|
+
const [deletingSource, setDeletingSource] = useState(false);
|
19
|
+
|
20
|
+
const handleDeleteStockSource = React.useCallback(() => {
|
21
|
+
const close = showModal("delete-stock-modal", {
|
22
|
+
close: () => close(),
|
23
|
+
uuid: uuid,
|
24
|
+
onConfirmation: () => {
|
25
|
+
const ids = [];
|
26
|
+
ids.push(uuid);
|
27
|
+
deleteStockSource(ids)
|
28
|
+
.then(
|
29
|
+
() => {
|
30
|
+
setDeletingSource(false);
|
31
|
+
|
32
|
+
handleMutate("ws/rest/v1/stockmanagement/stocksource");
|
33
|
+
showToast({
|
34
|
+
critical: true,
|
35
|
+
title: t("deletingSource", "Delete Source"),
|
36
|
+
kind: "success",
|
37
|
+
description: t(
|
38
|
+
"stocksourcedeletedsuccessfully",
|
39
|
+
"Stock Source Deleted Successfully"
|
40
|
+
),
|
41
|
+
});
|
42
|
+
},
|
43
|
+
(error) => {
|
44
|
+
setDeletingSource(false);
|
45
|
+
showNotification({
|
46
|
+
title: t(`errorDeletingSource', 'error deleting a source`),
|
47
|
+
kind: "error",
|
48
|
+
critical: true,
|
49
|
+
description: error?.message,
|
50
|
+
});
|
51
|
+
}
|
52
|
+
)
|
53
|
+
.catch();
|
54
|
+
close();
|
55
|
+
},
|
56
|
+
});
|
57
|
+
}, [t, uuid]);
|
58
|
+
|
59
|
+
const deleteButton = (
|
60
|
+
<Button
|
61
|
+
kind="ghost"
|
62
|
+
size="md"
|
63
|
+
onClick={handleDeleteStockSource}
|
64
|
+
iconDescription={t("deleteSource", "Delete Source")}
|
65
|
+
renderIcon={(props) => <TrashCan size={16} {...props} />}
|
66
|
+
/>
|
67
|
+
);
|
68
|
+
|
69
|
+
return deletingSource ? <InlineLoading /> : deleteButton;
|
70
|
+
};
|
71
|
+
|
72
|
+
export default StockSourcesDeleteActionMenu;
|
@@ -0,0 +1,35 @@
|
|
1
|
+
import styles from "./stock-sources-filter.scss";
|
2
|
+
import { Dropdown, DropdownSkeleton } from "@carbon/react";
|
3
|
+
import React from "react";
|
4
|
+
import { STOCK_SOURCE_TYPE_CODED_CONCEPT_ID } from "../../constants";
|
5
|
+
import { useConceptById } from "../../stock-lookups/stock-lookups.resource";
|
6
|
+
|
7
|
+
const StockSourcesFilter: React.FC<{
|
8
|
+
onFilterChange: (selectedSourceType: string) => void;
|
9
|
+
}> = ({ onFilterChange }) => {
|
10
|
+
// get stock sources
|
11
|
+
const { items, isLoading, isError } = useConceptById(
|
12
|
+
STOCK_SOURCE_TYPE_CODED_CONCEPT_ID
|
13
|
+
);
|
14
|
+
if (isLoading || isError) {
|
15
|
+
return <DropdownSkeleton />;
|
16
|
+
}
|
17
|
+
return (
|
18
|
+
<>
|
19
|
+
<div className={styles.filterContainer}>
|
20
|
+
<Dropdown
|
21
|
+
id="stockSourcesFiter"
|
22
|
+
items={[...items.answers]}
|
23
|
+
initialSelectedItem={items.answers[0]}
|
24
|
+
itemToString={(item) => (item ? item.display : "Not Set")}
|
25
|
+
titleText="Filter: "
|
26
|
+
type="inline"
|
27
|
+
size="sm"
|
28
|
+
onChange={({ selectedItem }) => onFilterChange(selectedItem?.display)}
|
29
|
+
/>
|
30
|
+
</div>
|
31
|
+
</>
|
32
|
+
);
|
33
|
+
};
|
34
|
+
|
35
|
+
export default StockSourcesFilter;
|
@@ -0,0 +1,213 @@
|
|
1
|
+
import React, { useMemo } from "react";
|
2
|
+
import {
|
3
|
+
TabPanel,
|
4
|
+
DataTable,
|
5
|
+
Pagination,
|
6
|
+
Table,
|
7
|
+
TableBody,
|
8
|
+
TableCell,
|
9
|
+
TableContainer,
|
10
|
+
TableHead,
|
11
|
+
TableHeader,
|
12
|
+
TableRow,
|
13
|
+
TableToolbar,
|
14
|
+
TableToolbarContent,
|
15
|
+
Tile,
|
16
|
+
DataTableSkeleton,
|
17
|
+
TableToolbarSearch,
|
18
|
+
} from "@carbon/react";
|
19
|
+
import { isDesktop } from "@openmrs/esm-framework";
|
20
|
+
import useStockSourcesPage from "./stock-sources-items-table.resource";
|
21
|
+
import { ResourceRepresentation } from "../core/api/api";
|
22
|
+
import AddStockSourceActionButton from "./add-stock-source-button.component";
|
23
|
+
import StockSourcesFilter from "./stock-sources-filter/stock-sources-filter.component";
|
24
|
+
import styles from "./stock-sources.scss";
|
25
|
+
import { useTranslation } from "react-i18next";
|
26
|
+
import StockSourcesDeleteActionMenu from "./stock-sources-delete/stock-sources-delete.component";
|
27
|
+
import EditStockSourceActionsMenu from "./edit-stock-source/edit-stock-source.component";
|
28
|
+
|
29
|
+
const StockSourcesItems: React.FC = () => {
|
30
|
+
const { t } = useTranslation();
|
31
|
+
const [selectedSourceType, setSelectedSourceType] = React.useState("");
|
32
|
+
|
33
|
+
// get sourcess
|
34
|
+
const {
|
35
|
+
items,
|
36
|
+
totalItems,
|
37
|
+
tableHeaders,
|
38
|
+
currentPage,
|
39
|
+
pageSizes,
|
40
|
+
goTo,
|
41
|
+
currentPageSize,
|
42
|
+
setPageSize,
|
43
|
+
isLoading,
|
44
|
+
} = useStockSourcesPage({
|
45
|
+
v: ResourceRepresentation.Default,
|
46
|
+
totalCount: true,
|
47
|
+
});
|
48
|
+
|
49
|
+
const tableRows = useMemo(() => {
|
50
|
+
return items?.map((entry, index) => {
|
51
|
+
return {
|
52
|
+
...entry,
|
53
|
+
id: entry?.uuid,
|
54
|
+
key: `key-${entry?.uuid}`,
|
55
|
+
uuid: entry?.uuid,
|
56
|
+
name: entry?.name,
|
57
|
+
acronym: entry?.acronym,
|
58
|
+
sourceType: entry?.sourceType?.display,
|
59
|
+
actions: (
|
60
|
+
<>
|
61
|
+
<EditStockSourceActionsMenu data={items[index]} />
|
62
|
+
<StockSourcesDeleteActionMenu uuid={items[index].uuid} />
|
63
|
+
</>
|
64
|
+
),
|
65
|
+
};
|
66
|
+
});
|
67
|
+
}, [items]);
|
68
|
+
const handleFilterChange = (selectedSourceType: string) => {
|
69
|
+
setSelectedSourceType(selectedSourceType);
|
70
|
+
};
|
71
|
+
|
72
|
+
const filteredTableRows = useMemo(() => {
|
73
|
+
if (!selectedSourceType) {
|
74
|
+
return tableRows;
|
75
|
+
}
|
76
|
+
return tableRows.filter((row) => row.sourceType === selectedSourceType);
|
77
|
+
}, [tableRows, selectedSourceType]);
|
78
|
+
|
79
|
+
if (isLoading) {
|
80
|
+
return <DataTableSkeleton role="progressbar" />;
|
81
|
+
}
|
82
|
+
|
83
|
+
return (
|
84
|
+
<div className={styles.tableOverride}>
|
85
|
+
<TabPanel>
|
86
|
+
{t(
|
87
|
+
"panelDescription",
|
88
|
+
"List of partners who provide stock to the facility."
|
89
|
+
)}
|
90
|
+
</TabPanel>
|
91
|
+
<div id="table-tool-bar">
|
92
|
+
<div></div>
|
93
|
+
<div className="right-filters"></div>
|
94
|
+
</div>
|
95
|
+
<DataTable
|
96
|
+
rows={filteredTableRows}
|
97
|
+
headers={tableHeaders}
|
98
|
+
isSortable={true}
|
99
|
+
useZebraStyles={true}
|
100
|
+
render={({
|
101
|
+
rows,
|
102
|
+
headers,
|
103
|
+
getHeaderProps,
|
104
|
+
getTableProps,
|
105
|
+
getRowProps,
|
106
|
+
onInputChange,
|
107
|
+
}) => (
|
108
|
+
<TableContainer>
|
109
|
+
<TableToolbar
|
110
|
+
style={{
|
111
|
+
position: "static",
|
112
|
+
overflow: "visible",
|
113
|
+
backgroundColor: "color",
|
114
|
+
}}
|
115
|
+
>
|
116
|
+
<TableToolbarContent className={styles.toolbarContent}>
|
117
|
+
<TableToolbarSearch persistent onChange={onInputChange} />
|
118
|
+
<div
|
119
|
+
style={{
|
120
|
+
display: "flex",
|
121
|
+
alignItems: "center",
|
122
|
+
}}
|
123
|
+
>
|
124
|
+
<StockSourcesFilter onFilterChange={handleFilterChange} />
|
125
|
+
</div>
|
126
|
+
|
127
|
+
<AddStockSourceActionButton />
|
128
|
+
</TableToolbarContent>
|
129
|
+
</TableToolbar>
|
130
|
+
<Table {...getTableProps()}>
|
131
|
+
<TableHead>
|
132
|
+
<TableRow>
|
133
|
+
{headers.map(
|
134
|
+
(header) =>
|
135
|
+
header.key !== "details" && (
|
136
|
+
<TableHeader
|
137
|
+
{...getHeaderProps({
|
138
|
+
header,
|
139
|
+
isSortable: header.isSortable,
|
140
|
+
})}
|
141
|
+
className={
|
142
|
+
isDesktop
|
143
|
+
? styles.desktopHeader
|
144
|
+
: styles.tabletHeader
|
145
|
+
}
|
146
|
+
key={`${header.key}`}
|
147
|
+
>
|
148
|
+
{header.header?.content ?? header.header}
|
149
|
+
</TableHeader>
|
150
|
+
)
|
151
|
+
)}
|
152
|
+
<TableHeader></TableHeader>
|
153
|
+
</TableRow>
|
154
|
+
</TableHead>
|
155
|
+
<TableBody>
|
156
|
+
{rows.map((row) => {
|
157
|
+
return (
|
158
|
+
<React.Fragment key={row.id}>
|
159
|
+
<TableRow
|
160
|
+
className={
|
161
|
+
isDesktop ? styles.desktopRow : styles.tabletRow
|
162
|
+
}
|
163
|
+
{...getRowProps({ row })}
|
164
|
+
>
|
165
|
+
{row.cells.map(
|
166
|
+
(cell) =>
|
167
|
+
cell?.info?.header !== "details" && (
|
168
|
+
<TableCell key={cell.id}>{cell.value}</TableCell>
|
169
|
+
)
|
170
|
+
)}
|
171
|
+
</TableRow>
|
172
|
+
</React.Fragment>
|
173
|
+
);
|
174
|
+
})}
|
175
|
+
</TableBody>
|
176
|
+
</Table>
|
177
|
+
{rows.length === 0 ? (
|
178
|
+
<div className={styles.tileContainer}>
|
179
|
+
<Tile className={styles.tile}>
|
180
|
+
<div className={styles.tileContent}>
|
181
|
+
<p className={styles.content}>
|
182
|
+
{t("noSourcesToDisplay", "No Stock sources to display")}
|
183
|
+
</p>
|
184
|
+
<p className={styles.helper}>
|
185
|
+
{t("checkFilters", "Check the filters above")}
|
186
|
+
</p>
|
187
|
+
</div>
|
188
|
+
</Tile>
|
189
|
+
</div>
|
190
|
+
) : null}
|
191
|
+
</TableContainer>
|
192
|
+
)}
|
193
|
+
></DataTable>
|
194
|
+
<Pagination
|
195
|
+
page={currentPage}
|
196
|
+
pageSize={currentPageSize}
|
197
|
+
pageSizes={pageSizes}
|
198
|
+
totalItems={totalItems}
|
199
|
+
onChange={({ pageSize, page }) => {
|
200
|
+
if (pageSize !== currentPageSize) {
|
201
|
+
setPageSize(pageSize);
|
202
|
+
}
|
203
|
+
if (page !== currentPage) {
|
204
|
+
goTo(page);
|
205
|
+
}
|
206
|
+
}}
|
207
|
+
className={styles.paginationOverride}
|
208
|
+
/>
|
209
|
+
</div>
|
210
|
+
);
|
211
|
+
};
|
212
|
+
|
213
|
+
export default StockSourcesItems;
|
@@ -0,0 +1,56 @@
|
|
1
|
+
import { useStockSources } from "./stock-sources.resource";
|
2
|
+
import { useMemo, useState } from "react";
|
3
|
+
import { usePagination } from "@openmrs/esm-framework";
|
4
|
+
import { StockOperationFilter } from "../stock-operations/stock-operations.resource";
|
5
|
+
|
6
|
+
export default function useStockSourcesPage(filter: StockOperationFilter) {
|
7
|
+
const { items, isLoading, isError } = useStockSources(filter);
|
8
|
+
|
9
|
+
const pageSizes = [10, 20, 30, 40, 50];
|
10
|
+
const [currentPageSize, setPageSize] = useState(10);
|
11
|
+
const {
|
12
|
+
goTo,
|
13
|
+
results: paginatedItems,
|
14
|
+
currentPage,
|
15
|
+
} = usePagination(items.results, currentPageSize);
|
16
|
+
|
17
|
+
const tableHeaders = useMemo(
|
18
|
+
() => [
|
19
|
+
{
|
20
|
+
id: 1,
|
21
|
+
header: "Name",
|
22
|
+
key: "name",
|
23
|
+
},
|
24
|
+
{
|
25
|
+
id: 2,
|
26
|
+
header: "Acronym",
|
27
|
+
key: "acronym",
|
28
|
+
},
|
29
|
+
{
|
30
|
+
id: 3,
|
31
|
+
header: "Source Type",
|
32
|
+
key: "sourceType",
|
33
|
+
},
|
34
|
+
{
|
35
|
+
id: 4,
|
36
|
+
header: "actions",
|
37
|
+
key: "actions",
|
38
|
+
},
|
39
|
+
],
|
40
|
+
[]
|
41
|
+
);
|
42
|
+
|
43
|
+
return {
|
44
|
+
items: paginatedItems,
|
45
|
+
totalItems: items?.totalCount,
|
46
|
+
currentPage,
|
47
|
+
currentPageSize,
|
48
|
+
paginatedItems,
|
49
|
+
goTo,
|
50
|
+
pageSizes,
|
51
|
+
isLoading,
|
52
|
+
isError,
|
53
|
+
setPageSize,
|
54
|
+
tableHeaders,
|
55
|
+
};
|
56
|
+
}
|