@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.
Files changed (366) hide show
  1. package/.editorconfig +12 -0
  2. package/.eslintignore +2 -0
  3. package/.eslintrc +39 -0
  4. package/.husky/pre-commit +4 -0
  5. package/.husky/pre-push +6 -0
  6. package/.prettierignore +14 -0
  7. package/.turbo.json +18 -0
  8. package/.yarn/plugins/@yarnpkg/plugin-outdated.cjs +35 -0
  9. package/LICENSE +401 -0
  10. package/README.md +3 -0
  11. package/__mocks__/react-i18next.js +55 -0
  12. package/dist/26.js +2 -0
  13. package/dist/26.js.LICENSE.txt +32 -0
  14. package/dist/26.js.map +1 -0
  15. package/dist/294.js +2 -0
  16. package/dist/294.js.LICENSE.txt +9 -0
  17. package/dist/294.js.map +1 -0
  18. package/dist/375.js +2 -0
  19. package/dist/375.js.LICENSE.txt +40 -0
  20. package/dist/375.js.map +1 -0
  21. package/dist/46.js +1 -0
  22. package/dist/46.js.map +1 -0
  23. package/dist/484.js +1 -0
  24. package/dist/484.js.map +1 -0
  25. package/dist/574.js +1 -0
  26. package/dist/629.js +1 -0
  27. package/dist/629.js.map +1 -0
  28. package/dist/707.js +1 -0
  29. package/dist/707.js.map +1 -0
  30. package/dist/800.js +2 -0
  31. package/dist/800.js.LICENSE.txt +3 -0
  32. package/dist/800.js.map +1 -0
  33. package/dist/935.js +2 -0
  34. package/dist/935.js.LICENSE.txt +19 -0
  35. package/dist/935.js.map +1 -0
  36. package/dist/979.js +1 -0
  37. package/dist/979.js.map +1 -0
  38. package/dist/main.js +2 -0
  39. package/dist/main.js.LICENSE.txt +60 -0
  40. package/dist/main.js.map +1 -0
  41. package/dist/openmrs-esm-stock-management-app.js +1 -0
  42. package/dist/openmrs-esm-stock-management-app.js.buildmanifest.json +356 -0
  43. package/dist/openmrs-esm-stock-management-app.js.map +1 -0
  44. package/dist/routes.json +1 -0
  45. package/i18next-parser.config.js +89 -0
  46. package/jest.config.js +25 -0
  47. package/package.json +116 -0
  48. package/src/config-schema.ts +18 -0
  49. package/src/constants.ts +214 -0
  50. package/src/core/api/api.ts +34 -0
  51. package/src/core/api/types/Auditable.ts +9 -0
  52. package/src/core/api/types/BaseOpenmrsData.ts +4 -0
  53. package/src/core/api/types/BaseOpenmrsMetadata.ts +6 -0
  54. package/src/core/api/types/BaseOpenmrsObject.ts +3 -0
  55. package/src/core/api/types/BatchJob.ts +121 -0
  56. package/src/core/api/types/DashboardExtension.ts +8 -0
  57. package/src/core/api/types/Location.ts +16 -0
  58. package/src/core/api/types/LocationTree.ts +7 -0
  59. package/src/core/api/types/OpenmrsData.ts +5 -0
  60. package/src/core/api/types/OpenmrsMetadata.ts +8 -0
  61. package/src/core/api/types/OpenmrsObject.ts +3 -0
  62. package/src/core/api/types/PageableResult.ts +15 -0
  63. package/src/core/api/types/Party.ts +8 -0
  64. package/src/core/api/types/RecordPermission.ts +9 -0
  65. package/src/core/api/types/Retireable.ts +9 -0
  66. package/src/core/api/types/Voidable.ts +9 -0
  67. package/src/core/api/types/concept/Concept.ts +24 -0
  68. package/src/core/api/types/concept/ConceptName.ts +14 -0
  69. package/src/core/api/types/concept/Drug.ts +14 -0
  70. package/src/core/api/types/identity/Credentials.ts +4 -0
  71. package/src/core/api/types/identity/Patient.ts +3 -0
  72. package/src/core/api/types/identity/Person.ts +4 -0
  73. package/src/core/api/types/identity/PriviledgeScope.ts +9 -0
  74. package/src/core/api/types/identity/Privilege.ts +5 -0
  75. package/src/core/api/types/identity/Role.ts +5 -0
  76. package/src/core/api/types/identity/Session.ts +16 -0
  77. package/src/core/api/types/identity/User.ts +19 -0
  78. package/src/core/api/types/identity/UserRoleScope.ts +17 -0
  79. package/src/core/api/types/identity/UserRoleScopeLocation.ts +7 -0
  80. package/src/core/api/types/identity/UserRoleScopeOperationType.ts +6 -0
  81. package/src/core/api/types/stockItem/ImportResult.ts +9 -0
  82. package/src/core/api/types/stockItem/StockBatch.ts +8 -0
  83. package/src/core/api/types/stockItem/StockBatchDTO.ts +8 -0
  84. package/src/core/api/types/stockItem/StockItem.ts +63 -0
  85. package/src/core/api/types/stockItem/StockItemInventory.ts +10 -0
  86. package/src/core/api/types/stockItem/StockItemPackagingUOM.ts +20 -0
  87. package/src/core/api/types/stockItem/StockItemTransaction.ts +22 -0
  88. package/src/core/api/types/stockItem/StockRule.ts +28 -0
  89. package/src/core/api/types/stockOperation/LocationType.ts +4 -0
  90. package/src/core/api/types/stockOperation/StockOperation.ts +36 -0
  91. package/src/core/api/types/stockOperation/StockOperationAction.ts +24 -0
  92. package/src/core/api/types/stockOperation/StockOperationDTO.ts +64 -0
  93. package/src/core/api/types/stockOperation/StockOperationItem.ts +13 -0
  94. package/src/core/api/types/stockOperation/StockOperationItemCost.ts +14 -0
  95. package/src/core/api/types/stockOperation/StockOperationItemDTO.ts +29 -0
  96. package/src/core/api/types/stockOperation/StockOperationLinkDTO.ts +13 -0
  97. package/src/core/api/types/stockOperation/StockOperationStatus.ts +18 -0
  98. package/src/core/api/types/stockOperation/StockOperationType.ts +162 -0
  99. package/src/core/api/types/stockOperation/StockSource.ts +8 -0
  100. package/src/core/components/carbon/controlled-combo-box/controlled-combo-box.component.tsx +37 -0
  101. package/src/core/components/carbon/controlled-combo-box/controlled-combo-box.resource.tsx +0 -0
  102. package/src/core/components/carbon/controlled-combo-box/controlled-combo-box.scss +0 -0
  103. package/src/core/components/carbon/controlled-combo-box/controlled-combo-box.test.tsx +8 -0
  104. package/src/core/components/carbon/controlled-dropdown/controlled-dropdown.component.tsx +40 -0
  105. package/src/core/components/carbon/controlled-dropdown/controlled-dropdown.resource.tsx +0 -0
  106. package/src/core/components/carbon/controlled-dropdown/controlled-dropdown.scss +0 -0
  107. package/src/core/components/carbon/controlled-dropdown/controlled-dropdown.test.tsx +8 -0
  108. package/src/core/components/carbon/controlled-number-input/controlled-number-input.component.tsx +44 -0
  109. package/src/core/components/carbon/controlled-number-input/controlled-number-input.resource.tsx +0 -0
  110. package/src/core/components/carbon/controlled-number-input/controlled-number-input.scss +0 -0
  111. package/src/core/components/carbon/controlled-number-input/controlled-number-input.test.tsx +8 -0
  112. package/src/core/components/carbon/controlled-radio-button-group/controlled-radio-button-group.component.tsx +54 -0
  113. package/src/core/components/carbon/controlled-radio-button-group/controlled-radio-button-group.resource.tsx +0 -0
  114. package/src/core/components/carbon/controlled-radio-button-group/controlled-radio-button-group.scss +0 -0
  115. package/src/core/components/carbon/controlled-radio-button-group/controlled-radio-button-group.test.tsx +8 -0
  116. package/src/core/components/carbon/controlled-text-area/controlled-text-area.component.tsx +37 -0
  117. package/src/core/components/carbon/controlled-text-area/controlled-text-area.resource.tsx +0 -0
  118. package/src/core/components/carbon/controlled-text-area/controlled-text-area.scss +0 -0
  119. package/src/core/components/carbon/controlled-text-area/controlled-text-area.test.tsx +11 -0
  120. package/src/core/components/carbon/controlled-text-input/controlled-text-input.component.tsx +37 -0
  121. package/src/core/components/carbon/controlled-text-input/controlled-text-input.resource.tsx +0 -0
  122. package/src/core/components/carbon/controlled-text-input/controlled-text-input.scss +0 -0
  123. package/src/core/components/carbon/controlled-text-input/controlled-text-input.test.tsx +8 -0
  124. package/src/core/components/carbon/types.ts +7 -0
  125. package/src/core/components/card/metrics-card-component.tsx +102 -0
  126. package/src/core/components/card/metrics-card.scss +78 -0
  127. package/src/core/components/overlay/hook.ts +47 -0
  128. package/src/core/components/overlay/overlay.component.tsx +52 -0
  129. package/src/core/components/overlay/overlay.scss +97 -0
  130. package/src/core/components/side-nav/side-nav.component.tsx +62 -0
  131. package/src/core/components/side-nav/side-nav.scss +126 -0
  132. package/src/core/components/side-nav/types.ts +6 -0
  133. package/src/core/components/table/table.component.tsx +239 -0
  134. package/src/core/components/table/table.scss +173 -0
  135. package/src/core/components/table/types.ts +8 -0
  136. package/src/core/components/tabs/types.ts +7 -0
  137. package/src/core/components/tabs/vertical-tabs.component.tsx +53 -0
  138. package/src/core/components/tabs/vertical-tabs.scss +126 -0
  139. package/src/core/hooks/debounce-hook.ts +35 -0
  140. package/src/core/print/PrintStyles.ts +774 -0
  141. package/src/core/print/PrintTemplate.ts +65 -0
  142. package/src/core/print/printUtils.ts +19 -0
  143. package/src/core/utils/alert.ts +10 -0
  144. package/src/core/utils/datetimeUtils.ts +84 -0
  145. package/src/core/utils/debounce.ts +21 -0
  146. package/src/core/utils/imageUtils.ts +82 -0
  147. package/src/core/utils/stringUtils.ts +27 -0
  148. package/src/core/utils/utils.ts +70 -0
  149. package/src/createDashboardLink.tsx +43 -0
  150. package/src/dashboard/stock-management-dashboard-side-nav.component.tsx +50 -0
  151. package/src/dashboard/stock-management-dashboard.component.tsx +41 -0
  152. package/src/dashboard/stock-management-dashboard.scss +8 -0
  153. package/src/dashboard.meta.ts +5 -0
  154. package/src/declarations.d.ts +6 -0
  155. package/src/index.ts +64 -0
  156. package/src/root.component.tsx +12 -0
  157. package/src/root.scss +174 -0
  158. package/src/routes.json +53 -0
  159. package/src/setup-tests.ts +1 -0
  160. package/src/stock-app-menu-item/item.component.tsx +21 -0
  161. package/src/stock-app-menu-item/item.resource.ts +0 -0
  162. package/src/stock-app-menu-item/item.scss +17 -0
  163. package/src/stock-batch/stock-batch.resource.ts +79 -0
  164. package/src/stock-home/stock-home-detail-card.scss +211 -0
  165. package/src/stock-home/stock-home-detail-cards.component.tsx +62 -0
  166. package/src/stock-home/stock-home-inventory-card.component.tsx +80 -0
  167. package/src/stock-home/stock-home-inventory-expiry.resource.tsx +32 -0
  168. package/src/stock-home/stock-home-inventory-items.resource.tsx +28 -0
  169. package/src/stock-home/stock-home-issuing-card.component.tsx +84 -0
  170. package/src/stock-home/stock-home-issuing.resource.tsx +18 -0
  171. package/src/stock-home/stock-home-landing-page-component.tsx +14 -0
  172. package/src/stock-home/stock-home-metrics.tsx +112 -0
  173. package/src/stock-home/stock-home-receiving-card.component.tsx +66 -0
  174. package/src/stock-home/stock-home-receiving.resource.tsx +17 -0
  175. package/src/stock-home/stock-home.scss +13 -0
  176. package/src/stock-home/useDisposalList.tsx +18 -0
  177. package/src/stock-home/useStockList.tsx +36 -0
  178. package/src/stock-items/add-bulk-stock-item/add-stock-items-bulk-import-action-button.component.tsx +26 -0
  179. package/src/stock-items/add-bulk-stock-item/stock-items-bulk-import.component.tsx +109 -0
  180. package/src/stock-items/add-bulk-stock-item/stock-items-bulk-import.resource.ts +14 -0
  181. package/src/stock-items/add-bulk-stock-item/stock-items-bulk-import.scss +0 -0
  182. package/src/stock-items/add-stock-item/add-stock-action-button.component.tsx +21 -0
  183. package/src/stock-items/add-stock-item/add-stock-item.component.tsx +84 -0
  184. package/src/stock-items/add-stock-item/add-stock-item.resource.tsx +36 -0
  185. package/src/stock-items/add-stock-item/add-stock-item.scss +5 -0
  186. package/src/stock-items/add-stock-item/batch-information/batch-information.component.tsx +98 -0
  187. package/src/stock-items/add-stock-item/batch-information/batch-information.resource.tsx +71 -0
  188. package/src/stock-items/add-stock-item/batch-information/batch-information.scss +0 -0
  189. package/src/stock-items/add-stock-item/concepts-selector/concepts-selector.component.tsx +79 -0
  190. package/src/stock-items/add-stock-item/concepts-selector/concepts-selector.resource.tsx +0 -0
  191. package/src/stock-items/add-stock-item/concepts-selector/concepts-selector.scss +0 -0
  192. package/src/stock-items/add-stock-item/concepts-selector/concepts-selector.test.tsx +8 -0
  193. package/src/stock-items/add-stock-item/dispensing-package-measurement/dispensing-package-measurement.component.tsx +76 -0
  194. package/src/stock-items/add-stock-item/dispensing-unit-selector/dispensing-unit-selector.component.tsx +66 -0
  195. package/src/stock-items/add-stock-item/dispensing-unit-selector/dispensing-unit-selector.resource.tsx +0 -0
  196. package/src/stock-items/add-stock-item/dispensing-unit-selector/dispensing-unit-selector.scss +0 -0
  197. package/src/stock-items/add-stock-item/dispensing-unit-selector/dispensing-unit-selector.test.tsx +8 -0
  198. package/src/stock-items/add-stock-item/drug-selector/drug-selector.component.tsx +83 -0
  199. package/src/stock-items/add-stock-item/drug-selector/drug-selector.resource.tsx +50 -0
  200. package/src/stock-items/add-stock-item/drug-selector/drug-selector.scss +0 -0
  201. package/src/stock-items/add-stock-item/packaging-units/packaging-units.component.tsx +255 -0
  202. package/src/stock-items/add-stock-item/packaging-units/packaging-units.resource.tsx +38 -0
  203. package/src/stock-items/add-stock-item/packaging-units/packaging-units.scss +21 -0
  204. package/src/stock-items/add-stock-item/packaging-units/validationSchema.ts +14 -0
  205. package/src/stock-items/add-stock-item/packaging-units-concept-selector/packaging-units-concept-selector.component.tsx +95 -0
  206. package/src/stock-items/add-stock-item/preferred-vendor-selector/preferred-vendor-selector.component.tsx +70 -0
  207. package/src/stock-items/add-stock-item/preferred-vendor-selector/preferred-vendor-selector.resource.tsx +0 -0
  208. package/src/stock-items/add-stock-item/preferred-vendor-selector/preferred-vendor-selector.scss +0 -0
  209. package/src/stock-items/add-stock-item/preferred-vendor-selector/preferred-vendor-selector.test.tsx +8 -0
  210. package/src/stock-items/add-stock-item/quantities/quantities.component.tsx +83 -0
  211. package/src/stock-items/add-stock-item/quantities/quantities.resource.tsx +69 -0
  212. package/src/stock-items/add-stock-item/quantities/quantities.scss +0 -0
  213. package/src/stock-items/add-stock-item/stock-item-category-selector/stock-item-category-selector.component.tsx +67 -0
  214. package/src/stock-items/add-stock-item/stock-item-category-selector/stock-item-category-selector.resource.tsx +0 -0
  215. package/src/stock-items/add-stock-item/stock-item-category-selector/stock-item-category-selector.scss +0 -0
  216. package/src/stock-items/add-stock-item/stock-item-category-selector/stock-item-category-selector.test.tsx +8 -0
  217. package/src/stock-items/add-stock-item/stock-item-details/stock-item-details.component.tsx +239 -0
  218. package/src/stock-items/add-stock-item/stock-item-details/stock-item-details.resource.tsx +14 -0
  219. package/src/stock-items/add-stock-item/stock-item-details/stock-item-details.scss +13 -0
  220. package/src/stock-items/add-stock-item/stock-item-rules/add-stock-rule-button.component.tsx +30 -0
  221. package/src/stock-items/add-stock-item/stock-item-rules/add-stock-rules.component.tsx +424 -0
  222. package/src/stock-items/add-stock-item/stock-item-rules/add-stock-rules.scss +18 -0
  223. package/src/stock-items/add-stock-item/stock-item-rules/delete-stock-rule-modal.component.tsx +47 -0
  224. package/src/stock-items/add-stock-item/stock-item-rules/edit-stock-rule.component.tsx +37 -0
  225. package/src/stock-items/add-stock-item/stock-item-rules/edit-stock-rule.scss +0 -0
  226. package/src/stock-items/add-stock-item/stock-item-rules/stock-item-rules.component.tsx +222 -0
  227. package/src/stock-items/add-stock-item/stock-item-rules/stock-item-rules.resource.tsx +72 -0
  228. package/src/stock-items/add-stock-item/stock-item-rules/stock-item-rules.scss +13 -0
  229. package/src/stock-items/add-stock-item/stock-item-rules/stock-rules-delete.component.tsx +67 -0
  230. package/src/stock-items/add-stock-item/stock-item-rules/stock-rules-delete.scss +0 -0
  231. package/src/stock-items/add-stock-item/stock-item-rules/stock-rules-filter.component.tsx +38 -0
  232. package/src/stock-items/add-stock-item/stock-item-rules/stock-rules-filter.scss +13 -0
  233. package/src/stock-items/add-stock-item/stock-item-rules/stock-rules.resource.ts +79 -0
  234. package/src/stock-items/add-stock-item/stock-item-units-edit/stock-item-units-edit.component.tsx +132 -0
  235. package/src/stock-items/add-stock-item/stock-rules/stock-rules.component.tsx +16 -0
  236. package/src/stock-items/add-stock-item/stock-rules/stock-rules.resource.tsx +0 -0
  237. package/src/stock-items/add-stock-item/stock-rules/stock-rules.scss +0 -0
  238. package/src/stock-items/add-stock-item/transactions/transactions.component.tsx +151 -0
  239. package/src/stock-items/add-stock-item/transactions/transactions.resource.tsx +109 -0
  240. package/src/stock-items/add-stock-item/transactions/transactions.scss +0 -0
  241. package/src/stock-items/components/filter-stock-items/filter-stock-items.component.tsx +28 -0
  242. package/src/stock-items/components/filter-stock-items/filter-stock-items.resource.tsx +0 -0
  243. package/src/stock-items/components/filter-stock-items/filter-stock-items.scss +3 -0
  244. package/src/stock-items/edit-stock-item/edit-stock-item-action-menu.component.tsx +30 -0
  245. package/src/stock-items/stock-item.utils.tsx +62 -0
  246. package/src/stock-items/stock-items-table.component.tsx +266 -0
  247. package/src/stock-items/stock-items-table.resource.ts +58 -0
  248. package/src/stock-items/stock-items-table.scss +66 -0
  249. package/src/stock-items/stock-items.component.tsx +12 -0
  250. package/src/stock-items/stock-items.resource.ts +365 -0
  251. package/src/stock-items/types.ts +8 -0
  252. package/src/stock-items/validationSchema.ts +67 -0
  253. package/src/stock-locations/stock-locations-table.component.tsx +69 -0
  254. package/src/stock-locations/stock-locations-table.resource.tsx +73 -0
  255. package/src/stock-locations/stock-locations-table.scss +0 -0
  256. package/src/stock-locations/stock-locations.component.tsx +12 -0
  257. package/src/stock-locations/stock-locations.resource.ts +0 -0
  258. package/src/stock-lookups/stock-lookups.resource.ts +306 -0
  259. package/src/stock-management-admin-card-link.component.tsx +29 -0
  260. package/src/stock-management-header/stock-management-Illustration.tsx +35 -0
  261. package/src/stock-management-header/stock-management-header.component.tsx +37 -0
  262. package/src/stock-management-header/stock-management-header.scss +58 -0
  263. package/src/stock-management.component.tsx +6 -0
  264. package/src/stock-operations/add-stock-operation/add-stock-operation.component.tsx +491 -0
  265. package/src/stock-operations/add-stock-operation/add-stock-operation.resource.tsx +33 -0
  266. package/src/stock-operations/add-stock-operation/add-stock-operation.scss +44 -0
  267. package/src/stock-operations/add-stock-operation/add-stock-operation.utils.tsx +241 -0
  268. package/src/stock-operations/add-stock-operation/add-stock-utils.ts +110 -0
  269. package/src/stock-operations/add-stock-operation/base-operation-details.component.tsx +352 -0
  270. package/src/stock-operations/add-stock-operation/stock-items-addition-row.component.tsx +347 -0
  271. package/src/stock-operations/add-stock-operation/stock-items-addition-row.resource.tsx +0 -0
  272. package/src/stock-operations/add-stock-operation/stock-items-addition-row.scss +0 -0
  273. package/src/stock-operations/add-stock-operation/stock-items-addition-row.test.tsx +11 -0
  274. package/src/stock-operations/add-stock-operation/stock-items-addition.component.scss +5 -0
  275. package/src/stock-operations/add-stock-operation/stock-items-addition.component.tsx +272 -0
  276. package/src/stock-operations/add-stock-operation/stock-operation-context/useStockOperationContext.tsx +22 -0
  277. package/src/stock-operations/add-stock-operation/stock-operation-submission.component.tsx +188 -0
  278. package/src/stock-operations/add-stock-operation/types.ts +55 -0
  279. package/src/stock-operations/add-stock-operation/validationSchema.ts +45 -0
  280. package/src/stock-operations/batch-no-selector/batch-no-selector.component.tsx +100 -0
  281. package/src/stock-operations/batch-no-selector/batch-no-selector.resource.tsx +46 -0
  282. package/src/stock-operations/batch-no-selector/batch-no-selector.scss +0 -0
  283. package/src/stock-operations/batch-no-selector/batch-no-selector.test.tsx +11 -0
  284. package/src/stock-operations/edit-stock-operation/edit-stock-operation-action-menu.component.tsx +73 -0
  285. package/src/stock-operations/party-selector/party-selector.component.tsx +58 -0
  286. package/src/stock-operations/qty-uom-selector/qty-uom-selector.component.tsx +65 -0
  287. package/src/stock-operations/qty-uom-selector/qty-uom-selector.resource.tsx +0 -0
  288. package/src/stock-operations/qty-uom-selector/qty-uom-selector.scss +0 -0
  289. package/src/stock-operations/qty-uom-selector/qty-uom-selector.test.tsx +11 -0
  290. package/src/stock-operations/stock-item-selector/stock-item-selector.component.tsx +74 -0
  291. package/src/stock-operations/stock-item-selector/stock-item-selector.resource.tsx +47 -0
  292. package/src/stock-operations/stock-item-selector/stock-item-selector.scss +0 -0
  293. package/src/stock-operations/stock-item-selector/stock-item-selector.test.tsx +11 -0
  294. package/src/stock-operations/stock-operation-operations-filter/stock-operation-operations-filter.component.tsx +27 -0
  295. package/src/stock-operations/stock-operation-operations-filter/stock-operation-operations-filter.scss +13 -0
  296. package/src/stock-operations/stock-operation-reason-selector/stock-operation-reason-selector.component.tsx +65 -0
  297. package/src/stock-operations/stock-operation-sources-filter/stock-operation-sources-filter.component.tsx +30 -0
  298. package/src/stock-operations/stock-operation-sources-filter/stock-operation-sources-filter.scss +13 -0
  299. package/src/stock-operations/stock-operation-statuses-filter/stock-operation-statuses-filter.component.tsx +32 -0
  300. package/src/stock-operations/stock-operation-statuses-filter/stock-operation-statuses-filter.scss +13 -0
  301. package/src/stock-operations/stock-operation-types-selector/stock-operation-types-selector.component.tsx +80 -0
  302. package/src/stock-operations/stock-operation.utils.tsx +106 -0
  303. package/src/stock-operations/stock-operations-dialog/stock-operations-approve-button.component.tsx +36 -0
  304. package/src/stock-operations/stock-operations-dialog/stock-operations-approve-dispatch-button.component.tsx +36 -0
  305. package/src/stock-operations/stock-operations-dialog/stock-operations-cancel-button.component.tsx +37 -0
  306. package/src/stock-operations/stock-operations-dialog/stock-operations-complete-button.component.tsx +36 -0
  307. package/src/stock-operations/stock-operations-dialog/stock-operations-completed-dispatch-button.component.tsx +36 -0
  308. package/src/stock-operations/stock-operations-dialog/stock-operations-dialog.component.tsx +167 -0
  309. package/src/stock-operations/stock-operations-dialog/stock-operations-dialog.scss +14 -0
  310. package/src/stock-operations/stock-operations-dialog/stock-operations-issue-stock-button.component.tsx +58 -0
  311. package/src/stock-operations/stock-operations-dialog/stock-operations-print-button.component.tsx +160 -0
  312. package/src/stock-operations/stock-operations-dialog/stock-operations-reject-button.component.tsx +37 -0
  313. package/src/stock-operations/stock-operations-dialog/stock-operations-return-button.component.tsx +37 -0
  314. package/src/stock-operations/stock-operations-table.component.tsx +524 -0
  315. package/src/stock-operations/stock-operations-table.resource.tsx +77 -0
  316. package/src/stock-operations/stock-operations-table.scss +0 -0
  317. package/src/stock-operations/stock-operations.component.tsx +12 -0
  318. package/src/stock-operations/stock-operations.resource.ts +238 -0
  319. package/src/stock-operations/stock-print-reports/GoodsReceivedNote.tsx +147 -0
  320. package/src/stock-operations/stock-print-reports/RequisitionDocument.tsx +153 -0
  321. package/src/stock-operations/stock-print-reports/StockOperationReport.tsx +133 -0
  322. package/src/stock-operations/stock-print-reports/StockTransferDocument.tsx +161 -0
  323. package/src/stock-operations/swr-revalidation.ts +7 -0
  324. package/src/stock-operations/users-selector/users-selector.component.tsx +77 -0
  325. package/src/stock-operations/users-selector/users-selector.resource.tsx +47 -0
  326. package/src/stock-operations/validation-schema.ts +195 -0
  327. package/src/stock-reports/ReportType.ts +63 -0
  328. package/src/stock-reports/stock-reports.component.tsx +0 -0
  329. package/src/stock-reports/stock-reports.resource.ts +0 -0
  330. package/src/stock-settings/stock-settings.component.tsx +11 -0
  331. package/src/stock-settings/stock-settings.resource.ts +0 -0
  332. package/src/stock-sources/add-stock-source-button.component.tsx +21 -0
  333. package/src/stock-sources/add-stock-sources/add-stock-sources.component.tsx +152 -0
  334. package/src/stock-sources/add-stock-sources/add-stock-sources.scss +18 -0
  335. package/src/stock-sources/delete-stock-modal.component.tsx +47 -0
  336. package/src/stock-sources/edit-stock-source/edit-stock-source.component.tsx +35 -0
  337. package/src/stock-sources/edit-stock-source/edit-stock-source.scss +0 -0
  338. package/src/stock-sources/stock-sources-delete/stock-sources-delate.scss +0 -0
  339. package/src/stock-sources/stock-sources-delete/stock-sources-delete.component.tsx +72 -0
  340. package/src/stock-sources/stock-sources-filter/stock-sources-filter.component.tsx +35 -0
  341. package/src/stock-sources/stock-sources-filter/stock-sources-filter.scss +13 -0
  342. package/src/stock-sources/stock-sources-items-table.component.tsx +213 -0
  343. package/src/stock-sources/stock-sources-items-table.resource.ts +56 -0
  344. package/src/stock-sources/stock-sources.component.tsx +12 -0
  345. package/src/stock-sources/stock-sources.resource.ts +80 -0
  346. package/src/stock-sources/stock-sources.scss +220 -0
  347. package/src/stock-sources/swr-revalidation.ts +7 -0
  348. package/src/stock-tabs/commodity-tabs.component.tsx +43 -0
  349. package/src/stock-tabs/commodity-tabs.scss +0 -0
  350. package/src/stock-user-role-scopes/add-stock-user-role-scope-button.component.tsx +21 -0
  351. package/src/stock-user-role-scopes/add-stock-user-scope/add-stock-user-role-scope.component.tsx +525 -0
  352. package/src/stock-user-role-scopes/add-stock-user-scope/add-stock-user-role-scope.scss +37 -0
  353. package/src/stock-user-role-scopes/delete-stock-user-scope/delete-stock-user-scope.component.tsx +73 -0
  354. package/src/stock-user-role-scopes/delete-stock-user-scope/delete-stock-user-scope.scss +0 -0
  355. package/src/stock-user-role-scopes/delete-stock-user-scope-modal.component.tsx +47 -0
  356. package/src/stock-user-role-scopes/edit-stock-user-scope/edit-stock-user-scope-action-menu.component.tsx +35 -0
  357. package/src/stock-user-role-scopes/stock-user-role-scopes-items-table.component.tsx +284 -0
  358. package/src/stock-user-role-scopes/stock-user-role-scopes-items-table.resource.ts +31 -0
  359. package/src/stock-user-role-scopes/stock-user-role-scopes.component.tsx +12 -0
  360. package/src/stock-user-role-scopes/stock-user-role-scopes.resource.ts +76 -0
  361. package/src/stock-user-role-scopes/stock-user-role-scopes.scss +61 -0
  362. package/src/stock-user-role-scopes/swr-revalidation.ts +7 -0
  363. package/src/utils.ts +10 -0
  364. package/translations/en.json +24 -0
  365. package/tsconfig.json +23 -0
  366. package/webpack.config.js +1 -0
