@burdenoff/microfe-movethewheels 2026.1016.2 → 2026.1016.4

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 (113) hide show
  1. package/README.md +10 -0
  2. package/dist/MoveTheWheelsRoot.js +5 -0
  3. package/dist/MoveTheWheelsRoutes.js +25 -21
  4. package/dist/components/ContainerEvidencePicker.js +55 -55
  5. package/dist/components/FleetAlertsPanel.js +2 -2
  6. package/dist/components/freight-cost/FreightCommercialEditor.js +217 -0
  7. package/dist/components/freight-cost/FreightCommercialFactEditor.js +217 -0
  8. package/dist/components/freight-cost/FreightCommercialHistory.js +115 -0
  9. package/dist/components/freight-cost/FreightDraftForm.js +106 -91
  10. package/dist/components/freight-cost/FreightHistory.js +42 -40
  11. package/dist/components/freight-invoice/InvoiceForm.js +366 -0
  12. package/dist/components/freight-invoice/InvoiceResults.js +240 -0
  13. package/dist/generated/consolidation-operations.d.ts +195 -265
  14. package/dist/generated/container-condition-operations.d.ts +124 -187
  15. package/dist/generated/container-operations.d.ts +59 -85
  16. package/dist/generated/empty-reuse-operations.d.ts +165 -271
  17. package/dist/generated/free-time-operations.d.ts +120 -184
  18. package/dist/generated/freight-cost-operations.d.ts +955 -165
  19. package/dist/generated/freight-invoice-operations.d.ts +1447 -0
  20. package/dist/generated/logistics-procedure-operations.d.ts +100 -156
  21. package/dist/generated/pending-pick-operations.d.ts +769 -1025
  22. package/dist/generated/shipment-status-authority-operations.d.ts +82 -103
  23. package/dist/generated/stock-binding-operations.d.ts +188 -260
  24. package/dist/generated/stock-observation-operations.d.ts +103 -138
  25. package/dist/generated/tracking-quality-operations.d.ts +27 -41
  26. package/dist/generated/trip-utilization-operations.d.ts +137 -185
  27. package/dist/generated/wspace-operations.d.ts +628 -2272
  28. package/dist/generated/wspace-types.d.ts +4 -23
  29. package/dist/hooks/useFreightRecoveryAction.js +20 -20
  30. package/dist/hooks/useInvoiceComparisonRecovery.js +118 -0
  31. package/dist/movethewheels/components/ContainerEvidencePicker.d.ts +2 -1
  32. package/dist/movethewheels/components/freight-cost/FreightCommercialEditor.d.ts +8 -0
  33. package/dist/movethewheels/components/freight-cost/FreightCommercialFactEditor.d.ts +8 -0
  34. package/dist/movethewheels/components/freight-cost/FreightCommercialHistory.d.ts +4 -0
  35. package/dist/movethewheels/components/freight-cost/FreightDraftForm.d.ts +4 -2
  36. package/dist/movethewheels/components/freight-cost/FreightHistory.d.ts +2 -2
  37. package/dist/movethewheels/components/freight-invoice/InvoiceForm.d.ts +19 -0
  38. package/dist/movethewheels/components/freight-invoice/InvoiceResults.d.ts +9 -0
  39. package/dist/movethewheels/hooks/useFleet.d.ts +1 -1
  40. package/dist/movethewheels/hooks/useFleetIntelligence.d.ts +1 -1
  41. package/dist/movethewheels/hooks/useInvoiceComparisonRecovery.d.ts +22 -0
  42. package/dist/movethewheels/hooks/useProcedureSelection.d.ts +1 -3
  43. package/dist/movethewheels/pages/FreightInvoicePage.d.ts +10 -0
  44. package/dist/movethewheels/utils/driverLicenseExpiry.d.ts +6 -0
  45. package/dist/movethewheels/utils/freightCommercial.d.ts +44 -0
  46. package/dist/movethewheels/utils/invoiceComparison.d.ts +32 -0
  47. package/dist/pages/DriverDetailsPage.js +306 -282
  48. package/dist/pages/FreightEstimatePage.js +97 -92
  49. package/dist/pages/FreightInvoicePage.js +346 -0
  50. package/dist/src/generated/consolidation-operations.js +3961 -503
  51. package/dist/src/generated/container-condition-operations.js +2968 -206
  52. package/dist/src/generated/container-operations.js +997 -99
  53. package/dist/src/generated/empty-reuse-operations.js +4811 -747
  54. package/dist/src/generated/free-time-operations.js +2824 -233
  55. package/dist/src/generated/freight-cost-operations.js +4852 -323
  56. package/dist/src/generated/freight-invoice-operations.js +4894 -0
  57. package/dist/src/generated/logistics-procedure-operations.js +2707 -360
  58. package/dist/src/generated/pending-pick-operations.js +8244 -1196
  59. package/dist/src/generated/shipment-status-authority-operations.js +1157 -84
  60. package/dist/src/generated/stock-binding-operations.js +2779 -173
  61. package/dist/src/generated/stock-observation-operations.js +1274 -91
  62. package/dist/src/generated/tracking-quality-operations.js +407 -42
  63. package/dist/src/generated/trip-utilization-operations.js +1765 -138
  64. package/dist/src/generated/wspace-operations.js +428 -706
  65. package/dist/utils/driverLicenseExpiry.js +14 -0
  66. package/dist/utils/freightAcknowledgement.js +6 -5
  67. package/dist/utils/freightCommercial.js +194 -0
  68. package/dist/utils/freightRecovery.js +22 -22
  69. package/dist/utils/invoiceComparison.js +272 -0
  70. package/package.json +30 -29
  71. package/src/generated/consolidation-operations.ts +60 -559
  72. package/src/generated/container-condition-operations.ts +63 -265
  73. package/src/generated/container-operations.ts +37 -132
  74. package/src/generated/empty-reuse-operations.ts +83 -824
  75. package/src/generated/free-time-operations.ts +55 -284
  76. package/src/generated/freight-cost-operations.ts +373 -349
  77. package/src/generated/freight-invoice-operations.ts +830 -0
  78. package/src/generated/logistics-procedure-operations.ts +60 -414
  79. package/src/generated/pending-pick-operations.ts +48 -1239
  80. package/src/generated/shipment-status-authority-operations.ts +33 -113
  81. package/src/generated/stock-binding-operations.ts +29 -198
  82. package/src/generated/stock-observation-operations.ts +24 -111
  83. package/src/generated/tracking-quality-operations.ts +19 -57
  84. package/src/generated/trip-utilization-operations.ts +32 -166
  85. package/src/generated/wspace-operations.ts +284 -2906
  86. package/src/generated/wspace-types.ts +2 -8
  87. package/src/movethewheels/MoveTheWheelsRoot.tsx +6 -0
  88. package/src/movethewheels/MoveTheWheelsRoutes.tsx +2 -0
  89. package/src/movethewheels/components/ContainerEvidencePicker.tsx +12 -4
  90. package/src/movethewheels/components/FleetAlertsPanel.tsx +4 -2
  91. package/src/movethewheels/components/freight-cost/FreightCommercialEditor.tsx +236 -0
  92. package/src/movethewheels/components/freight-cost/FreightCommercialFactEditor.tsx +258 -0
  93. package/src/movethewheels/components/freight-cost/FreightCommercialHistory.tsx +90 -0
  94. package/src/movethewheels/components/freight-cost/FreightDraftForm.tsx +33 -4
  95. package/src/movethewheels/components/freight-cost/FreightHistory.tsx +4 -2
  96. package/src/movethewheels/components/freight-invoice/InvoiceForm.tsx +412 -0
  97. package/src/movethewheels/components/freight-invoice/InvoiceResults.tsx +162 -0
  98. package/src/movethewheels/hooks/useFleet.ts +1 -1
  99. package/src/movethewheels/hooks/useFleetIntelligence.ts +5 -1
  100. package/src/movethewheels/hooks/useFreightRecoveryAction.ts +2 -1
  101. package/src/movethewheels/hooks/useInvoiceComparisonRecovery.ts +227 -0
  102. package/src/movethewheels/pages/DriverDetailsPage.tsx +35 -9
  103. package/src/movethewheels/pages/FreightEstimatePage.tsx +15 -7
  104. package/src/movethewheels/pages/FreightInvoicePage.tsx +477 -0
  105. package/src/movethewheels/utils/driverLicenseExpiry.ts +25 -0
  106. package/src/movethewheels/utils/freightAcknowledgement.ts +3 -1
  107. package/src/movethewheels/utils/freightCommercial.ts +388 -0
  108. package/src/movethewheels/utils/freightRecovery.ts +6 -2
  109. package/src/movethewheels/utils/invoiceComparison.ts +520 -0
  110. package/src/operations/freight-cost/commercial.graphql +483 -0
  111. package/src/operations/freight-invoice/comparison.graphql +40 -0
  112. package/src/operations/wspace/freight-invoice-evidence.graphql +6 -0
  113. package/patches/braces@3.0.3.patch +0 -87
