@burdenoff/microfe-movethewheels 2026.921.1 → 2026.924.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 (32) hide show
  1. package/dist/components/CustomerPicker.js +94 -101
  2. package/dist/components/EntityCombobox.js +105 -0
  3. package/dist/components/ui.js +2 -2
  4. package/dist/generated/wspace-types.d.ts +1676 -3
  5. package/dist/hooks/index.js +1 -1
  6. package/dist/hooks/useFleet.js +57 -51
  7. package/dist/hooks/useOrders.js +89 -84
  8. package/dist/hooks/useRoutes.js +1 -1
  9. package/dist/index.js +27 -27
  10. package/dist/movethewheels/components/CustomerPicker.d.ts +3 -2
  11. package/dist/movethewheels/components/EntityCombobox.d.ts +40 -0
  12. package/dist/movethewheels/components/ui.d.ts +1 -1
  13. package/dist/movethewheels/hooks/useFleet.d.ts +4 -0
  14. package/dist/movethewheels/hooks/useOrders.d.ts +15 -0
  15. package/dist/movethewheels/hooks/useRoutes.d.ts +16 -0
  16. package/dist/movethewheels/types/index.d.ts +5 -0
  17. package/dist/node_modules/lucide-react/dist/esm/icons/chevrons-up-down.js +11 -0
  18. package/dist/pages/CreateOrderPage.js +196 -134
  19. package/dist/pages/OrderDetailsPage.js +328 -263
  20. package/dist/pages/RouteDetailsPage.js +277 -266
  21. package/package.json +1 -1
  22. package/src/generated/wspace-types.ts +1948 -3
  23. package/src/movethewheels/components/CustomerPicker.tsx +26 -36
  24. package/src/movethewheels/components/EntityCombobox.tsx +237 -0
  25. package/src/movethewheels/components/ui.tsx +9 -0
  26. package/src/movethewheels/hooks/useFleet.ts +19 -6
  27. package/src/movethewheels/hooks/useOrders.ts +35 -0
  28. package/src/movethewheels/hooks/useRoutes.ts +1 -1
  29. package/src/movethewheels/pages/CreateOrderPage.tsx +108 -5
  30. package/src/movethewheels/pages/OrderDetailsPage.tsx +130 -60
  31. package/src/movethewheels/pages/RouteDetailsPage.tsx +57 -47
  32. package/src/movethewheels/types/index.ts +5 -0
@@ -3,22 +3,24 @@ import { CalendarClock as t } from "../node_modules/lucide-react/dist/esm/icons/
3
3
  import { MapPin as n } from "../node_modules/lucide-react/dist/esm/icons/map-pin.js";
4
4
  import { Package as r } from "../node_modules/lucide-react/dist/esm/icons/package.js";
5
5
  import { Plus as i } from "../node_modules/lucide-react/dist/esm/icons/plus.js";
6
- import { Save as a } from "../node_modules/lucide-react/dist/esm/icons/save.js";
6
+ import { Route as a } from "../node_modules/lucide-react/dist/esm/icons/route.js";
7
+ import { Save as o } from "../node_modules/lucide-react/dist/esm/icons/save.js";
7
8
  import { Trash2 as ee } from "../node_modules/lucide-react/dist/esm/icons/trash-2.js";
