@burdenoff/microfe-movethewheels 2026.703.8 → 2026.704.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 (37) hide show
  1. package/dist/{CreateOrderPage-V8aXfcpN.js → CreateOrderPage-CXbhJLLz.js} +163 -138
  2. package/dist/{DashboardPage-DiD-cWwD.js → DashboardPage-BoswH3ec.js} +2 -2
  3. package/dist/DriverDetailsPage-CPO0G8Ki.js +518 -0
  4. package/dist/{DriversPage-DW-FGPFW.js → DriversPage-6Z61dpDI.js} +1 -1
  5. package/dist/{FleetPage-P9k4zZqP.js → FleetPage-qWRj7WFO.js} +1 -1
  6. package/dist/{InventoryPage-BWikjZMW.js → InventoryPage-DbR4Z--d.js} +1 -1
  7. package/dist/{LiveTrackingPage-UQBWlthJ.js → LiveTrackingPage-5U68u3oA.js} +1 -1
  8. package/dist/{OrderDetailsPage-2J4ua0wd.js → OrderDetailsPage-DRYifXm9.js} +1 -1
  9. package/dist/ProductDetailsPage-CWgcRqGR.js +375 -0
  10. package/dist/{ProductsPage-Bn1U2jTj.js → ProductsPage-CokwDOR2.js} +1 -1
  11. package/dist/{RouteDetailsPage-CgSY1CTd.js → RouteDetailsPage-BHQbFgI9.js} +242 -210
  12. package/dist/{SettingsPage-2a05Sq2k.js → SettingsPage-_6SIlcBX.js} +1 -1
  13. package/dist/{TrackingPage-SnjW6qeD.js → TrackingPage-Cg0tYGJe.js} +1 -1
  14. package/dist/{VehicleDetailsPage-CvRMJ2zC.js → VehicleDetailsPage-BbZlCFPo.js} +159 -135
  15. package/dist/{VehiclesPage-qxf-1C1B.js → VehiclesPage-BfBEyXGs.js} +1 -1
  16. package/dist/WarehouseDetailsPage-DxNhiaoI.js +515 -0
  17. package/dist/{WarehousesPage-44Wj7AGT.js → WarehousesPage-M3NaBT0z.js} +1 -1
  18. package/dist/index.js +25 -5
  19. package/dist/{useFleet-BXSocBD_.js → useFleet-BfA_-VUW.js} +100 -71
  20. package/dist/{useInventory-DmZficcp.js → useInventory-BO7TSgq_.js} +98 -72
  21. package/dist/{useSettings-CteNasBE.js → useSettings-BNNzQs_B.js} +1 -1
  22. package/dist/{useTracking-B7ttexRe.js → useTracking-7nd_XOSL.js} +1 -1
  23. package/package.json +1 -1
  24. package/src/movethewheels/MoveTheWheelsRoutes.tsx +5 -0
  25. package/src/movethewheels/hooks/useFleet.ts +113 -0
  26. package/src/movethewheels/hooks/useInventory.ts +86 -0
  27. package/src/movethewheels/hooks/useSettings.ts +8 -1
  28. package/src/movethewheels/pages/CreateOrderPage.tsx +48 -6
  29. package/src/movethewheels/pages/DriverDetailsPage.tsx +56 -18
  30. package/src/movethewheels/pages/ProductDetailsPage.tsx +51 -15
  31. package/src/movethewheels/pages/RouteDetailsPage.tsx +51 -7
  32. package/src/movethewheels/pages/VehicleDetailsPage.tsx +51 -15
  33. package/src/movethewheels/pages/WarehouseDetailsPage.tsx +46 -10
  34. package/src/movethewheels/types/index.ts +3 -0
  35. package/dist/DriverDetailsPage-DjaXaATQ.js +0 -490
  36. package/dist/ProductDetailsPage-BSjWLrty.js +0 -350
  37. package/dist/WarehouseDetailsPage-D0Wyyj1Y.js +0 -493
@@ -11,22 +11,22 @@ import { t as k } from "./plus-Bk_G-lFC.js";
11
11
  import { t as A } from "./save-CcfoIn2J.js";
12
12
  import { t as j } from "./square-pen-Dr1X-P2s.js";
13
13
  import { t as M } from "./trash-2-CC4KugEJ.js";
14
- import { r as N } from "./useFleet-BXSocBD_.js";
14
+ import { r as N } from "./useFleet-BfA_-VUW.js";
15
15
  import { r as P, t as F } from "./useRoutes-C_ZCYJ_h.js";
16
16
  import { n as I } from "./maps-CtfuCAmh.js";
17
17
  import { o as L, r as R } from "./StatusBadge-BfiF-nNI.js";
18
18
  import { t as z } from "./FormError-D4T5FWZA.js";
19
19
  import { n as B, r as V, t as H } from "./formatters-FWJDwTFv.js";
20
20
  import { n as U } from "./mapMarkers-NCV9MRKR.js";
21
- import { useState as W } from "react";
22
- import { useParams as ee } from "react-router-dom";
23
- import { jsx as G, jsxs as K } from "react/jsx-runtime";
24
- import { EmphasisPanel as q, NextSteps as te, PagePurpose as J } from "@burdenoff/fe-libs/ui";
21
+ import { useEffect as W, useState as G } from "react";
22
+ import { useLocation as K, useParams as q } from "react-router-dom";
23
+ import { jsx as J, jsxs as Y } from "react/jsx-runtime";
24
+ import { EmphasisPanel as X, NextSteps as Z, PagePurpose as Q } from "@burdenoff/fe-libs/ui";
25
25
  //#region node_modules/lucide-react/dist/esm/icons/zap.js