@@ -0,0 +1,217 @@
1
+ import { Button as e } from "../ui.js";
2
+ import { newCommercialFact as t } from "../../utils/freightCommercial.js";
3
+ import { FreightSelect as n, FreightText as r } from "./FreightFields.js";
4
+ import { freightInstant as i, freightLocalTime as a } from "../../utils/freightDraft.js";
5
+ import { useState as o } from "react";
6
+ import { Fragment as s, jsx as c, jsxs as l } from "react/jsx-runtime";
7
+ //#region src/movethewheels/components/freight-cost/FreightCommercialFactEditor.tsx
8
+ function u({ slot: i, value: a, onChange: s, evidence: u }) {
9
+ let [p, m] = o(!1), h = i[0].toUpperCase() + i.slice(1), g = (e) => s({
10
+ ...a,
11
+ ...e
12
+ });
13
+ return /* @__PURE__ */ l("fieldset", {
14
+ className: "min-w-0 space-y-3 rounded border p-3",
15
+ children: [
16
+ /* @__PURE__ */ c("legend", {
17
+ className: "px-1 font-semibold",
18
+ children: h
19
+ }),
20
+ /* @__PURE__ */ l(n, {
21
+ label: `${h} status`,
22
+ value: a.status,
23
+ onChange: (e) => {
24
+ (e === "UNKNOWN" || e === "SOURCED" || e === "NOT_APPLICABLE") && (m(!1), s(t(e)));
25
+ },
26
+ children: [
27
+ /* @__PURE__ */ c("option", {
28
+ value: "UNKNOWN",
29
+ children: "Unknown — not recorded"
30
+ }),
31
+ /* @__PURE__ */ c("option", {
32
+ value: "SOURCED",
33
+ children: "Sourced"
34
+ }),
35
+ /* @__PURE__ */ c("option", {
36
+ value: "NOT_APPLICABLE",
37
+ children: "Not applicable"
38
+ })
39
+ ]
40
+ }),
41
+ a.status === "UNKNOWN" && !p && /* @__PURE__ */ l("div", {
42
+ className: "flex flex-wrap items-center gap-2",
43
+ children: [/* @__PURE__ */ c("p", { children: a.reason }), /* @__PURE__ */ l(e, {
44
+ type: "button",
45
+ variant: "outline",
46
+ onClick: () => m(!0),
47
+ children: [
48
+ "Edit ",
49
+ h.toLowerCase(),
50
+ " reason"
51
+ ]
52
+ })]
53
+ }),
54
+ (a.status === "NOT_APPLICABLE" || a.status === "UNKNOWN" && p) && /* @__PURE__ */ c(r, {
55
+ label: `${h} reason`,
56
+ value: a.reason,
57
+ required: !0,
58
+ onChange: (e) => g({ reason: e })
59
+ }),
60
+ a.status === "SOURCED" && /* @__PURE__ */ c(d, {
61
+ slot: i,
62
+ label: h,
63
+ value: a,
64
+ patch: g
65
+ }),
66
+ a.status !== "UNKNOWN" && /* @__PURE__ */ c(f, {
67
+ label: h,
68
+ value: a,
69
+ patch: g,
70
+ evidence: u
71
+ })
72
+ ]
73
+ });
74
+ }
75
+ function d({ slot: e, label: t, value: i, patch: a }) {
76
+ return /* @__PURE__ */ l(s, { children: [
77
+ (e === "origin" || e === "destination") && /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ l(n, {
78
+ label: `${t} label kind`,
79
+ value: i.kind,
80
+ onChange: (e) => a({ kind: e }),
81
+ children: [/* @__PURE__ */ c("option", {
82
+ value: "",
83
+ children: "Choose a label kind"
84
+ }), [
85
+ "ADDRESS_LABEL",
86
+ "PORT_LABEL",
87
+ "TERMINAL_LABEL",
88
+ "POSTCODE_LABEL",
89
+ "CUSTOM_LABEL"
90
+ ].map((e) => /* @__PURE__ */ c("option", {
91
+ value: e,
92
+ children: e.replaceAll("_", " ").toLowerCase()
93
+ }, e))]
94
+ }), /* @__PURE__ */ c(r, {
95
+ label: `${t} jurisdiction label (optional)`,
96
+ value: i.jurisdiction,
97
+ onChange: (e) => a({ jurisdiction: e })
98
+ })] }),
99
+ e === "carrier" && /* @__PURE__ */ c(r, {
100
+ label: "Carrier reference",
101
+ value: i.reference,
102
+ required: !0,
103
+ onChange: (e) => a({ reference: e })
104
+ }),
105
+ e !== "weight" && e !== "volume" && /* @__PURE__ */ c(r, {
106
+ label: e === "cargo" ? "Cargo classification label" : e === "equipment" ? "Equipment type label" : `${t} label`,
107
+ value: i.label,
108
+ required: !0,
109
+ onChange: (e) => a({ label: e })
110
+ }),
111
+ e === "cargo" && /* @__PURE__ */ c(r, {
112
+ label: "Cargo description",
113
+ value: i.description,
114
+ required: !0,
115
+ onChange: (e) => a({ description: e })
116
+ }),
117
+ (e === "weight" || e === "volume") && /* @__PURE__ */ l(s, { children: [
118
+ /* @__PURE__ */ c(r, {
119
+ label: `${t} amount`,
120
+ value: i.amount,
121
+ required: !0,
122
+ onChange: (e) => a({
123
+ amount: e,
124
+ zeroReason: e === "0" ? i.zeroReason : ""
125
+ })
126
+ }),
127
+ /* @__PURE__ */ l(n, {
128
+ label: `${t} recorded unit`,
129
+ value: i.unit,
130
+ onChange: (e) => a({ unit: e }),
131
+ children: [/* @__PURE__ */ c("option", {
132
+ value: "",
133
+ children: "Choose a unit"
134
+ }), (e === "weight" ? [
135
+ "KG",
136
+ "TONNE",
137
+ "LB"
138
+ ] : ["M3", "FT3"]).map((e) => /* @__PURE__ */ c("option", {
139
+ value: e,
140
+ children: e
141
+ }, e))]
142
+ }),
143
+ i.amount === "0" && /* @__PURE__ */ c(r, {
144
+ label: `${t} recorded zero reason`,
145
+ value: i.zeroReason,
146
+ required: !0,
147
+ onChange: (e) => a({ zeroReason: e })
148
+ }),
149
+ /* @__PURE__ */ c("p", {
150
+ className: "text-sm",
151
+ children: "Record the source unit. No conversion is inferred."
152
+ })
153
+ ] }),
154
+ e === "equipment" && /* @__PURE__ */ c(r, {
155
+ label: "Equipment count",
156
+ value: i.count,
157
+ required: !0,
158
+ onChange: (e) => a({ count: e })
159
+ })
160
+ ] });
161
+ }
162
+ function f({ label: e, value: t, patch: n, evidence: o }) {
163
+ return /* @__PURE__ */ l(s, { children: [
164
+ /* @__PURE__ */ l("h4", {
165
+ className: "font-medium",
166
+ children: [e, " source declaration"]
167
+ }),
168
+ /* @__PURE__ */ c(r, {
169
+ label: `${e} source reference`,
170
+ value: t.sourceReference,
171
+ required: !0,
172
+ onChange: (e) => n({ sourceReference: e })
173
+ }),
174
+ /* @__PURE__ */ c(r, {
175
+ label: `${e} source revision`,
176
+ value: t.sourceRevision,
177
+ required: !0,
178
+ onChange: (e) => n({ sourceRevision: e })
179
+ }),
180
+ /* @__PURE__ */ c(r, {
181
+ label: `${e} observed at (local time, optional)`,
182
+ type: "datetime-local",
183
+ value: t.observedAt ? a(t.observedAt) : "",
184
+ onChange: (e) => n({ observedAt: e ? i(e) : "" })
185
+ }),
186
+ /* @__PURE__ */ c("p", {
187
+ className: "text-sm",
188
+ children: "Blank observation time is recorded as Unknown. No date is inferred from the upload or file check."
189
+ }),
190
+ /* @__PURE__ */ c("p", {
191
+ className: "text-sm",
192
+ children: "Choose 1–2 versions from the evidence selected below for this record. This declares the source; it does not verify its authority."
193
+ }),
194
+ o.map((e) => {
195
+ let r = t.evidenceLinks.some((t) => t.fileId === e.fileId && t.versionId === e.versionId);
196
+ return /* @__PURE__ */ l("label", {
197
+ className: "flex min-h-11 items-center gap-2 break-words text-sm",
198
+ children: [/* @__PURE__ */ c("input", {
199
+ type: "checkbox",
200
+ checked: r,
201
+ disabled: !r && t.evidenceLinks.length >= 2,
202
+ onChange: () => n({ evidenceLinks: r ? t.evidenceLinks.filter((t) => !(t.fileId === e.fileId && t.versionId === e.versionId)) : [...t.evidenceLinks, {
203
+ fileId: e.fileId,
204
+ versionId: e.versionId
205
+ }] })
206
+ }), e.label]
207
+ }, e.versionId);
208
+ }),
209
+ !o.length && /* @__PURE__ */ c("p", { children: "Select an exact Files version in Evidence for this record." }),
210
+ t.evidenceLinks.some((e) => !o.some((t) => t.fileId === e.fileId && t.versionId === e.versionId)) && /* @__PURE__ */ c("p", {
211
+ role: "alert",
212
+ children: "A linked evidence version was removed. Select the fact status again and review its source links before saving."
213
+ })
214
+ ] });
215
+ }
216
+ //#endregion
217
+ export { u as FreightCommercialFactEditor };
@@ -0,0 +1,115 @@
1
+ import { commercialSlots as e } from "../../utils/freightCommercial.js";
2
+ import { freightLabel as t } from "../../utils/freightDraft.js";
3
+ import { jsx as n, jsxs as r } from "react/jsx-runtime";
4
+ //#region src/movethewheels/components/freight-cost/FreightCommercialHistory.tsx
5
+ function i({ capture: i }) {
6
+ return i === void 0 ? /* @__PURE__ */ n("p", {
7
+ role: "alert",
8
+ children: "Commercial context is unavailable in this reply."
9
+ }) : i === null ? /* @__PURE__ */ n("p", { children: "Commercial context was not captured with this version." }) : /* @__PURE__ */ r("section", {
10
+ className: "min-w-0 space-y-4 break-words rounded border p-4",
11
+ children: [
12
+ /* @__PURE__ */ r("h3", {
13
+ className: "font-semibold",
14
+ children: ["Recorded commercial context — schema ", i.schemaVersion]
15
+ }),
16
+ /* @__PURE__ */ n("p", {
17
+ className: "text-sm",
18
+ children: "These are source declarations, not quote acceptance, verified authority or a complete commercial checklist."
19
+ }),
20
+ /* @__PURE__ */ n("div", {
21
+ className: "grid min-w-0 gap-3 md:grid-cols-2",
22
+ children: e.map((e) => {
23
+ let a = i[e];
24
+ return /* @__PURE__ */ r("article", {
25
+ className: "space-y-2 rounded border p-3",
26
+ children: [
27
+ /* @__PURE__ */ r("h4", {
28
+ className: "font-medium",
29
+ children: [
30
+ t(e),
31
+ " — ",
32
+ t(a.status)
33
+ ]
34
+ }),
35
+ a.reason && /* @__PURE__ */ n("p", { children: a.reason }),
36
+ typeof a.value == "string" ? /* @__PURE__ */ n("p", { children: a.value }) : a.value && /* @__PURE__ */ n("dl", { children: Object.entries(a.value).filter(([e]) => e !== "__typename").map(([e, t]) => /* @__PURE__ */ r("div", { children: [/* @__PURE__ */ r("dt", {
37
+ className: "inline font-medium",
38
+ children: [e, ": "]
39
+ }), /* @__PURE__ */ n("dd", {
40
+ className: "inline",
41
+ children: t == null ? "Not recorded" : String(t)
42
+ })] }, e)) }),
43
+ a.provenance && /* @__PURE__ */ r("div", {
44
+ className: "text-sm",
45
+ children: [/* @__PURE__ */ r("p", { children: [
46
+ "Declared source ",
47
+ a.provenance.sourceReference,
48
+ " /",
49
+ " ",
50
+ a.provenance.sourceRevision,
51
+ "; observed",
52
+ " ",
53
+ a.provenance.observedAt ?? "Unknown",
54
+ "."
55
+ ] }), a.provenance.evidenceLinks.map((e) => /* @__PURE__ */ r("p", { children: [
56
+ "Exact Files link: ",
57
+ e.fileId,
58
+ "; version ",
59
+ e.versionId,
60
+ "."
61
+ ] }, JSON.stringify([e.fileId, e.versionId])))]
62
+ })
63
+ ]
64
+ }, e);
65
+ })
66
+ }),
67
+ /* @__PURE__ */ r("section", {
68
+ className: "space-y-2",
69
+ children: [
70
+ /* @__PURE__ */ n("h4", {
71
+ className: "font-medium",
72
+ children: "Server-recorded owner context (separate from declared facts)"
73
+ }),
74
+ /* @__PURE__ */ r("p", { children: [
75
+ "Shipment ",
76
+ i.ownerShipment.shipmentId,
77
+ "; revision at ",
78
+ i.ownerShipment.updatedAt,
79
+ "; mode ",
80
+ i.ownerShipment.primaryMode,
81
+ "."
82
+ ] }),
83
+ i.ownerLegs.length === 0 && /* @__PURE__ */ n("p", { children: "No legs selected for this capture. This does not mean the shipment has no legs." }),
84
+ i.ownerLegs.map((e) => /* @__PURE__ */ r("p", { children: [
85
+ "Leg ",
86
+ e.legNumber,
87
+ " (",
88
+ e.id,
89
+ ") / ",
90
+ e.mode,
91
+ "; revision ",
92
+ e.updatedAt,
93
+ "; carrier",
94
+ " ",
95
+ e.carrierName ?? "Not recorded",
96
+ " (",
97
+ e.carrierId ?? "No carrier reference",
98
+ "); weight",
99
+ " ",
100
+ e.weightKg ?? "Not recorded",
101
+ " kg; volume ",
102
+ e.volumeCbm ?? "Not recorded",
103
+ " m³; equipment ",
104
+ e.containerType ?? "Not recorded",
105
+ " × ",
106
+ e.containerCount ?? "Not recorded",
107
+ "."
108
+ ] }, e.id))
109
+ ]
110
+ })
111
+ ]
112
+ });
113
+ }
114
+ //#endregion
115
+ export { i as FreightCommercialHistory };
@@ -1,96 +1,105 @@
1
1
  import { Button as e } from "../ui.js";
