@burdenoff/microfe-movethewheels 2026.929.4 → 2026.930.1

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 (42) hide show
  1. package/dist/components/CustomerPicker.js +52 -48
  2. package/dist/components/EntityCombobox.js +25 -23
  3. package/dist/components/OrderItemRow.js +123 -78
  4. package/dist/hooks/useCustomers.js +52 -17
  5. package/dist/hooks/useFleet.js +126 -44
  6. package/dist/hooks/useInventory.js +43 -7
  7. package/dist/hooks/useMultiModalShipments.js +30 -26
  8. package/dist/hooks/useRoutes.js +55 -15
  9. package/dist/movethewheels/components/CustomerPicker.d.ts +5 -1
  10. package/dist/movethewheels/components/EntityCombobox.d.ts +6 -3
  11. package/dist/movethewheels/components/OrderItemRow.d.ts +7 -1
  12. package/dist/movethewheels/hooks/useCustomers.d.ts +3 -0
  13. package/dist/movethewheels/hooks/useFleet.d.ts +6 -0
  14. package/dist/movethewheels/hooks/useInventory.d.ts +2 -0
  15. package/dist/movethewheels/hooks/useMultiModalShipments.d.ts +1 -0
  16. package/dist/movethewheels/hooks/useRoutes.d.ts +3 -0
  17. package/dist/movethewheels/utils/orderValidation.d.ts +11 -0
  18. package/dist/pages/CreateOrderPage.js +349 -297
  19. package/dist/pages/DriverDetailsPage.js +337 -333
  20. package/dist/pages/DriversPage.js +3 -1
  21. package/dist/pages/MultiModalShipmentPage.js +139 -125
  22. package/dist/pages/OrderDetailsPage.js +132 -140
  23. package/dist/pages/RouteDetailsPage.js +202 -202
  24. package/dist/pages/TrackingPage.js +2 -1
  25. package/dist/utils/orderValidation.js +18 -0
  26. package/package.json +1 -1
  27. package/src/movethewheels/components/CustomerPicker.tsx +12 -0
  28. package/src/movethewheels/components/EntityCombobox.tsx +30 -11
  29. package/src/movethewheels/components/OrderItemRow.tsx +44 -0
  30. package/src/movethewheels/hooks/useCustomers.ts +38 -0
  31. package/src/movethewheels/hooks/useFleet.ts +125 -5
  32. package/src/movethewheels/hooks/useInventory.ts +42 -0
  33. package/src/movethewheels/hooks/useMultiModalShipments.ts +9 -7
  34. package/src/movethewheels/hooks/useRoutes.ts +51 -0
  35. package/src/movethewheels/pages/CreateOrderPage.tsx +66 -2
  36. package/src/movethewheels/pages/DriverDetailsPage.tsx +12 -1
  37. package/src/movethewheels/pages/DriversPage.tsx +7 -1
  38. package/src/movethewheels/pages/MultiModalShipmentPage.tsx +15 -1
  39. package/src/movethewheels/pages/OrderDetailsPage.tsx +25 -25
  40. package/src/movethewheels/pages/RouteDetailsPage.tsx +8 -4
  41. package/src/movethewheels/pages/TrackingPage.tsx +7 -2
  42. package/src/movethewheels/utils/orderValidation.ts +53 -0
@@ -16,8 +16,8 @@ import { useMoveTheWheels as te } from "../providers/MoveTheWheelsProvider.js";
16
16
  import { useRoute as ne, useRoutes as re } from "../hooks/useRoutes.js";
17
17
  import { useDriver as p, useDrivers as ie, useVehicle as ae, useVehicles as m } from "../hooks/useFleet.js";
18
18
  import { Badge as h, Button as g, Card as _, CardContent as v, CardHeader as y, CardTitle as b, Input as x, Label as S, Select as C, SelectContent as w, SelectItem as T, SelectTrigger as E, SelectValue as D } from "../components/ui.js";
19
- import { ErrorState as oe, LoadingState as se, PageLayout as O } from "../components/PageLayout.js";
20
- import { RouteMap as k } from "../components/maps/RouteMap.js";
19
+ import { ErrorState as oe, LoadingState as O, PageLayout as k } from "../components/PageLayout.js";
20
+ import { RouteMap as se } from "../components/maps/RouteMap.js";
21
21
  import "../components/maps/index.js";
22
22
  import { ROUTE_STATUS_COLORS as A } from "../constants/index.js";
23
23
  import { StatusBadge as j } from "../components/StatusBadge.js";
@@ -25,16 +25,16 @@ import { FormError as M } from "../components/FormError.js";
25
25
  import { Notice as N, useNotice as ce } from "../components/Notice.js";
26
26
  import { formatAddress as P, formatCurrency as le, formatDate as F } from "../utils/formatters.js";
27
27
  import { EntityCombobox as I } from "../components/EntityCombobox.js";
28
- import { firstRealLatLng as L } from "../utils/mapMarkers.js";
29
- import { useAssignmentSuggestions as ue } from "../hooks/useFleetIntelligence.js";
30
- import { AssignmentSuggestions as de } from "../components/AssignmentSuggestions.js";
31
- import { useEffect as R, useState as z } from "react";
32
- import { useLocation as B, useParams as V } from "react-router";
33
- import { Fragment as H, jsx as U, jsxs as W } from "react/jsx-runtime";
34
- import { useI18n as fe } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
35
- import { EmphasisPanel as pe, NextSteps as me, PagePurpose as he, ResponsiveDialog as ge, ResponsiveDialogContent as _e, ResponsiveDialogDescription as G, ResponsiveDialogFooter as K, ResponsiveDialogHeader as ve, ResponsiveDialogTitle as q } from "@burdenoff/fe-libs/ui";
28
+ import { firstRealLatLng as ue } from "../utils/mapMarkers.js";
29
+ import { useAssignmentSuggestions as de } from "../hooks/useFleetIntelligence.js";
30
+ import { AssignmentSuggestions as fe } from "../components/AssignmentSuggestions.js";
31
+ import { useEffect as L, useState as R } from "react";
32
+ import { useLocation as z, useParams as B } from "react-router";
33
+ import { Fragment as V, jsx as H, jsxs as U } from "react/jsx-runtime";
34
+ import { useI18n as pe } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
35
+ import { EmphasisPanel as me, NextSteps as he, PagePurpose as ge, ResponsiveDialog as _e, ResponsiveDialogContent as ve, ResponsiveDialogDescription as ye, ResponsiveDialogFooter as be, ResponsiveDialogHeader as xe, ResponsiveDialogTitle as Se } from "@burdenoff/fe-libs/ui";
36
36
  //#region src/movethewheels/pages/RouteDetailsPage.tsx
