@burdenoff/microfe-movethewheels 2026.930.5 → 2026.1010.2

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 (375) hide show
  1. package/dist/MoveTheWheelsRoot.js +177 -102
  2. package/dist/MoveTheWheelsRoutes.js +55 -11
  3. package/dist/_virtual/_rolldown/runtime.js +1 -1
  4. package/dist/components/ContainerEvidencePicker.js +143 -0
  5. package/dist/components/FreeTimeAgreementForm.js +496 -0
  6. package/dist/components/ReturnInstructionForm.js +108 -0
  7. package/dist/components/ReuseControls.js +91 -0
  8. package/dist/components/ReusePermissionForm.js +114 -0
  9. package/dist/components/ReuseProposalForm.js +455 -0
  10. package/dist/components/ReuseSourceFields.js +78 -0
  11. package/dist/components/consolidation/ConsolidationHistory.js +244 -0
  12. package/dist/components/consolidation/ConsolidationLotEditor.js +133 -0
  13. package/dist/components/consolidation/ConsolidationManifestWorkbench.js +143 -0
  14. package/dist/components/consolidation/ConsolidationPlanForm.js +172 -0
  15. package/dist/components/consolidation/ConsolidationPlanWorkbench.js +321 -0
  16. package/dist/components/consolidation/ConsolidationReportForm.js +94 -0
  17. package/dist/components/consolidation/ConsolidationReportsWorkbench.js +195 -0
  18. package/dist/components/consolidation/ConsolidationSummary.js +76 -0
  19. package/dist/components/consolidation/OriginalConsolidationHistory.js +112 -0
  20. package/dist/components/freight-cost/FreightDraftForm.js +213 -0
  21. package/dist/components/freight-cost/FreightFields.js +70 -0
  22. package/dist/components/freight-cost/FreightFxEditor.js +90 -0
  23. package/dist/components/freight-cost/FreightHistory.js +164 -0
  24. package/dist/components/freight-cost/FreightLineEditor.js +191 -0
  25. package/dist/components/freight-cost/FreightScopeEditor.js +72 -0
  26. package/dist/components/freight-cost/FreightTotals.js +66 -0
  27. package/dist/components/logistics-procedure/ProcedureDecisionForm.js +197 -0
  28. package/dist/components/logistics-procedure/ProcedureFields.js +31 -0
  29. package/dist/components/logistics-procedure/ProcedureHistory.js +177 -0
  30. package/dist/components/logistics-procedure/ProcedurePolicyForm.js +227 -0
  31. package/dist/components/logistics-procedure/ProcedurePolicyWorkbench.js +155 -0
  32. package/dist/components/logistics-procedure/ProcedureReviewWorkbench.js +221 -0
  33. package/dist/components/logistics-procedure/ProcedureRunWorkbench.js +190 -0
  34. package/dist/components/logistics-procedure/ProcedureSubjectPicker.js +130 -0
  35. package/dist/components/pending-pick/PendingPickDraft.js +84 -0
  36. package/dist/components/pending-pick/PendingPickHistory.js +113 -0
  37. package/dist/components/pending-pick/PickCapture.js +166 -0
  38. package/dist/components/pending-pick/PickLineSelection.js +111 -0
  39. package/dist/components/stock-binding/StockAssessmentDraft.js +48 -0
  40. package/dist/components/stock-binding/StockAssessmentHistory.js +61 -0
  41. package/dist/components/stock-binding/StockAssessmentSummary.js +199 -0
  42. package/dist/components/stock-binding/StockFactForm.js +232 -0
  43. package/dist/components/stock-observation/StockIssueForm.js +148 -0
  44. package/dist/components/stock-observation/StockIssueHistory.js +116 -0
  45. package/dist/components/stock-observation/StockIssueReadPanel.js +70 -0
  46. package/dist/components/trip-utilization/TripReportForm.js +118 -0
  47. package/dist/components/trip-utilization/TripReportHistory.js +54 -0
  48. package/dist/components/trip-utilization/TripReportSummary.js +216 -0
  49. package/dist/components/trip-utilization/TripSegmentFields.js +166 -0
  50. package/dist/generated/consolidation-operations.d.ts +1060 -0
  51. package/dist/generated/container-condition-operations.d.ts +868 -0
  52. package/dist/generated/container-operations.d.ts +356 -0
  53. package/dist/generated/empty-reuse-operations.d.ts +1578 -0
  54. package/dist/generated/free-time-operations.d.ts +938 -0
  55. package/dist/generated/freight-cost-operations.d.ts +716 -0
  56. package/dist/generated/logistics-procedure-operations.d.ts +938 -0
  57. package/dist/generated/pending-pick-operations.d.ts +1969 -0
  58. package/dist/generated/stock-binding-operations.d.ts +930 -0
  59. package/dist/generated/stock-observation-operations.d.ts +476 -0
  60. package/dist/generated/trip-utilization-operations.d.ts +651 -0
  61. package/dist/generated/wspace-operations.d.ts +143 -50
  62. package/dist/hooks/useConsolidationAction.js +119 -0
  63. package/dist/hooks/useContainerCondition.js +105 -0
  64. package/dist/hooks/useContainerLifecycle.js +192 -0
  65. package/dist/hooks/useEmptyReuseAction.js +45 -0
  66. package/dist/hooks/useFreightRecoveryAction.js +117 -0
  67. package/dist/hooks/useMultiModalShipments.js +1 -1
  68. package/dist/hooks/useProcedureAction.js +119 -0
  69. package/dist/hooks/useProcedureSelection.js +53 -0
  70. package/dist/hooks/useReuseRecoveryAction.js +116 -0
  71. package/dist/movethewheels/components/ContainerEvidencePicker.d.ts +10 -0
  72. package/dist/movethewheels/components/FreeTimeAgreementForm.d.ts +14 -0
  73. package/dist/movethewheels/components/ReturnInstructionForm.d.ts +8 -0
  74. package/dist/movethewheels/components/ReuseControls.d.ts +42 -0
  75. package/dist/movethewheels/components/ReusePermissionForm.d.ts +9 -0
  76. package/dist/movethewheels/components/ReuseProposalForm.d.ts +11 -0
  77. package/dist/movethewheels/components/ReuseSourceFields.d.ts +9 -0
  78. package/dist/movethewheels/components/consolidation/ConsolidationHistory.d.ts +13 -0
  79. package/dist/movethewheels/components/consolidation/ConsolidationLotEditor.d.ts +6 -0
  80. package/dist/movethewheels/components/consolidation/ConsolidationManifestWorkbench.d.ts +8 -0
  81. package/dist/movethewheels/components/consolidation/ConsolidationPlanForm.d.ts +8 -0
  82. package/dist/movethewheels/components/consolidation/ConsolidationPlanWorkbench.d.ts +5 -0
  83. package/dist/movethewheels/components/consolidation/ConsolidationReportForm.d.ts +9 -0
  84. package/dist/movethewheels/components/consolidation/ConsolidationReportsWorkbench.d.ts +7 -0
  85. package/dist/movethewheels/components/consolidation/ConsolidationSummary.d.ts +6 -0
  86. package/dist/movethewheels/components/consolidation/OriginalConsolidationHistory.d.ts +8 -0
  87. package/dist/movethewheels/components/freight-cost/FreightDraftForm.d.ts +8 -0
  88. package/dist/movethewheels/components/freight-cost/FreightFields.d.ts +23 -0
  89. package/dist/movethewheels/components/freight-cost/FreightFxEditor.d.ts +6 -0
  90. package/dist/movethewheels/components/freight-cost/FreightHistory.d.ts +5 -0
  91. package/dist/movethewheels/components/freight-cost/FreightLineEditor.d.ts +8 -0
  92. package/dist/movethewheels/components/freight-cost/FreightScopeEditor.d.ts +6 -0
  93. package/dist/movethewheels/components/freight-cost/FreightTotals.d.ts +6 -0
  94. package/dist/movethewheels/components/logistics-procedure/ProcedureDecisionForm.d.ts +20 -0
  95. package/dist/movethewheels/components/logistics-procedure/ProcedureFields.d.ts +17 -0
  96. package/dist/movethewheels/components/logistics-procedure/ProcedureHistory.d.ts +7 -0
  97. package/dist/movethewheels/components/logistics-procedure/ProcedurePolicyForm.d.ts +10 -0
  98. package/dist/movethewheels/components/logistics-procedure/ProcedurePolicyWorkbench.d.ts +5 -0
  99. package/dist/movethewheels/components/logistics-procedure/ProcedureReviewWorkbench.d.ts +5 -0
  100. package/dist/movethewheels/components/logistics-procedure/ProcedureRunWorkbench.d.ts +6 -0
  101. package/dist/movethewheels/components/logistics-procedure/ProcedureSubjectPicker.d.ts +7 -0
  102. package/dist/movethewheels/components/pending-pick/PendingPickDraft.d.ts +16 -0
  103. package/dist/movethewheels/components/pending-pick/PendingPickHistory.d.ts +5 -0
  104. package/dist/movethewheels/components/pending-pick/PickCapture.d.ts +6 -0
  105. package/dist/movethewheels/components/pending-pick/PickLineSelection.d.ts +17 -0
  106. package/dist/movethewheels/components/stock-binding/StockAssessmentDraft.d.ts +13 -0
  107. package/dist/movethewheels/components/stock-binding/StockAssessmentHistory.d.ts +18 -0
  108. package/dist/movethewheels/components/stock-binding/StockAssessmentSummary.d.ts +9 -0
  109. package/dist/movethewheels/components/stock-binding/StockFactForm.d.ts +6 -0
  110. package/dist/movethewheels/components/stock-observation/StockIssueForm.d.ts +7 -0
  111. package/dist/movethewheels/components/stock-observation/StockIssueHistory.d.ts +7 -0
  112. package/dist/movethewheels/components/stock-observation/StockIssueReadPanel.d.ts +5 -0
  113. package/dist/movethewheels/components/trip-utilization/TripReportForm.d.ts +6 -0
  114. package/dist/movethewheels/components/trip-utilization/TripReportHistory.d.ts +14 -0
  115. package/dist/movethewheels/components/trip-utilization/TripReportSummary.d.ts +5 -0
  116. package/dist/movethewheels/components/trip-utilization/TripSegmentFields.d.ts +9 -0
  117. package/dist/movethewheels/hooks/useConsolidationAction.d.ts +19 -0
  118. package/dist/movethewheels/hooks/useContainerCondition.d.ts +21 -0
  119. package/dist/movethewheels/hooks/useContainerLifecycle.d.ts +40 -0
  120. package/dist/movethewheels/hooks/useEmptyReuseAction.d.ts +14 -0
  121. package/dist/movethewheels/hooks/useFreightRecoveryAction.d.ts +23 -0
  122. package/dist/movethewheels/hooks/useProcedureAction.d.ts +18 -0
  123. package/dist/movethewheels/hooks/useProcedureSelection.d.ts +51 -0
  124. package/dist/movethewheels/hooks/useReuseRecoveryAction.d.ts +18 -0
  125. package/dist/movethewheels/pages/ConsolidationPage.d.ts +1 -0
  126. package/dist/movethewheels/pages/ContainerConditionPage.d.ts +1 -0
  127. package/dist/movethewheels/pages/ContainersPage.d.ts +2 -0
  128. package/dist/movethewheels/pages/EmptyReusePage.d.ts +1 -0
  129. package/dist/movethewheels/pages/FreeTimePage.d.ts +1 -0
  130. package/dist/movethewheels/pages/FreightEstimatePage.d.ts +1 -0
  131. package/dist/movethewheels/pages/LogisticsProceduresPage.d.ts +1 -0
  132. package/dist/movethewheels/pages/PendingPickPage.d.ts +1 -0
  133. package/dist/movethewheels/pages/StockBindingPage.d.ts +1 -0
  134. package/dist/movethewheels/pages/StockObservationsPage.d.ts +1 -0
  135. package/dist/movethewheels/pages/TripUtilizationPage.d.ts +1 -0
  136. package/dist/movethewheels/utils/consolidationHistoryTarget.d.ts +12 -0
  137. package/dist/movethewheels/utils/consolidationInput.d.ts +15 -0
  138. package/dist/movethewheels/utils/consolidationLot.d.ts +3 -0
  139. package/dist/movethewheels/utils/consolidationPins.d.ts +20 -0
  140. package/dist/movethewheels/utils/consolidationRecovery.d.ts +5 -0
  141. package/dist/movethewheels/utils/consolidationReportHead.d.ts +5 -0
  142. package/dist/movethewheels/utils/freeTimeDate.d.ts +1 -0
  143. package/dist/movethewheels/utils/freightAcknowledgement.d.ts +2 -0
  144. package/dist/movethewheels/utils/freightDraft.d.ts +36 -0
  145. package/dist/movethewheels/utils/freightRecovery.d.ts +5 -0
  146. package/dist/movethewheels/utils/graphqlClient.d.ts +2 -1
  147. package/dist/movethewheels/utils/pendingPickDraft.d.ts +8 -0
  148. package/dist/movethewheels/utils/procedureInput.d.ts +18 -0
  149. package/dist/movethewheels/utils/procedureRecovery.d.ts +5 -0
  150. package/dist/movethewheels/utils/reuseAttempt.d.ts +7 -0
  151. package/dist/movethewheels/utils/reuseForm.d.ts +6 -0
  152. package/dist/movethewheels/utils/reuseRecovery.d.ts +26 -0
  153. package/dist/movethewheels/utils/stockBindingForm.d.ts +23 -0
  154. package/dist/movethewheels/utils/stockBindingLabels.d.ts +10 -0
  155. package/dist/movethewheels/utils/stockObservationForm.d.ts +5 -0
  156. package/dist/movethewheels/utils/tripDraftContext.d.ts +25 -0
  157. package/dist/movethewheels/utils/tripUtilizationForm.d.ts +6 -0
  158. package/dist/node_modules/@react-leaflet/core/lib/component.js +5 -5
  159. package/dist/node_modules/fast-equals/dist/es/index.js +87 -74
  160. package/dist/node_modules/leaflet/dist/leaflet-src.js +8 -5
  161. package/dist/node_modules/lodash/_Stack.js +2 -1
  162. package/dist/node_modules/lucide-react/dist/esm/icons/clipboard-list.js +35 -0
  163. package/dist/node_modules/lucide-react/dist/esm/icons/repeat-2.js +22 -0
  164. package/dist/node_modules/react-leaflet/lib/MapContainer.js +3 -3
  165. package/dist/node_modules/react-smooth/es6/Animate.js +2 -2
  166. package/dist/node_modules/recharts/es6/cartesian/Area.js +13 -13
  167. package/dist/node_modules/recharts/es6/cartesian/Bar.js +9 -9
  168. package/dist/node_modules/recharts/es6/cartesian/Brush.js +12 -12
  169. package/dist/node_modules/recharts/es6/cartesian/CartesianAxis.js +7 -7
  170. package/dist/node_modules/recharts/es6/cartesian/CartesianGrid.js +13 -13
  171. package/dist/node_modules/recharts/es6/cartesian/ErrorBar.js +4 -4
  172. package/dist/node_modules/recharts/es6/cartesian/Line.js +10 -10
  173. package/dist/node_modules/recharts/es6/cartesian/ReferenceArea.js +3 -3
  174. package/dist/node_modules/recharts/es6/cartesian/ReferenceDot.js +3 -3
  175. package/dist/node_modules/recharts/es6/cartesian/ReferenceLine.js +4 -4
  176. package/dist/node_modules/recharts/es6/cartesian/XAxis.js +3 -3
  177. package/dist/node_modules/recharts/es6/cartesian/YAxis.js +3 -3
  178. package/dist/node_modules/recharts/es6/chart/AccessibilityManager.js +1 -1
  179. package/dist/node_modules/recharts/es6/chart/generateCategoricalChart.js +22 -22
  180. package/dist/node_modules/recharts/es6/component/Cursor.js +1 -1
  181. package/dist/node_modules/recharts/es6/component/DefaultLegendContent.js +11 -11
  182. package/dist/node_modules/recharts/es6/component/DefaultTooltipContent.js +6 -6
  183. package/dist/node_modules/recharts/es6/component/Label.js +14 -14
  184. package/dist/node_modules/recharts/es6/component/LabelList.js +6 -6
  185. package/dist/node_modules/recharts/es6/component/Legend.js +5 -5
  186. package/dist/node_modules/recharts/es6/component/ResponsiveContainer.js +3 -3
  187. package/dist/node_modules/recharts/es6/component/Text.js +2 -2
  188. package/dist/node_modules/recharts/es6/component/Tooltip.js +3 -3
  189. package/dist/node_modules/recharts/es6/component/TooltipBoundingBox.js +2 -2
  190. package/dist/node_modules/recharts/es6/container/Layer.js +2 -2
  191. package/dist/node_modules/recharts/es6/container/Surface.js +2 -2
  192. package/dist/node_modules/recharts/es6/context/chartLayoutContext.js +2 -2
  193. package/dist/node_modules/recharts/es6/polar/Pie.js +13 -13
  194. package/dist/node_modules/recharts/es6/polar/PolarAngleAxis.js +8 -8
  195. package/dist/node_modules/recharts/es6/polar/PolarRadiusAxis.js +6 -6
  196. package/dist/node_modules/recharts/es6/shape/Cross.js +1 -1
  197. package/dist/node_modules/recharts/es6/shape/Curve.js +1 -1
  198. package/dist/node_modules/recharts/es6/shape/Dot.js +1 -1
  199. package/dist/node_modules/recharts/es6/shape/Polygon.js +4 -4
  200. package/dist/node_modules/recharts/es6/shape/Rectangle.js +4 -4
  201. package/dist/node_modules/recharts/es6/shape/Sector.js +1 -1
  202. package/dist/node_modules/recharts/es6/shape/Symbols.js +1 -1
  203. package/dist/node_modules/recharts/es6/shape/Trapezoid.js +4 -4
  204. package/dist/node_modules/recharts/es6/util/ActiveShapeUtils.js +9 -9
  205. package/dist/node_modules/recharts/es6/util/BarUtils.js +1 -1
  206. package/dist/node_modules/recharts/es6/util/CartesianUtils.js +1 -1
  207. package/dist/node_modules/recharts/es6/util/PolarUtils.js +1 -1
  208. package/dist/node_modules/recharts/es6/util/ReactUtils.js +2 -2
  209. package/dist/node_modules/recharts/es6/util/ReduceCSSCalc.js +1 -1
  210. package/dist/node_modules/recharts/es6/util/types.js +1 -1
  211. package/dist/node_modules/{react-is → recharts/node_modules/react-is}/cjs/react-is.development.js +2 -2
  212. package/dist/node_modules/{react-is → recharts/node_modules/react-is}/cjs/react-is.production.min.js +2 -2
  213. package/dist/node_modules/{react-is → recharts/node_modules/react-is}/index.js +2 -2
  214. package/dist/node_modules/tailwind-merge/dist/bundle-mjs.js +97 -18
  215. package/dist/node_modules/zustand/esm/middleware.js +2 -2
  216. package/dist/pages/ConsolidationPage.js +76 -0
  217. package/dist/pages/ContainerConditionPage.js +972 -0
  218. package/dist/pages/ContainersPage.js +522 -0
  219. package/dist/pages/EmptyReusePage.js +777 -0
  220. package/dist/pages/FreeTimePage.js +657 -0
  221. package/dist/pages/FreightEstimatePage.js +284 -0
  222. package/dist/pages/LogisticsProceduresPage.js +100 -0
  223. package/dist/pages/PendingPickPage.js +155 -0
  224. package/dist/pages/StockBindingPage.js +236 -0
  225. package/dist/pages/StockObservationsPage.js +168 -0
  226. package/dist/pages/TripUtilizationPage.js +227 -0
  227. package/dist/src/generated/consolidation-operations.js +505 -0
  228. package/dist/src/generated/container-condition-operations.js +208 -0
  229. package/dist/src/generated/container-operations.js +101 -0
  230. package/dist/src/generated/empty-reuse-operations.js +749 -0
  231. package/dist/src/generated/free-time-operations.js +235 -0
  232. package/dist/src/generated/freight-cost-operations.js +325 -0
  233. package/dist/src/generated/logistics-procedure-operations.js +362 -0
  234. package/dist/src/generated/pending-pick-operations.js +1128 -0
  235. package/dist/src/generated/stock-binding-operations.js +175 -0
  236. package/dist/src/generated/stock-observation-operations.js +93 -0
  237. package/dist/src/generated/trip-utilization-operations.js +140 -0
  238. package/dist/src/generated/wspace-operations.js +708 -0
  239. package/dist/utils/consolidationHistoryTarget.js +27 -0
  240. package/dist/utils/consolidationInput.js +21 -0
  241. package/dist/utils/consolidationLot.js +29 -0
  242. package/dist/utils/consolidationPins.js +13 -0
  243. package/dist/utils/consolidationRecovery.js +40 -0
  244. package/dist/utils/consolidationReportHead.js +18 -0
  245. package/dist/utils/freeTimeDate.js +26 -0
  246. package/dist/utils/freightAcknowledgement.js +8 -0
  247. package/dist/utils/freightDraft.js +125 -0
  248. package/dist/utils/freightRecovery.js +36 -0
  249. package/dist/utils/graphqlClient.js +28 -28
  250. package/dist/utils/pendingPickDraft.js +46 -0
  251. package/dist/utils/procedureInput.js +43 -0
  252. package/dist/utils/procedureRecovery.js +42 -0
  253. package/dist/utils/reuseAttempt.js +20 -0
  254. package/dist/utils/reuseForm.js +25 -0
  255. package/dist/utils/reuseRecovery.js +71 -0
  256. package/dist/utils/stockBindingForm.js +142 -0
  257. package/dist/utils/stockBindingLabels.js +23 -0
  258. package/dist/utils/stockObservationForm.js +55 -0
  259. package/dist/utils/tripDraftContext.js +19 -0
  260. package/dist/utils/tripUtilizationForm.js +60 -0
  261. package/package.json +20 -5
  262. package/src/generated/consolidation-operations.ts +1138 -0
  263. package/src/generated/container-condition-operations.ts +771 -0
  264. package/src/generated/container-operations.ts +376 -0
  265. package/src/generated/empty-reuse-operations.ts +1648 -0
  266. package/src/generated/free-time-operations.ts +814 -0
  267. package/src/generated/freight-cost-operations.ts +753 -0
  268. package/src/generated/logistics-procedure-operations.ts +1047 -0
  269. package/src/generated/pending-pick-operations.ts +1508 -0
  270. package/src/generated/stock-binding-operations.ts +631 -0
  271. package/src/generated/stock-observation-operations.ts +373 -0
  272. package/src/generated/trip-utilization-operations.ts +500 -0
  273. package/src/generated/wspace-operations.ts +116 -0
  274. package/src/movethewheels/MoveTheWheelsRoot.tsx +79 -0
  275. package/src/movethewheels/MoveTheWheelsRoutes.tsx +22 -0
  276. package/src/movethewheels/components/ContainerEvidencePicker.tsx +146 -0
  277. package/src/movethewheels/components/FreeTimeAgreementForm.tsx +483 -0
  278. package/src/movethewheels/components/ReturnInstructionForm.tsx +102 -0
  279. package/src/movethewheels/components/ReuseControls.tsx +138 -0
  280. package/src/movethewheels/components/ReusePermissionForm.tsx +123 -0
  281. package/src/movethewheels/components/ReuseProposalForm.tsx +484 -0
  282. package/src/movethewheels/components/ReuseSourceFields.tsx +80 -0
  283. package/src/movethewheels/components/consolidation/ConsolidationHistory.tsx +159 -0
  284. package/src/movethewheels/components/consolidation/ConsolidationLotEditor.tsx +144 -0
  285. package/src/movethewheels/components/consolidation/ConsolidationManifestWorkbench.tsx +168 -0
  286. package/src/movethewheels/components/consolidation/ConsolidationPlanForm.tsx +185 -0
  287. package/src/movethewheels/components/consolidation/ConsolidationPlanWorkbench.tsx +395 -0
  288. package/src/movethewheels/components/consolidation/ConsolidationReportForm.tsx +124 -0
  289. package/src/movethewheels/components/consolidation/ConsolidationReportsWorkbench.tsx +233 -0
  290. package/src/movethewheels/components/consolidation/ConsolidationSummary.tsx +84 -0
  291. package/src/movethewheels/components/consolidation/OriginalConsolidationHistory.tsx +133 -0
  292. package/src/movethewheels/components/freight-cost/FreightDraftForm.tsx +224 -0
  293. package/src/movethewheels/components/freight-cost/FreightFields.tsx +91 -0
  294. package/src/movethewheels/components/freight-cost/FreightFxEditor.tsx +98 -0
  295. package/src/movethewheels/components/freight-cost/FreightHistory.tsx +91 -0
  296. package/src/movethewheels/components/freight-cost/FreightLineEditor.tsx +192 -0
  297. package/src/movethewheels/components/freight-cost/FreightScopeEditor.tsx +64 -0
  298. package/src/movethewheels/components/freight-cost/FreightTotals.tsx +68 -0
  299. package/src/movethewheels/components/logistics-procedure/ProcedureDecisionForm.tsx +204 -0
  300. package/src/movethewheels/components/logistics-procedure/ProcedureFields.tsx +43 -0
  301. package/src/movethewheels/components/logistics-procedure/ProcedureHistory.tsx +102 -0
  302. package/src/movethewheels/components/logistics-procedure/ProcedurePolicyForm.tsx +226 -0
  303. package/src/movethewheels/components/logistics-procedure/ProcedurePolicyWorkbench.tsx +174 -0
  304. package/src/movethewheels/components/logistics-procedure/ProcedureReviewWorkbench.tsx +278 -0
  305. package/src/movethewheels/components/logistics-procedure/ProcedureRunWorkbench.tsx +292 -0
  306. package/src/movethewheels/components/logistics-procedure/ProcedureSubjectPicker.tsx +111 -0
  307. package/src/movethewheels/components/pending-pick/PendingPickDraft.tsx +82 -0
  308. package/src/movethewheels/components/pending-pick/PendingPickHistory.tsx +93 -0
  309. package/src/movethewheels/components/pending-pick/PickCapture.tsx +70 -0
  310. package/src/movethewheels/components/pending-pick/PickLineSelection.tsx +130 -0
  311. package/src/movethewheels/components/stock-binding/StockAssessmentDraft.tsx +52 -0
  312. package/src/movethewheels/components/stock-binding/StockAssessmentHistory.tsx +56 -0
  313. package/src/movethewheels/components/stock-binding/StockAssessmentSummary.tsx +108 -0
  314. package/src/movethewheels/components/stock-binding/StockFactForm.tsx +186 -0
  315. package/src/movethewheels/components/stock-observation/StockIssueForm.tsx +103 -0
  316. package/src/movethewheels/components/stock-observation/StockIssueHistory.tsx +96 -0
  317. package/src/movethewheels/components/stock-observation/StockIssueReadPanel.tsx +72 -0
  318. package/src/movethewheels/components/trip-utilization/TripReportForm.tsx +116 -0
  319. package/src/movethewheels/components/trip-utilization/TripReportHistory.tsx +51 -0
  320. package/src/movethewheels/components/trip-utilization/TripReportSummary.tsx +127 -0
  321. package/src/movethewheels/components/trip-utilization/TripSegmentFields.tsx +118 -0
  322. package/src/movethewheels/hooks/useConsolidationAction.ts +196 -0
  323. package/src/movethewheels/hooks/useContainerCondition.ts +129 -0
  324. package/src/movethewheels/hooks/useContainerLifecycle.ts +291 -0
  325. package/src/movethewheels/hooks/useEmptyReuseAction.ts +72 -0
  326. package/src/movethewheels/hooks/useFreightRecoveryAction.ts +201 -0
  327. package/src/movethewheels/hooks/useMultiModalShipments.ts +2 -1
  328. package/src/movethewheels/hooks/useProcedureAction.ts +196 -0
  329. package/src/movethewheels/hooks/useProcedureSelection.ts +75 -0
  330. package/src/movethewheels/hooks/useReuseRecoveryAction.ts +192 -0
  331. package/src/movethewheels/pages/ConsolidationPage.tsx +70 -0
  332. package/src/movethewheels/pages/ContainerConditionPage.tsx +959 -0
  333. package/src/movethewheels/pages/ContainersPage.tsx +490 -0
  334. package/src/movethewheels/pages/EmptyReusePage.tsx +823 -0
  335. package/src/movethewheels/pages/FreeTimePage.tsx +720 -0
  336. package/src/movethewheels/pages/FreightEstimatePage.tsx +353 -0
  337. package/src/movethewheels/pages/LogisticsProceduresPage.tsx +86 -0
  338. package/src/movethewheels/pages/PendingPickPage.tsx +226 -0
  339. package/src/movethewheels/pages/StockBindingPage.tsx +299 -0
  340. package/src/movethewheels/pages/StockObservationsPage.tsx +181 -0
  341. package/src/movethewheels/pages/TripUtilizationPage.tsx +315 -0
  342. package/src/movethewheels/utils/consolidationHistoryTarget.ts +39 -0
  343. package/src/movethewheels/utils/consolidationInput.ts +70 -0
  344. package/src/movethewheels/utils/consolidationLot.ts +24 -0
  345. package/src/movethewheels/utils/consolidationPins.ts +52 -0
  346. package/src/movethewheels/utils/consolidationRecovery.ts +88 -0
  347. package/src/movethewheels/utils/consolidationReportHead.ts +29 -0
  348. package/src/movethewheels/utils/freeTimeDate.ts +31 -0
  349. package/src/movethewheels/utils/freightAcknowledgement.ts +31 -0
  350. package/src/movethewheels/utils/freightDraft.ts +170 -0
  351. package/src/movethewheels/utils/freightRecovery.ts +79 -0
  352. package/src/movethewheels/utils/graphqlClient.ts +14 -5
  353. package/src/movethewheels/utils/pendingPickDraft.ts +61 -0
  354. package/src/movethewheels/utils/procedureInput.ts +98 -0
  355. package/src/movethewheels/utils/procedureRecovery.ts +92 -0
  356. package/src/movethewheels/utils/reuseAttempt.ts +29 -0
  357. package/src/movethewheels/utils/reuseForm.ts +30 -0
  358. package/src/movethewheels/utils/reuseRecovery.ts +151 -0
  359. package/src/movethewheels/utils/stockBindingForm.ts +209 -0
  360. package/src/movethewheels/utils/stockBindingLabels.ts +41 -0
  361. package/src/movethewheels/utils/stockObservationForm.ts +73 -0
  362. package/src/movethewheels/utils/tripDraftContext.ts +61 -0
  363. package/src/movethewheels/utils/tripUtilizationForm.ts +105 -0
  364. package/src/operations/condition/container-condition.graphql +41 -0
  365. package/src/operations/consolidation/consolidation.graphql +490 -0
  366. package/src/operations/container/container-lifecycle.graphql +80 -0
  367. package/src/operations/empty-reuse/empty-reuse.graphql +737 -0
  368. package/src/operations/free-time/free-time.graphql +47 -0
  369. package/src/operations/freight-cost/freight.graphql +6 -0
  370. package/src/operations/logistics-procedure/procedure.graphql +15 -0
  371. package/src/operations/pending-pick/pending-pick.graphql +1122 -0
  372. package/src/operations/stock-binding/stock-binding.graphql +160 -0
  373. package/src/operations/stock-observation/stock-observation.graphql +20 -0
  374. package/src/operations/trip-utilization/trip-utilization.graphql +126 -0
  375. package/src/operations/wspace/container-evidence.graphql +6 -0