2
2
  import { ContainerEvidencePicker as t } from "../ContainerEvidencePicker.js";
3
- import { FreightCurrency as n, FreightSelect as r, FreightText as i } from "./FreightFields.js";
4
- import { freightInstant as a, freightLocalTime as o, newFreightFacts as s, newFreightLine as c } from "../../utils/freightDraft.js";
5
- import { FreightLineEditor as l } from "./FreightLineEditor.js";
6
- import { FreightScopeEditor as u } from "./FreightScopeEditor.js";
7
- import { FreightFxEditor as d } from "./FreightFxEditor.js";
8
- import { FreightTotals as f } from "./FreightTotals.js";
9
- import { useRef as p, useState as m } from "react";
10
- import { jsx as h, jsxs as g } from "react/jsx-runtime";
3
+ import { commercialCanonical as n, commercialCaptureInput as r } from "../../utils/freightCommercial.js";
4
+ import { FreightCurrency as i, FreightSelect as a, FreightText as o } from "./FreightFields.js";
5
+ import { freightInstant as s, freightLocalTime as c, newFreightFacts as l, newFreightLine as u } from "../../utils/freightDraft.js";
6
+ import { FreightCommercialEditor as d } from "./FreightCommercialEditor.js";
7
+ import { FreightLineEditor as f } from "./FreightLineEditor.js";
8
+ import { FreightScopeEditor as p } from "./FreightScopeEditor.js";
9
+ import { FreightFxEditor as m } from "./FreightFxEditor.js";
10
+ import { FreightTotals as h } from "./FreightTotals.js";
11
+ import { useRef as g, useState as _ } from "react";
12
+ import { jsx as v, jsxs as y } from "react/jsx-runtime";
11
13
  //#region src/movethewheels/components/freight-cost/FreightDraftForm.tsx