37
- var J = [
37
+ var W = [
38
38
  {
39
39
  value: "planned",
40
40
  label: "Planned"
@@ -52,8 +52,8 @@ var J = [
52
52
  label: "Cancelled"
53
53
  }
54
54
  ];
55
- function Y({ editId: r }) {
56
- let { basePath: i, navigate: a } = te(), { createRoute: ee, updateRoute: l } = re(), { route: d } = ne(r), [h, oe] = z(""), [se, k] = z(""), A = !!r, [j, N] = z({
55
+ function G({ editId: r }) {
56
+ let { basePath: i, navigate: a } = te(), { createRoute: ee, updateRoute: l } = re(), { route: d } = ne(r), [h, oe] = R(""), [O, se] = R(""), A = !!r, [j, N] = R({
57
57
  name: "",
58
58
  status: "planned",
59
59
  vehicleId: "",
@@ -62,16 +62,14 @@ function Y({ editId: r }) {
62
62
  address: "",
63
63
  type: "delivery"
64
64
  }]
65
- }), { vehicles: ce, isLoading: le, hasMore: F, totalVehicles: L } = m({
65
+ }), { vehicles: ce, isLoading: le, hasMore: F, totalVehicles: ue, loadMore: de, isLoadingMore: fe } = m({
66
66
  limit: 20,
67
- search: h || void 0,
68
- driverId: j.driverId || void 0
69
- }), { drivers: ue, isLoading: de, hasMore: B, totalDrivers: V } = ie({
67
+ search: h || void 0
68
+ }), { drivers: z, isLoading: B, hasMore: pe, totalDrivers: he, loadMore: _e, isLoadingMore: ve } = ie({
70
69
  limit: 20,
71
- search: se || void 0,
72
- vehicleId: j.vehicleId || void 0
73
- }), { vehicle: fe, isLoading: me } = ae(j.vehicleId || void 0), { driver: ge, isLoading: _e } = p(j.driverId || void 0), [G, K] = z(!1), [ve, q] = z(null);
74
- R(() => {
70
+ search: O || void 0
71
+ }), { vehicle: ye, isLoading: be } = ae(j.vehicleId || void 0), { driver: xe, isLoading: Se } = p(j.driverId || void 0), [G, K] = R(!1), [Ce, q] = R(null);
72
+ L(() => {
75
73
  !r || !d || N({
76
74
  name: d.name || "",
77
75
  status: d.status,
@@ -86,13 +84,13 @@ function Y({ editId: r }) {
86
84
  }]
87
85
  });
88
86
  }, [r, d]);
89
- let Y = () => a?.(f(i, "routes")), X = () => N((e) => ({
87
+ let J = () => a?.(f(i, "routes")), Y = () => N((e) => ({
90
88
  ...e,
91
89
  stops: [...e.stops, {
92
90
  address: "",
93
91
  type: "delivery"
94
92
  }]
95
- })), ye = (e) => N((t) => ({
93
+ })), X = (e) => N((t) => ({
96
94
  ...t,
97
95
  stops: t.stops.filter((t, n) => n !== e)
98
96
  })), Z = (e, t, n) => N((r) => ({
@@ -158,51 +156,51 @@ function Y({ editId: r }) {
158
156
  console.error("Failed to create route:", e), q(e instanceof Error ? e.message : "Failed to create route. Please try again."), K(!1);
159
157
  }
160
158
  };
161
- return /* @__PURE__ */ W(O, {
159
+ return /* @__PURE__ */ U(k, {
162
160
  title: A ? "Edit Route" : "Create Route",
163
161
  subtitle: "Plan a new delivery route",
164
- icon: /* @__PURE__ */ U(o, { size: 24 }),
165
- headerActions: /* @__PURE__ */ W("div", {
162
+ icon: /* @__PURE__ */ H(o, { size: 24 }),
163
+ headerActions: /* @__PURE__ */ U("div", {
166
164
  className: "flex gap-2",
167
- children: [/* @__PURE__ */ W(g, {
165
+ children: [/* @__PURE__ */ U(g, {
168
166
  variant: "outline",
169
- onClick: Y,
167
+ onClick: J,
170
168
  disabled: G,
171
- children: [/* @__PURE__ */ U(t, { size: 16 }), " Cancel"]
172
- }), /* @__PURE__ */ W(g, {
169
+ children: [/* @__PURE__ */ H(t, { size: 16 }), " Cancel"]
170
+ }), /* @__PURE__ */ U(g, {
173
171
  onClick: $,
174
172
  disabled: G,
175
173
  children: [
176
- /* @__PURE__ */ U(c, { size: 16 }),
174
+ /* @__PURE__ */ H(c, { size: 16 }),
177
175
  " ",
178
176
  A ? G ? "Saving..." : "Save Changes" : G ? "Saving..." : "Create Route"
179
177
  ]
180
178
  })]
181
179
  }),
182
- children: [/* @__PURE__ */ U(he, {
183
- icon: /* @__PURE__ */ U(o, { size: 18 }),
180
+ children: [/* @__PURE__ */ H(ge, {
181
+ icon: /* @__PURE__ */ H(o, { size: 18 }),
184
182
  children: "Plan a new delivery route — name it, list the stops to visit, and optionally assign a vehicle and driver. Once created you can optimize it to sequence the stops into the shortest run."
185
- }), /* @__PURE__ */ W("form", {
183
+ }), /* @__PURE__ */ U("form", {
186
184
  onSubmit: $,
187
185
  className: "max-w-3xl space-y-6",
188
186
  children: [
189
- /* @__PURE__ */ U(M, { message: ve }),
190
- /* @__PURE__ */ W(pe, { children: [/* @__PURE__ */ U("h2", {
187
+ /* @__PURE__ */ H(M, { message: Ce }),
188
+ /* @__PURE__ */ U(me, { children: [/* @__PURE__ */ H("h2", {
191
189
  className: "text-base font-semibold text-text-primary mb-4",
192
190
  children: "Route Details"
193
- }), /* @__PURE__ */ W("div", {
191
+ }), /* @__PURE__ */ U("div", {
194
192
  className: "space-y-4",
195
- children: [/* @__PURE__ */ W("div", {
193
+ children: [/* @__PURE__ */ U("div", {
196
194
  className: "grid grid-cols-1 md:grid-cols-2 gap-4",
197
- children: [/* @__PURE__ */ W("div", {
195
+ children: [/* @__PURE__ */ U("div", {
198
196
  className: "space-y-2",
199
- children: [/* @__PURE__ */ W(S, {
197
+ children: [/* @__PURE__ */ U(S, {
200
198
  htmlFor: "name",
201
- children: ["Route Name ", /* @__PURE__ */ U("span", {
199
+ children: ["Route Name ", /* @__PURE__ */ H("span", {
202
200
  className: "text-status-error-text",
203
201
  children: "*"
204
202
  })]
205
- }), /* @__PURE__ */ U(x, {
203
+ }), /* @__PURE__ */ H(x, {
206
204
  id: "name",
207
205
  value: j.name,
208
206
  onChange: (e) => N((t) => ({
@@ -212,34 +210,34 @@ function Y({ editId: r }) {
212
210
  placeholder: "Downtown morning run",
213
211
  required: !0
214
212
  })]
215
- }), /* @__PURE__ */ W("div", {
213
+ }), /* @__PURE__ */ U("div", {
216
214
  className: "space-y-2",
217
- children: [/* @__PURE__ */ U(S, {
215
+ children: [/* @__PURE__ */ H(S, {
218
216
  htmlFor: "status",
219
217
  children: "Status"
220
- }), /* @__PURE__ */ W(C, {
218
+ }), /* @__PURE__ */ U(C, {
221
219
  value: j.status,
222
220
  onValueChange: (e) => N((t) => ({
223
221
  ...t,
224
222
  status: e
225
223
  })),
226
- children: [/* @__PURE__ */ U(E, {
224
+ children: [/* @__PURE__ */ H(E, {
227
225
  id: "status",
228
- children: /* @__PURE__ */ U(D, {})
229
- }), /* @__PURE__ */ U(w, { children: J.map((e) => /* @__PURE__ */ U(T, {
226
+ children: /* @__PURE__ */ H(D, {})
227
+ }), /* @__PURE__ */ H(w, { children: W.map((e) => /* @__PURE__ */ H(T, {
230
228
  value: e.value,
231
229
  children: e.label
232
230
  }, e.value)) })]
233
231
  })]
234
232
  })]
235
- }), /* @__PURE__ */ W("div", {
233
+ }), /* @__PURE__ */ U("div", {
236
234
  className: "grid grid-cols-1 md:grid-cols-2 gap-4",
237
- children: [/* @__PURE__ */ W("div", {
235
+ children: [/* @__PURE__ */ U("div", {
238
236
  className: "space-y-2",
239
- children: [/* @__PURE__ */ U(S, {
237
+ children: [/* @__PURE__ */ H(S, {
240
238
  htmlFor: "vehicle",
241
239
  children: "Vehicle (optional)"
242
- }), /* @__PURE__ */ U(I, {
240
+ }), /* @__PURE__ */ H(I, {
243
241
  id: "vehicle",
244
242
  value: j.vehicleId,
245
243
  onChange: (e) => N((t) => ({
@@ -250,140 +248,142 @@ function Y({ editId: r }) {
250
248
  loading: le,
251
249
  getId: (e) => e.id,
252
250
  getLabel: (e) => `${e.vehicleNumber} (${e.type})`,
253
- renderOption: (e) => /* @__PURE__ */ W(H, { children: [
251
+ renderOption: (e) => /* @__PURE__ */ U(V, { children: [
254
252
  e.vehicleNumber,
255
253
  " (",
256
254
  e.type,
257
255
  ")"
258
256
  ] }),
259
- selectedOption: fe,
260
- selectedLoading: me,
257
+ selectedOption: ye,
258
+ selectedLoading: be,
261
259
  onSearchChange: oe,
262
260
  searchPlaceholder: "Search vehicle number or type…",
263
261
  hasMore: F,
264
- totalCount: L,
265
- required: !0,
262
+ totalCount: ue,
263
+ onLoadMore: de,
264
+ loadingMore: fe,
266
265
  placeholder: "Assign later",
267
266
  emptyText: "No available vehicles."
268
267
  })]
269
- }), /* @__PURE__ */ W("div", {
268
+ }), /* @__PURE__ */ U("div", {
270
269
  className: "space-y-2",
271
- children: [/* @__PURE__ */ U(S, {
270
+ children: [/* @__PURE__ */ H(S, {
272
271
  htmlFor: "driver",
273
272
  children: "Driver (optional)"
274
- }), /* @__PURE__ */ U(I, {
273
+ }), /* @__PURE__ */ H(I, {
275
274
  id: "driver",
276
275
  value: j.driverId,
277
276
  onChange: (e) => N((t) => ({
278
277
  ...t,
279
278
  driverId: e
280
279
  })),
281
- options: ue,
282
- loading: de,
280
+ options: z,
281
+ loading: B,
283
282
  getId: (e) => e.id,
284
283
  getLabel: (e) => `${e.fullName} (${e.employeeId})`,
285
- renderOption: (e) => /* @__PURE__ */ W(H, { children: [
284
+ renderOption: (e) => /* @__PURE__ */ U(V, { children: [
286
285
  e.fullName,
287
286
  " (",
288
287
  e.employeeId,
289
288
  ")"
290
289
  ] }),
291
- selectedOption: ge,
292
- selectedLoading: _e,
293
- onSearchChange: k,
290
+ selectedOption: xe,
291
+ selectedLoading: Se,
292
+ onSearchChange: se,
294
293
  searchPlaceholder: "Search driver name or employee ID…",
295
- hasMore: B,
296
- totalCount: V,
297
- required: !0,
294
+ hasMore: pe,
295
+ totalCount: he,
296
+ onLoadMore: _e,
297
+ loadingMore: ve,
298
298
  placeholder: "Assign later",
299
299
  emptyText: "No available drivers."
300
300
  })]
301
301
  })]
302
302
  })]
303
303
  })] }),
304
- /* @__PURE__ */ W(_, { children: [/* @__PURE__ */ W(y, {
304
+ /* @__PURE__ */ U(_, { children: [/* @__PURE__ */ U(y, {
305
305
  className: "flex flex-row items-center justify-between",
306
- children: [/* @__PURE__ */ W(b, { children: ["Stops ", /* @__PURE__ */ U("span", {
306
+ children: [/* @__PURE__ */ U(b, { children: ["Stops ", /* @__PURE__ */ H("span", {
307
307
  className: "text-status-error-text",
308
308
  children: "*"
309
- })] }), /* @__PURE__ */ W(g, {
309
+ })] }), /* @__PURE__ */ U(g, {
310
310
  type: "button",
311
311
  variant: "outline",
312
312
  size: "sm",
313
- onClick: X,
314
- children: [/* @__PURE__ */ U(s, { size: 16 }), " Add Stop"]
313
+ onClick: Y,
314
+ children: [/* @__PURE__ */ H(s, { size: 16 }), " Add Stop"]
315
315
  })]
316
- }), /* @__PURE__ */ U(v, {
316
+ }), /* @__PURE__ */ H(v, {
317
317
  className: "space-y-4",
318
- children: j.stops.map((t, r) => /* @__PURE__ */ W("div", {
318
+ children: j.stops.map((t, r) => /* @__PURE__ */ U("div", {
319
319
  className: "grid grid-cols-1 md:grid-cols-12 gap-3 items-end",
320
320
  children: [
321
- /* @__PURE__ */ W("div", {
321
+ /* @__PURE__ */ U("div", {
322
322
  className: "md:col-span-7 space-y-2",
323
- children: [/* @__PURE__ */ W(S, {
323
+ children: [/* @__PURE__ */ U(S, {
324
324
  htmlFor: `stop-address-${r}`,
325
325
  children: [
326
326
  "Stop ",
327
327
  r + 1,
328
328
  " address"
329
329
  ]
330
- }), /* @__PURE__ */ U(x, {
330
+ }), /* @__PURE__ */ H(x, {
331
331
  id: `stop-address-${r}`,
332
332
  value: t.address,
333
333
  onChange: (e) => Z(r, "address", e.target.value),
334
334
  placeholder: "123 Main St, San Francisco, CA"
335
335
  })]
336
336
  }),
337
- /* @__PURE__ */ W("div", {
337
+ /* @__PURE__ */ U("div", {
338
338
  className: "md:col-span-4 space-y-2",
339
- children: [/* @__PURE__ */ U(S, {
339
+ children: [/* @__PURE__ */ H(S, {
340
340
  htmlFor: `stop-type-${r}`,
341
341
  children: "Type"
342
- }), /* @__PURE__ */ W(C, {
342
+ }), /* @__PURE__ */ U(C, {
343
343
  value: t.type,
344
344
  onValueChange: (e) => Z(r, "type", e),
345
- children: [/* @__PURE__ */ U(E, {
345
+ children: [/* @__PURE__ */ H(E, {
346
346
  id: `stop-type-${r}`,
347
- children: /* @__PURE__ */ U(D, {})
348
- }), /* @__PURE__ */ W(w, { children: [/* @__PURE__ */ U(T, {
347
+ children: /* @__PURE__ */ H(D, {})
348
+ }), /* @__PURE__ */ U(w, { children: [/* @__PURE__ */ H(T, {
349
349
  value: "pickup",
350
350
  children: "Pickup"
351
- }), /* @__PURE__ */ U(T, {
351
+ }), /* @__PURE__ */ H(T, {
352
352
  value: "delivery",
353
353
  children: "Delivery"
354
354
  })] })]
355
355
  })]
356
356
  }),
357
- /* @__PURE__ */ W("div", {
357
+ /* @__PURE__ */ U("div", {
358
358
  className: "md:col-span-1 flex justify-end gap-1",
359
359
  children: [
360
- /* @__PURE__ */ U(g, {
360
+ /* @__PURE__ */ H(g, {
361
361
  type: "button",
362
362
  variant: "ghost",
363
363
  size: "icon",
364
364
  onClick: () => Q(r, -1),
365
365
  disabled: r === 0,
366
366
  "aria-label": `Move stop ${r + 1} up`,
367
- children: /* @__PURE__ */ U(n, { size: 16 })
367
+ children: /* @__PURE__ */ H(n, { size: 16 })
368
368
  }),
369
- /* @__PURE__ */ U(g, {
369
+ /* @__PURE__ */ H(g, {
370
370
  type: "button",
371
371
  variant: "ghost",
372
372
  size: "icon",
373
373
  onClick: () => Q(r, 1),
374
374
  disabled: r === j.stops.length - 1,
375
375
  "aria-label": `Move stop ${r + 1} down`,
376
- children: /* @__PURE__ */ U(e, { size: 16 })
376
+ children: /* @__PURE__ */ H(e, { size: 16 })
377
377
  }),
378
- /* @__PURE__ */ U(g, {
378
+ /* @__PURE__ */ H(g, {
379
379
  type: "button",
380
380
  variant: "ghost",
381
381
  size: "icon",
382
382
  className: "text-status-error-text",
383
- onClick: () => ye(r),
383
+ onClick: () => X(r),
384
384
  disabled: j.stops.length === 1,
385
385
  "aria-label": `Remove stop ${r + 1}`,
386
- children: /* @__PURE__ */ U(u, { size: 16 })
386
+ children: /* @__PURE__ */ H(u, { size: 16 })
387
387
  })
388
388
  ]
389
389
  })
@@ -394,42 +394,42 @@ function Y({ editId: r }) {
394
394
  })]
395
395
  });
396
396
  }
397
- function X() {
398
- let { routeId: e } = V(), n = B().pathname.endsWith("/edit"), { basePath: s, navigate: c } = te(), { route: p, isLoading: ie, error: ae, refetch: m } = ne(e), { optimizeRoute: x, updateRoute: S, deleteRoute: C } = re(), w = ue(e), { t: T } = fe(), E = (e, t) => {
397
+ function K() {
398
+ let { routeId: e } = B(), n = z().pathname.endsWith("/edit"), { basePath: s, navigate: c } = te(), { route: p, isLoading: ie, error: ae, refetch: m } = ne(e), { optimizeRoute: x, updateRoute: S, deleteRoute: C } = re(), w = de(e), { t: T } = pe(), E = (e, t) => {
399
399
  let n = T(e);
400
400
  return n === e ? t : n;
401
- }, { message: D, notify: I } = ce(), [R, H] = z(null), [J, X] = z(!1), [ye, Z] = z(!1), [Q, $] = z(!1), [be, xe] = z(null), Se = () => c?.(f(s, "routes")), Ce = (e) => c?.(f(s, e)), we = async () => {
401
+ }, { message: D, notify: I } = ce(), [L, V] = R(null), [W, K] = R(!1), [Ce, q] = R(!1), [J, Y] = R(!1), [X, Z] = R(null), Q = () => c?.(f(s, "routes")), $ = (e) => c?.(f(s, e)), we = async () => {
402
402
  if (e) {
403
- $(!0), xe(null);
403
+ Y(!0), Z(null);
404
404
  try {
405
- await C(e), Z(!1), Se();
405
+ await C(e), q(!1), Q();
406
406
  } catch (e) {
407
- xe(e instanceof Error ? e.message : "Failed to delete route."), $(!1);
407
+ Z(e instanceof Error ? e.message : "Failed to delete route."), Y(!1);
408
408
  }
409
409
  }
410
410
  }, Te = async () => {
411
411
  if (e) {
412
- X(!0), H(null);
412
+ K(!0), V(null);
413
413
  try {
414
414
  await x(e), I("Route optimized — stops resequenced for the shortest run."), m();
415
415
  } catch (e) {
416
- H(e instanceof Error ? e.message : "Failed to optimize route.");
416
+ V(e instanceof Error ? e.message : "Failed to optimize route.");
417
417
  } finally {
418
- X(!1);
418
+ K(!1);
419
419
  }
420
420
  }
421
421
  }, Ee = async (t) => {
422
422
  e && (await S(e, t), I(E("movethewheels.routes.suggest.done", "Assignment saved.")), m(), w.refetch());
423
423
  };
424
- if (!e) return /* @__PURE__ */ U(Y, {});
425
- if (n) return /* @__PURE__ */ U(Y, { editId: e });
426
- if (ie) return /* @__PURE__ */ U(se, { message: "Loading route details..." });
427
- if (ae || !p) return /* @__PURE__ */ U(oe, {
424
+ if (!e) return /* @__PURE__ */ H(G, {});
425
+ if (n) return /* @__PURE__ */ H(G, { editId: e });
426
+ if (ie) return /* @__PURE__ */ H(O, { message: "Loading route details..." });
427
+ if (ae || !p) return /* @__PURE__ */ H(oe, {
428
428
  title: "Route not found",
429
429
  onRetry: m
430
430
  });
431
431
  let De = p.stops.map((e) => {
432
- let t = L(e.address);
432
+ let t = ue(e.address);
433
433
  return t ? {
434
434
  lat: t.lat,
435
435
  lng: t.lng,
@@ -437,152 +437,152 @@ function X() {
437
437
  label: P(e.address) || `Order #${e.orderId || e.sequence}`
438
438
  } : null;
439
439
  }).filter((e) => e !== null);
440
- return /* @__PURE__ */ W(O, {
440
+ return /* @__PURE__ */ U(k, {
441
441
  title: p.name,
442
442
  subtitle: `${p.stops.length} stops - ${p.distance.toFixed(1)} km`,
443
- icon: /* @__PURE__ */ U(o, { size: 24 }),
444
- headerActions: /* @__PURE__ */ W("div", {
443
+ icon: /* @__PURE__ */ H(o, { size: 24 }),
444
+ headerActions: /* @__PURE__ */ U("div", {
445
445
  className: "flex gap-2",
446
446
  children: [
447
- /* @__PURE__ */ W(g, {
447
+ /* @__PURE__ */ U(g, {
448
448
  variant: "outline",
449
- onClick: Se,
450
- children: [/* @__PURE__ */ U(t, { size: 16 }), " Back"]
449
+ onClick: Q,
450
+ children: [/* @__PURE__ */ H(t, { size: 16 }), " Back"]
451
451
  }),
452
- !p.optimized && /* @__PURE__ */ W(g, {
452
+ !p.optimized && /* @__PURE__ */ U(g, {
453
453
  variant: "outline",
454
454
  onClick: Te,
455
- disabled: J,
455
+ disabled: W,
456
456
  children: [
457
- /* @__PURE__ */ U(d, { size: 16 }),
457
+ /* @__PURE__ */ H(d, { size: 16 }),
458
458
  " ",
459
- J ? "Optimizing…" : "Optimize"
459
+ W ? "Optimizing…" : "Optimize"
460
460
  ]
461
461
  }),
462
- /* @__PURE__ */ W(g, {
462
+ /* @__PURE__ */ U(g, {
463
463
  onClick: () => c?.(f(s, `routes/${e}/edit`)),
464
- children: [/* @__PURE__ */ U(l, { size: 16 }), " Edit"]
464
+ children: [/* @__PURE__ */ H(l, { size: 16 }), " Edit"]
465
465
  })
466
466
  ]
467
467
  }),
468
- headerContent: /* @__PURE__ */ W("div", {
468
+ headerContent: /* @__PURE__ */ U("div", {
469
469
  className: "flex gap-2",
470
- children: [/* @__PURE__ */ U(j, {
470
+ children: [/* @__PURE__ */ H(j, {
471
471
  status: p.status,
472
472
  customColors: A[p.status]
473
- }), /* @__PURE__ */ U(h, {
473
+ }), /* @__PURE__ */ H(h, {
474
474
  variant: p.optimized === !0 ? "default" : "secondary",
475
475
  children: p.optimized === void 0 ? "Optimization unknown" : p.optimized ? "Optimized" : "Not Optimized"
476
476
  })]
477
477
  }),
478
478
  children: [
479
- /* @__PURE__ */ U(he, {
480
- icon: /* @__PURE__ */ U(o, { size: 18 }),
479
+ /* @__PURE__ */ H(ge, {
480
+ icon: /* @__PURE__ */ H(o, { size: 18 }),
481
481
  children: "A single optimized driving plan that chains together this route's stops. Review the sequence, distance and timing here, re-optimize if traffic or stops change, then hand the itinerary to a driver."
482
482
  }),
483
- /* @__PURE__ */ U(me, {
483
+ /* @__PURE__ */ H(he, {
484
484
  storageKey: "movethewheels-route-details",
485
485
  steps: [
486
486
  ...p.optimized ? [] : [{
487
487
  id: "optimize",
488
488
  label: "Optimize this route",
489
489
  description: "Reorder stops to cut distance and driving time.",
490
- icon: /* @__PURE__ */ U(d, { size: 16 }),
490
+ icon: /* @__PURE__ */ H(d, { size: 16 }),
491
491
  onClick: Te
492
492
  }],
493
493
  {
494
494
  id: "edit",
495
495
  label: "Adjust stops",
496
496
  description: "Add, remove or reorder the delivery stops.",
497
- icon: /* @__PURE__ */ U(l, { size: 16 }),
497
+ icon: /* @__PURE__ */ H(l, { size: 16 }),
498
498
  onClick: () => {}
499
499
  },
500
500
  {
501
501
  id: "orders",
502
502
  label: "Review the orders on this route",
503
503
  description: "Check the deliveries bundled into this run.",
504
- icon: /* @__PURE__ */ U(ee, { size: 16 }),
505
- onClick: () => Ce("orders")
504
+ icon: /* @__PURE__ */ H(ee, { size: 16 }),
505
+ onClick: () => $("orders")
506
506
  }
507
507
  ]
508
508
  }),
509
- R && /* @__PURE__ */ U("div", {
509
+ L && /* @__PURE__ */ H("div", {
510
510
  className: "mb-2",
511
- children: /* @__PURE__ */ U(M, { message: R })
511
+ children: /* @__PURE__ */ H(M, { message: L })
512
512
  }),
513
- D && /* @__PURE__ */ U("div", {
513
+ D && /* @__PURE__ */ H("div", {
514
514
  className: "mb-2",
515
- children: /* @__PURE__ */ U(N, { message: D })
515
+ children: /* @__PURE__ */ H(N, { message: D })
516
516
  }),
517
- /* @__PURE__ */ W("div", {
517
+ /* @__PURE__ */ U("div", {
518
518
  className: "grid grid-cols-1 lg:grid-cols-3 gap-6",
519
- children: [/* @__PURE__ */ W("div", {
519
+ children: [/* @__PURE__ */ U("div", {
520
520
  className: "lg:col-span-2 space-y-6",
521
- children: [/* @__PURE__ */ W(_, { children: [/* @__PURE__ */ U(y, { children: /* @__PURE__ */ U(b, { children: "Route Map" }) }), /* @__PURE__ */ U(v, { children: De.length > 0 ? /* @__PURE__ */ U(k, {
521
+ children: [/* @__PURE__ */ U(_, { children: [/* @__PURE__ */ H(y, { children: /* @__PURE__ */ H(b, { children: "Route Map" }) }), /* @__PURE__ */ H(v, { children: De.length > 0 ? /* @__PURE__ */ H(se, {
522
522
  className: "overflow-hidden rounded-lg border border-border-seam",
523
523
  height: 360,
524
524
  stops: De
525
- }) : /* @__PURE__ */ W("div", {
525
+ }) : /* @__PURE__ */ U("div", {
526
526
  className: "rounded-lg border border-border-seam bg-bg-sunken/40 p-4",
527
- children: [/* @__PURE__ */ U("p", {
527
+ children: [/* @__PURE__ */ H("p", {
528
528
  className: "mb-3 text-sm text-text-secondary",
529
529
  children: "These stops don't have map coordinates yet — showing the planned sequence instead."
530
- }), /* @__PURE__ */ U("ol", {
530
+ }), /* @__PURE__ */ H("ol", {
531
531
  className: "space-y-2",
532
- children: p.stops.map((e) => /* @__PURE__ */ W("li", {
532
+ children: p.stops.map((e) => /* @__PURE__ */ U("li", {
533
533
  className: "flex items-start gap-3",
534
- children: [/* @__PURE__ */ U("span", {
534
+ children: [/* @__PURE__ */ H("span", {
535
535
  className: "flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-action-primary-bg/10 text-xs font-semibold text-primary",
536
536
  children: e.sequence
537
- }), /* @__PURE__ */ U("span", {
537
+ }), /* @__PURE__ */ H("span", {
538
538
  className: "text-sm",
539
539
  children: P(e.address) || `Order #${e.orderId || e.sequence}`
540
540
  })]
541
541
  }, e.id))
542
542
  })]
543
- }) })] }), /* @__PURE__ */ W(_, { children: [/* @__PURE__ */ U(y, { children: /* @__PURE__ */ W(b, { children: [
543
+ }) })] }), /* @__PURE__ */ U(_, { children: [/* @__PURE__ */ H(y, { children: /* @__PURE__ */ U(b, { children: [
544
544
  "Stops (",
545
545
  p.stops.length,
546
546
  ")"
547
- ] }) }), /* @__PURE__ */ U(v, { children: /* @__PURE__ */ U("div", {
547
+ ] }) }), /* @__PURE__ */ H(v, { children: /* @__PURE__ */ H("div", {
548
548
  className: "space-y-4",
549
- children: p.stops.map((e, t) => /* @__PURE__ */ W("div", {
549
+ children: p.stops.map((e, t) => /* @__PURE__ */ U("div", {
550
550
  className: "flex gap-4",
551
- children: [/* @__PURE__ */ W("div", {
551
+ children: [/* @__PURE__ */ U("div", {
552
552
  className: "relative",
553
- children: [/* @__PURE__ */ U("div", {
553
+ children: [/* @__PURE__ */ H("div", {
554
554
  className: `w-8 h-8 rounded-full flex items-center justify-center ${e.status === "completed" ? "bg-status-success-text text-text-inverse" : "bg-bg-sunken"}`,
555
- children: e.status === "completed" ? /* @__PURE__ */ U(r, { size: 16 }) : e.sequence
556
- }), t < p.stops.length - 1 && /* @__PURE__ */ U("div", { className: "absolute top-8 left-4 w-px h-12 bg-border" })]
557
- }), /* @__PURE__ */ U("div", {
555
+ children: e.status === "completed" ? /* @__PURE__ */ H(r, { size: 16 }) : e.sequence
556
+ }), t < p.stops.length - 1 && /* @__PURE__ */ H("div", { className: "absolute top-8 left-4 w-px h-12 bg-border" })]
557
+ }), /* @__PURE__ */ H("div", {
558
558
  className: "flex-1 pb-4",
559
- children: /* @__PURE__ */ W("div", {
559
+ children: /* @__PURE__ */ U("div", {
560
560
  className: "flex items-center justify-between",
561
- children: [/* @__PURE__ */ W("div", { children: [/* @__PURE__ */ W("div", {
561
+ children: [/* @__PURE__ */ U("div", { children: [/* @__PURE__ */ U("div", {
562
562
  className: "flex items-center gap-2",
563
- children: [/* @__PURE__ */ U(h, {
563
+ children: [/* @__PURE__ */ H(h, {
564
564
  variant: e.type === "pickup" ? "secondary" : "default",
565
565
  className: "capitalize",
566
566
  children: e.type
567
- }), /* @__PURE__ */ W("span", {
567
+ }), /* @__PURE__ */ U("span", {
568
568
  className: "font-medium",
569
569
  children: ["Order #", e.orderId]
570
570
  })]
571
- }), /* @__PURE__ */ U("p", {
571
+ }), /* @__PURE__ */ H("p", {
572
572
  className: "text-sm text-text-secondary mt-1",
573
573
  children: P(e.address)
574
- })] }), /* @__PURE__ */ W("div", {
574
+ })] }), /* @__PURE__ */ U("div", {
575
575
  className: "text-right",
576
576
  children: [
577
- /* @__PURE__ */ U("p", {
577
+ /* @__PURE__ */ H("p", {
578
578
  className: "text-sm",
579
579
  children: e.scheduledTime ? `Scheduled: ${F(e.scheduledTime, "time")}` : "Scheduled: Not provided"
580
580
  }),
581
- e.actualTime && /* @__PURE__ */ W("p", {
581
+ e.actualTime && /* @__PURE__ */ U("p", {
582
582
  className: "text-sm text-status-success-text",
583
583
  children: ["Actual: ", F(e.actualTime, "time")]
584
584
  }),
585
- /* @__PURE__ */ U("p", {
585
+ /* @__PURE__ */ H("p", {
586
586
  className: "text-xs text-text-secondary",
587
587
  children: e.duration === void 0 ? "Duration not provided" : `${e.duration} min stop`
588
588
  })
@@ -592,10 +592,10 @@ function X() {
592
592
  })]
593
593
  }, e.id))
594
594
  }) })] })]
595
- }), /* @__PURE__ */ W("div", {
595
+ }), /* @__PURE__ */ U("div", {
596
596
  className: "space-y-6",
597
597
  children: [
598
- (p.status === "planned" || p.status === "in_progress") && /* @__PURE__ */ U(de, {
598
+ (p.status === "planned" || p.status === "in_progress") && /* @__PURE__ */ H(fe, {
599
599
  suggestions: w.data,
600
600
  isLoading: w.isLoading,
601
601
  error: w.error,
@@ -605,103 +605,103 @@ function X() {
605
605
  onAssign: Ee,
606
606
  t: E
607
607
  }),
608
- /* @__PURE__ */ W(pe, {
608
+ /* @__PURE__ */ U(me, {
609
609
  className: "space-y-4",
610
610
  children: [
611
- /* @__PURE__ */ U("h2", {
611
+ /* @__PURE__ */ H("h2", {
612
612
  className: "text-base font-semibold text-text-primary",
613
613
  children: "Route Info"
614
614
  }),
615
- /* @__PURE__ */ W("div", { children: [/* @__PURE__ */ U("p", {
615
+ /* @__PURE__ */ U("div", { children: [/* @__PURE__ */ H("p", {
616
616
  className: "text-sm text-text-secondary",
617
617
  children: "Total Distance"
618
- }), /* @__PURE__ */ W("p", {
618
+ }), /* @__PURE__ */ U("p", {
619
619
  className: "text-2xl font-bold",
620
- children: [p.distance.toFixed(1), /* @__PURE__ */ U("span", {
620
+ children: [p.distance.toFixed(1), /* @__PURE__ */ H("span", {
621
621
  className: "text-sm font-normal",
622
622
  children: " km"
623
623
  })]
624
624
  })] }),
625
- /* @__PURE__ */ W("div", { children: [/* @__PURE__ */ U("p", {
625
+ /* @__PURE__ */ U("div", { children: [/* @__PURE__ */ H("p", {
626
626
  className: "text-sm text-text-secondary",
627
627
  children: "Est. Duration"
628
- }), /* @__PURE__ */ W("p", {
628
+ }), /* @__PURE__ */ U("p", {
629
629
  className: "text-2xl font-bold",
630
- children: [p.estimatedDuration, /* @__PURE__ */ U("span", {
630
+ children: [p.estimatedDuration, /* @__PURE__ */ H("span", {
631
631
  className: "text-sm font-normal",
632
632
  children: " min"
633
633
  })]
634
634
  })] }),
635
- p.fuelCost !== void 0 && /* @__PURE__ */ W("div", { children: [/* @__PURE__ */ W("p", {
635
+ p.fuelCost !== void 0 && /* @__PURE__ */ U("div", { children: [/* @__PURE__ */ U("p", {
636
636
  className: "text-sm text-text-secondary flex items-center gap-1",
637
- children: [/* @__PURE__ */ U(a, { size: 14 }), " Est. Fuel Cost"]
638
- }), /* @__PURE__ */ U("p", {
637
+ children: [/* @__PURE__ */ H(a, { size: 14 }), " Est. Fuel Cost"]
638
+ }), /* @__PURE__ */ H("p", {
639
639
  className: "text-2xl font-bold",
640
640
  children: le(p.fuelCost)
641
641
  })] }),
642
- p.actualDuration && /* @__PURE__ */ W("div", { children: [/* @__PURE__ */ U("p", {
642
+ p.actualDuration && /* @__PURE__ */ U("div", { children: [/* @__PURE__ */ H("p", {
643
643
  className: "text-sm text-text-secondary",
644
644
  children: "Actual Duration"
645
- }), /* @__PURE__ */ W("p", {
645
+ }), /* @__PURE__ */ U("p", {
646
646
  className: "text-2xl font-bold",
647
- children: [p.actualDuration, /* @__PURE__ */ U("span", {
647
+ children: [p.actualDuration, /* @__PURE__ */ H("span", {
648
648
  className: "text-sm font-normal",
649
649
  children: " min"
650
650
  })]
651
651
  })] })
652
652
  ]
653
653
  }),
654
- /* @__PURE__ */ W(_, { children: [/* @__PURE__ */ U(y, { children: /* @__PURE__ */ W(b, {
654
+ /* @__PURE__ */ U(_, { children: [/* @__PURE__ */ H(y, { children: /* @__PURE__ */ U(b, {
655
655
  className: "flex items-center gap-2",
656
- children: [/* @__PURE__ */ U(i, { size: 18 }), " Timeline"]
657
- }) }), /* @__PURE__ */ U(v, {
656
+ children: [/* @__PURE__ */ H(i, { size: 18 }), " Timeline"]
657
+ }) }), /* @__PURE__ */ H(v, {
658
658
  className: "space-y-3",
659
- children: /* @__PURE__ */ W("div", { children: [/* @__PURE__ */ U("p", {
659
+ children: /* @__PURE__ */ U("div", { children: [/* @__PURE__ */ H("p", {
660
660
  className: "text-sm text-text-secondary",
661
661
  children: "Created"
662
- }), /* @__PURE__ */ U("p", { children: F(p.createdAt, "full") })] })
662
+ }), /* @__PURE__ */ H("p", { children: F(p.createdAt, "full") })] })
663
663
  })] }),
664
- /* @__PURE__ */ W(_, {
664
+ /* @__PURE__ */ U(_, {
665
665
  className: "border-status-error-border",
666
- children: [/* @__PURE__ */ U(y, { children: /* @__PURE__ */ W(b, {
666
+ children: [/* @__PURE__ */ H(y, { children: /* @__PURE__ */ U(b, {
667
667
  className: "flex items-center gap-2 text-status-error-text",
668
- children: [/* @__PURE__ */ U(u, { size: 18 }), " Delete Route"]
669
- }) }), /* @__PURE__ */ W(v, { children: [/* @__PURE__ */ U("p", {
668
+ children: [/* @__PURE__ */ H(u, { size: 18 }), " Delete Route"]
669
+ }) }), /* @__PURE__ */ U(v, { children: [/* @__PURE__ */ H("p", {
670
670
  className: "mb-3 text-sm text-text-secondary",
671
671
  children: "Removes this route. It can no longer be dispatched. This cannot be undone from here."
672
- }), /* @__PURE__ */ W(g, {
672
+ }), /* @__PURE__ */ U(g, {
673
673
  variant: "outline",
674
674
  className: "border-status-error-border text-status-error-text hover:bg-status-error-bg-subtle",
675
- onClick: () => Z(!0),
676
- children: [/* @__PURE__ */ U(u, { size: 16 }), " Delete this route"]
675
+ onClick: () => q(!0),
676
+ children: [/* @__PURE__ */ H(u, { size: 16 }), " Delete this route"]
677
677
  })] })]
678
678
  })
679
679
  ]
680
680
  })]
681
681
  }),
682
- /* @__PURE__ */ U(ge, {
683
- open: ye,
684
- onOpenChange: Z,
685
- children: /* @__PURE__ */ W(_e, { children: [
686
- /* @__PURE__ */ W(ve, { children: [/* @__PURE__ */ U(q, { children: "Delete this route?" }), /* @__PURE__ */ W(G, { children: [
682
+ /* @__PURE__ */ H(_e, {
683
+ open: Ce,
684
+ onOpenChange: q,
685
+ children: /* @__PURE__ */ U(ve, { children: [
686
+ /* @__PURE__ */ U(xe, { children: [/* @__PURE__ */ H(Se, { children: "Delete this route?" }), /* @__PURE__ */ U(ye, { children: [
687
687
  "This removes ",
688
688
  p.name,
689
689
  " and cannot be undone from here."
690
690
  ] })] }),
691
- /* @__PURE__ */ U("div", {
691
+ /* @__PURE__ */ H("div", {
692
692
  className: "px-1",
693
- children: /* @__PURE__ */ U(M, { message: be })
693
+ children: /* @__PURE__ */ H(M, { message: X })
694
694
  }),
695
- /* @__PURE__ */ W(K, { children: [/* @__PURE__ */ U(g, {
695
+ /* @__PURE__ */ U(be, { children: [/* @__PURE__ */ H(g, {
696
696
  variant: "outline",
697
- onClick: () => Z(!1),
698
- disabled: Q,
697
+ onClick: () => q(!1),
698
+ disabled: J,
699
699
  children: "Cancel"
700
- }), /* @__PURE__ */ U(g, {
700
+ }), /* @__PURE__ */ H(g, {
701
701
  className: "bg-status-error-text text-text-inverse hover:opacity-90",
702
702
  onClick: we,
703
- disabled: Q,
704
- children: Q ? "Deleting..." : "Delete route"
703
+ disabled: J,
704
+ children: J ? "Deleting..." : "Delete route"
705
705
  })] })
706
706
  ] })
707
707
  })
@@ -709,4 +709,4 @@ function X() {
709
709
  });
710
710
  }
711
711
  //#endregion
712
- export { X as default };
712
+ export { K as default };