@argusoft/medplat-core 1.0.29 → 1.0.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (217) hide show
  1. package/dist/AccessRights-DUgY6ewy.js +1031 -0
  2. package/dist/AccessRights-DUgY6ewy.js.map +1 -0
  3. package/dist/AddEditQueryBuilder-D-iQiVIe.js +365 -0
  4. package/dist/AddEditQueryBuilder-D-iQiVIe.js.map +1 -0
  5. package/dist/{AddFeatures-v3TmGQee.js → AddFeatures-D1sU8RjY.js} +2 -2
  6. package/dist/{AddFeatures-v3TmGQee.js.map → AddFeatures-D1sU8RjY.js.map} +1 -1
  7. package/dist/AddLabelModal-Bq-wRqv9.js +631 -0
  8. package/dist/AddLabelModal-Bq-wRqv9.js.map +1 -0
  9. package/dist/AddMenuConfiguration-c6ZKiN0i.js +8898 -0
  10. package/dist/AddMenuConfiguration-c6ZKiN0i.js.map +1 -0
  11. package/dist/AppModal-CCtrQ5Tr.js +394 -0
  12. package/dist/AppModal-CCtrQ5Tr.js.map +1 -0
  13. package/dist/BrandsPage-DMw2vT0u-BVhvhc6J.js +387 -0
  14. package/dist/BrandsPage-DMw2vT0u-BVhvhc6J.js.map +1 -0
  15. package/dist/CategoriesPage-D3ihx9Gi-CT58g0ry.js +398 -0
  16. package/dist/CategoriesPage-D3ihx9Gi-CT58g0ry.js.map +1 -0
  17. package/dist/{ChangePasswordModalCore-DutQAZOx.js → ChangePasswordModalCore-lQ9GamH1.js} +1605 -1610
  18. package/dist/ChangePasswordModalCore-lQ9GamH1.js.map +1 -0
  19. package/dist/ConditionConfig-BQBmBHaM.js +408 -0
  20. package/dist/ConditionConfig-BQBmBHaM.js.map +1 -0
  21. package/dist/DashboardPage-asr2XDRu-uOOlX9Vq.js +435 -0
  22. package/dist/DashboardPage-asr2XDRu-uOOlX9Vq.js.map +1 -0
  23. package/dist/EventConfig-BY2cgGyx.js +27 -0
  24. package/dist/EventConfig-BY2cgGyx.js.map +1 -0
  25. package/dist/EventConfigurations-CUPEN5BV.js +544 -0
  26. package/dist/EventConfigurations-CUPEN5BV.js.map +1 -0
  27. package/dist/EventConfigurations.css +1 -1
  28. package/dist/EventsExceptionModal-BX-ArkBE.js +188 -0
  29. package/dist/EventsExceptionModal-BX-ArkBE.js.map +1 -0
  30. package/dist/EventsUi-D6O9S7BK.js +258 -0
  31. package/dist/EventsUi-D6O9S7BK.js.map +1 -0
  32. package/dist/FacilityPicker-DYl_PDyt-Cbwo2tAY.js +79 -0
  33. package/dist/FacilityPicker-DYl_PDyt-Cbwo2tAY.js.map +1 -0
  34. package/dist/FeatureMenu-CHsBbw3W.js +525 -0
  35. package/dist/FeatureMenu-CHsBbw3W.js.map +1 -0
  36. package/dist/{FhirServerList-Dkq7Kbes.js → FhirServerList-iXBPkRVF.js} +22 -22
  37. package/dist/{FhirServerList-Dkq7Kbes.js.map → FhirServerList-iXBPkRVF.js.map} +1 -1
  38. package/dist/{FhirServerWizard-Db6Hm4bQ.js → FhirServerWizard-DZI8Olku.js} +15 -15
  39. package/dist/{FhirServerWizard-Db6Hm4bQ.js.map → FhirServerWizard-DZI8Olku.js.map} +1 -1
  40. package/dist/FlywayQuery-CQygj51V.js +179 -0
  41. package/dist/FlywayQuery-CQygj51V.js.map +1 -0
  42. package/dist/GrantPermissionModal-D7iNZd0M.js +239 -0
  43. package/dist/GrantPermissionModal-D7iNZd0M.js.map +1 -0
  44. package/dist/ImmunizationConfigurationBase-aUtx0JEe.js +8019 -0
  45. package/dist/ImmunizationConfigurationBase-aUtx0JEe.js.map +1 -0
  46. package/dist/ImmunizationConfigurationBase.css +1 -1
  47. package/dist/ImmunizationConfigurationsList-TZcLDEci.js +369 -0
  48. package/dist/ImmunizationConfigurationsList-TZcLDEci.js.map +1 -0
  49. package/dist/InventoryPage-DOotGZrj-CoPjOJEI.js +665 -0
  50. package/dist/InventoryPage-DOotGZrj-CoPjOJEI.js.map +1 -0
  51. package/dist/LanguagesModal-B3NTebYT.js +352 -0
  52. package/dist/LanguagesModal-B3NTebYT.js.map +1 -0
  53. package/dist/ManageDynamicFeature-BU0I45dd.js +4475 -0
  54. package/dist/ManageDynamicFeature-BU0I45dd.js.map +1 -0
  55. package/dist/ManageEventConfiguration-DqW3krT6.js +1216 -0
  56. package/dist/ManageEventConfiguration-DqW3krT6.js.map +1 -0
  57. package/dist/ManageEventConfiguration.css +1 -1
  58. package/dist/{ManageNotification-CfhHlfxA.js → ManageNotification-C5MhV77Q.js} +2 -2
  59. package/dist/{ManageNotification-CfhHlfxA.js.map → ManageNotification-C5MhV77Q.js.map} +1 -1
  60. package/dist/{ManageRole-4Y2PP4dQ.js → ManageRole-CNZBRKGU.js} +2 -2
  61. package/dist/{ManageRole-4Y2PP4dQ.js.map → ManageRole-CNZBRKGU.js.map} +1 -1
  62. package/dist/ManageTranslation-vRiptUAP.js +833 -0
  63. package/dist/ManageTranslation-vRiptUAP.js.map +1 -0
  64. package/dist/ManageTranslation.css +1 -1
  65. package/dist/{ManageUser-DDzyd9jm.js → ManageUser-DZltBina.js} +224 -224
  66. package/dist/{ManageUser-DDzyd9jm.js.map → ManageUser-DZltBina.js.map} +1 -1
  67. package/dist/MemberProfileCard-D5CgkTdJ-D2NgDJl3.js +272 -0
  68. package/dist/MemberProfileCard-D5CgkTdJ-D2NgDJl3.js.map +1 -0
  69. package/dist/MobileAnalytics-BLOionG_.js +17301 -0
  70. package/dist/MobileAnalytics-BLOionG_.js.map +1 -0
  71. package/dist/MobileMenuManagement-68Wijb0X.js +220 -0
  72. package/dist/MobileMenuManagement-68Wijb0X.js.map +1 -0
  73. package/dist/MobileTypeEventConfigModal-CMcj7Ozp.js +752 -0
  74. package/dist/MobileTypeEventConfigModal-CMcj7Ozp.js.map +1 -0
  75. package/dist/NotificationFlywayQuery-BAHVjf6N.js +247 -0
  76. package/dist/NotificationFlywayQuery-BAHVjf6N.js.map +1 -0
  77. package/dist/{NotificationList-BMFpNUJG.js → NotificationList-DEyRZEuM.js} +2 -2
  78. package/dist/{NotificationList-BMFpNUJG.js.map → NotificationList-DEyRZEuM.js.map} +1 -1
  79. package/dist/OtherTypeEventConfigModal-stNmuSv_.js +1812 -0
  80. package/dist/OtherTypeEventConfigModal-stNmuSv_.js.map +1 -0
  81. package/dist/PaymentCreatePage-DfvSZ-kB-CckogYoe.js +482 -0
  82. package/dist/PaymentCreatePage-DfvSZ-kB-CckogYoe.js.map +1 -0
  83. package/dist/PaymentsPage-DMNjYWAJ-ChO9IXmk.js +157 -0
  84. package/dist/PaymentsPage-DMNjYWAJ-ChO9IXmk.js.map +1 -0
  85. package/dist/PermissionsModal-CCYkcKlC.js +151 -0
  86. package/dist/PermissionsModal-CCYkcKlC.js.map +1 -0
  87. package/dist/PickupBatchLinesEditor-CE2RuyJT-BPceiJr8.js +119 -0
  88. package/dist/PickupBatchLinesEditor-CE2RuyJT-BPceiJr8.js.map +1 -0
  89. package/dist/PickupCreatePage-B4O_-vE5-DoOo9nJO.js +783 -0
  90. package/dist/PickupCreatePage-B4O_-vE5-DoOo9nJO.js.map +1 -0
  91. package/dist/PickupsPage-D7zyioJB-bHKnARYw.js +818 -0
  92. package/dist/PickupsPage-D7zyioJB-bHKnARYw.js.map +1 -0
  93. package/dist/PmGuard-BZE-y4In-D_pUm5MP.js +599 -0
  94. package/dist/PmGuard-BZE-y4In-D_pUm5MP.js.map +1 -0
  95. package/dist/ProductEditPage-BVlVUCtD-BR-tJ5Wb.js +1305 -0
  96. package/dist/ProductEditPage-BVlVUCtD-BR-tJ5Wb.js.map +1 -0
  97. package/dist/ProductsPage-DvNHIeZt-BoOOJJtk.js +253 -0
  98. package/dist/ProductsPage-DvNHIeZt-BoOOJJtk.js.map +1 -0
  99. package/dist/PurchaseCreatePage-Cq_i9snz-DRtHHFWw.js +675 -0
  100. package/dist/PurchaseCreatePage-Cq_i9snz-DRtHHFWw.js.map +1 -0
  101. package/dist/PurchaseRequestDetailPage-CA9KFOfE-CtjG4Gx6.js +1577 -0
  102. package/dist/PurchaseRequestDetailPage-CA9KFOfE-CtjG4Gx6.js.map +1 -0
  103. package/dist/PurchaseRequestsPage-DS9i4o0--TpoxA5Kd.js +279 -0
  104. package/dist/PurchaseRequestsPage-DS9i4o0--TpoxA5Kd.js.map +1 -0
  105. package/dist/PurchasesPage-DgL5T6BY-DePUuE9l.js +293 -0
  106. package/dist/PurchasesPage-DgL5T6BY-DePUuE9l.js.map +1 -0
  107. package/dist/QueryBuilder-CXaBe6sr.js +478 -0
  108. package/dist/QueryBuilder-CXaBe6sr.js.map +1 -0
  109. package/dist/{RoleManagement-DEiBNfT8.js → RoleManagement-s8iNx2Mu.js} +145 -155
  110. package/dist/RoleManagement-s8iNx2Mu.js.map +1 -0
  111. package/dist/Roles-BIyiic67.js +14 -0
  112. package/dist/Roles-BIyiic67.js.map +1 -0
  113. package/dist/SaleCreatePage-CZnIOydv-DKBw-qp7.js +544 -0
  114. package/dist/SaleCreatePage-CZnIOydv-DKBw-qp7.js.map +1 -0
  115. package/dist/SalesPage-DPIRrC_O-M8rqnK7z.js +315 -0
  116. package/dist/SalesPage-DPIRrC_O-M8rqnK7z.js.map +1 -0
  117. package/dist/SettingsPage-BC_R6Z-Q-CKNt9zRu.js +676 -0
  118. package/dist/SettingsPage-BC_R6Z-Q-CKNt9zRu.js.map +1 -0
  119. package/dist/ShowFlywayQuery-D10Olk5Z.js +154 -0
  120. package/dist/ShowFlywayQuery-D10Olk5Z.js.map +1 -0
  121. package/dist/{ShowFlywayQuery-DVRCd384.js → ShowFlywayQuery-DIOUdYfG.js} +170 -123
  122. package/dist/ShowFlywayQuery-DIOUdYfG.js.map +1 -0
  123. package/dist/ShowQueryHistory-DRBKYDKk.js +313 -0
  124. package/dist/ShowQueryHistory-DRBKYDKk.js.map +1 -0
  125. package/dist/StorageUnitsPage-BDRkdCjW-UF64rf7q.js +728 -0
  126. package/dist/StorageUnitsPage-BDRkdCjW-UF64rf7q.js.map +1 -0
  127. package/dist/SubMenu-BdMTYtC1.js +319 -0
  128. package/dist/SubMenu-BdMTYtC1.js.map +1 -0
  129. package/dist/TransactionsPage-CqWTMNU8-Df6eGFDW.js +746 -0
  130. package/dist/TransactionsPage-CqWTMNU8-Df6eGFDW.js.map +1 -0
  131. package/dist/TransferCreatePage-DF7FZaTJ-CL79V3aR.js +315 -0
  132. package/dist/TransferCreatePage-DF7FZaTJ-CL79V3aR.js.map +1 -0
  133. package/dist/TransfersPage-CGrRFaBF-cTwBUv0o.js +476 -0
  134. package/dist/TransfersPage-CGrRFaBF-cTwBUv0o.js.map +1 -0
  135. package/dist/TypeConfiguration-JbRCN6GR.js +114 -0
  136. package/dist/TypeConfiguration-JbRCN6GR.js.map +1 -0
  137. package/dist/{UserList-Bc8gYxRL.js → UserList-L41Xw0Q6.js} +253 -236
  138. package/dist/{UserList-Bc8gYxRL.js.map → UserList-L41Xw0Q6.js.map} +1 -1
  139. package/dist/Users-CsJ08Kjm.js.map +1 -1
  140. package/dist/VialsPage-rvvXjgZG-Oqo1v6kQ.js +321 -0
  141. package/dist/VialsPage-rvvXjgZG-Oqo1v6kQ.js.map +1 -0
  142. package/dist/constants-DpXnLsAB-D6lN5cjK.js +445 -0
  143. package/dist/constants-DpXnLsAB-D6lN5cjK.js.map +1 -0
  144. package/dist/{dashboardLayoutUtils-D1xCAxp3.js → dashboardLayoutUtils-CJivzaU1.js} +95 -92
  145. package/dist/dashboardLayoutUtils-CJivzaU1.js.map +1 -0
  146. package/dist/format-UOyOu75i-D0GyylyQ.js +63 -0
  147. package/dist/format-UOyOu75i-D0GyylyQ.js.map +1 -0
  148. package/dist/index.css +1 -1
  149. package/dist/index.js +1 -1
  150. package/dist/index.lib-ETRQOzvE.js +894 -0
  151. package/dist/index.lib-ETRQOzvE.js.map +1 -0
  152. package/dist/listValueStore-BFQtDYIR-Bj0yX145.js +36 -0
  153. package/dist/listValueStore-BFQtDYIR-Bj0yX145.js.map +1 -0
  154. package/dist/useFieldErrors-hDG8ox_x-DbSAzrGo.js +28 -0
  155. package/dist/useFieldErrors-hDG8ox_x-DbSAzrGo.js.map +1 -0
  156. package/dist/validation-BzlHnL-r-CCJm2utQ.js +125 -0
  157. package/dist/validation-BzlHnL-r-CCJm2utQ.js.map +1 -0
  158. package/package.json +4 -3
  159. package/dist/AccessRights-Zm8Obm4N.js +0 -1284
  160. package/dist/AccessRights-Zm8Obm4N.js.map +0 -1
  161. package/dist/AddEditQueryBuilder-Brdnm6rQ.js +0 -313
  162. package/dist/AddEditQueryBuilder-Brdnm6rQ.js.map +0 -1
  163. package/dist/AddLabelModal-DFllBVcd.js +0 -734
  164. package/dist/AddLabelModal-DFllBVcd.js.map +0 -1
  165. package/dist/AddMenuConfiguration-Ce91MhnU.js +0 -8547
  166. package/dist/AddMenuConfiguration-Ce91MhnU.js.map +0 -1
  167. package/dist/AppModal-CtG2GjD_.js +0 -428
  168. package/dist/AppModal-CtG2GjD_.js.map +0 -1
  169. package/dist/ChangePasswordModalCore-DutQAZOx.js.map +0 -1
  170. package/dist/ConditionConfig-B4Ffpgj3.js +0 -395
  171. package/dist/ConditionConfig-B4Ffpgj3.js.map +0 -1
  172. package/dist/ConditionConfig.css +0 -1
  173. package/dist/EventConfigurations-BJcURufo.js +0 -449
  174. package/dist/EventConfigurations-BJcURufo.js.map +0 -1
  175. package/dist/EventsExceptionModal-BlZtBQoR.js +0 -200
  176. package/dist/EventsExceptionModal-BlZtBQoR.js.map +0 -1
  177. package/dist/EventsSkeleton-DK6JDKAK.js +0 -83
  178. package/dist/EventsSkeleton-DK6JDKAK.js.map +0 -1
  179. package/dist/FeatureMenu-C3503UIX.js +0 -265
  180. package/dist/FeatureMenu-C3503UIX.js.map +0 -1
  181. package/dist/FlywayQuery-Cx2sly6g.js +0 -169
  182. package/dist/FlywayQuery-Cx2sly6g.js.map +0 -1
  183. package/dist/ImmunizationConfigurationBase-DLQVSNnt.js +0 -5895
  184. package/dist/ImmunizationConfigurationBase-DLQVSNnt.js.map +0 -1
  185. package/dist/ImmunizationConfigurationsList-DdSZicTP.js +0 -344
  186. package/dist/ImmunizationConfigurationsList-DdSZicTP.js.map +0 -1
  187. package/dist/LanguagesModal-D6VfaGrl.js +0 -394
  188. package/dist/LanguagesModal-D6VfaGrl.js.map +0 -1
  189. package/dist/ManageDynamicFeature-dt096fyj.js +0 -4189
  190. package/dist/ManageDynamicFeature-dt096fyj.js.map +0 -1
  191. package/dist/ManageEventConfiguration-BpSJszSX.js +0 -1017
  192. package/dist/ManageEventConfiguration-BpSJszSX.js.map +0 -1
  193. package/dist/ManageTranslation-B4C9-lWD.js +0 -625
  194. package/dist/ManageTranslation-B4C9-lWD.js.map +0 -1
  195. package/dist/MobileMenuManagement-Cf8IZlla.js +0 -108
  196. package/dist/MobileMenuManagement-Cf8IZlla.js.map +0 -1
  197. package/dist/MobileTypeEventConfigModal-DUkUYACe.js +0 -783
  198. package/dist/MobileTypeEventConfigModal-DUkUYACe.js.map +0 -1
  199. package/dist/NotificationFlywayQuery-BY8Zzml_.js +0 -244
  200. package/dist/NotificationFlywayQuery-BY8Zzml_.js.map +0 -1
  201. package/dist/OtherTypeEventConfigModal-CYBfr2XE.js +0 -2046
  202. package/dist/OtherTypeEventConfigModal-CYBfr2XE.js.map +0 -1
  203. package/dist/QueryBuilder-z7eqfd7D.js +0 -383
  204. package/dist/QueryBuilder-z7eqfd7D.js.map +0 -1
  205. package/dist/RoleManagement-DEiBNfT8.js.map +0 -1
  206. package/dist/ShowFlywayQuery-DVRCd384.js.map +0 -1
  207. package/dist/ShowFlywayQuery-tj42YQAS.js +0 -130
  208. package/dist/ShowFlywayQuery-tj42YQAS.js.map +0 -1
  209. package/dist/ShowQueryHistory-BDN0tzHg.js +0 -190
  210. package/dist/ShowQueryHistory-BDN0tzHg.js.map +0 -1
  211. package/dist/SubMenu-B072oEGb.js +0 -191
  212. package/dist/SubMenu-B072oEGb.js.map +0 -1
  213. package/dist/TypeConfiguration-C3xoP2Nb.js +0 -117
  214. package/dist/TypeConfiguration-C3xoP2Nb.js.map +0 -1
  215. package/dist/dashboardLayoutUtils-D1xCAxp3.js.map +0 -1
  216. package/dist/index.lib-C3fwoM3y.js +0 -820
  217. package/dist/index.lib-C3fwoM3y.js.map +0 -1