@@ -0,0 +1,241 @@
1
+ import { StockOperationDTO } from "../../core/api/types/stockOperation/StockOperationDTO";
2
+ import { initialStockOperationValue } from "../../core/utils/utils";
3
+ import { MAIN_STORE_LOCATION_TAG, today } from "../../constants";
4
+ import {
5
+ operationFromString,
6
+ OperationType,
7
+ StockOperationType,
8
+ StockOperationTypeCanCapturePurchasePrice,
9
+ StockOperationTypeHasPrint,
10
+ StockOperationTypeIsNegativeQtyAllowed,
11
+ StockOperationTypeIsQuantityOptional,
12
+ StockOperationTypeRequiresActualBatchInformation,
13
+ StockOperationTypeRequiresBatchUuid,
14
+ StockOperationTypeRequiresDispatchAcknowledgement,
15
+ StockOperationTypeRequiresStockAdjustmentReason,
16
+ } from "../../core/api/types/stockOperation/StockOperationType";
17
+ import { StockOperationItemDTO } from "../../core/api/types/stockOperation/StockOperationItemDTO";
18
+ import { InitializeResult } from "./types";
19
+ import {
20
+ LocationTypeLocation,
21
+ LocationTypeOther,
22
+ } from "../../core/api/types/stockOperation/LocationType";
23
+ import {
24
+ getParties,
25
+ getStockOperationTypes,
26
+ } from "../../stock-lookups/stock-lookups.resource";
27
+ import { Party } from "../../core/api/types/Party";
28
+
29
+ export async function initializeNewStockOperation(
30
+ currentStockOperationType: StockOperationType,
31
+ // urlQueryParams?: URLSearchParams,
32
+ stockOperation?: StockOperationDTO,
33
+ stockOperationTypes?: StockOperationType[]
34
+ ): Promise<InitializeResult> {
35
+ let model: StockOperationDTO;
36
+ const isNew = !!stockOperation;
37
+ const newItemsToCopy: StockOperationItemDTO[] = [];
38
+ const showQuantityRequested = false;
39
+
40
+ let operationTypes = stockOperationTypes;
41
+ const canIssueStock =
42
+ stockOperation?.permission?.isRequisitionAndCanIssueStock ?? false;
43
+ const sourceTags =
44
+ currentStockOperationType?.stockOperationTypeLocationScopes
45
+ ?.filter((p) => currentStockOperationType?.hasSource && p.isSource)
46
+ .map((p) => p.locationTag) ?? [];
47
+ const shouldLockSource =
48
+ sourceTags.length === 1 && sourceTags[0] === MAIN_STORE_LOCATION_TAG;
49
+
50
+ const destinationTags =
51
+ currentStockOperationType?.stockOperationTypeLocationScopes
52
+ ?.filter(
53
+ (p) => currentStockOperationType?.hasDestination && p.isDestination
54
+ )
55
+ .map((p) => p.locationTag) ?? [];
56
+ const shouldLockDestination =
57
+ destinationTags.length === 1 &&
58
+ destinationTags[0] === MAIN_STORE_LOCATION_TAG;
59
+ let location: string | null | undefined = null;
60
+ let sourcePartyList: Party[] | null | undefined;
61
+ let destinationPartyList: Party[] | null | undefined;
62
+
63
+ if (isNew) {
64
+ model = structuredClone(initialStockOperationValue());
65
+ model = Object.assign(model, {
66
+ operationDate: today(),
67
+ operationTypeName: currentStockOperationType?.name,
68
+ operationTypeUuid: currentStockOperationType?.uuid,
69
+ operationType: currentStockOperationType?.operationType,
70
+ });
71
+
72
+ if (
73
+ currentStockOperationType.operationType ==
74
+ OperationType.STOCK_ISSUE_OPERATION_TYPE
75
+ ) {
76
+ // requisition = urlQueryParams?.get("requisition");
77
+ // if (requisition) {
78
+ // const response = await getStockOperation(requisition);
79
+ // if (!response.ok) {
80
+ // return;
81
+ // }
82
+ //
83
+ // const requisitionStockOperation = response.data;
84
+ //
85
+ // if (
86
+ // !requisitionStockOperation.responsiblePersonUuid &&
87
+ // requisitionStockOperation.responsiblePersonOther
88
+ // ) {
89
+ // requisitionStockOperation.responsiblePersonUuid = "Other";
90
+ // }
91
+ //
92
+ // if (
93
+ // requisitionStockOperation &&
94
+ // requisitionStockOperation.stockOperationItems
95
+ // ) {
96
+ // let hasQtyRequested = false;
97
+ // requisitionStockOperation.stockOperationItems.forEach((si) => {
98
+ // if (si.quantity && si.stockItemPackagingUOMName) {
99
+ // hasQtyRequested = true;
100
+ // }
101
+ //
102
+ // const itemId = `new-item-${getStockOperationUniqueId()}`;
103
+ // si.id = itemId;
104
+ // si.uuid = itemId;
105
+ // newItemsToCopy.push({
106
+ // ...si,
107
+ // quantityRequested: si.quantity,
108
+ // quantityRequestedPackagingUOMUuid: si.stockItemPackagingUOMUuid,
109
+ // quantityRequestedPackagingUOMName: si.stockItemPackagingUOMName,
110
+ // });
111
+ // });
112
+ // if (hasQtyRequested) {
113
+ // showQuantityRequested = true;
114
+ // }
115
+ // }
116
+ // newItemsToCopy.push({ uuid: `new-item-1`, id: `new-item-1` });
117
+ // model.destinationUuid = requisitionStockOperation.sourceUuid;
118
+ // model.destinationName = requisitionStockOperation.sourceName;
119
+ // model.responsiblePersonUuid =
120
+ // requisitionStockOperation.responsiblePersonUuid;
121
+ // model.responsiblePersonOther =
122
+ // requisitionStockOperation.responsiblePersonOther;
123
+ // model.responsiblePersonFamilyName =
124
+ // requisitionStockOperation.responsiblePersonFamilyName;
125
+ // model.responsiblePersonGivenName =
126
+ // requisitionStockOperation.responsiblePersonGivenName;
127
+ // model.remarks = requisitionStockOperation.remarks;
128
+ // }
129
+ }
130
+ const partyList = await getParties();
131
+ if (!partyList.ok) throw Error("Error loading parties");
132
+
133
+ sourcePartyList = partyList?.data?.results?.filter(
134
+ (p) =>
135
+ (p.locationUuid &&
136
+ currentStockOperationType?.sourceType === LocationTypeLocation &&
137
+ (sourceTags.length === 0 ||
138
+ (p.tags && sourceTags.some((x) => p.tags.includes(x))))) ||
139
+ (p.stockSourceUuid &&
140
+ currentStockOperationType?.sourceType === LocationTypeOther)
141
+ );
142
+ if (currentStockOperationType?.hasSource) {
143
+ if (isNew && shouldLockSource && sourcePartyList?.length > 0) {
144
+ const party = sourcePartyList[0];
145
+ model.sourceUuid = party.uuid;
146
+ model.sourceName = party.name;
147
+ location = party?.locationUuid;
148
+ }
149
+ }
150
+
151
+ if (currentStockOperationType?.hasDestination) {
152
+ destinationPartyList = partyList?.data?.results?.filter(
153
+ (p) =>
154
+ (p.locationUuid &&
155
+ currentStockOperationType?.destinationType ===
156
+ LocationTypeLocation &&
157
+ (destinationTags.length === 0 ||
158
+ (p.tags && destinationTags.some((x) => p.tags.includes(x))))) ||
159
+ (p.stockSourceUuid &&
160
+ currentStockOperationType?.destinationType === LocationTypeOther)
161
+ );
162
+
163
+ if (isNew && shouldLockDestination && destinationPartyList?.length > 0) {
164
+ const party = destinationPartyList[0];
165
+ model.destinationUuid = party.uuid;
166
+ model.destinationName = party.name;
167
+ }
168
+ }
169
+ } else {
170
+ const response = await getStockOperationTypes();
171
+ if (response.ok) {
172
+ operationTypes = response.data.results;
173
+ } else {
174
+ throw Error("Error loading operation types");
175
+ }
176
+ }
177
+
178
+ const opType = operationFromString(currentStockOperationType.operationType);
179
+ return {
180
+ batchBalance: {},
181
+ batchNos: {},
182
+ itemUoM: {},
183
+ requisition: "",
184
+ showQuantityRequested: false,
185
+ dto: model,
186
+ stockItems: newItemsToCopy,
187
+ // showQuantityRequested,
188
+ // requisition,
189
+ isNegativeQuantityAllowed: StockOperationTypeIsNegativeQtyAllowed(opType),
190
+ requiresBatchUuid: StockOperationTypeRequiresBatchUuid(opType),
191
+ requiresActualBatchInfo:
192
+ StockOperationTypeRequiresActualBatchInformation(opType),
193
+ isQuantityOptional: StockOperationTypeIsQuantityOptional(opType),
194
+ canCaptureQuantityPrice: StockOperationTypeCanCapturePurchasePrice(opType),
195
+ requiresStockAdjustmentReason:
196
+ StockOperationTypeRequiresStockAdjustmentReason(opType),
197
+ requiresDispatchAcknowledgement:
198
+ StockOperationTypeRequiresDispatchAcknowledgement(opType),
199
+ allowExpiredBatchNumbers:
200
+ currentStockOperationType?.allowExpiredBatchNumbers ?? false,
201
+ canEditModel: stockOperation?.permission?.canEdit ?? false,
202
+ canViewModel: stockOperation?.permission?.canView ?? false,
203
+ canApproveModel: stockOperation?.permission?.canApprove ?? false,
204
+ canIssueStock,
205
+ canReceiveItems: stockOperation?.permission?.canReceiveItems ?? false,
206
+ canDisplayReceivedItems:
207
+ stockOperation?.permission?.canDisplayReceivedItems ?? false,
208
+ canUpdateItemsBatchInformation:
209
+ stockOperation?.permission?.canUpdateBatchInformation ?? false,
210
+ canPrint: canIssueStock || StockOperationTypeHasPrint(opType),
211
+ sourceTags,
212
+ destinationTags,
213
+ shouldLockDestination,
214
+ shouldLockSource,
215
+ sourcePartyListFilter: (p) => {
216
+ return (
217
+ (p.locationUuid &&
218
+ currentStockOperationType?.sourceType === LocationTypeLocation &&
219
+ (sourceTags.length === 0 ||
220
+ (p.tags && sourceTags.some((x) => p.tags.includes(x))))) ||
221
+ (p.stockSourceUuid &&
222
+ currentStockOperationType?.sourceType === LocationTypeOther)
223
+ );
224
+ },
225
+ destinationPartyListFilter: (p) => {
226
+ return (
227
+ (p.locationUuid &&
228
+ currentStockOperationType?.destinationType === LocationTypeLocation &&
229
+ (destinationTags.length === 0 ||
230
+ (p.tags && destinationTags.some((x) => p.tags.includes(x))))) ||
231
+ (p.stockSourceUuid &&
232
+ currentStockOperationType?.destinationType === LocationTypeOther)
233
+ );
234
+ },
235
+ location,
236
+ sourcePartyList,
237
+ destinationPartyList,
238
+ stockOperationTypes: operationTypes,
239
+ hasQtyRequested: showQuantityRequested,
240
+ };
241
+ }
@@ -0,0 +1,110 @@
1
+ import { StockOperationDTO } from "../../core/api/types/stockOperation/StockOperationDTO";
2
+ import { OperationType } from "../../core/api/types/stockOperation/StockOperationType";
3
+
4
+ const OPERATION_TYPES_FOR_DESTINATION_NAME_DELETION = [
5
+ OperationType.ADJUSTMENT_OPERATION_TYPE,
6
+ OperationType.RECEIPT_OPERATION_TYPE,
7
+ OperationType.STOCK_ISSUE_OPERATION_TYPE,
8
+ OperationType.STOCK_TAKE_OPERATION_TYPE,
9
+ OperationType.RETURN_OPERATION_TYPE,
10
+ OperationType.DISPOSED_OPERATION_TYPE,
11
+ OperationType.OPENING_STOCK_OPERATION_TYPE,
12
+ OperationType.TRANSFER_OUT_OPERATION_TYPE,
13
+ ];
14
+
15
+ const OPERATION_TYPES_FOR_DESTINATION_UUID_DELETION = [
16
+ OperationType.ADJUSTMENT_OPERATION_TYPE,
17
+ OperationType.DISPOSED_OPERATION_TYPE,
18
+ OperationType.STOCK_TAKE_OPERATION_TYPE,
19
+ OperationType.OPENING_STOCK_OPERATION_TYPE,
20
+ ];
21
+
22
+ export function getRequisitionStockOperations(
23
+ items: Array<StockOperationDTO> = []
24
+ ) {
25
+ // Extract stock issued requisition UUIDs
26
+ const stockIssuedRequisitionUuids =
27
+ items
28
+ ?.filter(
29
+ (item) =>
30
+ item.operationType === OperationType.STOCK_ISSUE_OPERATION_TYPE
31
+ )
32
+ .map((item) => item.requisitionStockOperationUuid) ?? [];
33
+
34
+ // Filter requisition stock operations
35
+ const requisitionStockOperations =
36
+ items?.filter(
37
+ (item) =>
38
+ item.operationType === OperationType.REQUISITION_OPERATION_TYPE &&
39
+ !stockIssuedRequisitionUuids.includes(item.uuid)
40
+ ) ?? [];
41
+
42
+ return requisitionStockOperations;
43
+ }
44
+
45
+ function deleteProperties(req, properties) {
46
+ properties.forEach((prop) => {
47
+ delete req[prop];
48
+ });
49
+ }
50
+
51
+ function shouldDeleteDestinationName(operationType) {
52
+ return OPERATION_TYPES_FOR_DESTINATION_NAME_DELETION.includes(operationType);
53
+ }
54
+
55
+ function shouldDeleteDestinationUuid(operationType) {
56
+ return OPERATION_TYPES_FOR_DESTINATION_UUID_DELETION.includes(operationType);
57
+ }
58
+
59
+ export function createBaseOperationPayload(model, item, operationType) {
60
+ const req = Object.assign(model, item);
61
+
62
+ const propertiesToDelete = [
63
+ "submitted",
64
+ "cancelledByFamilyName",
65
+ "atLocationName",
66
+ "completedByGivenName",
67
+ "cancelledBy",
68
+ "submittedByFamilyName",
69
+ "operationOrder",
70
+ "dispatchedByGivenName",
71
+ "submittedByGivenName",
72
+ "returnedByGivenName",
73
+ "operationNumber",
74
+ "responsiblePersonFamilyName",
75
+ "returnReason",
76
+ "atLocationUuid",
77
+ "cancelReason",
78
+ "rejectedByGivenName",
79
+ "reasonName",
80
+ "submittedBy",
81
+ "creator",
82
+ "completedByFamilyName",
83
+ "operationTypeName",
84
+ "rejectedByFamilyName",
85
+ "responsiblePerson",
86
+ "creatorFamilyName",
87
+ "returnedByFamilyName",
88
+ "cancelledByGivenName",
89
+ "operationType",
90
+ "responsiblePersonGivenName",
91
+ "sourceName",
92
+ "rejectionReason",
93
+ "completedBy",
94
+ "creatorGivenName",
95
+ "dispatchedByFamilyName",
96
+ "uuid",
97
+ ];
98
+
99
+ deleteProperties(req, propertiesToDelete);
100
+
101
+ if (shouldDeleteDestinationName(operationType)) {
102
+ delete req.destinationName;
103
+ }
104
+
105
+ if (shouldDeleteDestinationUuid(operationType)) {
106
+ delete req.destinationUuid;
107
+ }
108
+
109
+ return req;
110
+ }
@@ -0,0 +1,352 @@
1
+ import React, { useState } from "react";
2
+ import { useTranslation } from "react-i18next";
3
+ import { StockOperationDTO } from "../../core/api/types/stockOperation/StockOperationDTO";
4
+ import { SaveStockOperation } from "../../stock-items/types";
5
+ import {
6
+ operationFromString,
7
+ OperationType,
8
+ StockOperationType,
9
+ } from "../../core/api/types/stockOperation/StockOperationType";
10
+ import {
11
+ DATE_PICKER_CONTROL_FORMAT,
12
+ DATE_PICKER_FORMAT,
13
+ formatForDatePicker,
14
+ today,
15
+ } from "../../constants";
16
+ import {
17
+ Button,
18
+ DatePicker,
19
+ DatePickerInput,
20
+ InlineLoading,
21
+ TextInput,
22
+ ComboBox,
23
+ } from "@carbon/react";
24
+ import { Controller, useForm } from "react-hook-form";
25
+ import { zodResolver } from "@hookform/resolvers/zod";
26
+ import { operationSchema, StockOperationFormData } from "../validation-schema";
27
+ import { ArrowRight } from "@carbon/react/icons";
28
+ import PartySelector from "../party-selector/party-selector.component";
29
+ import UsersSelector from "../users-selector/users-selector.component";
30
+ import { otherUser } from "../../core/utils/utils";
31
+ import ControlledTextInput from "../../core/components/carbon/controlled-text-input/controlled-text-input.component";
32
+ import StockOperationReasonSelector from "../stock-operation-reason-selector/stock-operation-reason-selector.component";
33
+ import ControlledTextArea from "../../core/components/carbon/controlled-text-area/controlled-text-area.component";
34
+ import { InitializeResult } from "./types";
35
+ import rootStyles from "../../root.scss";
36
+ import { ResourceRepresentation } from "../../core/api/api";
37
+ import { useStockOperationPages } from "../stock-operations-table.resource";
38
+ import { useStockOperationContext } from "./stock-operation-context/useStockOperationContext";
39
+ import {
40
+ createBaseOperationPayload,
41
+ getRequisitionStockOperations,
42
+ } from "./add-stock-utils";
43
+
44
+ interface BaseOperationDetailsProps {
45
+ isEditing?: boolean;
46
+ canEdit?: boolean;
47
+ model?: StockOperationDTO;
48
+ onSave?: SaveStockOperation;
49
+ operation: StockOperationType;
50
+ setup: InitializeResult;
51
+ }
52
+
53
+ const BaseOperationDetails: React.FC<BaseOperationDetailsProps> = ({
54
+ model,
55
+ onSave,
56
+ operation,
57
+ canEdit,
58
+ isEditing,
59
+ setup: {
60
+ requiresStockAdjustmentReason: showReason,
61
+ shouldLockSource: lockSource,
62
+ shouldLockDestination: lockDestination,
63
+ sourcePartyList,
64
+ destinationPartyList,
65
+ },
66
+ }) => {
67
+ const { t } = useTranslation();
68
+ const { setFormContext } = useStockOperationContext();
69
+ const { isLoading, items } = useStockOperationPages({
70
+ v: ResourceRepresentation.Full,
71
+ totalCount: true,
72
+ });
73
+ const requisitionStockOperations = getRequisitionStockOperations(items);
74
+ const operationType = operationFromString(operation.operationType);
75
+
76
+ const {
77
+ handleSubmit,
78
+ control,
79
+ formState: { errors },
80
+ setValue,
81
+ } = useForm<StockOperationFormData>({
82
+ defaultValues: model,
83
+ mode: "all",
84
+ resolver: zodResolver(operationSchema(operationType)),
85
+ });
86
+
87
+ const [isOtherUser, setIsOtherUser] = useState<boolean | null>();
88
+ const [isSaving, setIsSaving] = useState(false);
89
+ if (isLoading) {
90
+ return (
91
+ <InlineLoading
92
+ status="active"
93
+ iconDescription="Loading"
94
+ description="Loading data..."
95
+ />
96
+ );
97
+ }
98
+
99
+ const handleSave = async (item: StockOperationDTO) => {
100
+ try {
101
+ setIsSaving(true);
102
+ const payload = createBaseOperationPayload(model, item, operationType);
103
+ await onSave(payload);
104
+ } catch (e) {
105
+ // Show notification
106
+ } finally {
107
+ setIsSaving(false);
108
+ }
109
+ };
110
+ return (
111
+ <div style={{ margin: "10px" }}>
112
+ <form
113
+ className={`${rootStyles.formContainer} ${rootStyles.verticalForm}`}
114
+ >
115
+ {operationType === OperationType.STOCK_ISSUE_OPERATION_TYPE && (
116
+ <Controller
117
+ control={control}
118
+ name="requisitionStockOperationUuid"
119
+ render={({ field }) => (
120
+ <ComboBox
121
+ id="requisitionStockOperationUuid"
122
+ items={requisitionStockOperations}
123
+ onChange={(data: { selectedItem: StockOperationDTO }) => {
124
+ field.onChange(data.selectedItem.uuid);
125
+ Object.assign(
126
+ model.stockOperationItems,
127
+ data.selectedItem.stockOperationItems
128
+ );
129
+ setFormContext({
130
+ stockItems: data.selectedItem.stockOperationItems,
131
+ });
132
+ }}
133
+ itemToString={(item) => `${item?.operationNumber}` ?? ""}
134
+ titleText={t("requisitionStockOperation", "Requisition")}
135
+ invalid={!!errors.requisitionStockOperationUuid}
136
+ invalidText={errors.requisitionStockOperationUuid?.message}
137
+ placeholder={t("chooseARequisition", "Choose a requisition")}
138
+ />
139
+ )}
140
+ />
141
+ )}
142
+
143
+ {canEdit && (
144
+ <Controller
145
+ control={control}
146
+ render={({ field: { onChange } }) => (
147
+ <DatePicker
148
+ datePickerType="single"
149
+ maxDate={formatForDatePicker(today())}
150
+ locale="en"
151
+ dateFormat={DATE_PICKER_CONTROL_FORMAT}
152
+ onChange={onChange}
153
+ >
154
+ <DatePickerInput
155
+ invalid={!!errors.operationDate}
156
+ invalidText={errors?.operationDate?.message}
157
+ id="operationDate"
158
+ name="operationDate"
159
+ placeholder={DATE_PICKER_FORMAT}
160
+ labelText={t("operationDate", "Operation Date")}
161
+ value={formatForDatePicker(model?.operationDate)}
162
+ />
163
+ </DatePicker>
164
+ )}
165
+ name="operationDate"
166
+ />
167
+ )}
168
+
169
+ {!canEdit && (
170
+ <>
171
+ <TextInput
172
+ id="operationDateLbl"
173
+ value={formatForDatePicker(model?.operationDate)}
174
+ readOnly={true}
175
+ labelText="Operation Date"
176
+ />
177
+ </>
178
+ )}
179
+
180
+ {isEditing && model?.operationNumber && (
181
+ <TextInput
182
+ id="operationNoLbl"
183
+ value={model?.operationNumber}
184
+ readOnly={true}
185
+ labelText={"Operation Number:"}
186
+ />
187
+ )}
188
+
189
+ {canEdit && !lockSource && operation?.hasSource && (
190
+ <PartySelector
191
+ controllerName="sourceUuid"
192
+ name="sourceUuid"
193
+ control={control}
194
+ title={
195
+ operation?.hasDestination
196
+ ? t("from:", "From:")
197
+ : t("location:", "Location:")
198
+ }
199
+ placeholder={
200
+ operation.hasDestination
201
+ ? t("chooseASource", "Choose a source")
202
+ : t("chooseALocation", "Choose a location")
203
+ }
204
+ invalid={!!errors.sourceUuid}
205
+ invalidText={errors.sourceUuid && errors?.sourceUuid?.message}
206
+ parties={sourcePartyList || []}
207
+ />
208
+ )}
209
+
210
+ {(!canEdit || isEditing || lockSource) && (
211
+ <TextInput
212
+ id="sourceUuidLbl"
213
+ value={model?.sourceName ?? ""}
214
+ readOnly={true}
215
+ labelText={operation?.hasDestination ? "From:" : "From:"}
216
+ />
217
+ )}
218
+ {canEdit && !lockDestination && operation?.hasDestination && (
219
+ <PartySelector
220
+ controllerName="destinationUuid"
221
+ name="destinationUuid"
222
+ control={control}
223
+ title={operation?.hasSource ? "To:" : "Location:"}
224
+ placeholder={
225
+ operation?.hasSource
226
+ ? t("chooseADestination", "Choose a destination")
227
+ : "Location"
228
+ }
229
+ invalid={!!errors.destinationUuid}
230
+ invalidText={
231
+ errors.destinationUuid && errors?.destinationUuid?.message
232
+ }
233
+ parties={destinationPartyList || []}
234
+ />
235
+ )}
236
+
237
+ {(!canEdit || isEditing || lockDestination) && (
238
+ <TextInput
239
+ id="destinationUuidLbl"
240
+ value={model?.destinationName ?? ""}
241
+ readOnly={true}
242
+ labelText={operation?.hasSource ? "To:" : "To:"}
243
+ />
244
+ )}
245
+
246
+ {canEdit && (
247
+ <UsersSelector
248
+ controllerName="responsiblePersonUuid"
249
+ name="responsiblePersonUuid"
250
+ control={control}
251
+ title={t("responsiblePerson:", "Responsible Person:")}
252
+ placeholder={t("filter", "Filter ...")}
253
+ invalid={!!errors.responsiblePersonUuid}
254
+ invalidText={
255
+ errors.responsiblePersonUuid &&
256
+ errors?.responsiblePersonUuid?.message
257
+ }
258
+ onUserChanged={(user) => {
259
+ if (user?.uuid === otherUser.uuid) {
260
+ setIsOtherUser(true);
261
+ }
262
+ }}
263
+ />
264
+ )}
265
+
266
+ {isOtherUser && (
267
+ <ControlledTextInput
268
+ id="responsiblePersonOther"
269
+ name="responsiblePersonOther"
270
+ control={control}
271
+ controllerName="responsiblePersonOther"
272
+ maxLength={255}
273
+ size={"md"}
274
+ value={`${model?.responsiblePersonOther ?? ""}`}
275
+ labelText={t("responsiblePerson", "Responsible Person:")}
276
+ placeholder={t("pleaseSpecify", "Please Specify:")}
277
+ invalid={!!errors.responsiblePersonOther}
278
+ invalidText={
279
+ errors.responsiblePersonOther &&
280
+ errors?.responsiblePersonOther?.message
281
+ }
282
+ />
283
+ )}
284
+
285
+ {!canEdit && (
286
+ <TextInput
287
+ id="responsiblePersonLbl"
288
+ value={
289
+ (model?.responsiblePersonUuid &&
290
+ model?.responsiblePersonUuid !== otherUser.uuid
291
+ ? `${model?.responsiblePersonFamilyName} ${model?.responsiblePersonGivenName}`
292
+ : model?.responsiblePersonOther) ?? ""
293
+ }
294
+ readOnly={true}
295
+ labelText={"Responsible Person"}
296
+ />
297
+ )}
298
+
299
+ {showReason && canEdit && (
300
+ <StockOperationReasonSelector
301
+ controllerName="reasonUuid"
302
+ name="reasonUuid"
303
+ control={control}
304
+ placeholder={t("chooseAReason", "Choose a reason")}
305
+ title={t("reason", "Reason:")}
306
+ invalid={!!errors.reasonUuid}
307
+ invalidText={errors.reasonUuid && errors?.reasonUuid?.message}
308
+ onReasonChange={(reason) => {
309
+ setValue("reasonUuid", reason.uuid);
310
+ }}
311
+ />
312
+ )}
313
+
314
+ {showReason && !canEdit && (
315
+ <TextInput
316
+ id="reasonUuidLbl"
317
+ value={model?.reasonName ?? ""}
318
+ readOnly={true}
319
+ labelText={"Reason:"}
320
+ />
321
+ )}
322
+
323
+ <ControlledTextArea
324
+ id="remarks"
325
+ name="remarks"
326
+ control={control}
327
+ controllerName="remarks"
328
+ maxLength={255}
329
+ value={`${model?.remarks ?? ""}`}
330
+ labelText={t("remarks:", "Remarks:")}
331
+ invalid={!!errors.remarks}
332
+ invalidText={errors.remarks && errors?.remarks?.message}
333
+ />
334
+
335
+ <div style={{ display: "flex", flexDirection: "row-reverse" }}>
336
+ <Button
337
+ name="save"
338
+ type="button"
339
+ className="submitButton"
340
+ onClick={handleSubmit(handleSave)}
341
+ kind="primary"
342
+ renderIcon={ArrowRight}
343
+ >
344
+ {isSaving ? <InlineLoading /> : t("next", "Next")}
345
+ </Button>
346
+ </div>
347
+ </form>
348
+ </div>
349
+ );
350
+ };
351
+
352
+ export default BaseOperationDetails;