8
- import { Users as o } from "../node_modules/lucide-react/dist/esm/icons/users.js";
9
- import { buildCustomerCreatePath as te, joinPath as s } from "../utils/navigation.js";
10
- import { useMoveTheWheels as c } from "../providers/MoveTheWheelsProvider.js";
11
- import { useOrder as l, useOrders as u } from "../hooks/useOrders.js";
12
- import { useCustomer as ne, useCustomers as re } from "../hooks/useCustomers.js";
13
- import { Button as d, Card as f, CardContent as p, CardHeader as m, CardTitle as h, Input as g, Label as _, Select as v, SelectContent as ie, SelectItem as y, SelectTrigger as ae, SelectValue as oe, Separator as se, Textarea as ce } from "../components/ui.js";
14
- import { EmptyState as le, PageLayout as ue } from "../components/PageLayout.js";
15
- import { FormError as de } from "../components/FormError.js";
16
- import { useDebouncedValue as fe } from "../hooks/useDebouncedValue.js";
17
- import { CustomerPicker as pe } from "../components/CustomerPicker.js";
9
+ import { Users as te } from "../node_modules/lucide-react/dist/esm/icons/users.js";
10
+ import { buildCustomerCreatePath as ne, joinPath as s } from "../utils/navigation.js";
11
+ import { useMoveTheWheels as re } from "../providers/MoveTheWheelsProvider.js";
12
+ import { useRoute as ie, useRoutes as ae } from "../hooks/useRoutes.js";
13
+ import { useOrder as oe, useOrders as c } from "../hooks/useOrders.js";
14
+ import { useCustomer as l, useCustomers as u } from "../hooks/useCustomers.js";
15
+ import { Button as d, Card as f, CardContent as p, CardHeader as m, CardTitle as h, Input as g, Label as _, Select as se, SelectContent as ce, SelectItem as v, SelectTrigger as le, SelectValue as ue, Separator as de, Textarea as y } from "../components/ui.js";
16
+ import { EmptyState as fe, PageLayout as pe } from "../components/PageLayout.js";
17
+ import { FormError as me } from "../components/FormError.js";
18
+ import { EntityCombobox as he } from "../components/EntityCombobox.js";
19
+ import { CustomerPicker as ge } from "../components/CustomerPicker.js";
18
20
  import { useEffect as b, useState as x } from "react";
19
- import { useParams as me, useSearchParams as he } from "react-router";
20
- import { jsx as S, jsxs as C } from "react/jsx-runtime";
21
- import { EmphasisPanel as ge, NextSteps as _e, PagePurpose as ve } from "@burdenoff/fe-libs/ui";
21
+ import { useParams as _e, useSearchParams as ve } from "react-router";
22
+ import { Fragment as ye, jsx as S, jsxs as C } from "react/jsx-runtime";
23
+ import { EmphasisPanel as be, NextSteps as xe, PagePurpose as Se } from "@burdenoff/fe-libs/ui";
22
24
  //#region src/movethewheels/pages/CreateOrderPage.tsx