@@ -0,0 +1,353 @@
1
+ import { useEffect, useRef, useState } from 'react';
2
+ import { DollarSign } from 'lucide-react';
3
+ import { PageLayout } from '../components/PageLayout';
4
+ import { Button } from '../components/ui';
5
+ import { PinnedSelect, ReusePager, ReuseState, reuseCard } from '../components/ReuseControls';
6
+ import { FreightDraftForm } from '../components/freight-cost/FreightDraftForm';
7
+ import { FreightHistory } from '../components/freight-cost/FreightHistory';
8
+ import { FreightText } from '../components/freight-cost/FreightFields';
9
+ import { useConditionApi, useConditionQuery } from '../hooks/useContainerCondition';
10
+ import { useFreightRecoveryAction } from '../hooks/useFreightRecoveryAction';
11
+ import { freightPinMatches, freightSaveInput, type FreightDraftPin } from '../utils/freightDraft';
12
+ import {
13
+ FreightShipmentsDocument,
14
+ FreightShipmentDocument,
15
+ FreightHistoryDocument,
16
+ FreightVersionDocument,
17
+ PreviewFreightCostsDocument,
18
+ SaveFreightCostsDocument,
19
+ type FreightShipmentsQuery,
20
+ type FreightShipmentQuery,
21
+ type FreightHistoryQuery,
22
+ type FreightVersionQuery,
23
+ type MtwFreightFactsInput,
24
+ type PreviewFreightCostsQuery,
25
+ } from '../../generated/freight-cost-operations';
26
+ import type { SelectedEvidence } from '../components/ContainerEvidencePicker';
27
+ export default function FreightEstimatePage() {
28
+ const actions = useFreightRecoveryAction();
29
+ return (
30
+ <PageLayout
31
+ title="Freight cost estimates"
32
+ subtitle="Dated source costs, visible unknowns and immutable versions."
33
+ icon={<DollarSign aria-hidden="true" />}
34
+ >
35
+ <FreightWorkbench key={actions.contextKey} actions={actions} />
36
+ </PageLayout>
37
+ );
38
+ }
39
+ function FreightWorkbench({ actions }: { actions: ReturnType<typeof useFreightRecoveryAction> }) {
40
+ const request = useConditionApi();
41
+ const [shipmentOffset, setShipmentOffset] = useState(0);
42
+ const [historyOffset, setHistoryOffset] = useState(0);
43
+ const [shipment, setShipment] = useState<{ id: string; label: string } | null>(null);
44
+ const [reference, setReference] = useState('');
45
+ const [selected, setSelected] = useState<string | null>(null);
46
+ const [draft, setDraft] = useState<(FreightDraftPin & { generation: string }) | null>(null);
47
+ const [checking, setChecking] = useState(false);
48
+ const [mismatch, setMismatch] = useState(false);
49
+ const [error, setError] = useState<string | null>(null);
50
+ const active = useRef(true),
51
+ preflight = useRef(false);
52
+ useEffect(() => {
53
+ active.current = true;
54
+ return () => {
55
+ active.current = false;
56
+ };
57
+ }, []);
58
+ const shipments = useConditionQuery<FreightShipmentsQuery>(
59
+ FreightShipmentsDocument,
60
+ { pagination: { limit: 25, offset: shipmentOffset } },
61
+ actions.revision
62
+ );
63
+ const current = useConditionQuery<FreightShipmentQuery>(
64
+ FreightShipmentDocument,
65
+ shipment ? { id: shipment.id } : null,
66
+ actions.revision
67
+ );
68
+ const latest = useConditionQuery<FreightHistoryQuery>(
69
+ FreightHistoryDocument,
70
+ shipment && reference.trim()
71
+ ? {
72
+ shipmentId: shipment.id,
73
+ estimateReference: reference.trim(),
74
+ pagination: { limit: 1, offset: 0 },
75
+ }
76
+ : null,
77
+ actions.revision
78
+ );
79
+ // Reloading clears unsent draft selection; unresolved history stays bound to its original input.
80
+ const historyTarget = actions.uncertain
81
+ ? actions.originalHistoryTarget
82
+ : shipment
83
+ ? { shipmentId: shipment.id, estimateReference: undefined }
84
+ : null;
85
+ const history = useConditionQuery<FreightHistoryQuery>(
86
+ FreightHistoryDocument,
87
+ historyTarget
88
+ ? {
89
+ shipmentId: historyTarget.shipmentId,
90
+ estimateReference: historyTarget.estimateReference,
91
+ pagination: { limit: 10, offset: historyOffset },
92
+ }
93
+ : null,
94
+ actions.revision
95
+ );
96
+ const exact = useConditionQuery<FreightVersionQuery>(
97
+ FreightVersionDocument,
98
+ historyTarget && selected ? { shipmentId: historyTarget.shipmentId, id: selected } : null,
99
+ actions.revision
100
+ );
101
+ const newest = latest.data?.mtwFreightEstimatePage.items[0] ?? null;
102
+ const changed =
103
+ !!draft &&
104
+ !!current.data &&
105
+ !!latest.data &&
106
+ !freightPinMatches(draft, current.data.shipment, newest);
107
+ const paused = actions.busy || checking || actions.uncertain;
108
+ const options =
109
+ shipments.data?.shipments.map((row) => ({
110
+ id: row.id,
111
+ label: `${row.shipmentNumber} — ${row.primaryMode} — ${row.status}`,
112
+ })) ?? [];
113
+ if (shipment && !options.some((row) => row.id === shipment.id))
114
+ options.unshift({ id: shipment.id, label: `${shipment.label} — selected outside this page` });
115
+ const save = async (facts: MtwFreightFactsInput, evidence: SelectedEvidence[]) => {
116
+ if (preflight.current || paused) return;
117
+ if (!draft) throw new Error('Review the shipment and current cost history first.');
118
+ preflight.current = true;
119
+ setChecking(true);
120
+ setError(null);
121
+ const pin = draft;
122
+ try {
123
+ const freshShipment = await request<FreightShipmentQuery>(FreightShipmentDocument, {
124
+ id: pin.shipmentId,
125
+ });
126
+ const freshHistory = await request<FreightHistoryQuery>(FreightHistoryDocument, {
127
+ shipmentId: pin.shipmentId,
128
+ estimateReference: pin.estimateReference,
129
+ pagination: { limit: 1, offset: 0 },
130
+ });
131
+ if (!active.current) throw new Error('The current workspace changed. Nothing was sent.');
132
+ const fresh = freshHistory.mtwFreightEstimatePage.items[0] ?? null;
133
+ if (!freightPinMatches(pin, freshShipment.shipment, fresh)) setMismatch(true);
134
+ const input = freightSaveInput(
135
+ pin,
136
+ freshShipment.shipment,
137
+ fresh,
138
+ facts,
139
+ evidence.map(({ fileId, versionId }) => ({ fileId, versionId }))
140
+ );
141
+ const result = await actions.run(
142
+ SaveFreightCostsDocument,
143
+ input,
144
+ 'Sourced cost version recorded.'
145
+ );
146
+ if (result && active.current) {
147
+ setSelected(result.saveMtwFreightEstimate.id);
148
+ setDraft(null);
149
+ setHistoryOffset(0);
150
+ }
151
+ } finally {
152
+ if (active.current) setChecking(false);
153
+ preflight.current = false;
154
+ }
155
+ };
156
+ const shipmentPage = shipments.data
157
+ ? {
158
+ total: shipments.data.shipmentsCount,
159
+ limit: 25,
160
+ offset: shipmentOffset,
161
+ hasMore: shipmentOffset + shipments.data.shipments.length < shipments.data.shipmentsCount,
162
+ nextOffset: shipmentOffset + 25,
163
+ }
164
+ : undefined;
165
+ return (
166
+ <div className="min-w-0 space-y-6 break-words">
167
+ <p className="rounded border p-4 text-sm">
168
+ Record the costs stated by your source. Missing facts are not zero. Saving does not book
169
+ freight, accept a quote or settle an invoice.
170
+ </p>
171
+ <section className={reuseCard}>
172
+ <h2 className="text-lg font-semibold">Shipment and cost sheet</h2>
173
+ <PinnedSelect
174
+ label="Shipment"
175
+ value={shipment?.id ?? ''}
176
+ options={options}
177
+ disabled={paused}
178
+ onChange={(id) => {
179
+ const row = options.find((item) => item.id === id);
180
+ setShipment(row ? { id: row.id, label: row.label } : null);
181
+ setDraft(null);
182
+ setSelected(null);
183
+ setHistoryOffset(0);
184
+ setMismatch(false);
185
+ }}
186
+ />
187
+ <ReuseState loading={shipments.loading} error={shipments.error} />
188
+ <ReusePager
189
+ page={shipmentPage}
190
+ busy={shipments.loading || paused}
191
+ offset={shipmentOffset}
192
+ onChange={setShipmentOffset}
193
+ />
194
+ <FreightText
195
+ label="Cost sheet reference"
196
+ value={reference}
197
+ disabled={paused || draft !== null}
198
+ onChange={setReference}
199
+ />
200
+ <ReuseState loading={current.loading} error={current.error} />
201
+ <ReuseState loading={latest.loading} error={latest.error} />
202
+ {current.data?.shipment && (
203
+ <p>
204
+ {current.data.shipment.shipmentNumber} — {current.data.shipment.primaryMode};{' '}
205
+ {newest ? `latest sheet version ${newest.version}` : 'no version in the loaded sheet'}.
206
+ </p>
207
+ )}
208
+ <div className="flex flex-wrap gap-3">
209
+ <Button type="button" variant="outline" disabled={paused} onClick={actions.refresh}>
210
+ Refresh current records
211
+ </Button>
212
+ <Button
213
+ type="button"
214
+ disabled={
215
+ paused ||
216
+ current.loading ||
217
+ latest.loading ||
218
+ !!current.error ||
219
+ !!latest.error ||
220
+ !current.data?.shipment ||
221
+ !latest.data ||
222
+ !reference.trim()
223
+ }
224
+ onClick={() => {
225
+ const row = current.data?.shipment;
226
+ if (row && latest.data) {
227
+ setDraft({
228
+ shipmentId: row.id,
229
+ shipmentUpdatedAt: row.updatedAt,
230
+ estimateReference: reference.trim(),
231
+ previousId: newest?.id ?? null,
232
+ version: newest?.version ?? 0,
233
+ generation: crypto.randomUUID(),
234
+ });
235
+ setMismatch(false);
236
+ setError(null);
237
+ }
238
+ }}
239
+ >
240
+ Review and start a new draft
241
+ </Button>
242
+ </div>
243
+ </section>
244
+ {(changed || mismatch) && (
245
+ <p role="alert">
246
+ The shipment or cost history changed. Review the current records and explicitly start a
247
+ new draft; entered facts were not rebound.
248
+ </p>
249
+ )}
250
+ {draft && !changed && !mismatch && (
251
+ <FreightDraftForm
252
+ key={draft.generation}
253
+ disabled={
254
+ paused || current.loading || latest.loading || !!current.error || !!latest.error
255
+ }
256
+ onPreview={async (facts) =>
257
+ (await request<PreviewFreightCostsQuery>(PreviewFreightCostsDocument, { input: facts }))
258
+ .previewMtwFreightTotal
259
+ }
260
+ onSave={save}
261
+ />
262
+ )}
263
+ {error && <p role="alert">{error}</p>}
264
+ {actions.error && <p role="alert">{actions.error}</p>}
265
+ {actions.notice && <p role="status">{actions.notice}</p>}
266
+ {actions.uncertain && (
267
+ <section className={reuseCard}>
268
+ <h2 className="font-semibold">Resolve the original save</h2>
269
+ <p>
270
+ The server may already have recorded it. Check history first. Return to the original
271
+ account, organization, workspace and project before retrying.
272
+ </p>
273
+ <Button
274
+ type="button"
275
+ disabled={!actions.canRetry || actions.busy}
276
+ onClick={() => void actions.retryOriginal()}
277
+ >
278
+ Retry original request
279
+ </Button>
280
+ <Button
281
+ type="button"
282
+ variant="outline"
283
+ disabled={actions.busy}
284
+ onClick={() => {
285
+ if (
286
+ window.confirm(
287
+ 'The server may have saved this request. Check history before abandoning its original request key. Abandon it?'
288
+ )
289
+ )
290
+ actions.discardAttempt();
291
+ }}
292
+ >
293
+ Abandon after checking history
294
+ </Button>
295
+ </section>
296
+ )}
297
+ {actions.uncertain && !actions.originalHistoryTarget && (
298
+ <p role="status">
299
+ Original history is unavailable in this context. Return to the original account,
300
+ organization, workspace and project. A malformed saved request cannot supply a history
301
+ target.
302
+ </p>
303
+ )}
304
+ {historyTarget && (
305
+ <section className={reuseCard}>
306
+ <h2 className="text-lg font-semibold">
307
+ {actions.uncertain ? 'Original request cost history' : 'Immutable cost history'}
308
+ </h2>
309
+ {actions.uncertain && (
310
+ <>
311
+ <p>
312
+ Shipment {historyTarget.shipmentId}; sheet {historyTarget.estimateReference}.
313
+ Reading these records does not confirm the original request key or clear recovery.
314
+ </p>
315
+ <Button
316
+ type="button"
317
+ variant="outline"
318
+ disabled={actions.busy}
319
+ onClick={actions.refresh}
320
+ >
321
+ Refresh original history
322
+ </Button>
323
+ </>
324
+ )}
325
+ <ReuseState loading={history.loading} error={history.error} />
326
+ {history.data?.mtwFreightEstimatePage.items.map((row) => (
327
+ <Button
328
+ key={row.id}
329
+ type="button"
330
+ variant="outline"
331
+ onClick={() => setSelected(row.id)}
332
+ >
333
+ {row.facts.title} / {row.estimateReference} / version {row.version} —{' '}
334
+ {new Date(row.recordedAt).toLocaleString()}
335
+ </Button>
336
+ ))}
337
+ <ReusePager
338
+ page={history.data?.mtwFreightEstimatePage}
339
+ busy={history.loading}
340
+ offset={historyOffset}
341
+ onChange={setHistoryOffset}
342
+ />
343
+ </section>
344
+ )}
345
+ {historyTarget && selected && (
346
+ <>
347
+ <ReuseState loading={exact.loading} error={exact.error} />
348
+ {exact.data && <FreightHistory record={exact.data.mtwFreightEstimateVersion} />}
349
+ </>
350
+ )}
351
+ </div>
352
+ );
353
+ }
@@ -0,0 +1,86 @@
1
+ import { useState } from 'react';
2
+ import { ClipboardList } from 'lucide-react';
3
+ import { Link } from 'react-router';
4
+ import { PageLayout } from '../components/PageLayout';
5
+ import { Button } from '../components/ui';
6
+ import { useProcedureAction } from '../hooks/useProcedureAction';
7
+ import { ProcedureReviewWorkbench } from '../components/logistics-procedure/ProcedureReviewWorkbench';
8
+ import { ProcedurePolicyWorkbench } from '../components/logistics-procedure/ProcedurePolicyWorkbench';
9
+ export default function LogisticsProceduresPage() {
10
+ const actions = useProcedureAction(),
11
+ [tab, setTab] = useState<'review' | 'policy'>('review');
12
+ return (
13
+ <PageLayout
14
+ title="Logistics procedures"
15
+ subtitle="Sourced checklist records and internal review history."
16
+ icon={<ClipboardList aria-hidden="true" />}
17
+ >
18
+ <div className="space-y-5">
19
+ <p className="rounded-lg border p-4">
20
+ Recording only: these checklists do not enforce reuse reservations, authorize movement or
21
+ certify condition or lane-specific compliance.
22
+ </p>
23
+ <p>
24
+ Shared{' '}
25
+ <Link to="/workflows" className="underline">
26
+ Workflows
27
+ </Link>{' '}
28
+ remain advisory. Published procedures and independent deviation notes require canonical
29
+ reviewer permissions.
30
+ </p>
31
+ <div className="flex flex-wrap gap-2">
32
+ <Button
33
+ variant={tab === 'review' ? 'default' : 'outline'}
34
+ disabled={actions.busy || actions.uncertain}
35
+ onClick={() => setTab('review')}
36
+ >
37
+ Checklist and history
38
+ </Button>
39
+ <Button
40
+ variant={tab === 'policy' ? 'default' : 'outline'}
41
+ disabled={actions.busy || actions.uncertain}
42
+ onClick={() => setTab('policy')}
43
+ >
44
+ Procedure versions
45
+ </Button>
46
+ <Button variant="outline" disabled={actions.busy} onClick={actions.refresh}>
47
+ Refresh history
48
+ </Button>
49
+ </div>
50
+ {actions.error && <p role="alert">{actions.error}</p>}
51
+ {actions.notice && <p role="status">{actions.notice}</p>}
52
+ {actions.uncertain && (
53
+ <section className="space-y-3 rounded-lg border p-4">
54
+ <h2 className="font-semibold">Original request remains unresolved</h2>
55
+ <p>
56
+ Check history first. A manual retry sends the exact original body, revisions and key;
57
+ refresh does not retag it. New records and selection changes are blocked.
58
+ </p>
59
+ {actions.originalContext && (
60
+ <p className="break-all">Original workspace: {actions.originalContext.workspaceId}</p>
61
+ )}
62
+ {actions.recoveryInvalid && (
63
+ <p>The retained request cannot be read safely. Nothing will be sent automatically.</p>
64
+ )}
65
+ <div className="flex flex-wrap gap-2">
66
+ <Button
67
+ disabled={!actions.canRetry || actions.busy}
68
+ onClick={() => void actions.retryOriginal()}
69
+ >
70
+ Retry original request
71
+ </Button>
72
+ <Button variant="outline" disabled={actions.busy} onClick={actions.discardAttempt}>
73
+ Abandon after checking history
74
+ </Button>
75
+ </div>
76
+ </section>
77
+ )}
78
+ {tab === 'review' ? (
79
+ <ProcedureReviewWorkbench key={actions.contextKey} actions={actions} />
80
+ ) : (
81
+ <ProcedurePolicyWorkbench key={actions.contextKey} actions={actions} />
82
+ )}
83
+ </div>
84
+ </PageLayout>
85
+ );
86
+ }
@@ -0,0 +1,226 @@
1
+ import { useEffect, useRef, useState } from 'react';
2
+ import { ClipboardList } from 'lucide-react';
3
+ import {
4
+ PickInventoryDocument,
5
+ PickPreparationDocument,
6
+ RecordPendingPickDocument,
7
+ type PickInventoryQuery,
8
+ type PickPreparationQuery,
9
+ type RecordPendingPickMutation,
10
+ } from '../../generated/pending-pick-operations';
11
+ import { PageLayout } from '../components/PageLayout';
12
+ import { Button } from '../components/ui';
13
+ import { ReuseState, reuseCard } from '../components/ReuseControls';
14
+ import { PickLineSelection } from '../components/pending-pick/PickLineSelection';
15
+ import { PendingPickDraft } from '../components/pending-pick/PendingPickDraft';
16
+ import { PendingPickHistory } from '../components/pending-pick/PendingPickHistory';
17
+ import { useConditionApi, useConditionQuery } from '../hooks/useContainerCondition';
18
+ import { useEmptyReuseAction } from '../hooks/useEmptyReuseAction';
19
+ import { useMoveTheWheels } from '../providers/MoveTheWheelsProvider';
20
+ import {
21
+ pendingContextSignature,
22
+ pendingPickInput,
23
+ pendingPickMatches,
24
+ type PendingPickInput,
25
+ } from '../utils/pendingPickDraft';
26
+ export default function PendingPickPage() {
27
+ const { workspaceId, tenantId, currentUser, apiGatewayUrl } = useMoveTheWheels();
28
+ return (
29
+ <PageLayout
30
+ title="Plan a pick"
31
+ subtitle="Record a pending pick-to-staging intent."
32
+ icon={<ClipboardList aria-hidden="true" />}
33
+ >
34
+ <p className="mb-4 text-sm">
35
+ Changing workspace or user clears this draft. Check recorded history before starting again.
36
+ </p>
37
+ <PickWorkbench
38
+ key={JSON.stringify([workspaceId, tenantId, currentUser?.id, apiGatewayUrl])}
39
+ />
40
+ </PageLayout>
41
+ );
42
+ }
43
+ function PickWorkbench() {
44
+ const actions = useEmptyReuseAction(),
45
+ request = useConditionApi(),
46
+ checkingRef = useRef(false),
47
+ active = useRef(true);
48
+ useEffect(() => {
49
+ active.current = true;
50
+ return () => {
51
+ active.current = false;
52
+ };
53
+ }, []);
54
+ const [offset, setOffset] = useState(0),
55
+ [sourceId, setSourceId] = useState(''),
56
+ [destinationId, setDestinationId] = useState('');
57
+ const [count, setCount] = useState(''),
58
+ [reason, setReason] = useState(''),
59
+ [draft, setDraft] = useState<{ input: PendingPickInput; signature: string } | null>(null),
60
+ [message, setMessage] = useState<string | null>(null),
61
+ [checking, setChecking] = useState(false);
62
+ const inventory = useConditionQuery<PickInventoryQuery>(
63
+ PickInventoryDocument,
64
+ { pagination: { limit: 25, offset } },
65
+ actions.revision
66
+ );
67
+ const preparation = useConditionQuery<PickPreparationQuery>(
68
+ PickPreparationDocument,
69
+ sourceId && destinationId
70
+ ? { sourceInventoryItemId: sourceId, destinationInventoryItemId: destinationId }
71
+ : null,
72
+ actions.revision
73
+ );
74
+ const context = preparation.data?.mtwPickPreparation;
75
+ const locked = actions.busy || actions.uncertain || checking;
76
+ const select = (side: 'source' | 'destination', id: string) => {
77
+ if (locked) return;
78
+ setDraft(null);
79
+ setMessage(null);
80
+ setCount('');
81
+ setReason('');
82
+ if (side === 'source') {
83
+ setSourceId(id);
84
+ setDestinationId('');
85
+ } else setDestinationId(id);
86
+ };
87
+ const review = () => {
88
+ if (!context || locked) return;
89
+ try {
90
+ setDraft({
91
+ input: pendingPickInput(context, count, reason),
92
+ signature: pendingContextSignature(context),
93
+ });
94
+ setMessage(null);
95
+ } catch {
96
+ setMessage(
97
+ 'Enter a positive whole count, a reason, and two distinct bins in the same cargo and warehouse.'
98
+ );
99
+ }
100
+ };
101
+ const save = async () => {
102
+ if (
103
+ !draft ||
104
+ !context ||
105
+ locked ||
106
+ checkingRef.current ||
107
+ !pendingPickMatches(draft.signature, context)
108
+ )
109
+ return;
110
+ checkingRef.current = true;
111
+ setChecking(true);
112
+ setMessage(null);
113
+ try {
114
+ const fresh = await request<PickPreparationQuery>(PickPreparationDocument, {
115
+ sourceInventoryItemId: sourceId,
116
+ destinationInventoryItemId: destinationId,
117
+ });
118
+ if (!active.current) return;
119
+ if (!pendingPickMatches(draft.signature, fresh.mtwPickPreparation)) {
120
+ setDraft(null);
121
+ setMessage('Current source facts changed. Refresh and review this plan again.');
122
+ actions.refresh();
123
+ return;
124
+ }
125
+ const result = await actions.run<RecordPendingPickMutation>(
126
+ RecordPendingPickDocument,
127
+ draft.input,
128
+ 'Pending plan recorded. No stock was reserved or moved.'
129
+ );
130
+ if (result) {
131
+ setDraft(null);
132
+ setCount('');
133
+ setReason('');
134
+ }
135
+ } catch {
136
+ setMessage(
137
+ 'Unable to recheck current source facts. Refresh before reviewing this plan again.'
138
+ );
139
+ setDraft(null);
140
+ } finally {
141
+ checkingRef.current = false;
142
+ if (active.current) setChecking(false);
143
+ }
144
+ };
145
+ const retry = async () => {
146
+ if (!draft || actions.busy) return;
147
+ // run retains the exact uncertain original body/key and returns success so this draft is consumed once.
148
+ const result = await actions.run<RecordPendingPickMutation>(
149
+ RecordPendingPickDocument,
150
+ draft.input,
151
+ 'Pending plan recorded. No stock was reserved or moved.'
152
+ );
153
+ if (result) {
154
+ setDraft(null);
155
+ setCount('');
156
+ setReason('');
157
+ }
158
+ };
159
+ const stale = !!draft && !!context && !pendingPickMatches(draft.signature, context);
160
+ return (
161
+ <div className="space-y-5">
162
+ <PickLineSelection
163
+ inventory={inventory}
164
+ sourceId={sourceId}
165
+ destinationId={destinationId}
166
+ locked={locked}
167
+ offset={offset}
168
+ onOffset={setOffset}
169
+ onSelect={select}
170
+ onRefresh={actions.refresh}
171
+ refreshBusy={checking || actions.busy}
172
+ />
173
+ <ReuseState loading={preparation.loading} error={preparation.error} />
174
+ <PendingPickDraft
175
+ context={context}
176
+ locked={locked}
177
+ loading={preparation.loading}
178
+ count={count}
179
+ reason={reason}
180
+ draft={draft?.input ?? null}
181
+ stale={stale}
182
+ onCount={(value) => {
183
+ setCount(value);
184
+ setDraft(null);
185
+ }}
186
+ onReason={(value) => {
187
+ setReason(value);
188
+ setDraft(null);
189
+ }}
190
+ onReview={review}
191
+ onSave={() => void save()}
192
+ />
193
+ {message && <p role="alert">{message}</p>}
194
+ {actions.error && <p role="alert">{actions.error}</p>}
195
+ {actions.notice && <p role="status">{actions.notice}</p>}
196
+ {actions.uncertain && (
197
+ <section className={reuseCard}>
198
+ <p>
199
+ The outcome is uncertain. Check history first. Retry keeps the exact original body,
200
+ versions and key.
201
+ </p>
202
+ <Button type="button" disabled={actions.busy} onClick={() => void retry()}>
203
+ Retry original request
204
+ </Button>
205
+ <Button
206
+ type="button"
207
+ variant="outline"
208
+ disabled={actions.busy}
209
+ onClick={() => {
210
+ actions.discardAttempt();
211
+ setDraft(null);
212
+ }}
213
+ >
214
+ Abandon after checking history
215
+ </Button>
216
+ </section>
217
+ )}
218
+ <PendingPickHistory
219
+ key={JSON.stringify([sourceId, destinationId])}
220
+ revision={actions.revision}
221
+ sourceId={sourceId}
222
+ destinationId={destinationId}
223
+ />
224
+ </div>
225
+ );
226
+ }