12
- function _({ disabled: _, onPreview: v, onSave: y }) {
13
- let [b, x] = m(s), [S, C] = m([]), [w, T] = m(null), [E, D] = m(null), [O, k] = m(!1), A = p(!1), j = JSON.stringify(b), M = w?.body === j ? w.value : null, N = (e) => x({
14
- ...b,
14
+ function b({ disabled: b, shipmentId: x, onPreview: S, onSave: C }) {
15
+ let [w, T] = _(null), [E, D] = _(l), [O, k] = _([]), [A, j] = _(null), [M, N] = _(null), [P, F] = _(!1), I = g(!1), L = JSON.stringify(E), R = A?.body === L ? A.value : null, z = (e) => D({
16
+ ...E,
15
17
  ...e
16
- }), P = async () => {
17
- if (A.current) return;
18
- A.current = !0, k(!0), D(null);
19
- let e = structuredClone(b);
18
+ }), B = async () => {
19
+ if (I.current) return;
20
+ I.current = !0, F(!0), N(null);
21
+ let e = structuredClone(E);
20
22
  try {
21
- let t = await v(e);
22
- T({
23
+ let t = await S(e);
24
+ j({
23
25
  body: JSON.stringify(e),
24
26
  value: t
25
27
  });
26
28
  } catch (e) {
27
- D(e instanceof Error ? e.message : "Unable to preview these costs.");
29
+ N(e instanceof Error ? e.message : "Unable to preview these costs.");
28
30
  } finally {
29
- A.current = !1, k(!1);
31
+ I.current = !1, F(!1);
30
32
  }
31
33
  };
32
- return /* @__PURE__ */ g("form", {
34
+ return /* @__PURE__ */ y("form", {
33
35
  className: "space-y-6",
34
36
  onSubmit: (e) => {
35
- if (e.preventDefault(), !M) {
36
- P();
37
+ if (e.preventDefault(), !R) {
38
+ B();
37
39
  return;
38
40
  }
39
- D(null), y(structuredClone(b), structuredClone(S)).catch((e) => D(e instanceof Error ? e.message : "Unable to save this cost record."));
41
+ N(null);
42
+ try {
43
+ if (w && w.reviewed !== n(w.selectedLegs)) throw Error("Explicitly review the commercial leg selection before saving.");
44
+ let e = w ? r(w.facts, w.selectedLegs, O) : void 0;
45
+ C(structuredClone(E), structuredClone(O), e).catch((e) => N(e instanceof Error ? e.message : "Unable to save this cost record."));
46
+ } catch (e) {
47
+ N(e instanceof Error ? e.message : "Review commercial facts before saving.");
48
+ }
40
49
  },
41
50
  children: [
42
- /* @__PURE__ */ g("fieldset", {
43
- disabled: _ || O,
51
+ /* @__PURE__ */ y("fieldset", {
52
+ disabled: b || P,
44
53
  className: "space-y-5",
45
54
  children: [
46
- /* @__PURE__ */ h("legend", {
55
+ /* @__PURE__ */ v("legend", {
47
56
  className: "text-lg font-semibold",
48
57
  children: "Sourced cost draft"
49
58
  }),
50
- /* @__PURE__ */ g("div", {
59
+ /* @__PURE__ */ y("div", {
51
60
  className: "grid gap-3 md:grid-cols-2",
52
61
  children: [
53
- /* @__PURE__ */ h(i, {
62
+ /* @__PURE__ */ v(o, {
54
63
  label: "Estimate title",
55
- value: b.title,
64
+ value: E.title,
56
65
  required: !0,
57
- onChange: (e) => N({ title: e })
66
+ onChange: (e) => z({ title: e })
58
67
  }),
59
- /* @__PURE__ */ g(r, {
68
+ /* @__PURE__ */ y(a, {
60
69
  label: "Record type",
61
- value: b.kind,
70
+ value: E.kind,
62
71
  onChange: (e) => {
63
- (e === "ESTIMATE" || e === "QUOTE") && N({ kind: e });
72
+ (e === "ESTIMATE" || e === "QUOTE") && z({ kind: e });
64
73
  },
65
- children: [/* @__PURE__ */ h("option", {
74
+ children: [/* @__PURE__ */ v("option", {
66
75
  value: "ESTIMATE",
67
76
  children: "Estimate"
68
- }), /* @__PURE__ */ h("option", {
77
+ }), /* @__PURE__ */ v("option", {
69
78
  value: "QUOTE",
70
79
  children: "Reported quote"
71
80
  })]
72
81
  }),
73
- /* @__PURE__ */ h(i, {
82
+ /* @__PURE__ */ v(o, {
74
83
  label: "Commercial source",
75
- value: b.sourceReference,
84
+ value: E.sourceReference,
76
85
  required: !0,
77
- onChange: (e) => N({ sourceReference: e })
86
+ onChange: (e) => z({ sourceReference: e })
78
87
  }),
79
- /* @__PURE__ */ h(i, {
88
+ /* @__PURE__ */ v(o, {
80
89
  label: "Source version",
81
- value: b.sourceRevision,
90
+ value: E.sourceRevision,
82
91
  required: !0,
83
- onChange: (e) => N({ sourceRevision: e })
92
+ onChange: (e) => z({ sourceRevision: e })
84
93
  })
85
94
  ]
86
95
  }),
87
- /* @__PURE__ */ h(i, {
96
+ /* @__PURE__ */ v(o, {
88
97
  label: "Shipment and services covered by this source",
89
- value: b.commercialScope,
98
+ value: E.commercialScope,
90
99
  required: !0,
91
- onChange: (e) => N({ commercialScope: e })
100
+ onChange: (e) => z({ commercialScope: e })
92
101
  }),
93
- /* @__PURE__ */ g("p", {
102
+ /* @__PURE__ */ y("p", {
94
103
  className: "text-sm",
95
104
  children: [
96
105
  "Dates use your local time zone: ",
@@ -98,116 +107,122 @@ function _({ disabled: _, onPreview: v, onSave: y }) {
98
107
  ". They are recorded as exact UTC instants."
99
108
  ]
100
109
  }),
101
- /* @__PURE__ */ h(i, {
110
+ /* @__PURE__ */ v(o, {
102
111
  label: "Price applies at",
103
112
  type: "datetime-local",
104
- value: o(b.pricingAt),
113
+ value: c(E.pricingAt),
105
114
  required: !0,
106
115
  onChange: (e) => {
107
- e && N({ pricingAt: a(e) });
116
+ e && z({ pricingAt: s(e) });
108
117
  }
109
118
  }),
110
- /* @__PURE__ */ g("section", {
119
+ /* @__PURE__ */ y("section", {
111
120
  className: "space-y-4",
112
121
  children: [
113
- /* @__PURE__ */ h("h3", {
122
+ /* @__PURE__ */ v("h3", {
114
123
  className: "font-semibold",
115
124
  children: "Cost items"
116
125
  }),
117
- /* @__PURE__ */ h("p", {
126
+ /* @__PURE__ */ v("p", {
118
127
  className: "text-sm",
119
128
  children: "Blank amounts are unknown. Currency codes and decimal places are recorded conventions."
120
129
  }),
121
- b.lines.map((e) => /* @__PURE__ */ h(l, {
130
+ E.lines.map((e) => /* @__PURE__ */ v(f, {
122
131
  line: e,
123
- others: b.lines,
124
- onChange: (t) => N({ lines: b.lines.map((n) => n.id === e.id ? t : n) }),
125
- onRemove: () => N({ lines: b.lines.filter((t) => t.id !== e.id) })
132
+ others: E.lines,
133
+ onChange: (t) => z({ lines: E.lines.map((n) => n.id === e.id ? t : n) }),
134
+ onRemove: () => z({ lines: E.lines.filter((t) => t.id !== e.id) })
126
135
  }, e.id)),
127
- /* @__PURE__ */ h(e, {
136
+ /* @__PURE__ */ v(e, {
128
137
  type: "button",
129
138
  variant: "outline",
130
- disabled: b.lines.length >= 100,
131
- onClick: () => N({ lines: [...b.lines, c()] }),
139
+ disabled: E.lines.length >= 100,
140
+ onClick: () => z({ lines: [...E.lines, u()] }),
132
141
  children: "Add cost item"
133
142
  })
134
143
  ]
135
144
  }),
136
- /* @__PURE__ */ g("details", {
145
+ /* @__PURE__ */ y("details", {
137
146
  className: "space-y-4 rounded border p-4",
138
147
  children: [
139
- /* @__PURE__ */ h("summary", {
148
+ /* @__PURE__ */ v("summary", {
140
149
  className: "min-h-11 cursor-pointer font-medium",
141
150
  children: "Review cost scope, dates and conversion"
142
151
  }),
143
- /* @__PURE__ */ h(u, {
144
- value: b.requirements,
145
- onChange: (e) => N({ requirements: e })
152
+ /* @__PURE__ */ v(p, {
153
+ value: E.requirements,
154
+ onChange: (e) => z({ requirements: e })
146
155
  }),
147
- /* @__PURE__ */ g("section", {
156
+ /* @__PURE__ */ y("section", {
148
157
  className: "space-y-3",
149
- children: [/* @__PURE__ */ h("h3", {
158
+ children: [/* @__PURE__ */ v("h3", {
150
159
  className: "font-semibold",
151
160
  children: "Recorded quote dates"
152
161
  }), [
153
162
  "quotedAt",
154
163
  "validFrom",
155
164
  "validUntil"
156
- ].map((e) => /* @__PURE__ */ h(i, {
165
+ ].map((e) => /* @__PURE__ */ v(o, {
157
166
  label: e === "quotedAt" ? "Quote received at" : e === "validFrom" ? "Quote valid from" : "Quote valid until",
158
167
  type: "datetime-local",
159
- value: b[e] ? o(b[e]) : "",
160
- onChange: (t) => N({ [e]: t ? a(t) : null })
168
+ value: E[e] ? c(E[e]) : "",
169
+ onChange: (t) => z({ [e]: t ? s(t) : null })
161
170
  }, e))]
162
171
  }),
163
- /* @__PURE__ */ g(r, {
172
+ /* @__PURE__ */ y(a, {
164
173
  label: "Reporting total",
165
- value: b.reportingCurrency ? "RECORDED" : "UNKNOWN",
166
- onChange: (e) => N({ reportingCurrency: e === "RECORDED" ? {
174
+ value: E.reportingCurrency ? "RECORDED" : "UNKNOWN",
175
+ onChange: (e) => z({ reportingCurrency: e === "RECORDED" ? {
167
176
  code: "USD",
168
177
  minorUnitDigits: 2
169
178
  } : null }),
170
- children: [/* @__PURE__ */ h("option", {
179
+ children: [/* @__PURE__ */ v("option", {
171
180
  value: "UNKNOWN",
172
181
  children: "No reporting currency yet"
173
- }), /* @__PURE__ */ h("option", {
182
+ }), /* @__PURE__ */ v("option", {
174
183
  value: "RECORDED",
175
184
  children: "Use a recorded currency convention"
176
185
  })]
177
186
  }),
178
- b.reportingCurrency && /* @__PURE__ */ h(n, {
187
+ E.reportingCurrency && /* @__PURE__ */ v(i, {
179
188
  label: "Reporting currency convention",
180
- value: b.reportingCurrency,
181
- onChange: (e) => N({ reportingCurrency: e })
189
+ value: E.reportingCurrency,
190
+ onChange: (e) => z({ reportingCurrency: e })
182
191
  }),
183
- /* @__PURE__ */ h(d, {
184
- value: b.fx,
185
- onChange: (e) => N({ fx: e })
192
+ /* @__PURE__ */ v(m, {
193
+ value: E.fx,
194
+ onChange: (e) => z({ fx: e })
186
195
  })
187
196
  ]
188
197
  }),
189
- /* @__PURE__ */ h(t, {
190
- value: S,
191
- onChange: C,
198
+ /* @__PURE__ */ v(d, {
199
+ value: w,
200
+ onChange: T,
201
+ shipmentId: x,
202
+ evidence: O
203
+ }),
204
+ /* @__PURE__ */ v(t, {
205
+ value: O,
206
+ onChange: k,
192
207
  description: "Choose the exact source document versions. A readable document supports this reported record; it does not accept a quote or confirm capacity."
193
208
  })
194
209
  ]
195
210
  }),
196
- E && /* @__PURE__ */ h("p", {
211
+ M && /* @__PURE__ */ v("p", {
197
212
  role: "alert",
198
- children: E
213
+ children: M
199
214
  }),
200
- M && /* @__PURE__ */ h(f, {
201
- value: M,
202
- currency: b.reportingCurrency
215
+ R && /* @__PURE__ */ v(h, {
216
+ value: R,
217
+ currency: E.reportingCurrency
203
218
  }),
204
- /* @__PURE__ */ h(e, {
219
+ /* @__PURE__ */ v(e, {
205
220
  type: "submit",
206
- disabled: _ || O || b.lines.length === 0 || !!M && S.length === 0,
207
- children: O ? "Previewing…" : M ? "Save immutable cost version" : "Preview costs and missing facts"
221
+ disabled: b || P || E.lines.length === 0 || !!R && O.length === 0,
222
+ children: P ? "Previewing…" : R ? "Save immutable cost version" : "Preview costs and missing facts"
208
223
  })
209
224
  ]
210
225
  });
211
226
  }
212
227
  //#endregion
213
- export { _ as FreightDraftForm };
228
+ export { b as FreightDraftForm };