26
- var Y = v("Zap", [["path", {
26
+ var $ = v("Zap", [["path", {
27
27
  d: "M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",
28
28
  key: "1xq2db"
29
- }]]), X = [
29
+ }]]), ee = [
30
30
  {
31
31
  value: "planned",
32
32
  label: "Planned"
@@ -44,8 +44,8 @@ var Y = v("Zap", [["path", {
44
44
  label: "Cancelled"
45
45
  }
46
46
  ];
47
- function ne() {
48
- let { basePath: f, navigate: m } = g(), { createRoute: h } = P(), { vehicles: v, drivers: S } = N(), [C, w] = W({
47
+ function te({ editId: f }) {
48
+ let { basePath: m, navigate: h } = g(), { createRoute: v, updateRoute: S } = P(), { route: C } = F(f), { vehicles: w, drivers: T } = N(), E = !!f, [D, j] = G({
49
49
  name: "",
50
50
  status: "planned",
51
51
  vehicleId: "",
@@ -54,22 +54,38 @@ function ne() {
54
54
  address: "",
55
55
  type: "delivery"
56
56
  }]
57
- }), [T, E] = W(!1), [D, j] = W(null), F = () => m?.(p(f, "routes")), I = () => w((e) => ({
57
+ }), [I, L] = G(!1), [R, B] = G(null);
58
+ W(() => {
59
+ !f || !C || j({
60
+ name: C.name || "",
61
+ status: C.status,
62
+ vehicleId: C.vehicleId || "",
63
+ driverId: C.driverId || "",
64
+ stops: C.stops.length > 0 ? C.stops.map((e) => ({
65
+ address: H(e.address) || e.address.street || "",
66
+ type: e.type
67
+ })) : [{
68
+ address: "",
69
+ type: "delivery"
70
+ }]
71
+ });
72
+ }, [f, C]);
73
+ let V = () => h?.(p(m, "routes")), U = () => j((e) => ({
58
74
  ...e,
59
75
  stops: [...e.stops, {
60
76
  address: "",
61
77
  type: "delivery"
62
78
  }]
63
- })), L = (e) => w((t) => ({
79
+ })), K = (e) => j((t) => ({
64
80
  ...t,
65
81
  stops: t.stops.filter((t, n) => n !== e)
66
- })), R = (e, t, n) => w((r) => ({
82
+ })), q = (e, t, n) => j((r) => ({
67
83
  ...r,
68
84
  stops: r.stops.map((r, i) => i === e ? {
69
85
  ...r,
70
86
  [t]: n
71
87
  } : r)
72
- })), B = (e, t) => w((n) => {
88
+ })), Z = (e, t) => j((n) => {
73
89
  let r = e + t;
74
90
  if (r < 0 || r >= n.stops.length) return n;
75
91
  let i = [...n.stops];
@@ -77,17 +93,17 @@ function ne() {
77
93
  ...n,
78
94
  stops: i
79
95
  };
80
- }), V = async (e) => {
81
- if (e.preventDefault(), !C.name.trim()) {
82
- j("Route name is required.");
96
+ }), $ = async (e) => {
97
+ if (e.preventDefault(), !D.name.trim()) {
98
+ B("Route name is required.");
83
99
  return;
84
100
  }
85
- let t = C.stops.filter((e) => e.address.trim());
101
+ let t = D.stops.filter((e) => e.address.trim());
86
102
  if (t.length === 0) {
87
- j("Add at least one stop with an address.");
103
+ B("Add at least one stop with an address.");
88
104
  return;
89
105
  }
90
- E(!0), j(null);
106
+ L(!0), B(null);
91
107
  try {
92
108
  let e = t.map((e, t) => ({
93
109
  id: `stop-${t + 1}`,
@@ -104,109 +120,121 @@ function ne() {
104
120
  scheduledTime: /* @__PURE__ */ new Date(),
105
121
  duration: 0,
106
122
  status: "pending"
107
- })), n = await h({
108
- name: C.name.trim(),
109
- status: C.status,
110
- vehicleId: C.vehicleId || void 0,
111
- driverId: C.driverId || void 0,
123
+ }));
124
+ if (E) {
125
+ let t = await S(f, {
126
+ name: D.name.trim(),
127
+ status: D.status,
128
+ vehicleId: D.vehicleId || void 0,
129
+ driverId: D.driverId || void 0,
130
+ stops: e
131
+ });
132
+ h?.(p(m, `routes/${t.id}`));
133
+ return;
134
+ }
135
+ let n = await v({
136
+ name: D.name.trim(),
137
+ status: D.status,
138
+ vehicleId: D.vehicleId || void 0,
139
+ driverId: D.driverId || void 0,
112
140
  stops: e
113
141
  });
114
- m?.(p(f, `routes/${n.id}`));
142
+ h?.(p(m, `routes/${n.id}`));
115
143
  } catch (e) {
116
- console.error("Failed to create route:", e), j(e instanceof Error ? e.message : "Failed to create route. Please try again."), E(!1);
144
+ console.error("Failed to create route:", e), B(e instanceof Error ? e.message : "Failed to create route. Please try again."), L(!1);
117
145
  }
118
146
  };
119
- return /* @__PURE__ */ K(u, {
120
- title: "Create Route",
147
+ return /* @__PURE__ */ Y(u, {
148
+ title: E ? "Edit Route" : "Create Route",
121
149
  subtitle: "Plan a new delivery route",
122
- icon: /* @__PURE__ */ G(O, { size: 24 }),
123
- headerActions: /* @__PURE__ */ K("div", {
150
+ icon: /* @__PURE__ */ J(O, { size: 24 }),
151
+ headerActions: /* @__PURE__ */ Y("div", {
124
152
  className: "flex gap-2",
125
- children: [/* @__PURE__ */ K(_, {
153
+ children: [/* @__PURE__ */ Y(_, {
126
154
  variant: "outline",
127
- onClick: F,
128
- disabled: T,
129
- children: [/* @__PURE__ */ G(x, { size: 16 }), " Cancel"]
130
- }), /* @__PURE__ */ K(_, {
131
155
  onClick: V,
132
- disabled: T,
156
+ disabled: I,
157
+ children: [/* @__PURE__ */ J(x, { size: 16 }), " Cancel"]
158
+ }), /* @__PURE__ */ Y(_, {
159
+ onClick: $,
160
+ disabled: I,
133
161
  children: [
134
- /* @__PURE__ */ G(A, { size: 16 }),
162
+ /* @__PURE__ */ J(A, { size: 16 }),
135
163
  " ",
136
- T ? "Saving..." : "Create Route"
164
+ E ? I ? "Saving..." : "Save Changes" : I ? "Saving..." : "Create Route"
137
165
  ]
138
166
  })]
139
167
  }),
140
- children: [/* @__PURE__ */ G(J, {
141
- icon: /* @__PURE__ */ G(O, { size: 18 }),
168
+ children: [/* @__PURE__ */ J(Q, {
169
+ icon: /* @__PURE__ */ J(O, { size: 18 }),
142
170
  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."
143
- }), /* @__PURE__ */ K("form", {
144
- onSubmit: V,
171
+ }), /* @__PURE__ */ Y("form", {
172
+ onSubmit: $,
145
173
  className: "max-w-3xl space-y-6",
146
174
  children: [
147
- /* @__PURE__ */ G(z, { message: D }),
148
- /* @__PURE__ */ K(q, { children: [/* @__PURE__ */ G("h2", {
175
+ /* @__PURE__ */ J(z, { message: R }),
176
+ /* @__PURE__ */ Y(X, { children: [/* @__PURE__ */ J("h2", {
149
177
  className: "text-base font-semibold text-text-primary mb-4",
150
178
  children: "Route Details"
151
- }), /* @__PURE__ */ K("div", {
179
+ }), /* @__PURE__ */ Y("div", {
152
180
  className: "space-y-4",
153
- children: [/* @__PURE__ */ K("div", {
181
+ children: [/* @__PURE__ */ Y("div", {
154
182
  className: "grid grid-cols-1 md:grid-cols-2 gap-4",
155
- children: [/* @__PURE__ */ K("div", {
183
+ children: [/* @__PURE__ */ Y("div", {
156
184
  className: "space-y-2",
157
- children: [/* @__PURE__ */ K(d, {
185
+ children: [/* @__PURE__ */ Y(d, {
158
186
  htmlFor: "name",
159
- children: ["Route Name ", /* @__PURE__ */ G("span", {
187
+ children: ["Route Name ", /* @__PURE__ */ J("span", {
160
188
  className: "text-status-error-text",
161
189
  children: "*"
162
190
  })]
163
- }), /* @__PURE__ */ G(e, {
191
+ }), /* @__PURE__ */ J(e, {
164
192
  id: "name",
165
- value: C.name,
166
- onChange: (e) => w((t) => ({
193
+ value: D.name,
194
+ onChange: (e) => j((t) => ({
167
195
  ...t,
168
196
  name: e.target.value
169
197
  })),
170
198
  placeholder: "Downtown morning run",
171
199
  required: !0
172
200
  })]
173
- }), /* @__PURE__ */ K("div", {
201
+ }), /* @__PURE__ */ Y("div", {
174
202
  className: "space-y-2",
175
- children: [/* @__PURE__ */ G(d, {
203
+ children: [/* @__PURE__ */ J(d, {
176
204
  htmlFor: "status",
177
205
  children: "Status"
178
- }), /* @__PURE__ */ K(i, {
179
- value: C.status,
180
- onValueChange: (e) => w((t) => ({
206
+ }), /* @__PURE__ */ Y(i, {
207
+ value: D.status,
208
+ onValueChange: (e) => j((t) => ({
181
209
  ...t,
182
210
  status: e
183
211
  })),
184
- children: [/* @__PURE__ */ G(r, {
212
+ children: [/* @__PURE__ */ J(r, {
185
213
  id: "status",
186
- children: /* @__PURE__ */ G(a, {})
187
- }), /* @__PURE__ */ G(t, { children: X.map((e) => /* @__PURE__ */ G(n, {
214
+ children: /* @__PURE__ */ J(a, {})
215
+ }), /* @__PURE__ */ J(t, { children: ee.map((e) => /* @__PURE__ */ J(n, {
188
216
  value: e.value,
189
217
  children: e.label
190
218
  }, e.value)) })]
191
219
  })]
192
220
  })]
193
- }), /* @__PURE__ */ K("div", {
221
+ }), /* @__PURE__ */ Y("div", {
194
222
  className: "grid grid-cols-1 md:grid-cols-2 gap-4",
195
- children: [/* @__PURE__ */ K("div", {
223
+ children: [/* @__PURE__ */ Y("div", {
196
224
  className: "space-y-2",
197
- children: [/* @__PURE__ */ G(d, {
225
+ children: [/* @__PURE__ */ J(d, {
198
226
  htmlFor: "vehicle",
199
227
  children: "Vehicle (optional)"
200
- }), /* @__PURE__ */ K(i, {
201
- value: C.vehicleId,
202
- onValueChange: (e) => w((t) => ({
228
+ }), /* @__PURE__ */ Y(i, {
229
+ value: D.vehicleId,
230
+ onValueChange: (e) => j((t) => ({
203
231
  ...t,
204
232
  vehicleId: e
205
233
  })),
206
- children: [/* @__PURE__ */ G(r, {
234
+ children: [/* @__PURE__ */ J(r, {
207
235
  id: "vehicle",
208
- children: /* @__PURE__ */ G(a, { placeholder: "Assign later" })
209
- }), /* @__PURE__ */ G(t, { children: v.map((e) => /* @__PURE__ */ K(n, {
236
+ children: /* @__PURE__ */ J(a, { placeholder: "Assign later" })
237
+ }), /* @__PURE__ */ J(t, { children: w.map((e) => /* @__PURE__ */ Y(n, {
210
238
  value: e.id,
211
239
  children: [
212
240
  e.vehicleNumber,
@@ -216,21 +244,21 @@ function ne() {
216
244
  ]
217
245
  }, e.id)) })]
218
246
  })]
219
- }), /* @__PURE__ */ K("div", {
247
+ }), /* @__PURE__ */ Y("div", {
220
248
  className: "space-y-2",
221
- children: [/* @__PURE__ */ G(d, {
249
+ children: [/* @__PURE__ */ J(d, {
222
250
  htmlFor: "driver",
223
251
  children: "Driver (optional)"
224
- }), /* @__PURE__ */ K(i, {
225
- value: C.driverId,
226
- onValueChange: (e) => w((t) => ({
252
+ }), /* @__PURE__ */ Y(i, {
253
+ value: D.driverId,
254
+ onValueChange: (e) => j((t) => ({
227
255
  ...t,
228
256
  driverId: e
229
257
  })),
230
- children: [/* @__PURE__ */ G(r, {
258
+ children: [/* @__PURE__ */ J(r, {
231
259
  id: "driver",
232
- children: /* @__PURE__ */ G(a, { placeholder: "Assign later" })
233
- }), /* @__PURE__ */ G(t, { children: S.map((e) => /* @__PURE__ */ K(n, {
260
+ children: /* @__PURE__ */ J(a, { placeholder: "Assign later" })
261
+ }), /* @__PURE__ */ J(t, { children: T.map((e) => /* @__PURE__ */ Y(n, {
234
262
  value: e.id,
235
263
  children: [
236
264
  e.fullName,
@@ -243,89 +271,89 @@ function ne() {
243
271
  })]
244
272
  })]
245
273
  })] }),
246
- /* @__PURE__ */ K(o, { children: [/* @__PURE__ */ K(l, {
274
+ /* @__PURE__ */ Y(o, { children: [/* @__PURE__ */ Y(l, {
247
275
  className: "flex flex-row items-center justify-between",
248
- children: [/* @__PURE__ */ K(c, { children: ["Stops ", /* @__PURE__ */ G("span", {
276
+ children: [/* @__PURE__ */ Y(c, { children: ["Stops ", /* @__PURE__ */ J("span", {
249
277
  className: "text-status-error-text",
250
278
  children: "*"
251
- })] }), /* @__PURE__ */ K(_, {
279
+ })] }), /* @__PURE__ */ Y(_, {
252
280
  type: "button",
253
281
  variant: "outline",
254
282
  size: "sm",
255
- onClick: I,
256
- children: [/* @__PURE__ */ G(k, { size: 16 }), " Add Stop"]
283
+ onClick: U,
284
+ children: [/* @__PURE__ */ J(k, { size: 16 }), " Add Stop"]
257
285
  })]
258
- }), /* @__PURE__ */ G(s, {
286
+ }), /* @__PURE__ */ J(s, {
259
287
  className: "space-y-4",
260
- children: C.stops.map((o, s) => /* @__PURE__ */ K("div", {
288
+ children: D.stops.map((o, s) => /* @__PURE__ */ Y("div", {
261
289
  className: "grid grid-cols-1 md:grid-cols-12 gap-3 items-end",
262
290
  children: [
263
- /* @__PURE__ */ K("div", {
291
+ /* @__PURE__ */ Y("div", {
264
292
  className: "md:col-span-7 space-y-2",
265
- children: [/* @__PURE__ */ K(d, {
293
+ children: [/* @__PURE__ */ Y(d, {
266
294
  htmlFor: `stop-address-${s}`,
267
295
  children: [
268
296
  "Stop ",
269
297
  s + 1,
270
298
  " address"
271
299
  ]
272
- }), /* @__PURE__ */ G(e, {
300
+ }), /* @__PURE__ */ J(e, {
273
301
  id: `stop-address-${s}`,
274
302
  value: o.address,
275
- onChange: (e) => R(s, "address", e.target.value),
303
+ onChange: (e) => q(s, "address", e.target.value),
276
304
  placeholder: "123 Main St, San Francisco, CA"
277
305
  })]
278
306
  }),
279
- /* @__PURE__ */ K("div", {
307
+ /* @__PURE__ */ Y("div", {
280
308
  className: "md:col-span-4 space-y-2",
281
- children: [/* @__PURE__ */ G(d, {
309
+ children: [/* @__PURE__ */ J(d, {
282
310
  htmlFor: `stop-type-${s}`,
283
311
  children: "Type"
284
- }), /* @__PURE__ */ K(i, {
312
+ }), /* @__PURE__ */ Y(i, {
285
313
  value: o.type,
286
- onValueChange: (e) => R(s, "type", e),
287
- children: [/* @__PURE__ */ G(r, {
314
+ onValueChange: (e) => q(s, "type", e),
315
+ children: [/* @__PURE__ */ J(r, {
288
316
  id: `stop-type-${s}`,
289
- children: /* @__PURE__ */ G(a, {})
290
- }), /* @__PURE__ */ K(t, { children: [/* @__PURE__ */ G(n, {
317
+ children: /* @__PURE__ */ J(a, {})
318
+ }), /* @__PURE__ */ Y(t, { children: [/* @__PURE__ */ J(n, {
291
319
  value: "pickup",
292
320
  children: "Pickup"
293
- }), /* @__PURE__ */ G(n, {
321
+ }), /* @__PURE__ */ J(n, {
294
322
  value: "delivery",
295
323
  children: "Delivery"
296
324
  })] })]
297
325
  })]
298
326
  }),
299
- /* @__PURE__ */ K("div", {
327
+ /* @__PURE__ */ Y("div", {
300
328
  className: "md:col-span-1 flex justify-end gap-1",
301
329
  children: [
302
- /* @__PURE__ */ G(_, {
330
+ /* @__PURE__ */ J(_, {
303
331
  type: "button",
304
332
  variant: "ghost",
305
333
  size: "icon",
306
- onClick: () => B(s, -1),
334
+ onClick: () => Z(s, -1),
307
335
  disabled: s === 0,
308
336
  "aria-label": `Move stop ${s + 1} up`,
309
- children: /* @__PURE__ */ G(b, { size: 16 })
337
+ children: /* @__PURE__ */ J(b, { size: 16 })
310
338
  }),
311
- /* @__PURE__ */ G(_, {
339
+ /* @__PURE__ */ J(_, {
312
340
  type: "button",
313
341
  variant: "ghost",
314
342
  size: "icon",
315
- onClick: () => B(s, 1),
316
- disabled: s === C.stops.length - 1,
343
+ onClick: () => Z(s, 1),
344
+ disabled: s === D.stops.length - 1,
317
345
  "aria-label": `Move stop ${s + 1} down`,
318
- children: /* @__PURE__ */ G(y, { size: 16 })
346
+ children: /* @__PURE__ */ J(y, { size: 16 })
319
347
  }),
320
- /* @__PURE__ */ G(_, {
348
+ /* @__PURE__ */ J(_, {
321
349
  type: "button",
322
350
  variant: "ghost",
323
351
  size: "icon",
324
352
  className: "text-status-error-text",
325
- onClick: () => L(s),
326
- disabled: C.stops.length === 1,
353
+ onClick: () => K(s),
354
+ disabled: D.stops.length === 1,
327
355
  "aria-label": `Remove stop ${s + 1}`,
328
- children: /* @__PURE__ */ G(M, { size: 16 })
356
+ children: /* @__PURE__ */ J(M, { size: 16 })
329
357
  })
330
358
  ]
331
359
  })
@@ -336,26 +364,27 @@ function ne() {
336
364
  })]
337
365
  });
338
366
  }
339
- function Z() {
340
- let { routeId: e } = ee(), { basePath: t, navigate: n } = g(), { route: r, isLoading: i, error: a, refetch: d } = F(e), { optimizeRoute: v } = P(), { message: y, notify: b } = T(), [k, A] = W(null), [M, N] = W(!1), X = () => n?.(p(t, "routes")), Z = (e) => n?.(p(t, e)), Q = async () => {
367
+ function ne() {
368
+ let { routeId: e } = q(), t = K().pathname.endsWith("/edit"), { basePath: n, navigate: r } = g(), { route: i, isLoading: a, error: d, refetch: v } = F(e), { optimizeRoute: y } = P(), { message: b, notify: k } = T(), [A, M] = G(null), [N, W] = G(!1), ee = () => r?.(p(n, "routes")), ne = (e) => r?.(p(n, e)), re = async () => {
341
369
  if (e) {
342
- N(!0), A(null);
370
+ W(!0), M(null);
343
371
  try {
344
- await v(e), b("Route optimized — stops resequenced for the shortest run."), d();
372
+ await y(e), k("Route optimized — stops resequenced for the shortest run."), v();
345
373
  } catch (e) {
346
- A(e instanceof Error ? e.message : "Failed to optimize route.");
374
+ M(e instanceof Error ? e.message : "Failed to optimize route.");
347
375
  } finally {
348
- N(!1);
376
+ W(!1);
349
377
  }
350
378
  }
351
379
  };
352
- if (!e) return /* @__PURE__ */ G(ne, {});
353
- if (i) return /* @__PURE__ */ G(h, { message: "Loading route details..." });
354
- if (a || !r) return /* @__PURE__ */ G(m, {
380
+ if (!e) return /* @__PURE__ */ J(te, {});
381
+ if (t) return /* @__PURE__ */ J(te, { editId: e });
382
+ if (a) return /* @__PURE__ */ J(h, { message: "Loading route details..." });
383
+ if (d || !i) return /* @__PURE__ */ J(m, {
355
384
  title: "Route not found",
356
- onRetry: d
385
+ onRetry: v
357
386
  });
358
- let $ = r.stops.map((e) => {
387
+ let ie = i.stops.map((e) => {
359
388
  let t = U(e.address);
360
389
  return t ? {
361
390
  lat: t.lat,
@@ -364,149 +393,152 @@ function Z() {
364
393
  label: H(e.address) || `Order #${e.orderId || e.sequence}`
365
394
  } : null;
366
395
  }).filter((e) => e !== null);
367
- return /* @__PURE__ */ K(u, {
368
- title: r.name,
369
- subtitle: `${r.stops.length} stops - ${r.distance.toFixed(1)} km`,
370
- icon: /* @__PURE__ */ G(O, { size: 24 }),
371
- headerActions: /* @__PURE__ */ K("div", {
396
+ return /* @__PURE__ */ Y(u, {
397
+ title: i.name,
398
+ subtitle: `${i.stops.length} stops - ${i.distance.toFixed(1)} km`,
399
+ icon: /* @__PURE__ */ J(O, { size: 24 }),
400
+ headerActions: /* @__PURE__ */ Y("div", {
372
401
  className: "flex gap-2",
373
402
  children: [
374
- /* @__PURE__ */ K(_, {
403
+ /* @__PURE__ */ Y(_, {
375
404
  variant: "outline",
376
- onClick: X,
377
- children: [/* @__PURE__ */ G(x, { size: 16 }), " Back"]
405
+ onClick: ee,
406
+ children: [/* @__PURE__ */ J(x, { size: 16 }), " Back"]
378
407
  }),
379
- !r.optimized && /* @__PURE__ */ K(_, {
408
+ !i.optimized && /* @__PURE__ */ Y(_, {
380
409
  variant: "outline",
381
- onClick: Q,
382
- disabled: M,
410
+ onClick: re,
411
+ disabled: N,
383
412
  children: [
384
- /* @__PURE__ */ G(Y, { size: 16 }),
413
+ /* @__PURE__ */ J($, { size: 16 }),
385
414
  " ",
386
- M ? "Optimizing…" : "Optimize"
415
+ N ? "Optimizing…" : "Optimize"
387
416
  ]
388
417
  }),
389
- /* @__PURE__ */ K(_, { children: [/* @__PURE__ */ G(j, { size: 16 }), " Edit"] })
418
+ /* @__PURE__ */ Y(_, {
419
+ onClick: () => r?.(p(n, `routes/${e}/edit`)),
420
+ children: [/* @__PURE__ */ J(j, { size: 16 }), " Edit"]
421
+ })
390
422
  ]
391
423
  }),
392
- headerContent: /* @__PURE__ */ K("div", {
424
+ headerContent: /* @__PURE__ */ Y("div", {
393
425
  className: "flex gap-2",
394
- children: [/* @__PURE__ */ G(R, {
395
- status: r.status,
396
- customColors: L[r.status]
397
- }), /* @__PURE__ */ G(f, {
398
- variant: r.optimized ? "default" : "secondary",
399
- children: r.optimized ? "Optimized" : "Not Optimized"
426
+ children: [/* @__PURE__ */ J(R, {
427
+ status: i.status,
428
+ customColors: L[i.status]
429
+ }), /* @__PURE__ */ J(f, {
430
+ variant: i.optimized ? "default" : "secondary",
431
+ children: i.optimized ? "Optimized" : "Not Optimized"
400
432
  })]
401
433
  }),
402
434
  children: [
403
- /* @__PURE__ */ G(J, {
404
- icon: /* @__PURE__ */ G(O, { size: 18 }),
435
+ /* @__PURE__ */ J(Q, {
436
+ icon: /* @__PURE__ */ J(O, { size: 18 }),
405
437
  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."
406
438
  }),
407
- /* @__PURE__ */ G(te, {
439
+ /* @__PURE__ */ J(Z, {
408
440
  storageKey: "movethewheels-route-details",
409
441
  steps: [
410
- ...r.optimized ? [] : [{
442
+ ...i.optimized ? [] : [{
411
443
  id: "optimize",
412
444
  label: "Optimize this route",
413
445
  description: "Reorder stops to cut distance and driving time.",
414
- icon: /* @__PURE__ */ G(Y, { size: 16 }),
415
- onClick: Q
446
+ icon: /* @__PURE__ */ J($, { size: 16 }),
447
+ onClick: re
416
448
  }],
417
449
  {
418
450
  id: "edit",
419
451
  label: "Adjust stops",
420
452
  description: "Add, remove or reorder the delivery stops.",
421
- icon: /* @__PURE__ */ G(j, { size: 16 }),
453
+ icon: /* @__PURE__ */ J(j, { size: 16 }),
422
454
  onClick: () => {}
423
455
  },
424
456
  {
425
457
  id: "orders",
426
458
  label: "Review the orders on this route",
427
459
  description: "Check the deliveries bundled into this run.",
428
- icon: /* @__PURE__ */ G(D, { size: 16 }),
429
- onClick: () => Z("orders")
460
+ icon: /* @__PURE__ */ J(D, { size: 16 }),
461
+ onClick: () => ne("orders")
430
462
  }
431
463
  ]
432
464
  }),
433
- k && /* @__PURE__ */ G("div", {
465
+ A && /* @__PURE__ */ J("div", {
434
466
  className: "mb-2",
435
- children: /* @__PURE__ */ G(z, { message: k })
467
+ children: /* @__PURE__ */ J(z, { message: A })
436
468
  }),
437
- y && /* @__PURE__ */ G("div", {
469
+ b && /* @__PURE__ */ J("div", {
438
470
  className: "mb-2",
439
- children: /* @__PURE__ */ G(E, { message: y })
471
+ children: /* @__PURE__ */ J(E, { message: b })
440
472
  }),
441
- /* @__PURE__ */ K("div", {
473
+ /* @__PURE__ */ Y("div", {
442
474
  className: "grid grid-cols-1 lg:grid-cols-3 gap-6",
443
- children: [/* @__PURE__ */ K("div", {
475
+ children: [/* @__PURE__ */ Y("div", {
444
476
  className: "lg:col-span-2 space-y-6",
445
- children: [/* @__PURE__ */ K(o, { children: [/* @__PURE__ */ G(l, { children: /* @__PURE__ */ G(c, { children: "Route Map" }) }), /* @__PURE__ */ G(s, { children: $.length > 0 ? /* @__PURE__ */ G(I, {
477
+ children: [/* @__PURE__ */ Y(o, { children: [/* @__PURE__ */ J(l, { children: /* @__PURE__ */ J(c, { children: "Route Map" }) }), /* @__PURE__ */ J(s, { children: ie.length > 0 ? /* @__PURE__ */ J(I, {
446
478
  className: "overflow-hidden rounded-lg border border-border-seam",
447
479
  height: 360,
448
- stops: $
449
- }) : /* @__PURE__ */ K("div", {
480
+ stops: ie
481
+ }) : /* @__PURE__ */ Y("div", {
450
482
  className: "rounded-lg border border-border-seam bg-bg-sunken/40 p-4",
451
- children: [/* @__PURE__ */ G("p", {
483
+ children: [/* @__PURE__ */ J("p", {
452
484
  className: "mb-3 text-sm text-text-secondary",
453
485
  children: "These stops don't have map coordinates yet — showing the planned sequence instead."
454
- }), /* @__PURE__ */ G("ol", {
486
+ }), /* @__PURE__ */ J("ol", {
455
487
  className: "space-y-2",
456
- children: r.stops.map((e) => /* @__PURE__ */ K("li", {
488
+ children: i.stops.map((e) => /* @__PURE__ */ Y("li", {
457
489
  className: "flex items-start gap-3",
458
- children: [/* @__PURE__ */ G("span", {
490
+ children: [/* @__PURE__ */ J("span", {
459
491
  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",
460
492
  children: e.sequence
461
- }), /* @__PURE__ */ G("span", {
493
+ }), /* @__PURE__ */ J("span", {
462
494
  className: "text-sm",
463
495
  children: H(e.address) || `Order #${e.orderId || e.sequence}`
464
496
  })]
465
497
  }, e.id))
466
498
  })]
467
- }) })] }), /* @__PURE__ */ K(o, { children: [/* @__PURE__ */ G(l, { children: /* @__PURE__ */ K(c, { children: [
499
+ }) })] }), /* @__PURE__ */ Y(o, { children: [/* @__PURE__ */ J(l, { children: /* @__PURE__ */ Y(c, { children: [
468
500
  "Stops (",
469
- r.stops.length,
501
+ i.stops.length,
470
502
  ")"
471
- ] }) }), /* @__PURE__ */ G(s, { children: /* @__PURE__ */ G("div", {
503
+ ] }) }), /* @__PURE__ */ J(s, { children: /* @__PURE__ */ J("div", {
472
504
  className: "space-y-4",
473
- children: r.stops.map((e, t) => /* @__PURE__ */ K("div", {
505
+ children: i.stops.map((e, t) => /* @__PURE__ */ Y("div", {
474
506
  className: "flex gap-4",
475
- children: [/* @__PURE__ */ K("div", {
507
+ children: [/* @__PURE__ */ Y("div", {
476
508
  className: "relative",
477
- children: [/* @__PURE__ */ G("div", {
509
+ children: [/* @__PURE__ */ J("div", {
478
510
  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"}`,
479
- children: e.status === "completed" ? /* @__PURE__ */ G(S, { size: 16 }) : e.sequence
480
- }), t < r.stops.length - 1 && /* @__PURE__ */ G("div", { className: "absolute top-8 left-4 w-px h-12 bg-border" })]
481
- }), /* @__PURE__ */ G("div", {
511
+ children: e.status === "completed" ? /* @__PURE__ */ J(S, { size: 16 }) : e.sequence
512
+ }), t < i.stops.length - 1 && /* @__PURE__ */ J("div", { className: "absolute top-8 left-4 w-px h-12 bg-border" })]
513
+ }), /* @__PURE__ */ J("div", {
482
514
  className: "flex-1 pb-4",
483
- children: /* @__PURE__ */ K("div", {
515
+ children: /* @__PURE__ */ Y("div", {
484
516
  className: "flex items-center justify-between",
485
- children: [/* @__PURE__ */ K("div", { children: [/* @__PURE__ */ K("div", {
517
+ children: [/* @__PURE__ */ Y("div", { children: [/* @__PURE__ */ Y("div", {
486
518
  className: "flex items-center gap-2",
487
- children: [/* @__PURE__ */ G(f, {
519
+ children: [/* @__PURE__ */ J(f, {
488
520
  variant: e.type === "pickup" ? "secondary" : "default",
489
521
  className: "capitalize",
490
522
  children: e.type
491
- }), /* @__PURE__ */ K("span", {
523
+ }), /* @__PURE__ */ Y("span", {
492
524
  className: "font-medium",
493
525
  children: ["Order #", e.orderId]
494
526
  })]
495
- }), /* @__PURE__ */ G("p", {
527
+ }), /* @__PURE__ */ J("p", {
496
528
  className: "text-sm text-text-secondary mt-1",
497
529
  children: H(e.address)
498
- })] }), /* @__PURE__ */ K("div", {
530
+ })] }), /* @__PURE__ */ Y("div", {
499
531
  className: "text-right",
500
532
  children: [
501
- /* @__PURE__ */ K("p", {
533
+ /* @__PURE__ */ Y("p", {
502
534
  className: "text-sm",
503
535
  children: ["Scheduled: ", V(e.scheduledTime, "time")]
504
536
  }),
505
- e.actualTime && /* @__PURE__ */ K("p", {
537
+ e.actualTime && /* @__PURE__ */ Y("p", {
506
538
  className: "text-sm text-status-success-text",
507
539
  children: ["Actual: ", V(e.actualTime, "time")]
508
540
  }),
509
- /* @__PURE__ */ K("p", {
541
+ /* @__PURE__ */ Y("p", {
510
542
  className: "text-xs text-text-secondary",
511
543
  children: [e.duration, " min stop"]
512
544
  })
@@ -516,81 +548,81 @@ function Z() {
516
548
  })]
517
549
  }, e.id))
518
550
  }) })] })]
519
- }), /* @__PURE__ */ K("div", {
551
+ }), /* @__PURE__ */ Y("div", {
520
552
  className: "space-y-6",
521
553
  children: [
522
- /* @__PURE__ */ K(q, {
554
+ /* @__PURE__ */ Y(X, {
523
555
  className: "space-y-4",
524
556
  children: [
525
- /* @__PURE__ */ G("h2", {
557
+ /* @__PURE__ */ J("h2", {
526
558
  className: "text-base font-semibold text-text-primary",
527
559
  children: "Route Info"
528
560
  }),
529
- /* @__PURE__ */ K("div", { children: [/* @__PURE__ */ G("p", {
561
+ /* @__PURE__ */ Y("div", { children: [/* @__PURE__ */ J("p", {
530
562
  className: "text-sm text-text-secondary",
531
563
  children: "Total Distance"
532
- }), /* @__PURE__ */ K("p", {
564
+ }), /* @__PURE__ */ Y("p", {
533
565
  className: "text-2xl font-bold",
534
- children: [r.distance.toFixed(1), /* @__PURE__ */ G("span", {
566
+ children: [i.distance.toFixed(1), /* @__PURE__ */ J("span", {
535
567
  className: "text-sm font-normal",
536
568
  children: " km"
537
569
  })]
538
570
  })] }),
539
- /* @__PURE__ */ K("div", { children: [/* @__PURE__ */ G("p", {
571
+ /* @__PURE__ */ Y("div", { children: [/* @__PURE__ */ J("p", {
540
572
  className: "text-sm text-text-secondary",
541
573
  children: "Est. Duration"
542
- }), /* @__PURE__ */ K("p", {
574
+ }), /* @__PURE__ */ Y("p", {
543
575
  className: "text-2xl font-bold",
544
- children: [r.estimatedDuration, /* @__PURE__ */ G("span", {
576
+ children: [i.estimatedDuration, /* @__PURE__ */ J("span", {
545
577
  className: "text-sm font-normal",
546
578
  children: " min"
547
579
  })]
548
580
  })] }),
549
- r.fuelCost !== void 0 && /* @__PURE__ */ K("div", { children: [/* @__PURE__ */ K("p", {
581
+ i.fuelCost !== void 0 && /* @__PURE__ */ Y("div", { children: [/* @__PURE__ */ Y("p", {
550
582
  className: "text-sm text-text-secondary flex items-center gap-1",
551
- children: [/* @__PURE__ */ G(w, { size: 14 }), " Est. Fuel Cost"]
552
- }), /* @__PURE__ */ G("p", {
583
+ children: [/* @__PURE__ */ J(w, { size: 14 }), " Est. Fuel Cost"]
584
+ }), /* @__PURE__ */ J("p", {
553
585
  className: "text-2xl font-bold",
554
- children: B(r.fuelCost)
586
+ children: B(i.fuelCost)
555
587
  })] }),
556
- r.actualDuration && /* @__PURE__ */ K("div", { children: [/* @__PURE__ */ G("p", {
588
+ i.actualDuration && /* @__PURE__ */ Y("div", { children: [/* @__PURE__ */ J("p", {
557
589
  className: "text-sm text-text-secondary",
558
590
  children: "Actual Duration"
559
- }), /* @__PURE__ */ K("p", {
591
+ }), /* @__PURE__ */ Y("p", {
560
592
  className: "text-2xl font-bold",
561
- children: [r.actualDuration, /* @__PURE__ */ G("span", {
593
+ children: [i.actualDuration, /* @__PURE__ */ J("span", {
562
594
  className: "text-sm font-normal",
563
595
  children: " min"
564
596
  })]
565
597
  })] })
566
598
  ]
567
599
  }),
568
- /* @__PURE__ */ K(o, { children: [/* @__PURE__ */ G(l, { children: /* @__PURE__ */ K(c, {
600
+ /* @__PURE__ */ Y(o, { children: [/* @__PURE__ */ J(l, { children: /* @__PURE__ */ Y(c, {
569
601
  className: "flex items-center gap-2",
570
- children: [/* @__PURE__ */ G(C, { size: 18 }), " Timeline"]
571
- }) }), /* @__PURE__ */ K(s, {
602
+ children: [/* @__PURE__ */ J(C, { size: 18 }), " Timeline"]
603
+ }) }), /* @__PURE__ */ Y(s, {
572
604
  className: "space-y-3",
573
605
  children: [
574
- r.startTime && /* @__PURE__ */ K("div", { children: [/* @__PURE__ */ G("p", {
606
+ i.startTime && /* @__PURE__ */ Y("div", { children: [/* @__PURE__ */ J("p", {
575
607
  className: "text-sm text-text-secondary",
576
608
  children: "Started"
577
- }), /* @__PURE__ */ G("p", { children: V(r.startTime, "full") })] }),
578
- r.endTime && /* @__PURE__ */ K("div", { children: [/* @__PURE__ */ G("p", {
609
+ }), /* @__PURE__ */ J("p", { children: V(i.startTime, "full") })] }),
610
+ i.endTime && /* @__PURE__ */ Y("div", { children: [/* @__PURE__ */ J("p", {
579
611
  className: "text-sm text-text-secondary",
580
612
  children: "Completed"
581
- }), /* @__PURE__ */ G("p", { children: V(r.endTime, "full") })] }),
582
- /* @__PURE__ */ K("div", { children: [/* @__PURE__ */ G("p", {
613
+ }), /* @__PURE__ */ J("p", { children: V(i.endTime, "full") })] }),
614
+ /* @__PURE__ */ Y("div", { children: [/* @__PURE__ */ J("p", {
583
615
  className: "text-sm text-text-secondary",
584
616
  children: "Created"
585
- }), /* @__PURE__ */ G("p", { children: V(r.createdAt, "full") })] })
617
+ }), /* @__PURE__ */ J("p", { children: V(i.createdAt, "full") })] })
586
618
  ]
587
619
  })] }),
588
- r.trafficConditions.length > 0 && /* @__PURE__ */ K(o, { children: [/* @__PURE__ */ G(l, { children: /* @__PURE__ */ G(c, { children: "Traffic Conditions" }) }), /* @__PURE__ */ G(s, { children: r.trafficConditions.map((e, t) => /* @__PURE__ */ K("div", {
620
+ i.trafficConditions.length > 0 && /* @__PURE__ */ Y(o, { children: [/* @__PURE__ */ J(l, { children: /* @__PURE__ */ J(c, { children: "Traffic Conditions" }) }), /* @__PURE__ */ J(s, { children: i.trafficConditions.map((e, t) => /* @__PURE__ */ Y("div", {
589
621
  className: `p-2 rounded mb-2 ${e.condition === "severe" ? "bg-status-error-bg-subtle" : (e.condition, "bg-status-warning-bg-subtle")}`,
590
- children: [/* @__PURE__ */ K("p", {
622
+ children: [/* @__PURE__ */ Y("p", {
591
623
  className: "text-sm font-medium capitalize",
592
624
  children: [e.condition, " traffic"]
593
- }), /* @__PURE__ */ K("p", {
625
+ }), /* @__PURE__ */ Y("p", {
594
626
  className: "text-xs text-text-secondary",
595
627
  children: [
596
628
  e.location,
@@ -607,4 +639,4 @@ function Z() {
607
639
  });
608
640
  }
609
641
  //#endregion
610
- export { Z as default };
642
+ export { ne as default };