@@ -0,0 +1,1577 @@
1
+ import { S as Jt, U as Xt, K as gt, H as vt, F as Zt, k as H, I as It, J as er, L as tr, N as rr, O as ar } from "./ImmunizationConfigurationBase-aUtx0JEe.js";
2
+ import { O as kt, S as Ct } from "./constants-DpXnLsAB-D6lN5cjK.js";
3
+ import { t as Ae, n as Nt } from "./format-UOyOu75i-D0GyylyQ.js";
4
+ import { X as ir, Y as nr, Z as lr, Q as or, q as sr } from "./PmGuard-BZE-y4In-D_pUm5MP.js";
5
+ import { useState as b, useMemo as T, Fragment as cr } from "react";
6
+ import { jsxs as n, jsx as t, Fragment as $ } from "react/jsx-runtime";
7
+ import { Box as C, Alert as Be, Card as ue, CardContent as de, Stack as m, Chip as R, Typography as d, Divider as Ie, ToggleButtonGroup as ke, ToggleButton as B, TextField as I, Button as q, Tooltip as Dt, IconButton as ur, Table as dr, TableHead as hr, TableRow as Ce, TableCell as k, TableBody as mr, Dialog as pr, DialogTitle as yr, DialogContent as br, DialogActions as fr } from "@mui/material";
8
+ import { alpha as J } from "@mui/material/styles";
9
+ import { v4 as Ne } from "uuid";
10
+ import xr from "@mui/icons-material/AddRounded";
11
+ import gr from "@mui/icons-material/RefreshRounded";
12
+ import { useNavigate as vr, useParams as Ir } from "react-router-dom";
13
+ import kr from "@mui/icons-material/Inventory2Rounded";
14
+ import Cr from "@mui/icons-material/LocalShippingRounded";
15
+ import { useSelector as Nr } from "react-redux";
16
+ import Dr from "@mui/icons-material/DeleteOutlineRounded";
17
+ import qr from "@mui/icons-material/ArrowBackRounded";
18
+ import ze from "@mui/icons-material/CheckCircleRounded";
19
+ import De from "@mui/icons-material/DoNotDisturbRounded";
20
+ import qe from "@mui/icons-material/ReportProblemRounded";
21
+ import wr from "@mui/icons-material/BlockRounded";
22
+ import Rr from "@mui/icons-material/HourglassEmptyRounded";
23
+ function Sr(g) {
24
+ switch (g) {
25
+ case "PENDING":
26
+ return "info";
27
+ case "APPROVED":
28
+ return "success";
29
+ case "PARTIALLY_APPROVED":
30
+ return "warning";
31
+ case "REJECTED":
32
+ return "error";
33
+ case "CANCELLED":
34
+ return "default";
35
+ default:
36
+ return "default";
37
+ }
38
+ }
39
+ function Tr(g) {
40
+ switch (g) {
41
+ case "PENDING_SHIPMENT":
42
+ return "warning";
43
+ case "IN_TRANSIT":
44
+ return "info";
45
+ case "RECEIVED":
46
+ return "success";
47
+ case "PARTIALLY_RECEIVED":
48
+ return "warning";
49
+ case "DISCREPANCY":
50
+ return "error";
51
+ default:
52
+ return "default";
53
+ }
54
+ }
55
+ function qt(g) {
56
+ return g ? g.toLowerCase().split("_").map((z) => z.charAt(0).toUpperCase() + z.slice(1)).join(" ") : "";
57
+ }
58
+ function we(g) {
59
+ return g ? new Date(g).toISOString().substring(0, 10) : "";
60
+ }
61
+ function Zr() {
62
+ var nt;
63
+ let g = vr(), { requestId: z } = Ir(), Se = ir().has("approve.manage.productManagement.purchase"), We = Nr((e) => {
64
+ var i, r;
65
+ return (r = (i = e.Authenticate) == null ? void 0 : i.user) == null ? void 0 : r.id;
66
+ }), X = ((nt = Jt()) == null ? void 0 : nt.managePurchaseAmounts) !== !1, [a, W] = b(null), [wt, Oe] = b(!0), [f, N] = b(!1), [je, v] = b(""), [Q, he] = b({}), [S, Fe] = b({}), [Y, Le] = b({}), [Z, Me] = b({}), [Te, Qe] = b(!1), [$e, Ye] = b(""), [ee, Ue] = b({}), [Ee, Ge] = b({}), [Ke, _e] = b(""), [Rt, te] = b(!1), [re, Ve] = b({}), [me, He] = b({}), [St, pe] = b({}), [Tt, Je] = b(!1);
67
+ function U(e) {
68
+ let i = {}, r = {}, l = {};
69
+ ((e == null ? void 0 : e.items) ?? []).forEach((p) => {
70
+ let c = (p.batches ?? []).map((w) => ({
71
+ key: Ne(),
72
+ batchId: w.batchId ?? null,
73
+ receiptStatus: w.receiptStatus ?? null,
74
+ quantity: String(w.quantity ?? ""),
75
+ lotNumber: w.lotNumber ?? "",
76
+ expiryDate: we(w.expiryDate),
77
+ manufactureDate: we(w.manufactureDate)
78
+ }));
79
+ c.length === 0 && c.push({
80
+ key: Ne(),
81
+ batchId: null,
82
+ receiptStatus: null,
83
+ quantity: String(p.requestedQuantity),
84
+ lotNumber: "",
85
+ expiryDate: "",
86
+ manufactureDate: ""
87
+ }), i[p.id] = c, r[p.id] = p.approvedQuantity == null ? !0 : p.approvedQuantity > 0, l[p.id] = !!p.isSplit || c.length > 1;
88
+ }), he(i), Fe(r), Le(l), Me({}), Qe(!1);
89
+ let o = {}, u = {}, h = {};
90
+ ((e == null ? void 0 : e.items) ?? []).forEach((p) => {
91
+ (p.batches ?? []).forEach((c) => {
92
+ c.batchId && (c.receiptStatus ?? (o[c.batchId] = "OK"), c.receiptStatus === "DISCREPANCY" && (u[c.batchId] = "CORRECT", h[c.batchId] = {
93
+ lotNumber: c.lotNumber ?? "",
94
+ expiryDate: we(c.expiryDate),
95
+ manufactureDate: we(c.manufactureDate)
96
+ }));
97
+ });
98
+ }), Ue(o), Ge({}), _e(""), Ve(u), He(h), pe({}), Je(!1);
99
+ }
100
+ async function Xe() {
101
+ var e, i;
102
+ Oe(!0), v("");
103
+ try {
104
+ let r = await ar(z);
105
+ W(r), U(r), Ye((r == null ? void 0 : r.decisionNotes) ?? "");
106
+ } catch (r) {
107
+ v(((i = (e = r == null ? void 0 : r.response) == null ? void 0 : e.data) == null ? void 0 : i.message) ?? (r == null ? void 0 : r.message) ?? "Failed to load purchase request");
108
+ } finally {
109
+ Oe(!1);
110
+ }
111
+ }
112
+ nr(["view.manage.productManagement.purchase", "approve.manage.productManagement.purchase"], () => {
113
+ Xe();
114
+ }, [z]);
115
+ let Ze = (a == null ? void 0 : a.status) === "PENDING", D = (a == null ? void 0 : a.fulfillmentStatus) ?? null, et = (a == null ? void 0 : a.requestedBy) != null && We != null && Number(a.requestedBy) === Number(We), $t = Ze && Se, Et = D === "DISCREPANCY" && Se, ae = $t, Pt = D === "PENDING_SHIPMENT" && Se, G = D === "IN_TRANSIT" && et, At = D === "IN_TRANSIT" || D === "DISCREPANCY";
116
+ function tt(e) {
117
+ return Q[e] ?? [];
118
+ }
119
+ function ye(e) {
120
+ let i = tt(e);
121
+ return Y[e] ? i : i.slice(0, 1);
122
+ }
123
+ function E(e) {
124
+ Me((i) => i[e] ? i : {
125
+ ...i,
126
+ [e]: !0
127
+ });
128
+ }
129
+ function P(e, i, r, l) {
130
+ he((o) => ({
131
+ ...o,
132
+ [e]: (o[e] ?? []).map((u) => u.key === i ? {
133
+ ...u,
134
+ [r]: l
135
+ } : u)
136
+ })), E(`${i}:${r}`);
137
+ }
138
+ function Bt(e) {
139
+ let i = ((a == null ? void 0 : a.items) ?? []).find((l) => l.id === e), r = i ? Math.max(i.requestedQuantity - be(e), 0) : 0;
140
+ he((l) => ({
141
+ ...l,
142
+ [e]: [...l[e] ?? [], {
143
+ key: Ne(),
144
+ batchId: null,
145
+ receiptStatus: null,
146
+ quantity: r > 0 ? String(r) : "",
147
+ lotNumber: "",
148
+ expiryDate: "",
149
+ manufactureDate: ""
150
+ }]
151
+ }));
152
+ }
153
+ function rt(e, i, r, l) {
154
+ if (r === "") {
155
+ P(e, i, "quantity", "");
156
+ return;
157
+ }
158
+ let o = Math.floor(Number(r));
159
+ if (!Number.isFinite(o)) return;
160
+ o < 1 && (o = 1);
161
+ let u = ye(e).filter((p) => p.key !== i).reduce((p, c) => p + (Number(c.quantity) > 0 ? Number(c.quantity) : 0), 0), h = Math.max(l - u, 1);
162
+ o > h && (o = h), P(e, i, "quantity", String(o));
163
+ }
164
+ function zt(e, i) {
165
+ he((r) => {
166
+ let l = (r[e] ?? []).filter((o) => o.key !== i);
167
+ return {
168
+ ...r,
169
+ [e]: l.length ? l : [{
170
+ key: Ne(),
171
+ quantity: "",
172
+ lotNumber: "",
173
+ expiryDate: ""
174
+ }]
175
+ };
176
+ });
177
+ }
178
+ function Wt(e, i) {
179
+ Fe((r) => ({
180
+ ...r,
181
+ [e]: i
182
+ }));
183
+ }
184
+ function Ot(e, i) {
185
+ Le((r) => ({
186
+ ...r,
187
+ [e]: i
188
+ }));
189
+ }
190
+ function be(e) {
191
+ return S[e] ? ye(e).reduce((i, r) => {
192
+ let l = Number(r.quantity);
193
+ return i + (Number.isFinite(l) && l > 0 ? l : 0);
194
+ }, 0) : 0;
195
+ }
196
+ let y = T(() => {
197
+ if (!a || !ae) return {};
198
+ let e = {}, i = (/* @__PURE__ */ new Date()).toISOString().substring(0, 10);
199
+ return (a.items ?? []).forEach((r) => {
200
+ if (!S[r.id]) return;
201
+ let l = Y[r.id] ? Q[r.id] ?? [] : (Q[r.id] ?? []).slice(0, 1), o = 0;
202
+ l.forEach((u) => {
203
+ let h = Number(u.quantity);
204
+ !Number.isInteger(h) || h <= 0 ? e[`${u.key}:quantity`] = "Enter a quantity" : o += h, (!u.lotNumber || !u.lotNumber.trim()) && (e[`${u.key}:lotNumber`] = "Lot is required"), u.expiryDate ? u.expiryDate < i && (e[`${u.key}:expiryDate`] = "Must be today or later") : e[`${u.key}:expiryDate`] = "Expiry is required", u.manufactureDate && u.manufactureDate > i && (e[`${u.key}:manufactureDate`] = "Cannot be in the future");
205
+ }), o > r.requestedQuantity && (e[`${r.id}:sum`] = `Total exceeds the requested ${r.requestedQuantity}`);
206
+ }), e;
207
+ }, [
208
+ a,
209
+ Q,
210
+ S,
211
+ Y,
212
+ ae
213
+ ]), jt = Object.keys(y).length === 0;
214
+ T(() => ((a == null ? void 0 : a.items) ?? []).some((e) => S[e.id] && be(e.id) > 0), [
215
+ a,
216
+ Q,
217
+ S,
218
+ Y
219
+ ]);
220
+ let Ft = T(() => ((a == null ? void 0 : a.items) ?? []).some((e) => S[e.id]), [a, S]), x = (e) => Te || Z[e];
221
+ function Lt(e) {
222
+ return Te ? !0 : ye(e).some((i) => Z[`${i.key}:quantity`] || Z[`${i.key}:lotNumber`] || Z[`${i.key}:expiryDate`] || Z[`${i.key}:manufactureDate`]);
223
+ }
224
+ function Mt() {
225
+ return (a.items ?? []).map((e) => ({
226
+ itemId: e.id,
227
+ batches: S[e.id] ? ye(e.id).map((i) => ({
228
+ quantity: Number(i.quantity),
229
+ lotNumber: i.lotNumber.trim(),
230
+ expiryDate: i.expiryDate,
231
+ manufactureDate: i.manufactureDate || null,
232
+ storageUnitId: e.storageUnitId ?? null
233
+ })) : []
234
+ }));
235
+ }
236
+ let at = T(() => {
237
+ if (!a || !X || !ae) return null;
238
+ let e = 0, i = !1;
239
+ return (a.items ?? []).forEach((r) => {
240
+ let l = be(r.id);
241
+ l <= 0 || r.buyPrice == null || (e += Number(r.buyPrice) * l, i = !0);
242
+ }), i ? e : null;
243
+ }, [
244
+ a,
245
+ Q,
246
+ S,
247
+ Y,
248
+ X,
249
+ ae
250
+ ]);
251
+ async function Qt() {
252
+ var e, i;
253
+ if (a) {
254
+ if (!jt) {
255
+ Qe(!0);
256
+ return;
257
+ }
258
+ N(!0), v("");
259
+ try {
260
+ let r = await It(a.id, {
261
+ decisionNotes: $e || null,
262
+ items: Mt()
263
+ });
264
+ W(r), U(r), H({
265
+ message: "Decision saved. Mark it as sent once it's on the way.",
266
+ type: "success"
267
+ });
268
+ } catch (r) {
269
+ v(((i = (e = r == null ? void 0 : r.response) == null ? void 0 : e.data) == null ? void 0 : i.message) ?? (r == null ? void 0 : r.message) ?? "Failed to submit decision");
270
+ } finally {
271
+ N(!1);
272
+ }
273
+ }
274
+ }
275
+ async function Yt() {
276
+ var e, i;
277
+ if (a) {
278
+ N(!0), v("");
279
+ try {
280
+ let r = await It(a.id, {
281
+ decisionNotes: $e || null,
282
+ items: (a.items ?? []).map((l) => ({
283
+ itemId: l.id,
284
+ batches: []
285
+ }))
286
+ });
287
+ W(r), U(r), te(!1), H({
288
+ message: "Request rejected.",
289
+ type: "success"
290
+ });
291
+ } catch (r) {
292
+ v(((i = (e = r == null ? void 0 : r.response) == null ? void 0 : e.data) == null ? void 0 : i.message) ?? (r == null ? void 0 : r.message) ?? "Failed to reject request");
293
+ } finally {
294
+ N(!1);
295
+ }
296
+ }
297
+ }
298
+ async function Ut() {
299
+ var e, i;
300
+ if (a) {
301
+ N(!0), v("");
302
+ try {
303
+ let r = await er(a.id, {});
304
+ W(r), U(r), H({
305
+ message: "Marked as on the way. The requester can confirm it when it arrives.",
306
+ type: "success"
307
+ });
308
+ } catch (r) {
309
+ v(((i = (e = r == null ? void 0 : r.response) == null ? void 0 : e.data) == null ? void 0 : i.message) ?? (r == null ? void 0 : r.message) ?? "Failed to mark in transit");
310
+ } finally {
311
+ N(!1);
312
+ }
313
+ }
314
+ }
315
+ async function Gt() {
316
+ var e, i;
317
+ if (a) {
318
+ if (!Ht) {
319
+ Je(!0);
320
+ return;
321
+ }
322
+ N(!0), v("");
323
+ try {
324
+ let r = await Zt(a.id, { corrections: A.map((l) => {
325
+ let o = re[l.batchId] ?? "CORRECT";
326
+ if (o === "CANNOT_SUPPLY") return {
327
+ batchId: l.batchId,
328
+ action: o
329
+ };
330
+ let u = me[l.batchId] ?? {};
331
+ return {
332
+ batchId: l.batchId,
333
+ action: o,
334
+ lotNumber: u.lotNumber.trim(),
335
+ expiryDate: u.expiryDate,
336
+ manufactureDate: u.manufactureDate || null
337
+ };
338
+ }) });
339
+ W(r), U(r), H({
340
+ message: _ > 0 ? `Sent back to ${a.requestedByName || "the requester"} to check again.` : "Closed. Those batches will not be supplied.",
341
+ type: "success"
342
+ });
343
+ } catch (r) {
344
+ v(((i = (e = r == null ? void 0 : r.response) == null ? void 0 : e.data) == null ? void 0 : i.message) ?? (r == null ? void 0 : r.message) ?? "Could not send the corrections.");
345
+ } finally {
346
+ N(!1);
347
+ }
348
+ }
349
+ }
350
+ async function Kt() {
351
+ var e, i;
352
+ if (a) {
353
+ N(!0), v("");
354
+ try {
355
+ let r = {};
356
+ O.forEach((o) => {
357
+ r[o] = (Ee[o] ?? "").trim();
358
+ });
359
+ let l = await tr(a.id, {
360
+ verifiedBatchIds: xe,
361
+ flaggedBatchIds: O,
362
+ discrepancyReasons: r,
363
+ notes: ie && Ke.trim() || null
364
+ });
365
+ W(l), U(l), H({
366
+ message: ne ? "Sent back to the approver." : ie ? `Received the OK batches. ${O.length} flagged ${O.length === 1 ? "batch was" : "batches were"} sent to the approver.` : "Received. The stock is now in your inventory.",
367
+ type: "success"
368
+ });
369
+ } catch (r) {
370
+ v(((i = (e = r == null ? void 0 : r.response) == null ? void 0 : e.data) == null ? void 0 : i.message) ?? (r == null ? void 0 : r.message) ?? "Could not submit the receipt.");
371
+ } finally {
372
+ N(!1);
373
+ }
374
+ }
375
+ }
376
+ async function _t() {
377
+ var e, i;
378
+ if (a) {
379
+ N(!0), v("");
380
+ try {
381
+ W(await rr(a.id)), H({
382
+ message: "Request cancelled.",
383
+ type: "success"
384
+ });
385
+ } catch (r) {
386
+ v(((i = (e = r == null ? void 0 : r.response) == null ? void 0 : e.data) == null ? void 0 : i.message) ?? (r == null ? void 0 : r.message) ?? "Failed to cancel request");
387
+ } finally {
388
+ N(!1);
389
+ }
390
+ }
391
+ }
392
+ let fe = T(() => {
393
+ let e = [];
394
+ return ((a == null ? void 0 : a.items) ?? []).forEach((i) => {
395
+ (i.batches ?? []).forEach((r) => {
396
+ (r.quantity ?? 0) > 0 && (r.lotNumber || r.expiryDate) && e.push({
397
+ ...r,
398
+ productName: i.productName,
399
+ itemId: i.id
400
+ });
401
+ });
402
+ }), e;
403
+ }, [a]), K = T(() => fe.filter((e) => e.batchId && e.receiptStatus == null), [fe]), xe = T(() => K.filter((e) => (ee[e.batchId] ?? "OK") === "OK").map((e) => e.batchId), [K, ee]), O = T(() => K.filter((e) => ee[e.batchId] === "ISSUE").map((e) => e.batchId), [K, ee]), ie = O.length > 0, ne = K.length > 0 && xe.length === 0, Vt = K.length > 0 && O.every((e) => (Ee[e] ?? "").trim()), A = T(() => fe.filter((e) => e.batchId && e.receiptStatus === "DISCREPANCY"), [fe]), _ = A.filter((e) => (re[e.batchId] ?? "CORRECT") === "CORRECT").length, it = A.length - _, le = T(() => {
404
+ let e = {}, i = (/* @__PURE__ */ new Date()).toISOString().substring(0, 10);
405
+ return A.forEach((r) => {
406
+ if ((re[r.batchId] ?? "CORRECT") !== "CORRECT") return;
407
+ let l = me[r.batchId] ?? {};
408
+ (!l.lotNumber || !l.lotNumber.trim()) && (e[`${r.batchId}:lotNumber`] = "Lot number is required"), l.expiryDate ? l.expiryDate < i && (e[`${r.batchId}:expiryDate`] = "Must be today or later") : e[`${r.batchId}:expiryDate`] = "Expiry is required", l.manufactureDate && l.manufactureDate > i && (e[`${r.batchId}:manufactureDate`] = "Cannot be in the future");
409
+ }), e;
410
+ }, [
411
+ A,
412
+ re,
413
+ me
414
+ ]), Ht = Object.keys(le).length === 0, V = (e) => (Tt || St[e]) && !!le[e];
415
+ function Pe(e, i, r) {
416
+ He((l) => ({
417
+ ...l,
418
+ [e]: {
419
+ ...l[e] ?? {},
420
+ [i]: r
421
+ }
422
+ }));
423
+ }
424
+ return /* @__PURE__ */ n(C, { children: [/* @__PURE__ */ t(lr, {}), /* @__PURE__ */ n(or, {
425
+ anyOf: ["view.manage.productManagement.purchase", "approve.manage.productManagement.purchase"],
426
+ children: [/* @__PURE__ */ n(sr, {
427
+ title: a != null && a.serialId ? `Purchase Request #${a.serialId}` : "Purchase Request",
428
+ subtitle: "Track this request from approval through to the stock arriving.",
429
+ chips: [...a != null && a.status ? [qt(a.status)] : [], ...D ? [kt(Ct, D)] : []],
430
+ actions: /* @__PURE__ */ n(m, {
431
+ direction: "row",
432
+ spacing: 1,
433
+ children: [/* @__PURE__ */ t(q, {
434
+ variant: "outlined",
435
+ startIcon: /* @__PURE__ */ t(qr, {}),
436
+ onClick: () => g("/ui/medplat/manage/pm/purchase-requests"),
437
+ children: "Back"
438
+ }), /* @__PURE__ */ t(q, {
439
+ variant: "outlined",
440
+ startIcon: /* @__PURE__ */ t(gr, {}),
441
+ onClick: () => void Xe(),
442
+ children: "Refresh"
443
+ })]
444
+ }),
445
+ children: [je ? /* @__PURE__ */ t(Be, {
446
+ severity: "error",
447
+ sx: { mb: 2 },
448
+ children: je
449
+ }) : null, !wt && a ? /* @__PURE__ */ n($, { children: [
450
+ /* @__PURE__ */ t(ue, {
451
+ sx: {
452
+ borderRadius: 1.5,
453
+ mb: 2,
454
+ border: "1px solid",
455
+ borderColor: "divider",
456
+ boxShadow: "0 12px 32px rgba(15, 23, 42, 0.045)"
457
+ },
458
+ children: /* @__PURE__ */ n(de, {
459
+ sx: { p: 2.5 },
460
+ children: [
461
+ /* @__PURE__ */ n(m, {
462
+ direction: {
463
+ xs: "column",
464
+ md: "row"
465
+ },
466
+ spacing: 2,
467
+ alignItems: { md: "flex-start" },
468
+ children: [/* @__PURE__ */ n(C, {
469
+ sx: {
470
+ flexGrow: 1,
471
+ minWidth: 0
472
+ },
473
+ children: [
474
+ /* @__PURE__ */ n(m, {
475
+ direction: "row",
476
+ alignItems: "center",
477
+ spacing: 1,
478
+ sx: { mb: 0.5 },
479
+ flexWrap: "wrap",
480
+ useFlexGap: !0,
481
+ children: [
482
+ /* @__PURE__ */ t(Xt, { id: a.serialId }),
483
+ /* @__PURE__ */ t(R, {
484
+ size: "small",
485
+ label: qt(a.status),
486
+ color: Sr(a.status)
487
+ }),
488
+ D ? /* @__PURE__ */ t(R, {
489
+ size: "small",
490
+ label: kt(Ct, D),
491
+ color: Tr(D)
492
+ }) : null,
493
+ /* @__PURE__ */ t(d, {
494
+ variant: "caption",
495
+ color: "text.secondary",
496
+ children: a.ownerType
497
+ })
498
+ ]
499
+ }),
500
+ /* @__PURE__ */ t(d, {
501
+ variant: "h6",
502
+ sx: { fontWeight: 800 },
503
+ children: a.ownerName || (a.ownerType === "USER" ? "Personal" : "Facility")
504
+ }),
505
+ /* @__PURE__ */ n(d, {
506
+ variant: "caption",
507
+ color: "text.secondary",
508
+ sx: { display: "block" },
509
+ children: ["For purchase date ", Ae(a.purchaseDate)]
510
+ })
511
+ ]
512
+ }), /* @__PURE__ */ n(m, {
513
+ spacing: 0.25,
514
+ sx: { minWidth: 260 },
515
+ children: [
516
+ /* @__PURE__ */ t(M, {
517
+ label: "Requested by",
518
+ children: a.requestedByName || `#${a.requestedBy}`
519
+ }),
520
+ /* @__PURE__ */ t(M, {
521
+ label: "Requested on",
522
+ children: Nt(a.requestedOn)
523
+ }),
524
+ a.decidedBy ? /* @__PURE__ */ n($, { children: [/* @__PURE__ */ t(M, {
525
+ label: "Decided by",
526
+ children: a.decidedByName || `#${a.decidedBy}`
527
+ }), /* @__PURE__ */ t(M, {
528
+ label: "Decided on",
529
+ children: Nt(a.decidedOn)
530
+ })] }) : null,
531
+ a.shippedBy ? /* @__PURE__ */ t(M, {
532
+ label: "Shipped by",
533
+ children: a.shippedByName || `#${a.shippedBy}`
534
+ }) : null,
535
+ a.receivedBy ? /* @__PURE__ */ t(M, {
536
+ label: "Received by",
537
+ children: a.receivedByName || `#${a.receivedBy}`
538
+ }) : null,
539
+ X && a.paymentMode ? /* @__PURE__ */ t(M, {
540
+ label: "Payment",
541
+ children: a.paymentMode
542
+ }) : null
543
+ ]
544
+ })]
545
+ }),
546
+ a.notes ? /* @__PURE__ */ n($, { children: [
547
+ /* @__PURE__ */ t(Ie, { sx: { my: 1.5 } }),
548
+ /* @__PURE__ */ t(Re, { children: "Requester notes" }),
549
+ /* @__PURE__ */ t(d, {
550
+ variant: "body2",
551
+ children: a.notes
552
+ })
553
+ ] }) : null,
554
+ a.decisionNotes ? /* @__PURE__ */ n($, { children: [
555
+ /* @__PURE__ */ t(Ie, { sx: { my: 1.5 } }),
556
+ /* @__PURE__ */ t(Re, { children: "Decision notes" }),
557
+ /* @__PURE__ */ t(d, {
558
+ variant: "body2",
559
+ children: a.decisionNotes
560
+ })
561
+ ] }) : null,
562
+ a.fulfillmentNotes ? /* @__PURE__ */ n($, { children: [
563
+ /* @__PURE__ */ t(Ie, { sx: { my: 1.5 } }),
564
+ /* @__PURE__ */ t(Re, { children: D === "DISCREPANCY" || D === "PARTIALLY_RECEIVED" ? "Reported discrepancy" : "Delivery note" }),
565
+ /* @__PURE__ */ t(d, {
566
+ variant: "body2",
567
+ children: a.fulfillmentNotes
568
+ })
569
+ ] }) : null
570
+ ]
571
+ })
572
+ }),
573
+ Et ? /* @__PURE__ */ t(ue, {
574
+ variant: "outlined",
575
+ sx: { mb: 2 },
576
+ children: /* @__PURE__ */ n(de, {
577
+ sx: { p: 2 },
578
+ children: [
579
+ /* @__PURE__ */ n(Be, {
580
+ severity: "warning",
581
+ sx: { mb: 2 },
582
+ icon: /* @__PURE__ */ t(qe, {}),
583
+ children: [
584
+ a.requestedByName || "The requester",
585
+ " could not accept",
586
+ A.length === 1 ? " this batch" : ` these ${A.length} batches`,
587
+ ". Fix the details so they can check again, or say it cannot be supplied."
588
+ ]
589
+ }),
590
+ /* @__PURE__ */ t(m, {
591
+ spacing: 1.5,
592
+ children: A.map((e) => {
593
+ let i = re[e.batchId] ?? "CORRECT", r = me[e.batchId] ?? {};
594
+ return /* @__PURE__ */ n(C, {
595
+ sx: (l) => ({
596
+ p: 1.5,
597
+ borderRadius: 1.5,
598
+ border: `1px solid ${J(l.palette.warning.main, 0.35)}`,
599
+ bgcolor: J(l.palette.warning.main, 0.04)
600
+ }),
601
+ children: [
602
+ /* @__PURE__ */ n(m, {
603
+ direction: {
604
+ xs: "column",
605
+ sm: "row"
606
+ },
607
+ spacing: 1,
608
+ justifyContent: "space-between",
609
+ alignItems: { sm: "center" },
610
+ children: [/* @__PURE__ */ n(C, { children: [/* @__PURE__ */ t(d, {
611
+ variant: "body2",
612
+ sx: { fontWeight: 700 },
613
+ children: e.productName
614
+ }), /* @__PURE__ */ n(d, {
615
+ variant: "caption",
616
+ color: "text.secondary",
617
+ children: [
618
+ "Sent as lot ",
619
+ e.lotNumber || "—",
620
+ " · ",
621
+ e.quantity,
622
+ " unit",
623
+ e.quantity === 1 ? "" : "s"
624
+ ]
625
+ })] }), /* @__PURE__ */ n(ke, {
626
+ size: "small",
627
+ exclusive: !0,
628
+ value: i,
629
+ onChange: (l, o) => {
630
+ o && Ve((u) => ({
631
+ ...u,
632
+ [e.batchId]: o
633
+ }));
634
+ },
635
+ children: [/* @__PURE__ */ t(B, {
636
+ value: "CORRECT",
637
+ sx: {
638
+ textTransform: "none",
639
+ px: 1.25
640
+ },
641
+ children: "Fix details"
642
+ }), /* @__PURE__ */ t(B, {
643
+ value: "CANNOT_SUPPLY",
644
+ color: "error",
645
+ sx: {
646
+ textTransform: "none",
647
+ px: 1.25
648
+ },
649
+ children: "Cannot supply"
650
+ })]
651
+ })]
652
+ }),
653
+ e.discrepancyReason ? /* @__PURE__ */ n(d, {
654
+ variant: "body2",
655
+ sx: {
656
+ mt: 1,
657
+ fontStyle: "italic"
658
+ },
659
+ children: [
660
+ "“",
661
+ e.discrepancyReason,
662
+ "”"
663
+ ]
664
+ }) : null,
665
+ i === "CORRECT" ? /* @__PURE__ */ n(C, {
666
+ sx: {
667
+ mt: 1.5,
668
+ display: "grid",
669
+ gap: 1.5,
670
+ gridTemplateColumns: {
671
+ xs: "1fr",
672
+ sm: "minmax(0,1fr) 180px 180px"
673
+ }
674
+ },
675
+ children: [
676
+ /* @__PURE__ */ t(I, {
677
+ size: "small",
678
+ label: "Lot number",
679
+ required: !0,
680
+ value: r.lotNumber ?? "",
681
+ onChange: (l) => Pe(e.batchId, "lotNumber", l.target.value),
682
+ onBlur: () => pe((l) => ({
683
+ ...l,
684
+ [`${e.batchId}:lotNumber`]: !0
685
+ })),
686
+ error: V(`${e.batchId}:lotNumber`),
687
+ helperText: V(`${e.batchId}:lotNumber`) ? le[`${e.batchId}:lotNumber`] : " "
688
+ }),
689
+ /* @__PURE__ */ t(I, {
690
+ size: "small",
691
+ type: "date",
692
+ label: "Expiry",
693
+ required: !0,
694
+ InputLabelProps: { shrink: !0 },
695
+ value: r.expiryDate ?? "",
696
+ onChange: (l) => Pe(e.batchId, "expiryDate", l.target.value),
697
+ onBlur: () => pe((l) => ({
698
+ ...l,
699
+ [`${e.batchId}:expiryDate`]: !0
700
+ })),
701
+ error: V(`${e.batchId}:expiryDate`),
702
+ helperText: V(`${e.batchId}:expiryDate`) ? le[`${e.batchId}:expiryDate`] : " "
703
+ }),
704
+ /* @__PURE__ */ t(I, {
705
+ size: "small",
706
+ type: "date",
707
+ label: "Manufactured",
708
+ InputLabelProps: { shrink: !0 },
709
+ value: r.manufactureDate ?? "",
710
+ onChange: (l) => Pe(e.batchId, "manufactureDate", l.target.value),
711
+ onBlur: () => pe((l) => ({
712
+ ...l,
713
+ [`${e.batchId}:manufactureDate`]: !0
714
+ })),
715
+ error: V(`${e.batchId}:manufactureDate`),
716
+ helperText: V(`${e.batchId}:manufactureDate`) ? le[`${e.batchId}:manufactureDate`] : "Optional"
717
+ })
718
+ ]
719
+ }) : /* @__PURE__ */ t(d, {
720
+ variant: "caption",
721
+ color: "error",
722
+ sx: {
723
+ display: "block",
724
+ mt: 1.5,
725
+ fontWeight: 600
726
+ },
727
+ children: "This batch will be closed. It will not come into stock, and this cannot be undone."
728
+ })
729
+ ]
730
+ }, e.batchId);
731
+ })
732
+ }),
733
+ /* @__PURE__ */ n(d, {
734
+ variant: "caption",
735
+ color: "text.secondary",
736
+ sx: {
737
+ display: "block",
738
+ mt: 2
739
+ },
740
+ children: [_ > 0 ? `${_} will go back for checking. ` : "", it > 0 ? `${it} will be closed.` : ""]
741
+ }),
742
+ /* @__PURE__ */ t(m, {
743
+ direction: "row",
744
+ spacing: 1,
745
+ justifyContent: "flex-end",
746
+ sx: { mt: 1 },
747
+ children: /* @__PURE__ */ t(q, {
748
+ variant: "contained",
749
+ color: _ === 0 ? "error" : "primary",
750
+ disabled: f,
751
+ onClick: () => void Gt(),
752
+ children: f ? "Sending…" : _ === 0 ? "Close These Batches" : "Send Corrections"
753
+ })
754
+ })
755
+ ]
756
+ })
757
+ }) : null,
758
+ ae ? /* @__PURE__ */ n($, { children: [
759
+ /* @__PURE__ */ t(gt, {
760
+ eyebrow: "Decision",
761
+ title: "Requested items",
762
+ hint: "Approve or reject each item. For approved items, add the batch(es) coming in with their lot number and expiry."
763
+ }),
764
+ /* @__PURE__ */ t(m, {
765
+ spacing: 2,
766
+ sx: {
767
+ mt: 1.5,
768
+ mb: 2
769
+ },
770
+ children: a.items.map((e) => {
771
+ var w, oe, se, ge, ce, j, ve, lt, ot, st, ct, ut, dt, ht, mt, pt, yt, bt, ft, xt;
772
+ let i = !!S[e.id], r = !!Y[e.id], l = tt(e.id), o = r ? l : l.slice(0, 1), u = be(e.id), h = Math.max(e.requestedQuantity - u, 0), p = y[`${e.id}:sum`], c = i ? u === e.requestedQuantity ? {
773
+ label: "Full",
774
+ color: "success"
775
+ } : u > 0 ? {
776
+ label: "Partial",
777
+ color: "warning"
778
+ } : {
779
+ label: "None yet",
780
+ color: "default"
781
+ } : {
782
+ label: "Rejected",
783
+ color: "default"
784
+ };
785
+ return /* @__PURE__ */ t(ue, {
786
+ variant: "outlined",
787
+ sx: {
788
+ borderRadius: 1.5,
789
+ borderColor: i ? "divider" : "action.disabledBackground",
790
+ bgcolor: i ? "background.paper" : (s) => J(s.palette.action.disabled, 0.03)
791
+ },
792
+ children: /* @__PURE__ */ n(de, {
793
+ sx: { p: 2 },
794
+ children: [/* @__PURE__ */ n(m, {
795
+ direction: {
796
+ xs: "column",
797
+ sm: "row"
798
+ },
799
+ justifyContent: "space-between",
800
+ alignItems: { sm: "center" },
801
+ spacing: 1,
802
+ children: [/* @__PURE__ */ n(C, {
803
+ sx: { minWidth: 0 },
804
+ children: [/* @__PURE__ */ t(d, {
805
+ variant: "subtitle1",
806
+ sx: { fontWeight: 800 },
807
+ children: e.productName
808
+ }), /* @__PURE__ */ n(m, {
809
+ direction: "row",
810
+ spacing: 1,
811
+ alignItems: "center",
812
+ flexWrap: "wrap",
813
+ useFlexGap: !0,
814
+ children: [
815
+ /* @__PURE__ */ t(R, {
816
+ size: "small",
817
+ variant: "outlined",
818
+ label: `Requested ${e.requestedQuantity}`,
819
+ sx: {
820
+ fontWeight: 700,
821
+ height: 22
822
+ }
823
+ }),
824
+ X && e.buyPrice != null ? /* @__PURE__ */ n(d, {
825
+ variant: "caption",
826
+ color: "text.secondary",
827
+ children: [/* @__PURE__ */ t(vt, {
828
+ value: e.buyPrice,
829
+ bold: !1
830
+ }), " each"]
831
+ }) : null,
832
+ e.storageUnitName ? /* @__PURE__ */ n(d, {
833
+ variant: "caption",
834
+ color: "text.secondary",
835
+ children: ["· ", e.storageUnitName]
836
+ }) : null
837
+ ]
838
+ })]
839
+ }), /* @__PURE__ */ n(ke, {
840
+ size: "small",
841
+ exclusive: !0,
842
+ value: i ? "approve" : "reject",
843
+ onChange: (s, F) => {
844
+ F && Wt(e.id, F === "approve");
845
+ },
846
+ children: [/* @__PURE__ */ t(B, {
847
+ value: "approve",
848
+ color: "success",
849
+ sx: {
850
+ textTransform: "none",
851
+ px: 1.5,
852
+ fontWeight: 700
853
+ },
854
+ children: "Approve"
855
+ }), /* @__PURE__ */ t(B, {
856
+ value: "reject",
857
+ color: "error",
858
+ sx: {
859
+ textTransform: "none",
860
+ px: 1.5,
861
+ fontWeight: 700
862
+ },
863
+ children: "Reject"
864
+ })]
865
+ })]
866
+ }), i ? /* @__PURE__ */ n($, { children: [
867
+ /* @__PURE__ */ t(Ie, { sx: { my: 1.5 } }),
868
+ /* @__PURE__ */ n(m, {
869
+ direction: {
870
+ xs: "column",
871
+ sm: "row"
872
+ },
873
+ justifyContent: "space-between",
874
+ alignItems: { sm: "center" },
875
+ spacing: 1,
876
+ sx: { mb: 1.5 },
877
+ children: [/* @__PURE__ */ n(ke, {
878
+ size: "small",
879
+ exclusive: !0,
880
+ value: r ? "multi" : "single",
881
+ onChange: (s, F) => {
882
+ F && Ot(e.id, F === "multi");
883
+ },
884
+ children: [/* @__PURE__ */ t(B, {
885
+ value: "single",
886
+ sx: {
887
+ textTransform: "none",
888
+ px: 1.5
889
+ },
890
+ children: "Single batch"
891
+ }), /* @__PURE__ */ t(B, {
892
+ value: "multi",
893
+ sx: {
894
+ textTransform: "none",
895
+ px: 1.5
896
+ },
897
+ children: "Multiple batches"
898
+ })]
899
+ }), /* @__PURE__ */ t(R, {
900
+ size: "small",
901
+ color: c.color,
902
+ label: `${u} of ${e.requestedQuantity} · ${c.label}`,
903
+ sx: { fontWeight: 700 }
904
+ })]
905
+ }),
906
+ r ? /* @__PURE__ */ n($, { children: [
907
+ /* @__PURE__ */ n(C, {
908
+ sx: (s) => ({
909
+ display: "flex",
910
+ justifyContent: "space-between",
911
+ alignItems: "center",
912
+ p: 1,
913
+ mb: 1.5,
914
+ borderRadius: 1,
915
+ bgcolor: J(s.palette.info.main, 0.06),
916
+ border: `1px solid ${J(s.palette.info.main, 0.16)}`
917
+ }),
918
+ children: [/* @__PURE__ */ n(d, {
919
+ variant: "caption",
920
+ sx: { fontWeight: 700 },
921
+ children: [
922
+ o.length,
923
+ " ",
924
+ o.length === 1 ? "batch" : "batches",
925
+ " · ",
926
+ u,
927
+ " of ",
928
+ e.requestedQuantity,
929
+ " allocated"
930
+ ]
931
+ }), /* @__PURE__ */ t(R, {
932
+ size: "small",
933
+ color: h === 0 ? "success" : "default",
934
+ label: h === 0 ? "Fully allocated" : `${h} left`,
935
+ sx: {
936
+ fontWeight: 700,
937
+ height: 22
938
+ }
939
+ })]
940
+ }),
941
+ /* @__PURE__ */ t(m, {
942
+ spacing: 1.5,
943
+ children: o.map((s, F) => /* @__PURE__ */ n(C, {
944
+ sx: {
945
+ p: 1.5,
946
+ border: "1px solid",
947
+ borderColor: "divider",
948
+ borderRadius: 1.5
949
+ },
950
+ children: [/* @__PURE__ */ n(m, {
951
+ direction: "row",
952
+ justifyContent: "space-between",
953
+ alignItems: "center",
954
+ sx: { mb: 1 },
955
+ children: [/* @__PURE__ */ t(R, {
956
+ size: "small",
957
+ label: `Batch ${F + 1}`,
958
+ sx: {
959
+ fontWeight: 700,
960
+ height: 22
961
+ }
962
+ }), /* @__PURE__ */ t(Dt, {
963
+ title: "Remove batch",
964
+ children: /* @__PURE__ */ t("span", { children: /* @__PURE__ */ t(ur, {
965
+ size: "small",
966
+ disabled: o.length <= 1,
967
+ onClick: () => zt(e.id, s.key),
968
+ children: /* @__PURE__ */ t(Dr, { fontSize: "small" })
969
+ }) })
970
+ })]
971
+ }), /* @__PURE__ */ n(C, {
972
+ sx: {
973
+ display: "grid",
974
+ gridTemplateColumns: {
975
+ xs: "1fr",
976
+ sm: "110px minmax(0, 1fr) 170px 170px"
977
+ },
978
+ gap: 1.5
979
+ },
980
+ children: [
981
+ /* @__PURE__ */ t(I, {
982
+ size: "small",
983
+ label: "Qty",
984
+ type: "number",
985
+ inputProps: {
986
+ min: 1,
987
+ max: e.requestedQuantity,
988
+ style: { textAlign: "right" }
989
+ },
990
+ value: s.quantity,
991
+ onChange: (L) => rt(e.id, s.key, L.target.value, e.requestedQuantity),
992
+ onBlur: () => E(`${s.key}:quantity`),
993
+ error: x(`${s.key}:quantity`) && !!y[`${s.key}:quantity`],
994
+ helperText: x(`${s.key}:quantity`) && y[`${s.key}:quantity`] || ""
995
+ }),
996
+ /* @__PURE__ */ t(I, {
997
+ size: "small",
998
+ label: "Lot number",
999
+ value: s.lotNumber,
1000
+ onChange: (L) => P(e.id, s.key, "lotNumber", L.target.value),
1001
+ onBlur: () => E(`${s.key}:lotNumber`),
1002
+ error: x(`${s.key}:lotNumber`) && !!y[`${s.key}:lotNumber`],
1003
+ helperText: x(`${s.key}:lotNumber`) && y[`${s.key}:lotNumber`] || "",
1004
+ inputProps: { style: {
1005
+ fontFamily: "monospace",
1006
+ fontSize: "0.8rem"
1007
+ } }
1008
+ }),
1009
+ /* @__PURE__ */ t(I, {
1010
+ size: "small",
1011
+ label: "Expiry",
1012
+ type: "date",
1013
+ InputLabelProps: { shrink: !0 },
1014
+ value: s.expiryDate,
1015
+ onChange: (L) => P(e.id, s.key, "expiryDate", L.target.value),
1016
+ onBlur: () => E(`${s.key}:expiryDate`),
1017
+ error: x(`${s.key}:expiryDate`) && !!y[`${s.key}:expiryDate`],
1018
+ helperText: x(`${s.key}:expiryDate`) && y[`${s.key}:expiryDate`] || ""
1019
+ }),
1020
+ /* @__PURE__ */ t(I, {
1021
+ size: "small",
1022
+ label: "Manufactured",
1023
+ type: "date",
1024
+ InputLabelProps: { shrink: !0 },
1025
+ value: s.manufactureDate ?? "",
1026
+ onChange: (L) => P(e.id, s.key, "manufactureDate", L.target.value),
1027
+ onBlur: () => E(`${s.key}:manufactureDate`),
1028
+ error: x(`${s.key}:manufactureDate`) && !!y[`${s.key}:manufactureDate`],
1029
+ helperText: x(`${s.key}:manufactureDate`) ? y[`${s.key}:manufactureDate`] || "" : "Optional"
1030
+ })
1031
+ ]
1032
+ })]
1033
+ }, s.key))
1034
+ }),
1035
+ /* @__PURE__ */ t(Dt, {
1036
+ title: h === 0 ? "All requested quantity is already allocated" : "",
1037
+ children: /* @__PURE__ */ t("span", { children: /* @__PURE__ */ t(q, {
1038
+ size: "small",
1039
+ startIcon: /* @__PURE__ */ t(xr, {}),
1040
+ sx: { mt: 1 },
1041
+ disabled: h <= 0,
1042
+ onClick: () => Bt(e.id),
1043
+ children: h > 0 ? `Add batch (${h} left)` : "Fully allocated"
1044
+ }) })
1045
+ })
1046
+ ] }) : /* @__PURE__ */ n(C, {
1047
+ sx: {
1048
+ display: "grid",
1049
+ gridTemplateColumns: {
1050
+ xs: "1fr",
1051
+ sm: "110px minmax(0, 1fr) 170px 170px"
1052
+ },
1053
+ gap: 1.5
1054
+ },
1055
+ children: [
1056
+ /* @__PURE__ */ t(I, {
1057
+ size: "small",
1058
+ label: "Qty",
1059
+ type: "number",
1060
+ inputProps: {
1061
+ min: 1,
1062
+ max: e.requestedQuantity,
1063
+ style: { textAlign: "right" }
1064
+ },
1065
+ value: ((w = o[0]) == null ? void 0 : w.quantity) ?? "",
1066
+ onChange: (s) => rt(e.id, o[0].key, s.target.value, e.requestedQuantity),
1067
+ onBlur: () => {
1068
+ var s;
1069
+ return E(`${(s = o[0]) == null ? void 0 : s.key}:quantity`);
1070
+ },
1071
+ error: x(`${(oe = o[0]) == null ? void 0 : oe.key}:quantity`) && !!y[`${(se = o[0]) == null ? void 0 : se.key}:quantity`],
1072
+ helperText: x(`${(ge = o[0]) == null ? void 0 : ge.key}:quantity`) && y[`${(ce = o[0]) == null ? void 0 : ce.key}:quantity`] || ""
1073
+ }),
1074
+ /* @__PURE__ */ t(I, {
1075
+ size: "small",
1076
+ label: "Lot number",
1077
+ value: ((j = o[0]) == null ? void 0 : j.lotNumber) ?? "",
1078
+ onChange: (s) => P(e.id, o[0].key, "lotNumber", s.target.value),
1079
+ onBlur: () => {
1080
+ var s;
1081
+ return E(`${(s = o[0]) == null ? void 0 : s.key}:lotNumber`);
1082
+ },
1083
+ error: x(`${(ve = o[0]) == null ? void 0 : ve.key}:lotNumber`) && !!y[`${(lt = o[0]) == null ? void 0 : lt.key}:lotNumber`],
1084
+ helperText: x(`${(ot = o[0]) == null ? void 0 : ot.key}:lotNumber`) && y[`${(st = o[0]) == null ? void 0 : st.key}:lotNumber`] || "",
1085
+ inputProps: { style: {
1086
+ fontFamily: "monospace",
1087
+ fontSize: "0.8rem"
1088
+ } }
1089
+ }),
1090
+ /* @__PURE__ */ t(I, {
1091
+ size: "small",
1092
+ label: "Expiry",
1093
+ type: "date",
1094
+ InputLabelProps: { shrink: !0 },
1095
+ value: ((ct = o[0]) == null ? void 0 : ct.expiryDate) ?? "",
1096
+ onChange: (s) => P(e.id, o[0].key, "expiryDate", s.target.value),
1097
+ onBlur: () => {
1098
+ var s;
1099
+ return E(`${(s = o[0]) == null ? void 0 : s.key}:expiryDate`);
1100
+ },
1101
+ error: x(`${(ut = o[0]) == null ? void 0 : ut.key}:expiryDate`) && !!y[`${(dt = o[0]) == null ? void 0 : dt.key}:expiryDate`],
1102
+ helperText: x(`${(ht = o[0]) == null ? void 0 : ht.key}:expiryDate`) && y[`${(mt = o[0]) == null ? void 0 : mt.key}:expiryDate`] || ""
1103
+ }),
1104
+ /* @__PURE__ */ t(I, {
1105
+ size: "small",
1106
+ label: "Manufactured",
1107
+ type: "date",
1108
+ InputLabelProps: { shrink: !0 },
1109
+ value: ((pt = o[0]) == null ? void 0 : pt.manufactureDate) ?? "",
1110
+ onChange: (s) => P(e.id, o[0].key, "manufactureDate", s.target.value),
1111
+ onBlur: () => {
1112
+ var s;
1113
+ return E(`${(s = o[0]) == null ? void 0 : s.key}:manufactureDate`);
1114
+ },
1115
+ error: x(`${(yt = o[0]) == null ? void 0 : yt.key}:manufactureDate`) && !!y[`${(bt = o[0]) == null ? void 0 : bt.key}:manufactureDate`],
1116
+ helperText: x(`${(ft = o[0]) == null ? void 0 : ft.key}:manufactureDate`) ? y[`${(xt = o[0]) == null ? void 0 : xt.key}:manufactureDate`] || "" : "Optional"
1117
+ })
1118
+ ]
1119
+ }),
1120
+ (Te || Lt(e.id)) && p ? /* @__PURE__ */ t(d, {
1121
+ variant: "caption",
1122
+ color: "error",
1123
+ sx: {
1124
+ display: "block",
1125
+ mt: 1
1126
+ },
1127
+ children: p
1128
+ }) : null
1129
+ ] }) : /* @__PURE__ */ t(d, {
1130
+ variant: "caption",
1131
+ color: "text.disabled",
1132
+ sx: {
1133
+ display: "block",
1134
+ mt: 1.5
1135
+ },
1136
+ children: "This item will be rejected — no stock will be received for it."
1137
+ })]
1138
+ })
1139
+ }, e.id);
1140
+ })
1141
+ }),
1142
+ /* @__PURE__ */ t(ue, {
1143
+ sx: {
1144
+ borderRadius: 1.5,
1145
+ mb: 2,
1146
+ border: "1px solid",
1147
+ borderColor: "divider"
1148
+ },
1149
+ children: /* @__PURE__ */ n(de, {
1150
+ sx: { p: 2.5 },
1151
+ children: [/* @__PURE__ */ n(m, {
1152
+ direction: {
1153
+ xs: "column",
1154
+ md: "row"
1155
+ },
1156
+ spacing: 2,
1157
+ alignItems: { md: "flex-start" },
1158
+ children: [/* @__PURE__ */ t(I, {
1159
+ fullWidth: !0,
1160
+ size: "small",
1161
+ multiline: !0,
1162
+ minRows: 2,
1163
+ label: "Decision notes (optional)",
1164
+ placeholder: "Shown to the requester",
1165
+ value: $e,
1166
+ onChange: (e) => Ye(e.target.value)
1167
+ }), X && at != null ? /* @__PURE__ */ n(C, {
1168
+ sx: (e) => ({
1169
+ minWidth: 220,
1170
+ p: 1.5,
1171
+ borderRadius: 1.5,
1172
+ border: "1px solid",
1173
+ borderColor: "divider",
1174
+ bgcolor: J(e.palette.primary.main, 0.04),
1175
+ textAlign: "right"
1176
+ }),
1177
+ children: [/* @__PURE__ */ t(Re, { children: "Total if approved" }), /* @__PURE__ */ t(vt, {
1178
+ value: Number(at.toFixed(2)),
1179
+ size: "big"
1180
+ })]
1181
+ }) : null]
1182
+ }), /* @__PURE__ */ t(m, {
1183
+ direction: "row",
1184
+ spacing: 1,
1185
+ justifyContent: "flex-end",
1186
+ sx: { mt: 2 },
1187
+ flexWrap: "wrap",
1188
+ useFlexGap: !0,
1189
+ children: Ft ? /* @__PURE__ */ n($, { children: [/* @__PURE__ */ t(q, {
1190
+ variant: "outlined",
1191
+ color: "error",
1192
+ startIcon: /* @__PURE__ */ t(De, {}),
1193
+ disabled: f,
1194
+ onClick: () => te(!0),
1195
+ children: "Reject Request"
1196
+ }), /* @__PURE__ */ t(q, {
1197
+ variant: "contained",
1198
+ startIcon: /* @__PURE__ */ t(ze, {}),
1199
+ disabled: f,
1200
+ onClick: () => void Qt(),
1201
+ children: f ? "Submitting…" : "Submit Decision"
1202
+ })] }) : /* @__PURE__ */ t(q, {
1203
+ variant: "contained",
1204
+ color: "error",
1205
+ startIcon: /* @__PURE__ */ t(De, {}),
1206
+ disabled: f,
1207
+ onClick: () => te(!0),
1208
+ children: "Reject Request"
1209
+ })
1210
+ })]
1211
+ })
1212
+ })
1213
+ ] }) : /* @__PURE__ */ t(ue, {
1214
+ sx: {
1215
+ borderRadius: 1.5,
1216
+ mb: 2,
1217
+ border: "1px solid",
1218
+ borderColor: "divider",
1219
+ boxShadow: "0 12px 32px rgba(15, 23, 42, 0.045)"
1220
+ },
1221
+ children: /* @__PURE__ */ n(de, {
1222
+ sx: { p: 2.5 },
1223
+ children: [
1224
+ /* @__PURE__ */ t(gt, {
1225
+ eyebrow: "Items",
1226
+ title: G ? "Check what arrived" : "Items & outcome",
1227
+ hint: G ? "Mark each batch OK if its lot and expiry match what you received, or flag it if something is off. Then submit." : "What was approved or rejected per item, the batches, and where each ended up."
1228
+ }),
1229
+ /* @__PURE__ */ t(m, {
1230
+ spacing: 1.5,
1231
+ sx: { mt: 1.5 },
1232
+ children: a.items.map((e) => {
1233
+ let i = a.status !== "PENDING", r = e.approvedQuantity, l = i && !(r > 0), o = i ? l ? {
1234
+ label: "Rejected",
1235
+ color: "default"
1236
+ } : r >= e.requestedQuantity ? {
1237
+ label: "Approved in full",
1238
+ color: "success"
1239
+ } : {
1240
+ label: `Partially approved · ${r} of ${e.requestedQuantity}`,
1241
+ color: "warning"
1242
+ } : {
1243
+ label: "Awaiting approval",
1244
+ color: "info"
1245
+ }, u = (e.batches ?? []).filter((c) => (c.quantity ?? 0) > 0 && (c.lotNumber || c.expiryDate)), h = G || u.some((c) => c.receiptStatus != null), p = 4 + +(a.ownerType === "FACILITY") + +!!h;
1246
+ return /* @__PURE__ */ n(C, {
1247
+ sx: {
1248
+ p: 1.5,
1249
+ border: "1px solid",
1250
+ borderColor: "divider",
1251
+ borderRadius: 1.5
1252
+ },
1253
+ children: [/* @__PURE__ */ n(m, {
1254
+ direction: {
1255
+ xs: "column",
1256
+ sm: "row"
1257
+ },
1258
+ justifyContent: "space-between",
1259
+ alignItems: { sm: "center" },
1260
+ spacing: 1,
1261
+ sx: { mb: +!!u.length },
1262
+ children: [/* @__PURE__ */ n(C, { children: [/* @__PURE__ */ t(d, {
1263
+ variant: "subtitle2",
1264
+ sx: { fontWeight: 800 },
1265
+ children: e.productName
1266
+ }), /* @__PURE__ */ n(d, {
1267
+ variant: "caption",
1268
+ color: "text.secondary",
1269
+ children: [
1270
+ "Requested ",
1271
+ e.requestedQuantity,
1272
+ r == null ? "" : ` · Approved ${r}`
1273
+ ]
1274
+ })] }), /* @__PURE__ */ t(R, {
1275
+ size: "small",
1276
+ color: o.color,
1277
+ label: o.label,
1278
+ sx: { fontWeight: 700 }
1279
+ })]
1280
+ }), u.length > 0 ? /* @__PURE__ */ n(dr, {
1281
+ size: "small",
1282
+ children: [/* @__PURE__ */ t(hr, { children: /* @__PURE__ */ n(Ce, { children: [
1283
+ /* @__PURE__ */ t(k, { children: "Lot" }),
1284
+ /* @__PURE__ */ t(k, { children: "Expiry" }),
1285
+ /* @__PURE__ */ t(k, { children: "Manufactured" }),
1286
+ /* @__PURE__ */ t(k, {
1287
+ align: "right",
1288
+ children: "Qty"
1289
+ }),
1290
+ a.ownerType === "FACILITY" ? /* @__PURE__ */ t(k, { children: "Storage" }) : null,
1291
+ h ? /* @__PURE__ */ t(k, {
1292
+ align: "center",
1293
+ sx: { width: 200 },
1294
+ children: G ? "Condition" : "Receipt"
1295
+ }) : null
1296
+ ] }) }), /* @__PURE__ */ t(mr, { children: u.map((c, w) => {
1297
+ let oe = ee[c.batchId] ?? "OK", se = G && c.batchId && c.receiptStatus == null, ge = se && oe === "ISSUE";
1298
+ return /* @__PURE__ */ n(cr, { children: [/* @__PURE__ */ n(Ce, { children: [
1299
+ /* @__PURE__ */ t(k, {
1300
+ sx: {
1301
+ fontFamily: "monospace",
1302
+ fontSize: "0.8rem"
1303
+ },
1304
+ children: c.lotNumber || "—"
1305
+ }),
1306
+ /* @__PURE__ */ t(k, { children: c.expiryDate ? Ae(c.expiryDate) : "—" }),
1307
+ /* @__PURE__ */ t(k, { children: c.manufactureDate ? Ae(c.manufactureDate) : "—" }),
1308
+ /* @__PURE__ */ t(k, {
1309
+ align: "right",
1310
+ sx: {
1311
+ fontVariantNumeric: "tabular-nums",
1312
+ fontWeight: 700
1313
+ },
1314
+ children: c.quantity
1315
+ }),
1316
+ a.ownerType === "FACILITY" ? /* @__PURE__ */ t(k, { children: c.storageUnitName || "—" }) : null,
1317
+ h ? /* @__PURE__ */ t(k, {
1318
+ align: "center",
1319
+ children: se ? /* @__PURE__ */ n(ke, {
1320
+ size: "small",
1321
+ exclusive: !0,
1322
+ value: oe,
1323
+ onChange: (ce, j) => {
1324
+ j && Ue((ve) => ({
1325
+ ...ve,
1326
+ [c.batchId]: j
1327
+ }));
1328
+ },
1329
+ children: [/* @__PURE__ */ n(B, {
1330
+ value: "OK",
1331
+ color: "success",
1332
+ sx: {
1333
+ textTransform: "none",
1334
+ px: 1.25
1335
+ },
1336
+ children: [/* @__PURE__ */ t(ze, {
1337
+ fontSize: "small",
1338
+ sx: { mr: 0.5 }
1339
+ }), " OK"]
1340
+ }), /* @__PURE__ */ n(B, {
1341
+ value: "ISSUE",
1342
+ color: "error",
1343
+ sx: {
1344
+ textTransform: "none",
1345
+ px: 1.25
1346
+ },
1347
+ children: [/* @__PURE__ */ t(qe, {
1348
+ fontSize: "small",
1349
+ sx: { mr: 0.5 }
1350
+ }), " Issue"]
1351
+ })]
1352
+ }) : c.receiptStatus === "RECEIVED" ? /* @__PURE__ */ t(R, {
1353
+ size: "small",
1354
+ color: "success",
1355
+ variant: "outlined",
1356
+ icon: /* @__PURE__ */ t(ze, {}),
1357
+ label: "Received",
1358
+ sx: { fontWeight: 700 }
1359
+ }) : c.receiptStatus === "DISCREPANCY" ? /* @__PURE__ */ t(R, {
1360
+ size: "small",
1361
+ color: "error",
1362
+ variant: "outlined",
1363
+ icon: /* @__PURE__ */ t(qe, {}),
1364
+ label: "Discrepancy",
1365
+ sx: { fontWeight: 700 }
1366
+ }) : c.receiptStatus === "REJECTED" ? /* @__PURE__ */ t(R, {
1367
+ size: "small",
1368
+ color: "error",
1369
+ variant: "outlined",
1370
+ icon: /* @__PURE__ */ t(wr, {}),
1371
+ label: "Not supplied",
1372
+ sx: { fontWeight: 700 }
1373
+ }) : At ? /* @__PURE__ */ t(R, {
1374
+ size: "small",
1375
+ color: "info",
1376
+ variant: "outlined",
1377
+ icon: /* @__PURE__ */ t(Rr, {}),
1378
+ label: "Awaiting check",
1379
+ sx: { fontWeight: 700 }
1380
+ }) : /* @__PURE__ */ t(d, {
1381
+ variant: "caption",
1382
+ color: "text.disabled",
1383
+ children: "—"
1384
+ })
1385
+ }) : null
1386
+ ] }), ge ? /* @__PURE__ */ t(Ce, { children: /* @__PURE__ */ t(k, {
1387
+ colSpan: p,
1388
+ sx: { py: 1 },
1389
+ children: /* @__PURE__ */ t(I, {
1390
+ fullWidth: !0,
1391
+ size: "small",
1392
+ required: !0,
1393
+ label: "What is wrong with this batch?",
1394
+ placeholder: "Say what did not match so the approver knows what to fix.",
1395
+ value: Ee[c.batchId] ?? "",
1396
+ onChange: (ce) => Ge((j) => ({
1397
+ ...j,
1398
+ [c.batchId]: ce.target.value
1399
+ }))
1400
+ })
1401
+ }) }) : c.discrepancyReason ? /* @__PURE__ */ t(Ce, { children: /* @__PURE__ */ t(k, {
1402
+ colSpan: p,
1403
+ sx: {
1404
+ py: 0.5,
1405
+ borderBottom: "none"
1406
+ },
1407
+ children: /* @__PURE__ */ n(d, {
1408
+ variant: "caption",
1409
+ color: "text.secondary",
1410
+ sx: { fontStyle: "italic" },
1411
+ children: [
1412
+ "“",
1413
+ c.discrepancyReason,
1414
+ "”"
1415
+ ]
1416
+ })
1417
+ }) }) : null] }, c.batchId || `${e.id}:${w}`);
1418
+ }) })]
1419
+ }) : l ? /* @__PURE__ */ t(d, {
1420
+ variant: "caption",
1421
+ color: "text.disabled",
1422
+ children: "No stock received for this item."
1423
+ }) : i ? null : /* @__PURE__ */ t(d, {
1424
+ variant: "caption",
1425
+ color: "text.disabled",
1426
+ children: "Waiting for the approver's decision."
1427
+ })]
1428
+ }, e.id);
1429
+ })
1430
+ }),
1431
+ Pt ? /* @__PURE__ */ t(m, {
1432
+ direction: "row",
1433
+ spacing: 1,
1434
+ justifyContent: "flex-end",
1435
+ sx: { mt: 2 },
1436
+ children: /* @__PURE__ */ t(q, {
1437
+ variant: "contained",
1438
+ startIcon: /* @__PURE__ */ t(Cr, {}),
1439
+ disabled: f,
1440
+ onClick: () => void Ut(),
1441
+ children: f ? "Updating…" : "Mark In Transit"
1442
+ })
1443
+ }) : null,
1444
+ G ? /* @__PURE__ */ n($, { children: [ie ? /* @__PURE__ */ t(I, {
1445
+ sx: { mt: 2 },
1446
+ fullWidth: !0,
1447
+ size: "small",
1448
+ multiline: !0,
1449
+ minRows: 2,
1450
+ label: "Anything else about this delivery? (optional)",
1451
+ placeholder: "Only if something applies to the shipment as a whole.",
1452
+ value: Ke,
1453
+ onChange: (e) => _e(e.target.value)
1454
+ }) : null, /* @__PURE__ */ n(m, {
1455
+ direction: {
1456
+ xs: "column",
1457
+ sm: "row"
1458
+ },
1459
+ spacing: 1,
1460
+ justifyContent: "flex-end",
1461
+ alignItems: { sm: "center" },
1462
+ sx: { mt: 2 },
1463
+ children: [ie ? /* @__PURE__ */ t(d, {
1464
+ variant: "caption",
1465
+ color: "text.secondary",
1466
+ sx: { mr: "auto" },
1467
+ children: ne ? "Every batch is flagged, so the whole shipment goes back to the approver." : `${xe.length} batch${xe.length === 1 ? "" : "es"} will come into inventory; the flagged ${O.length === 1 ? "one goes" : "ones go"} back to the approver.`
1468
+ }) : null, /* @__PURE__ */ t(q, {
1469
+ variant: "contained",
1470
+ color: ne ? "error" : "primary",
1471
+ startIcon: t(ne ? qe : kr, {}),
1472
+ disabled: f || !Vt,
1473
+ onClick: () => void Kt(),
1474
+ children: f ? "Submitting…" : ne ? "Send Back to Approver" : ie ? "Receive OK & Flag Issues" : "Receive into Inventory"
1475
+ })]
1476
+ })] }) : null,
1477
+ Ze && et ? /* @__PURE__ */ t(m, {
1478
+ direction: "row",
1479
+ spacing: 1,
1480
+ justifyContent: "flex-end",
1481
+ sx: { mt: 2 },
1482
+ children: /* @__PURE__ */ t(q, {
1483
+ variant: "outlined",
1484
+ color: "error",
1485
+ startIcon: /* @__PURE__ */ t(De, {}),
1486
+ disabled: f,
1487
+ onClick: () => void _t(),
1488
+ children: f ? "Cancelling…" : "Cancel Request"
1489
+ })
1490
+ }) : null,
1491
+ a.approvedPurchaseId ? /* @__PURE__ */ n(Be, {
1492
+ severity: "success",
1493
+ sx: { mt: 2 },
1494
+ children: [
1495
+ "Stock was added to inventory under purchase id ",
1496
+ /* @__PURE__ */ t("strong", { children: a.approvedPurchaseId }),
1497
+ "."
1498
+ ]
1499
+ }) : null
1500
+ ]
1501
+ })
1502
+ })
1503
+ ] }) : null]
1504
+ }), /* @__PURE__ */ n(pr, {
1505
+ open: Rt,
1506
+ onClose: () => f ? null : te(!1),
1507
+ fullWidth: !0,
1508
+ maxWidth: "xs",
1509
+ children: [
1510
+ /* @__PURE__ */ t(yr, { children: "Reject this request?" }),
1511
+ /* @__PURE__ */ t(br, {
1512
+ dividers: !0,
1513
+ children: /* @__PURE__ */ t(d, {
1514
+ variant: "body2",
1515
+ color: "text.secondary",
1516
+ children: "Every item will be rejected and no stock will be received. This closes the request."
1517
+ })
1518
+ }),
1519
+ /* @__PURE__ */ n(fr, { children: [/* @__PURE__ */ t(q, {
1520
+ onClick: () => te(!1),
1521
+ disabled: f,
1522
+ children: "Cancel"
1523
+ }), /* @__PURE__ */ t(q, {
1524
+ variant: "contained",
1525
+ color: "error",
1526
+ startIcon: /* @__PURE__ */ t(De, {}),
1527
+ disabled: f,
1528
+ onClick: () => void Yt(),
1529
+ children: f ? "Rejecting…" : "Reject Request"
1530
+ })] })
1531
+ ]
1532
+ })]
1533
+ })] });
1534
+ }
1535
+ function Re({ children: g }) {
1536
+ return /* @__PURE__ */ t(d, {
1537
+ variant: "caption",
1538
+ color: "text.secondary",
1539
+ sx: {
1540
+ display: "block",
1541
+ mb: 0.5,
1542
+ fontWeight: 700,
1543
+ textTransform: "uppercase",
1544
+ letterSpacing: 0.6
1545
+ },
1546
+ children: g
1547
+ });
1548
+ }
1549
+ function M({ label: g, children: z }) {
1550
+ return /* @__PURE__ */ n(m, {
1551
+ direction: "row",
1552
+ spacing: 1,
1553
+ sx: { minWidth: 0 },
1554
+ children: [/* @__PURE__ */ t(d, {
1555
+ variant: "caption",
1556
+ color: "text.secondary",
1557
+ sx: {
1558
+ minWidth: 100,
1559
+ fontWeight: 700,
1560
+ textTransform: "uppercase",
1561
+ letterSpacing: 0.5
1562
+ },
1563
+ children: g
1564
+ }), /* @__PURE__ */ t(d, {
1565
+ variant: "caption",
1566
+ sx: {
1567
+ minWidth: 0,
1568
+ fontWeight: 700
1569
+ },
1570
+ children: z
1571
+ })]
1572
+ });
1573
+ }
1574
+ export {
1575
+ Zr as default
1576
+ };
1577
+ //# sourceMappingURL=PurchaseRequestDetailPage-CA9KFOfE-CtjG4Gx6.js.map