@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,222 @@
|
|
1
|
+
import React, { useState, useEffect, useMemo } from "react";
|
2
|
+
import { ResourceRepresentation } from "../../../core/api/api";
|
3
|
+
import { useStockItemRules } from "./stock-item-rules.resource";
|
4
|
+
import {
|
5
|
+
DataTable,
|
6
|
+
Pagination,
|
7
|
+
Table,
|
8
|
+
TableBody,
|
9
|
+
TableCell,
|
10
|
+
TableContainer,
|
11
|
+
TableHead,
|
12
|
+
TableHeader,
|
13
|
+
TableRow,
|
14
|
+
TableToolbar,
|
15
|
+
TableToolbarContent,
|
16
|
+
Tile,
|
17
|
+
TableToolbarAction,
|
18
|
+
TableToolbarMenu,
|
19
|
+
DataTableSkeleton,
|
20
|
+
TableToolbarSearch,
|
21
|
+
} from "@carbon/react";
|
22
|
+
import { formatDisplayDate } from "../../../core/utils/datetimeUtils";
|
23
|
+
import styles from "../../stock-items-table.scss";
|
24
|
+
import { StockRule } from "../../../core/api/types/stockItem/StockRule";
|
25
|
+
import AddStockRuleActionButton from "./add-stock-rule-button.component";
|
26
|
+
import { isDesktop } from "@openmrs/esm-framework";
|
27
|
+
import StockRulesFilter from "./stock-rules-filter.component";
|
28
|
+
import { useTranslation } from "react-i18next";
|
29
|
+
import StockRulesDeleteActionMenu from "./stock-rules-delete.component";
|
30
|
+
import EditStockRuleActionsMenu from "./edit-stock-rule.component";
|
31
|
+
|
32
|
+
interface StockItemRulesProps {
|
33
|
+
onSubmit?: () => void;
|
34
|
+
stockItemUuid: string;
|
35
|
+
model?: StockRule;
|
36
|
+
canEdit?: boolean;
|
37
|
+
}
|
38
|
+
|
39
|
+
const StockItemRules: React.FC<StockItemRulesProps> = ({
|
40
|
+
stockItemUuid,
|
41
|
+
model,
|
42
|
+
canEdit = true,
|
43
|
+
}) => {
|
44
|
+
const { t } = useTranslation();
|
45
|
+
console.warn("Found stock uuid: " + stockItemUuid);
|
46
|
+
const {
|
47
|
+
isLoading,
|
48
|
+
items,
|
49
|
+
tableHeaders,
|
50
|
+
currentPage,
|
51
|
+
currentPageSize,
|
52
|
+
pageSizes,
|
53
|
+
totalItems,
|
54
|
+
setPageSize,
|
55
|
+
goTo,
|
56
|
+
} = useStockItemRules({
|
57
|
+
v: ResourceRepresentation.Default,
|
58
|
+
totalCount: true,
|
59
|
+
stockItemUuid: stockItemUuid,
|
60
|
+
});
|
61
|
+
|
62
|
+
const tableRows = useMemo(() => {
|
63
|
+
return items?.map((stockRule, index) => ({
|
64
|
+
...stockRule,
|
65
|
+
id: `${stockRule?.id}-${index}`,
|
66
|
+
key: `key-${stockRule?.uuid}`,
|
67
|
+
uuid: `${stockRule?.uuid}`,
|
68
|
+
dateCreated: formatDisplayDate(stockRule?.dateCreated),
|
69
|
+
location: stockRule?.locationName,
|
70
|
+
quantity: `${stockRule?.quantity?.toLocaleString()} ${
|
71
|
+
stockRule?.packagingUomName ?? ""
|
72
|
+
}`,
|
73
|
+
name: `${stockRule?.name}`,
|
74
|
+
description: `${stockRule?.description}`,
|
75
|
+
evaluationFrequency: `${stockRule?.evaluationFrequency}`,
|
76
|
+
actionFrequency: `${stockRule?.actionFrequency}`,
|
77
|
+
lastActionDate: formatDisplayDate(stockRule?.lastActionDate),
|
78
|
+
nextActionDate: formatDisplayDate(stockRule?.nextActionDate),
|
79
|
+
enabled: stockRule.enabled ? "Yes" : "No",
|
80
|
+
actions: (
|
81
|
+
<>
|
82
|
+
<EditStockRuleActionsMenu
|
83
|
+
data={items[index]}
|
84
|
+
stockItemUuid={items[index].stockItemUuid}
|
85
|
+
/>
|
86
|
+
<StockRulesDeleteActionMenu uuid={items[index].uuid} />
|
87
|
+
</>
|
88
|
+
),
|
89
|
+
}));
|
90
|
+
}, [items]);
|
91
|
+
|
92
|
+
if (isLoading) {
|
93
|
+
return <DataTableSkeleton role="progressbar" />;
|
94
|
+
}
|
95
|
+
|
96
|
+
return (
|
97
|
+
<div className={styles.tableOverride}>
|
98
|
+
<div id="table-tool-bar">
|
99
|
+
<div></div>
|
100
|
+
<div className="right-filters"></div>
|
101
|
+
</div>
|
102
|
+
<DataTable
|
103
|
+
rows={tableRows}
|
104
|
+
headers={tableHeaders}
|
105
|
+
isSortable={true}
|
106
|
+
useZebraStyles={true}
|
107
|
+
render={({
|
108
|
+
rows,
|
109
|
+
headers,
|
110
|
+
getHeaderProps,
|
111
|
+
getTableProps,
|
112
|
+
getRowProps,
|
113
|
+
onInputChange,
|
114
|
+
}) => (
|
115
|
+
<TableContainer>
|
116
|
+
<TableToolbar
|
117
|
+
style={{
|
118
|
+
position: "static",
|
119
|
+
overflow: "visible",
|
120
|
+
backgroundColor: "color",
|
121
|
+
}}
|
122
|
+
>
|
123
|
+
<TableToolbarContent className={styles.toolbarContent}>
|
124
|
+
<TableToolbarSearch persistent onChange={onInputChange} />
|
125
|
+
<div
|
126
|
+
style={{
|
127
|
+
display: "flex",
|
128
|
+
alignItems: "center",
|
129
|
+
}}
|
130
|
+
>
|
131
|
+
<StockRulesFilter stockItemUuid={stockItemUuid} />
|
132
|
+
</div>
|
133
|
+
<TableToolbarMenu>
|
134
|
+
<TableToolbarAction onClick={""}>Refresh</TableToolbarAction>
|
135
|
+
</TableToolbarMenu>
|
136
|
+
<AddStockRuleActionButton stockItemUuid={stockItemUuid} />
|
137
|
+
</TableToolbarContent>
|
138
|
+
</TableToolbar>
|
139
|
+
<Table {...getTableProps()}>
|
140
|
+
<TableHead>
|
141
|
+
<TableRow>
|
142
|
+
{headers.map(
|
143
|
+
(header: any) =>
|
144
|
+
header.key !== "details" && (
|
145
|
+
<TableHeader
|
146
|
+
{...getHeaderProps({
|
147
|
+
header,
|
148
|
+
isSortable: header.isSortable,
|
149
|
+
})}
|
150
|
+
className={
|
151
|
+
isDesktop
|
152
|
+
? styles.desktopHeader
|
153
|
+
: styles.tabletHeader
|
154
|
+
}
|
155
|
+
key={`${header.key}`}
|
156
|
+
>
|
157
|
+
{header.header?.content ?? header.header}
|
158
|
+
</TableHeader>
|
159
|
+
)
|
160
|
+
)}
|
161
|
+
<TableHeader></TableHeader>
|
162
|
+
</TableRow>
|
163
|
+
</TableHead>
|
164
|
+
<TableBody>
|
165
|
+
{rows.map((row: any) => {
|
166
|
+
return (
|
167
|
+
<React.Fragment key={row.id}>
|
168
|
+
<TableRow
|
169
|
+
className={
|
170
|
+
isDesktop ? styles.desktopRow : styles.tabletRow
|
171
|
+
}
|
172
|
+
{...getRowProps({ row })}
|
173
|
+
>
|
174
|
+
{row.cells.map(
|
175
|
+
(cell: any) =>
|
176
|
+
cell?.info?.header !== "details" && (
|
177
|
+
<TableCell key={cell.id}>{cell.value}</TableCell>
|
178
|
+
)
|
179
|
+
)}
|
180
|
+
</TableRow>
|
181
|
+
</React.Fragment>
|
182
|
+
);
|
183
|
+
})}
|
184
|
+
</TableBody>
|
185
|
+
</Table>
|
186
|
+
{rows.length === 0 ? (
|
187
|
+
<div className={styles.tileContainer}>
|
188
|
+
<Tile className={styles.tile}>
|
189
|
+
<div className={styles.tileContent}>
|
190
|
+
<p className={styles.content}>
|
191
|
+
{t("noRulesToDisplay", "No Stock rules to display")}
|
192
|
+
</p>
|
193
|
+
<p className={styles.helper}>
|
194
|
+
{t("checkFilters", "Check the filters above")}
|
195
|
+
</p>
|
196
|
+
</div>
|
197
|
+
</Tile>
|
198
|
+
</div>
|
199
|
+
) : null}
|
200
|
+
</TableContainer>
|
201
|
+
)}
|
202
|
+
></DataTable>
|
203
|
+
<Pagination
|
204
|
+
page={currentPage}
|
205
|
+
pageSize={currentPageSize}
|
206
|
+
pageSizes={pageSizes}
|
207
|
+
totalItems={totalItems}
|
208
|
+
onChange={({ pageSize, page }) => {
|
209
|
+
if (pageSize !== currentPageSize) {
|
210
|
+
setPageSize(pageSize);
|
211
|
+
}
|
212
|
+
if (page !== currentPage) {
|
213
|
+
goTo(page);
|
214
|
+
}
|
215
|
+
}}
|
216
|
+
className={styles.paginationOverride}
|
217
|
+
/>
|
218
|
+
</div>
|
219
|
+
);
|
220
|
+
};
|
221
|
+
|
222
|
+
export default StockItemRules;
|
@@ -0,0 +1,72 @@
|
|
1
|
+
import { useMemo, useState } from "react";
|
2
|
+
import { StockRuleFilter, useStockRules } from "../../stock-items.resource";
|
3
|
+
import { usePagination } from "@openmrs/esm-framework";
|
4
|
+
|
5
|
+
export function useStockItemRules(filter: StockRuleFilter) {
|
6
|
+
const { items, isLoading, isError } = useStockRules(filter);
|
7
|
+
|
8
|
+
const pageSizes = [10, 20, 30, 40, 50];
|
9
|
+
const [currentPageSize, setPageSize] = useState(10);
|
10
|
+
const {
|
11
|
+
goTo,
|
12
|
+
results: paginatedItems,
|
13
|
+
currentPage,
|
14
|
+
} = usePagination(items.results, currentPageSize);
|
15
|
+
|
16
|
+
const tableHeaders = useMemo(
|
17
|
+
() => [
|
18
|
+
{
|
19
|
+
key: "location",
|
20
|
+
header: "Location",
|
21
|
+
},
|
22
|
+
{
|
23
|
+
key: "name",
|
24
|
+
header: "Name",
|
25
|
+
},
|
26
|
+
{
|
27
|
+
key: "quantity",
|
28
|
+
header: "Quantity Threshold",
|
29
|
+
},
|
30
|
+
{
|
31
|
+
key: "evaluationFrequency",
|
32
|
+
header: "Frequency Check",
|
33
|
+
},
|
34
|
+
{
|
35
|
+
key: "actionFrequency",
|
36
|
+
header: "Notification Frequency",
|
37
|
+
},
|
38
|
+
{
|
39
|
+
key: "alertRole",
|
40
|
+
header: "Alert Role",
|
41
|
+
},
|
42
|
+
{
|
43
|
+
key: "mailRole",
|
44
|
+
header: "Mail Role",
|
45
|
+
},
|
46
|
+
{
|
47
|
+
key: "enabled",
|
48
|
+
header: "Enabled?",
|
49
|
+
},
|
50
|
+
{
|
51
|
+
// id: 4,
|
52
|
+
header: "actions",
|
53
|
+
key: "actions",
|
54
|
+
},
|
55
|
+
],
|
56
|
+
[]
|
57
|
+
);
|
58
|
+
|
59
|
+
return {
|
60
|
+
items: paginatedItems,
|
61
|
+
totalItems: items?.totalCount,
|
62
|
+
currentPage,
|
63
|
+
currentPageSize,
|
64
|
+
paginatedItems,
|
65
|
+
goTo,
|
66
|
+
pageSizes,
|
67
|
+
isLoading,
|
68
|
+
isError,
|
69
|
+
setPageSize,
|
70
|
+
tableHeaders,
|
71
|
+
};
|
72
|
+
}
|
@@ -0,0 +1,67 @@
|
|
1
|
+
import React, { useState } from "react";
|
2
|
+
import { Button, InlineLoading } from "@carbon/react";
|
3
|
+
import { useTranslation } from "react-i18next";
|
4
|
+
import { TrashCan } from "@carbon/react/icons";
|
5
|
+
import { deleteStockRule } from "../../stock-items.resource";
|
6
|
+
import { showModal, showNotification, showToast } from "@openmrs/esm-framework";
|
7
|
+
|
8
|
+
interface StockRulesDeleteActionMenuProps {
|
9
|
+
uuid: string;
|
10
|
+
}
|
11
|
+
|
12
|
+
const StockRulesDeleteActionMenu: React.FC<StockRulesDeleteActionMenuProps> = ({
|
13
|
+
uuid,
|
14
|
+
}) => {
|
15
|
+
const { t } = useTranslation();
|
16
|
+
|
17
|
+
const [deletingRule, setDeletingRule] = useState(false);
|
18
|
+
|
19
|
+
const handleDeleteStockRule = React.useCallback(() => {
|
20
|
+
const close = showModal("delete-stock-rule-modal", {
|
21
|
+
close: () => close(),
|
22
|
+
uuid: uuid,
|
23
|
+
onConfirmation: () => {
|
24
|
+
deleteStockRule(uuid)
|
25
|
+
.then(
|
26
|
+
() => {
|
27
|
+
setDeletingRule(false);
|
28
|
+
showToast({
|
29
|
+
critical: true,
|
30
|
+
title: t("deletingRule", "Delete Rule"),
|
31
|
+
kind: "success",
|
32
|
+
description: t(
|
33
|
+
"stockruledeletedsuccessfully",
|
34
|
+
"Stock Rule Deleted Successfully"
|
35
|
+
),
|
36
|
+
});
|
37
|
+
},
|
38
|
+
(error) => {
|
39
|
+
setDeletingRule(false);
|
40
|
+
showNotification({
|
41
|
+
title: t(`errorDeletingRule', 'error deleting a rule`),
|
42
|
+
kind: "error",
|
43
|
+
critical: true,
|
44
|
+
description: error?.message,
|
45
|
+
});
|
46
|
+
}
|
47
|
+
)
|
48
|
+
.catch();
|
49
|
+
close();
|
50
|
+
},
|
51
|
+
});
|
52
|
+
}, [t, uuid]);
|
53
|
+
|
54
|
+
const deleteButton = (
|
55
|
+
<Button
|
56
|
+
kind="ghost"
|
57
|
+
size="md"
|
58
|
+
onClick={handleDeleteStockRule}
|
59
|
+
iconDescription={t("deleteRule", "Delete Rule")}
|
60
|
+
renderIcon={(props) => <TrashCan size={16} {...props} />}
|
61
|
+
/>
|
62
|
+
);
|
63
|
+
|
64
|
+
return deletingRule ? <InlineLoading /> : deleteButton;
|
65
|
+
};
|
66
|
+
|
67
|
+
export default StockRulesDeleteActionMenu;
|
File without changes
|
@@ -0,0 +1,38 @@
|
|
1
|
+
import styles from "./stock-rules-filter.scss";
|
2
|
+
import { Dropdown, DropdownSkeleton } from "@carbon/react";
|
3
|
+
import React from "react";
|
4
|
+
import { useStockRules } from "./stock-rules.resource";
|
5
|
+
import { ResourceRepresentation } from "../../../core/api/api";
|
6
|
+
|
7
|
+
interface StockRulesFilterProps {
|
8
|
+
stockItemUuid: string;
|
9
|
+
}
|
10
|
+
|
11
|
+
const StockRulesFilter: React.FC<StockRulesFilterProps> = ({
|
12
|
+
stockItemUuid,
|
13
|
+
}) => {
|
14
|
+
const { items, isLoading, isError } = useStockRules({
|
15
|
+
v: ResourceRepresentation.Default,
|
16
|
+
totalCount: true,
|
17
|
+
stockItemUuid: stockItemUuid,
|
18
|
+
});
|
19
|
+
|
20
|
+
if (isLoading || isError) {
|
21
|
+
return <DropdownSkeleton />;
|
22
|
+
}
|
23
|
+
return (
|
24
|
+
<>
|
25
|
+
<div className={styles.filterContainer}>
|
26
|
+
<Dropdown
|
27
|
+
id="stockRulesFiter"
|
28
|
+
items={[...items.results]}
|
29
|
+
itemToString={(item) => (item ? item.display : "Not Set")}
|
30
|
+
type="inline"
|
31
|
+
size="sm"
|
32
|
+
/>
|
33
|
+
</div>
|
34
|
+
</>
|
35
|
+
);
|
36
|
+
};
|
37
|
+
|
38
|
+
export default StockRulesFilter;
|
@@ -0,0 +1,79 @@
|
|
1
|
+
import { openmrsFetch } from "@openmrs/esm-framework";
|
2
|
+
import { ResourceFilterCriteria, toQueryParams } from "../../../core/api/api";
|
3
|
+
import useSWR from "swr";
|
4
|
+
import { PageableResult } from "../../../core/api/types/PageableResult";
|
5
|
+
import { StockRule } from "../../../core/api/types/stockItem/StockRule";
|
6
|
+
|
7
|
+
export interface StockSourceFilter extends ResourceFilterCriteria {
|
8
|
+
stockItemUuid?: string | null;
|
9
|
+
}
|
10
|
+
|
11
|
+
// Get Stock Rules
|
12
|
+
export function useStockRules(filter: StockSourceFilter) {
|
13
|
+
const apiUrl = `ws/rest/v1/stockmanagement/stockrule${toQueryParams(filter)}`;
|
14
|
+
|
15
|
+
const { data, error, isLoading } = useSWR<
|
16
|
+
{ data: PageableResult<StockRule> },
|
17
|
+
Error
|
18
|
+
>(apiUrl, openmrsFetch);
|
19
|
+
|
20
|
+
return {
|
21
|
+
items: data?.data || <PageableResult<StockRule>>{},
|
22
|
+
isLoading,
|
23
|
+
isError: error,
|
24
|
+
};
|
25
|
+
}
|
26
|
+
|
27
|
+
// Get Stock Rule
|
28
|
+
export function useStockRule(id: string) {
|
29
|
+
const apiUrl = `ws/rest/v1/stockmanagement/stockrule/${id}`;
|
30
|
+
const { data, error, isLoading } = useSWR<{ data: StockRule }, Error>(
|
31
|
+
apiUrl,
|
32
|
+
openmrsFetch
|
33
|
+
);
|
34
|
+
return {
|
35
|
+
items: data.data ? data.data : [],
|
36
|
+
isLoading,
|
37
|
+
isError: error,
|
38
|
+
};
|
39
|
+
}
|
40
|
+
|
41
|
+
// Delete Stock Rule
|
42
|
+
export function deleteStockRule(ids: string[]) {
|
43
|
+
let otherIds = ids.reduce((p, c, i) => {
|
44
|
+
if (i === 0) return p;
|
45
|
+
p += (p.length > 0 ? "," : "") + encodeURIComponent(c);
|
46
|
+
return p;
|
47
|
+
}, "");
|
48
|
+
if (otherIds.length > 0) {
|
49
|
+
otherIds = "?ids=" + otherIds;
|
50
|
+
}
|
51
|
+
const apiUrl = `ws/rest/v1/stockmanagement/stockrule/${ids[0]}${otherIds}`;
|
52
|
+
const abortController = new AbortController();
|
53
|
+
return openmrsFetch(apiUrl, {
|
54
|
+
method: "DELETE",
|
55
|
+
headers: {
|
56
|
+
"Content-Type": "application/json",
|
57
|
+
},
|
58
|
+
signal: abortController.signal,
|
59
|
+
});
|
60
|
+
}
|
61
|
+
|
62
|
+
// Create Or Update Stock Rule
|
63
|
+
export function createOrUpdateStockRule(item: StockRule) {
|
64
|
+
const isNew = item.uuid != null;
|
65
|
+
|
66
|
+
const apiUrl = `ws/rest/v1/stockmanagement/stockrule${
|
67
|
+
isNew ? "/" + item.uuid : ""
|
68
|
+
}`;
|
69
|
+
const abortController = new AbortController();
|
70
|
+
return openmrsFetch(apiUrl, {
|
71
|
+
method: "POST",
|
72
|
+
headers: {
|
73
|
+
"Content-Type": "application/json",
|
74
|
+
},
|
75
|
+
signal: abortController.signal,
|
76
|
+
// body: { ...item, sourceType: item?.sourceType?.uuid },
|
77
|
+
body: { ...item },
|
78
|
+
});
|
79
|
+
}
|
package/src/stock-items/add-stock-item/stock-item-units-edit/stock-item-units-edit.component.tsx
ADDED
@@ -0,0 +1,132 @@
|
|
1
|
+
import React from "react";
|
2
|
+
import { useTranslation } from "react-i18next";
|
3
|
+
import { useStockItem } from "../../stock-items.resource";
|
4
|
+
import DispensingPackageMeasurement from "../dispensing-package-measurement/dispensing-package-measurement.component";
|
5
|
+
import { Control, FormState } from "react-hook-form";
|
6
|
+
import { StockItemFormData } from "../../validationSchema";
|
7
|
+
import ControlledNumberInput from "../../../core/components/carbon/controlled-number-input/controlled-number-input.component";
|
8
|
+
import { NumberInputSkeleton } from "@carbon/react";
|
9
|
+
|
10
|
+
interface StockItemUnitsEditProps {
|
11
|
+
stockItemUuid: string;
|
12
|
+
control: Control<StockItemFormData>;
|
13
|
+
formState: FormState<StockItemFormData>;
|
14
|
+
}
|
15
|
+
|
16
|
+
const StockItemUnitsEdit: React.FC<StockItemUnitsEditProps> = ({
|
17
|
+
stockItemUuid,
|
18
|
+
control,
|
19
|
+
formState: { errors },
|
20
|
+
}) => {
|
21
|
+
const { t } = useTranslation();
|
22
|
+
|
23
|
+
const { item: stockItem, isLoading } = useStockItem(stockItemUuid);
|
24
|
+
|
25
|
+
if (
|
26
|
+
!(
|
27
|
+
stockItem &&
|
28
|
+
stockItem.packagingUnits &&
|
29
|
+
stockItem.packagingUnits.length > 0
|
30
|
+
)
|
31
|
+
)
|
32
|
+
return <></>;
|
33
|
+
|
34
|
+
return (
|
35
|
+
<>
|
36
|
+
<DispensingPackageMeasurement
|
37
|
+
name="dispensingUnitPackagingUoMUuid"
|
38
|
+
controllerName="dispensingUnitPackagingUoMUuid"
|
39
|
+
control={control}
|
40
|
+
title={t(
|
41
|
+
"dispensingUnitOfMeasurement",
|
42
|
+
"Dispensing packaging unit of measurement:"
|
43
|
+
)}
|
44
|
+
placeholder={t("chooseAPackagingUoM", "Choose a packaging UoM")}
|
45
|
+
isLoading={isLoading}
|
46
|
+
packagingUnits={stockItem.packagingUnits}
|
47
|
+
invalid={!!errors.dispensingUnitPackagingUoMUuid}
|
48
|
+
invalidText={
|
49
|
+
errors.dispensingUnitPackagingUoMUuid &&
|
50
|
+
errors?.dispensingUnitPackagingUoMUuid?.message
|
51
|
+
}
|
52
|
+
/>
|
53
|
+
<DispensingPackageMeasurement
|
54
|
+
name="defaultStockOperationsUoMUuid"
|
55
|
+
controllerName="defaultStockOperationsUoMUuid"
|
56
|
+
control={control}
|
57
|
+
title={t(
|
58
|
+
"defaultStockOperationsPackagingUnit:",
|
59
|
+
"Default stock operations packaging unit:"
|
60
|
+
)}
|
61
|
+
placeholder={t("chooseAPackagingUoM", "Choose a packaging UoM")}
|
62
|
+
isLoading={isLoading}
|
63
|
+
packagingUnits={stockItem.packagingUnits}
|
64
|
+
invalid={!!errors.defaultStockOperationsUoMUuid}
|
65
|
+
invalidText={
|
66
|
+
errors.defaultStockOperationsUoMUuid &&
|
67
|
+
errors?.defaultStockOperationsUoMUuid?.message
|
68
|
+
}
|
69
|
+
/>
|
70
|
+
{isLoading ? (
|
71
|
+
<NumberInputSkeleton />
|
72
|
+
) : (
|
73
|
+
<ControlledNumberInput
|
74
|
+
id="reorderLevel"
|
75
|
+
name="reorderLevel"
|
76
|
+
control={control}
|
77
|
+
controllerName="reorderLevel"
|
78
|
+
size={"md"}
|
79
|
+
allowEmpty={true}
|
80
|
+
label={t("orderLevel", "Reorder level:")}
|
81
|
+
invalid={!!errors.reorderLevel}
|
82
|
+
value={stockItem.reorderLevel ?? ""}
|
83
|
+
invalidText={errors.reorderLevel && errors?.reorderLevel?.message}
|
84
|
+
/>
|
85
|
+
)}
|
86
|
+
<DispensingPackageMeasurement
|
87
|
+
name="reorderLevelUoMUuid"
|
88
|
+
controllerName="reorderLevelUoMUuid"
|
89
|
+
control={control}
|
90
|
+
title={t("reorderLevelPackagingUnit:", "Reorder level packaging unit:")}
|
91
|
+
placeholder={t("notSet", "Not Set")}
|
92
|
+
isLoading={isLoading}
|
93
|
+
packagingUnits={stockItem.packagingUnits}
|
94
|
+
invalid={!!errors.reorderLevelUoMUuid}
|
95
|
+
invalidText={
|
96
|
+
errors.reorderLevelUoMUuid && errors?.reorderLevelUoMUuid?.message
|
97
|
+
}
|
98
|
+
/>
|
99
|
+
{isLoading ? (
|
100
|
+
<NumberInputSkeleton />
|
101
|
+
) : (
|
102
|
+
<ControlledNumberInput
|
103
|
+
id="purchasePrice"
|
104
|
+
name="purchasePrice"
|
105
|
+
control={control}
|
106
|
+
controllerName="purchasePrice"
|
107
|
+
size={"md"}
|
108
|
+
allowEmpty={true}
|
109
|
+
label={t("purchasePrice", "Purchase Price")}
|
110
|
+
value={stockItem.purchasePrice ?? ""}
|
111
|
+
invalid={!!errors.purchasePrice}
|
112
|
+
invalidText={errors.purchasePrice && errors?.purchasePrice?.message}
|
113
|
+
/>
|
114
|
+
)}
|
115
|
+
<DispensingPackageMeasurement
|
116
|
+
name="purchasePriceUoMUuid"
|
117
|
+
controllerName="purchasePriceUoMUuid"
|
118
|
+
control={control}
|
119
|
+
title={t("purchasePricePackagingUnit", "Purchase price packaging unit")}
|
120
|
+
placeholder={t("notSet", "Not Set")}
|
121
|
+
isLoading={isLoading}
|
122
|
+
packagingUnits={stockItem.packagingUnits}
|
123
|
+
invalid={!!errors.purchasePriceUoMUuid}
|
124
|
+
invalidText={
|
125
|
+
errors.purchasePriceUoMUuid && errors?.purchasePriceUoMUuid?.message
|
126
|
+
}
|
127
|
+
/>
|
128
|
+
</>
|
129
|
+
);
|
130
|
+
};
|
131
|
+
|
132
|
+
export default StockItemUnitsEdit;
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import React from "react";
|
2
|
+
import addStockStyles from "../add-stock-item.scss";
|
3
|
+
|
4
|
+
interface StockRulesProps {
|
5
|
+
onSubmit?: () => void;
|
6
|
+
}
|
7
|
+
|
8
|
+
const StockRules: React.FC<StockRulesProps> = () => {
|
9
|
+
return (
|
10
|
+
<div className={addStockStyles.formContainer}>
|
11
|
+
Stock rules Coming soon ...
|
12
|
+
</div>
|
13
|
+
);
|
14
|
+
};
|
15
|
+
|
16
|
+
export default StockRules;
|
File without changes
|
File without changes
|