23
25
  function w(e) {
24
26
  if (!e || Number.isNaN(e.getTime())) return "";
@@ -26,116 +28,143 @@ function w(e) {
26
28
  return `${e.getFullYear()}-${t(e.getMonth() + 1)}-${t(e.getDate())}T${t(e.getHours())}:${t(e.getMinutes())}`;
27
29
  }
28
30
  function T() {
29
- let { orderId: T } = me(), [ye] = he(), E = ye.get("customerId")?.trim() || void 0, { basePath: D, navigate: O } = c(), { order: k } = l(T), { createOrder: A, updateOrder: j } = u(), [M, N] = x(""), { customers: P, createCustomer: be, isLoading: F, error: I, refetch: xe } = re({
31
+ let { orderId: T } = _e(), [E] = ve(), D = E.get("customerId")?.trim() || void 0, { basePath: O, navigate: k } = re(), { order: A } = oe(T), { createOrder: j, updateOrder: Ce } = c(), [we, Te] = x(""), { customers: M, createCustomer: Ee, isLoading: N, error: P, refetch: De } = u({
30
32
  limit: 20,
31
- filters: { search: fe(M) || void 0 }
32
- }), { customer: L } = ne(E ?? k?.customerId), R = !!T && !!k, [z, B] = x(null), [V, H] = x({
33
- customerId: E || k?.customerId || "",
34
- priority: k?.priority || "normal",
33
+ filters: { search: we || void 0 }
34
+ }), { customer: F } = l(D ?? A?.customerId), [Oe, ke] = x(""), { routes: I, isLoading: L, error: R, hasMore: Ae, totalRoutes: je } = ae({
35
+ status: "planned",
36
+ search: Oe || void 0,
37
+ limit: 20
38
+ }), z = !!T && !!A, [B, V] = x(null), [H, U] = x({
39
+ customerId: D || A?.customerId || "",
40
+ priority: A?.priority || "normal",
41
+ routeId: A?.routeId || "",
35
42
  pickupAddress: {
36
- street: k?.pickupAddress.street || "",
37
- city: k?.pickupAddress.city || "",
38
- state: k?.pickupAddress.state || "",
39
- postalCode: k?.pickupAddress.postalCode || "",
40
- country: k?.pickupAddress.country || "USA"
43
+ street: A?.pickupAddress.street || "",
44
+ city: A?.pickupAddress.city || "",
45
+ state: A?.pickupAddress.state || "",
46
+ postalCode: A?.pickupAddress.postalCode || "",
47
+ country: A?.pickupAddress.country || "USA"
41
48
  },
42
49
  deliveryAddress: {
43
- street: k?.deliveryAddress.street || "",
44
- city: k?.deliveryAddress.city || "",
45
- state: k?.deliveryAddress.state || "",
46
- postalCode: k?.deliveryAddress.postalCode || "",
47
- country: k?.deliveryAddress.country || "USA"
50
+ street: A?.deliveryAddress.street || "",
51
+ city: A?.deliveryAddress.city || "",
52
+ state: A?.deliveryAddress.state || "",
53
+ postalCode: A?.deliveryAddress.postalCode || "",
54
+ country: A?.deliveryAddress.country || "USA"
48
55
  },
49
- items: k?.items || [],
50
- scheduledDelivery: w(k?.scheduledDelivery),
51
- specialInstructions: k?.specialInstructions || ""
52
- }), [U, W] = x(!1), [Se, G] = x(null);
56
+ items: A?.items || [],
57
+ scheduledDelivery: w(A?.scheduledDelivery),
58
+ specialInstructions: A?.specialInstructions || ""
59
+ }), { route: Me, isLoading: Ne } = ie(H.routeId || void 0), [W, G] = x(!1), [Pe, K] = x(null);
53
60
  b(() => {
54
- L && (B((e) => e?.id === L.id ? e : L), H((e) => e.customerId ? e : {
61
+ F && (V((e) => e?.id === F.id ? e : F), U((e) => e.customerId ? e : {
55
62
  ...e,
56
- customerId: L.id
63
+ customerId: F.id
57
64
  }));
58
- }, [L]), b(() => {
59
- k && H({
60
- customerId: k.customerId || "",
61
- priority: k.priority || "normal",
65
+ }, [F]), b(() => {
66
+ A && U({
67
+ customerId: A.customerId || "",
68
+ priority: A.priority || "normal",
69
+ routeId: A.routeId || "",
62
70
  pickupAddress: {
63
- street: k.pickupAddress.street || "",
64
- city: k.pickupAddress.city || "",
65
- state: k.pickupAddress.state || "",
66
- postalCode: k.pickupAddress.postalCode || "",
67
- country: k.pickupAddress.country || "USA"
71
+ street: A.pickupAddress.street || "",
72
+ city: A.pickupAddress.city || "",
73
+ state: A.pickupAddress.state || "",
74
+ postalCode: A.pickupAddress.postalCode || "",
75
+ country: A.pickupAddress.country || "USA"
68
76
  },
69
77
  deliveryAddress: {
70
- street: k.deliveryAddress.street || "",
71
- city: k.deliveryAddress.city || "",
72
- state: k.deliveryAddress.state || "",
73
- postalCode: k.deliveryAddress.postalCode || "",
74
- country: k.deliveryAddress.country || "USA"
78
+ street: A.deliveryAddress.street || "",
79
+ city: A.deliveryAddress.city || "",
80
+ state: A.deliveryAddress.state || "",
81
+ postalCode: A.deliveryAddress.postalCode || "",
82
+ country: A.deliveryAddress.country || "USA"
75
83
  },
76
- items: k.items || [],
77
- scheduledDelivery: w(k.scheduledDelivery),
78
- specialInstructions: k.specialInstructions || ""
84
+ items: A.items || [],
85
+ scheduledDelivery: w(A.scheduledDelivery),
86
+ specialInstructions: A.specialInstructions || ""
79
87
  });
80
- }, [k]);
81
- let K = () => {
82
- if (O) {
83
- if (!R && E) {
84
- O(s(D, `customers/${E}`));
88
+ }, [A]);
89
+ let q = () => {
90
+ if (k) {
91
+ if (!z && D) {
92
+ k(s(O, `customers/${D}`));
85
93
  return;
86
94
  }
87
- O(s(D, "orders"));
95
+ k(s(O, "orders"));
88
96
  }
89
- }, q = () => z ?? P.find((e) => e.id === V.customerId), J = () => !V.customerId || !q() ? I ? "Customers could not be loaded. Retry or create a customer before continuing." : "Select a customer for this order." : V.pickupAddress.street.trim() ? V.deliveryAddress.street.trim() ? V.items.length === 0 ? "Add at least one item to the order." : V.scheduledDelivery && Number.isNaN(Date.parse(V.scheduledDelivery)) ? "Enter a valid scheduled delivery date and time." : null : "Enter a delivery street address." : "Enter a pickup street address.", Y = async (e) => {
90
- e.preventDefault(), G(null);
91
- let t = J();
97
+ }, J = () => B ?? M.find((e) => e.id === H.customerId), Fe = () => !H.customerId || !J() ? P ? "Customers could not be loaded. Retry or create a customer before continuing." : "Select a customer for this order." : H.pickupAddress.street.trim() ? H.deliveryAddress.street.trim() ? H.items.length === 0 ? "Add at least one item to the order." : H.scheduledDelivery && Number.isNaN(Date.parse(H.scheduledDelivery)) ? "Enter a valid scheduled delivery date and time." : null : "Enter a delivery street address." : "Enter a pickup street address.", Y = async (e) => {
98
+ e.preventDefault(), K(null);
99
+ let t = Fe();
92
100
  if (t) {
93
- G(t);
101
+ K(t);
94
102
  return;
95
103
  }
96
- let n = q();
104
+ let n = J();
97
105
  if (!n) {
98
- G(I ? "Customers could not be loaded. Retry or create a customer before continuing." : "Select a customer for this order.");
106
+ K(P ? "Customers could not be loaded. Retry or create a customer before continuing." : "Select a customer for this order.");
99
107
  return;
100
108
  }
101
- W(!0);
109
+ G(!0);
102
110
  try {
103
111
  let e = {
104
- customerId: V.customerId,
112
+ customerId: H.customerId,
105
113
  customerInfo: {
106
114
  name: n.name,
107
115
  email: n.email,
108
116
  phone: n.phone,
109
117
  company: n.company
110
118
  },
111
- priority: V.priority,
112
- pickupAddress: V.pickupAddress,
113
- deliveryAddress: V.deliveryAddress,
114
- items: V.items,
115
- scheduledDelivery: V.scheduledDelivery ? new Date(V.scheduledDelivery) : null,
116
- specialInstructions: V.specialInstructions
119
+ priority: H.priority,
120
+ pickupAddress: H.pickupAddress,
121
+ deliveryAddress: H.deliveryAddress,
122
+ items: H.items,
123
+ scheduledDelivery: H.scheduledDelivery ? new Date(H.scheduledDelivery) : null,
124
+ routeId: H.routeId || void 0,
125
+ specialInstructions: H.specialInstructions
117
126
  };
118
- R && T ? (await j(T, e), O && O(s(D, `orders/${T}`))) : (await A(e), K());
127
+ z && T ? (await Ce(T, e), k && k(s(O, `orders/${T}`))) : (await j(e), q());
119
128
  } catch (e) {
120
- G(e instanceof Error ? e.message : R ? "Could not update the order. Please try again." : "Could not create the order. Please try again.");
129
+ K(e instanceof Error ? e.message : z ? "Could not update the order. Please try again." : "Could not create the order. Please try again.");
121
130
  } finally {
122
- W(!1);
131
+ G(!1);
123
132
  }
124
133
  }, X = (e, t) => {
125
- H((n) => ({
134
+ U((n) => ({
126
135
  ...n,
127
136
  [e]: t
128
137
  }));
129
138
  }, Z = (e, t, n) => {
130
- H((r) => ({
139
+ U((r) => ({
131
140
  ...r,
132
141
  [e]: {
133
142
  ...r[e],
134
143
  [t]: n
135
144
  }
136
145
  }));
146
+ }, Ie = (e) => {
147
+ if (!e) {
148
+ X("routeId", "");
149
+ return;
150
+ }
151
+ let t = I.find((t) => t.id === e);
152
+ if (!t) return;
153
+ let n = t.stops.find((e) => e.type === "pickup")?.address, r = [...t.stops].reverse().find((e) => e.type === "delivery")?.address, i = (e, t) => t ? {
154
+ street: e.street.trim() ? e.street : t.street,
155
+ city: e.city.trim() ? e.city : t.city,
156
+ state: e.state.trim() ? e.state : t.state,
157
+ postalCode: e.postalCode.trim() ? e.postalCode : t.postalCode,
158
+ country: e.country.trim() ? e.country : t.country
159
+ } : e;
160
+ U((e) => ({
161
+ ...e,
162
+ routeId: t.id,
163
+ pickupAddress: i(e.pickupAddress, n),
164
+ deliveryAddress: i(e.deliveryAddress, r)
165
+ }));
137
166
  }, Q = () => {
138
- H((e) => ({
167
+ U((e) => ({
139
168
  ...e,
140
169
  items: [...e.items, {
141
170
  id: `item-${Date.now()}`,
@@ -153,13 +182,13 @@ function T() {
153
182
  sku: ""
154
183
  }]
155
184
  }));
156
- }, Ce = (e) => {
157
- H((t) => ({
185
+ }, Le = (e) => {
186
+ U((t) => ({
158
187
  ...t,
159
188
  items: t.items.filter((t, n) => n !== e)
160
189
  }));
161
190
  }, $ = (e, t, n) => {
162
- H((r) => ({
191
+ U((r) => ({
163
192
  ...r,
164
193
  items: r.items.map((r, i) => i === e ? {
165
194
  ...r,
@@ -167,36 +196,36 @@ function T() {
167
196
  } : r)
168
197
  }));
169
198
  };
170
- return /* @__PURE__ */ C(ue, {
171
- title: R ? "Edit Order" : "Create Order",
172
- subtitle: R ? `Editing ${k?.orderNumber}` : "Create a new delivery order",
199
+ return /* @__PURE__ */ C(pe, {
200
+ title: z ? "Edit Order" : "Create Order",
201
+ subtitle: z ? `Editing ${A?.orderNumber}` : "Create a new delivery order",
173
202
  icon: /* @__PURE__ */ S(r, { size: 24 }),
174
203
  headerActions: /* @__PURE__ */ C("div", {
175
204
  className: "flex gap-2",
176
205
  children: [/* @__PURE__ */ C(d, {
177
206
  variant: "outline",
178
- onClick: K,
207
+ onClick: q,
179
208
  children: [/* @__PURE__ */ S(e, { size: 16 }), "Cancel"]
180
209
  }), /* @__PURE__ */ C(d, {
181
210
  onClick: Y,
182
- disabled: U || F,
183
- children: [/* @__PURE__ */ S(a, { size: 16 }), U ? "Saving..." : R ? "Save Changes" : "Create Order"]
211
+ disabled: W || N,
212
+ children: [/* @__PURE__ */ S(o, { size: 16 }), W ? "Saving..." : z ? "Save Changes" : "Create Order"]
184
213
  })]
185
214
  }),
186
215
  children: [
187
- /* @__PURE__ */ S(ve, {
216
+ /* @__PURE__ */ S(Se, {
188
217
  icon: /* @__PURE__ */ S(r, { size: 18 }),
189
- children: R ? "Update this delivery before it goes out — change the customer, addresses, items or handling notes, then save." : "Book a new delivery in a few steps: choose who it’s for, set pickup and drop-off addresses, list what’s being shipped, and add any handling notes. Once created it joins the orders pipeline ready to assign and track."
218
+ children: z ? "Update this delivery before it goes out — change the customer, addresses, items or handling notes, then save." : "Book a new delivery in a few steps: choose who it’s for, set pickup and drop-off addresses, list what’s being shipped, and add any handling notes. Once created it joins the orders pipeline ready to assign and track."
190
219
  }),
191
- /* @__PURE__ */ S(_e, {
220
+ /* @__PURE__ */ S(xe, {
192
221
  storageKey: "movethewheels-create-order",
193
222
  steps: [
194
223
  {
195
224
  id: "customer",
196
225
  label: "Pick the customer first",
197
226
  description: "Their saved contact details auto-fill the order.",
198
- icon: /* @__PURE__ */ S(o, { size: 16 }),
199
- done: !!V.customerId,
227
+ icon: /* @__PURE__ */ S(te, { size: 16 }),
228
+ done: !!H.customerId,
200
229
  onClick: () => document.getElementById("customer")?.focus()
201
230
  },
202
231
  {
@@ -204,7 +233,7 @@ function T() {
204
233
  label: "Set pickup & delivery addresses",
205
234
  description: "Where the shipment is collected and dropped off.",
206
235
  icon: /* @__PURE__ */ S(n, { size: 16 }),
207
- done: !!V.pickupAddress.street && !!V.deliveryAddress.street,
236
+ done: !!H.pickupAddress.street && !!H.deliveryAddress.street,
208
237
  onClick: () => document.getElementById("pickupStreet")?.focus()
209
238
  },
210
239
  {
@@ -212,7 +241,7 @@ function T() {
212
241
  label: "Add the items to ship",
213
242
  description: "List each product with its quantity and value.",
214
243
  icon: /* @__PURE__ */ S(r, { size: 16 }),
215
- done: V.items.length > 0,
244
+ done: H.items.length > 0,
216
245
  onClick: Q
217
246
  }
218
247
  ]
@@ -221,58 +250,57 @@ function T() {
221
250
  onSubmit: Y,
222
251
  className: "space-y-6",
223
252
  children: [
224
- /* @__PURE__ */ S(de, { message: Se }),
225
- /* @__PURE__ */ C(ge, { children: [/* @__PURE__ */ S("h2", {
253
+ /* @__PURE__ */ S(me, { message: Pe }),
254
+ /* @__PURE__ */ C(be, { children: [/* @__PURE__ */ S("h2", {
226
255
  className: "text-base font-semibold text-text-primary mb-4",
227
256
  children: "Order Details"
228
257
  }), /* @__PURE__ */ S("div", {
229
258
  className: "space-y-4",
230
259
  children: /* @__PURE__ */ C("div", {
231
260
  className: "grid grid-cols-1 md:grid-cols-2 gap-4",
232
- children: [/* @__PURE__ */ S(pe, {
233
- customers: P,
234
- value: V.customerId,
261
+ children: [/* @__PURE__ */ S(ge, {
262
+ customers: M,
263
+ value: H.customerId,
235
264
  onValueChange: (e) => {
236
- e && (X("customerId", e), B(P.find((t) => t.id === e) ?? (z?.id === e ? z : null)), G(null));
265
+ e && (X("customerId", e), V(M.find((t) => t.id === e) ?? (B?.id === e ? B : null)), K(null));
237
266
  },
238
267
  onCreated: (e) => {
239
- B(e), X("customerId", e.id), G(null);
268
+ V(e), X("customerId", e.id), K(null);
240
269
  },
241
- createCustomer: be,
242
- isLoading: F,
243
- error: I,
244
- onRetry: xe,
270
+ createCustomer: Ee,
271
+ isLoading: N,
272
+ error: P,
273
+ onRetry: De,
245
274
  onOpenCustomers: () => {
246
- O && O(s(D, te(R && T ? `orders/${T}/edit` : "orders/new")));
275
+ k && k(s(O, ne(z && T ? `orders/${T}/edit` : "orders/new")));
247
276
  },
248
- selectedCustomer: z,
249
- searchQuery: M,
250
- onSearchQueryChange: N
277
+ selectedCustomer: B,
278
+ onSearchQueryChange: Te
251
279
  }), /* @__PURE__ */ C("div", {
252
280
  className: "space-y-2",
253
281
  children: [/* @__PURE__ */ S(_, {
254
282
  htmlFor: "priority",
255
283
  children: "Priority"
256
- }), /* @__PURE__ */ C(v, {
257
- value: V.priority,
284
+ }), /* @__PURE__ */ C(se, {
285
+ value: H.priority,
258
286
  onValueChange: (e) => X("priority", e),
259
- children: [/* @__PURE__ */ S(ae, {
287
+ children: [/* @__PURE__ */ S(le, {
260
288
  id: "priority",
261
- children: /* @__PURE__ */ S(oe, {})
262
- }), /* @__PURE__ */ C(ie, { children: [
263
- /* @__PURE__ */ S(y, {
289
+ children: /* @__PURE__ */ S(ue, {})
290
+ }), /* @__PURE__ */ C(ce, { children: [
291
+ /* @__PURE__ */ S(v, {
264
292
  value: "low",
265
293
  children: "Low"
266
294
  }),
267
- /* @__PURE__ */ S(y, {
295
+ /* @__PURE__ */ S(v, {
268
296
  value: "normal",
269
297
  children: "Normal"
270
298
  }),
271
- /* @__PURE__ */ S(y, {
299
+ /* @__PURE__ */ S(v, {
272
300
  value: "high",
273
301
  children: "High"
274
302
  }),
275
- /* @__PURE__ */ S(y, {
303
+ /* @__PURE__ */ S(v, {
276
304
  value: "urgent",
277
305
  children: "Urgent"
278
306
  })
@@ -281,6 +309,40 @@ function T() {
281
309
  })]
282
310
  })
283
311
  })] }),
312
+ /* @__PURE__ */ C(f, { children: [/* @__PURE__ */ S(m, { children: /* @__PURE__ */ C(h, {
313
+ className: "flex items-center gap-2",
314
+ children: [/* @__PURE__ */ S(a, { size: 18 }), "Saved Route (Optional)"]
315
+ }) }), /* @__PURE__ */ C(p, {
316
+ className: "space-y-2",
317
+ children: [/* @__PURE__ */ S(he, {
318
+ id: "saved-route",
319
+ value: H.routeId,
320
+ onChange: Ie,
321
+ options: I,
322
+ loading: L,
323
+ getId: (e) => e.id,
324
+ getLabel: (e) => `${e.name} · ${e.stops.length} stops`,
325
+ renderOption: (e) => /* @__PURE__ */ C(ye, { children: [
326
+ e.name,
327
+ " · ",
328
+ e.stops.length,
329
+ " stops"
330
+ ] }),
331
+ selectedOption: Me,
332
+ selectedLoading: Ne,
333
+ placeholder: "Choose a saved route",
334
+ searchPlaceholder: "Search saved routes",
335
+ emptyText: "No saved routes found.",
336
+ noneLabel: "No saved route",
337
+ error: R ? "Saved routes are unavailable" : void 0,
338
+ onSearchChange: ke,
339
+ hasMore: Ae,
340
+ totalCount: je
341
+ }), /* @__PURE__ */ S("p", {
342
+ className: "text-xs text-text-secondary",
343
+ children: L ? "Loading planned routes…" : R ? "Saved routes are unavailable; enter pickup and delivery addresses manually." : "A saved route fills any blank address fields. You can always edit both addresses below."
344
+ })]
345
+ })] }),
284
346
  /* @__PURE__ */ C("div", {
285
347
  className: "grid grid-cols-1 md:grid-cols-2 gap-6",
286
348
  children: [/* @__PURE__ */ C(f, { children: [/* @__PURE__ */ S(m, { children: /* @__PURE__ */ S(h, { children: "Pickup Address" }) }), /* @__PURE__ */ C(p, {
@@ -293,7 +355,7 @@ function T() {
293
355
  children: "Street Address"
294
356
  }), /* @__PURE__ */ S(g, {
295
357
  id: "pickupStreet",
296
- value: V.pickupAddress.street,
358
+ value: H.pickupAddress.street,
297
359
  onChange: (e) => Z("pickupAddress", "street", e.target.value),
298
360
  placeholder: "123 Main St"
299
361
  })]
@@ -307,7 +369,7 @@ function T() {
307
369
  children: "City"
308
370
  }), /* @__PURE__ */ S(g, {
309
371
  id: "pickupCity",
310
- value: V.pickupAddress.city,
372
+ value: H.pickupAddress.city,
311
373
  onChange: (e) => Z("pickupAddress", "city", e.target.value),
312
374
  placeholder: "San Francisco"
313
375
  })]
@@ -318,7 +380,7 @@ function T() {
318
380
  children: "State"
319
381
  }), /* @__PURE__ */ S(g, {
320
382
  id: "pickupState",
321
- value: V.pickupAddress.state,
383
+ value: H.pickupAddress.state,
322
384
  onChange: (e) => Z("pickupAddress", "state", e.target.value),
323
385
  placeholder: "CA"
324
386
  })]
@@ -333,7 +395,7 @@ function T() {
333
395
  children: "Postal Code"
334
396
  }), /* @__PURE__ */ S(g, {
335
397
  id: "pickupPostal",
336
- value: V.pickupAddress.postalCode,
398
+ value: H.pickupAddress.postalCode,
337
399
  onChange: (e) => Z("pickupAddress", "postalCode", e.target.value),
338
400
  placeholder: "94103"
339
401
  })]
@@ -344,7 +406,7 @@ function T() {
344
406
  children: "Country"
345
407
  }), /* @__PURE__ */ S(g, {
346
408
  id: "pickupCountry",
347
- value: V.pickupAddress.country,
409
+ value: H.pickupAddress.country,
348
410
  onChange: (e) => Z("pickupAddress", "country", e.target.value),
349
411
  placeholder: "USA"
350
412
  })]
@@ -361,7 +423,7 @@ function T() {
361
423
  children: "Street Address"
362
424
  }), /* @__PURE__ */ S(g, {
363
425
  id: "deliveryStreet",
364
- value: V.deliveryAddress.street,
426
+ value: H.deliveryAddress.street,
365
427
  onChange: (e) => Z("deliveryAddress", "street", e.target.value),
366
428
  placeholder: "456 Oak Ave"
367
429
  })]
@@ -375,7 +437,7 @@ function T() {
375
437
  children: "City"
376
438
  }), /* @__PURE__ */ S(g, {
377
439
  id: "deliveryCity",
378
- value: V.deliveryAddress.city,
440
+ value: H.deliveryAddress.city,
379
441
  onChange: (e) => Z("deliveryAddress", "city", e.target.value),
380
442
  placeholder: "Los Angeles"
381
443
  })]
@@ -386,7 +448,7 @@ function T() {
386
448
  children: "State"
387
449
  }), /* @__PURE__ */ S(g, {
388
450
  id: "deliveryState",
389
- value: V.deliveryAddress.state,
451
+ value: H.deliveryAddress.state,
390
452
  onChange: (e) => Z("deliveryAddress", "state", e.target.value),
391
453
  placeholder: "CA"
392
454
  })]
@@ -401,7 +463,7 @@ function T() {
401
463
  children: "Postal Code"
402
464
  }), /* @__PURE__ */ S(g, {
403
465
  id: "deliveryPostal",
404
- value: V.deliveryAddress.postalCode,
466
+ value: H.deliveryAddress.postalCode,
405
467
  onChange: (e) => Z("deliveryAddress", "postalCode", e.target.value),
406
468
  placeholder: "90210"
407
469
  })]
@@ -412,7 +474,7 @@ function T() {
412
474
  children: "Country"
413
475
  }), /* @__PURE__ */ S(g, {
414
476
  id: "deliveryCountry",
415
- value: V.deliveryAddress.country,
477
+ value: H.deliveryAddress.country,
416
478
  onChange: (e) => Z("deliveryAddress", "country", e.target.value),
417
479
  placeholder: "USA"
418
480
  })]
@@ -430,7 +492,7 @@ function T() {
430
492
  onClick: Q,
431
493
  children: [/* @__PURE__ */ S(i, { size: 16 }), "Add Item"]
432
494
  })]
433
- }), /* @__PURE__ */ S(p, { children: V.items.length === 0 ? /* @__PURE__ */ S(le, {
495
+ }), /* @__PURE__ */ S(p, { children: H.items.length === 0 ? /* @__PURE__ */ S(fe, {
434
496
  illustration: "empty-files",
435
497
  title: "No items added yet",
436
498
  description: "Add the products this order will ship — each with a name, SKU, quantity and value.",
@@ -445,7 +507,7 @@ function T() {
445
507
  })
446
508
  }) : /* @__PURE__ */ S("div", {
447
509
  className: "space-y-4",
448
- children: V.items.map((e, t) => /* @__PURE__ */ C("div", { children: [t > 0 && /* @__PURE__ */ S(se, { className: "my-4" }), /* @__PURE__ */ C("div", {
510
+ children: H.items.map((e, t) => /* @__PURE__ */ C("div", { children: [t > 0 && /* @__PURE__ */ S(de, { className: "my-4" }), /* @__PURE__ */ C("div", {
449
511
  className: "grid grid-cols-1 md:grid-cols-7 gap-4",
450
512
  children: [
451
513
  /* @__PURE__ */ C("div", {
@@ -500,7 +562,7 @@ function T() {
500
562
  variant: "ghost",
501
563
  size: "icon",
502
564
  className: "text-status-error-text",
503
- onClick: () => Ce(t),
565
+ onClick: () => Le(t),
504
566
  children: /* @__PURE__ */ S(ee, { size: 16 })
505
567
  })
506
568
  })
@@ -523,7 +585,7 @@ function T() {
523
585
  /* @__PURE__ */ S(g, {
524
586
  id: "scheduledDelivery",
525
587
  type: "datetime-local",
526
- value: V.scheduledDelivery,
588
+ value: H.scheduledDelivery,
527
589
  onChange: (e) => X("scheduledDelivery", e.target.value)
528
590
  }),
529
591
  /* @__PURE__ */ S("p", {
@@ -536,9 +598,9 @@ function T() {
536
598
  children: [/* @__PURE__ */ S(_, {
537
599
  htmlFor: "specialInstructions",
538
600
  children: "Special Instructions"
539
- }), /* @__PURE__ */ S(ce, {
601
+ }), /* @__PURE__ */ S(y, {
540
602
  id: "specialInstructions",
541
- value: V.specialInstructions,
603
+ value: H.specialInstructions,
542
604
  onChange: (e) => X("specialInstructions", e.target.value),
543
605
  placeholder: "Any special handling or delivery instructions...",
544
606
  rows: 4