@burdenoff/microfe-movethewheels 2026.923.1 → 2026.924.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,149 +5,154 @@ import { Package as r } from "../node_modules/lucide-react/dist/esm/icons/packag
5
5
  import { Plus as i } from "../node_modules/lucide-react/dist/esm/icons/plus.js";
6
6
  import { Route as a } from "../node_modules/lucide-react/dist/esm/icons/route.js";
7
7
  import { Save as ee } from "../node_modules/lucide-react/dist/esm/icons/save.js";
8
- import { Trash2 as te } from "../node_modules/lucide-react/dist/esm/icons/trash-2.js";
9
- import { Users as ne } from "../node_modules/lucide-react/dist/esm/icons/users.js";
10
- import { buildCustomerCreatePath as re, joinPath as o } from "../utils/navigation.js";
11
- import { useMoveTheWheels as ie } from "../providers/MoveTheWheelsProvider.js";
12
- import { useRoutes as ae } from "../hooks/useRoutes.js";
13
- import { useOrder as oe, useOrders as se } from "../hooks/useOrders.js";
14
- import { useCustomer as ce, useCustomers as le } from "../hooks/useCustomers.js";
15
- import { Button as s, Card as c, CardContent as l, CardHeader as u, CardTitle as d, Input as f, Label as p, Select as m, SelectContent as h, SelectItem as g, SelectTrigger as _, SelectValue as v, Separator as ue, Textarea as de } from "../components/ui.js";
16
- import { EmptyState as fe, PageLayout as y } from "../components/PageLayout.js";
17
- import { FormError as pe } from "../components/FormError.js";
18
- import { useDebouncedValue as me } from "../hooks/useDebouncedValue.js";
19
- import { CustomerPicker as he } from "../components/CustomerPicker.js";
20
- import { useEffect as b, useState as x } from "react";
21
- import { useParams as ge, useSearchParams as S } from "react-router";
22
- import { jsx as C, jsxs as w } from "react/jsx-runtime";
23
- import { EmphasisPanel as _e, NextSteps as ve, PagePurpose as ye } from "@burdenoff/fe-libs/ui";
8
+ import { Users as te } from "../node_modules/lucide-react/dist/esm/icons/users.js";
9
+ import { buildCustomerCreatePath as ne, joinPath as o } from "../utils/navigation.js";
10
+ import { useMoveTheWheels as s } from "../providers/MoveTheWheelsProvider.js";
11
+ import { useRoute as c, useRoutes as l } from "../hooks/useRoutes.js";
12
+ import { useOrder as re, useOrders as ie } from "../hooks/useOrders.js";
13
+ import { useProducts as ae } from "../hooks/useInventory.js";
14
+ import { useCustomer as oe, useCustomers as se } from "../hooks/useCustomers.js";
15
+ import { Button as u, Card as d, CardContent as f, CardHeader as p, CardTitle as m, Input as h, Label as g, Select as ce, SelectContent as le, SelectItem as _, SelectTrigger as v, SelectValue as ue, Textarea as de } 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";
20
+ import { OrderItemRow as _e } from "../components/OrderItemRow.js";
21
+ import { useEffect as y, useState as b } from "react";
22
+ import { useParams as ve, useSearchParams as ye } from "react-router";
23
+ import { Fragment as be, jsx as x, jsxs as S } from "react/jsx-runtime";
24
+ import { EmphasisPanel as xe, NextSteps as Se, PagePurpose as Ce } from "@burdenoff/fe-libs/ui";
24
25
  //#region src/movethewheels/pages/CreateOrderPage.tsx
25
- function T(e) {
26
+ function C(e) {
26
27
  if (!e || Number.isNaN(e.getTime())) return "";
27
28
  let t = (e) => String(e).padStart(2, "0");
28
29
  return `${e.getFullYear()}-${t(e.getMonth() + 1)}-${t(e.getDate())}T${t(e.getHours())}:${t(e.getMinutes())}`;
29
30
  }
30
- function E() {
31
- let { orderId: E } = ge(), [be] = S(), D = be.get("customerId")?.trim() || void 0, { basePath: O, navigate: k } = ie(), { order: A } = oe(E), { createOrder: j, updateOrder: M } = se(), [N, xe] = x(""), { customers: P, createCustomer: Se, isLoading: F, error: I, refetch: Ce } = le({
31
+ function w() {
32
+ let { orderId: w } = ve(), [T] = ye(), E = T.get("customerId")?.trim() || void 0, { basePath: D, navigate: O } = s(), { order: k } = re(w), { createOrder: A, updateOrder: we } = ie(), [Te, Ee] = b(""), { customers: j, createCustomer: M, isLoading: N, error: P, refetch: De } = se({
32
33
  limit: 20,
33
- filters: { search: me(N) || void 0 }
34
- }), { customer: L } = ce(D ?? A?.customerId), { routes: R, isLoading: we, error: Te } = ae({
34
+ filters: { search: Te || void 0 }
35
+ }), { customer: F } = oe(E ?? k?.customerId), [Oe, ke] = b(""), { routes: I, isLoading: L, error: R, hasMore: Ae, totalRoutes: je } = l({
35
36
  status: "planned",
37
+ search: Oe || void 0,
36
38
  limit: 20
37
- }), z = !!E && !!A, [B, V] = x(null), [H, U] = x({
38
- customerId: D || A?.customerId || "",
39
- priority: A?.priority || "normal",
40
- routeId: A?.routeId || "",
39
+ }), [z, Me] = b(""), { products: Ne, isLoading: Pe } = ae({
40
+ search: z || void 0,
41
+ limit: 20
42
+ }), B = !!w && !!k, [V, H] = b(null), [U, W] = b({
43
+ customerId: E || k?.customerId || "",
44
+ priority: k?.priority || "normal",
45
+ routeId: k?.routeId || "",
41
46
  pickupAddress: {
42
- street: A?.pickupAddress.street || "",
43
- city: A?.pickupAddress.city || "",
44
- state: A?.pickupAddress.state || "",
45
- postalCode: A?.pickupAddress.postalCode || "",
46
- country: A?.pickupAddress.country || "USA"
47
+ street: k?.pickupAddress.street || "",
48
+ city: k?.pickupAddress.city || "",
49
+ state: k?.pickupAddress.state || "",
50
+ postalCode: k?.pickupAddress.postalCode || "",
51
+ country: k?.pickupAddress.country || "USA"
47
52
  },
48
53
  deliveryAddress: {
49
- street: A?.deliveryAddress.street || "",
50
- city: A?.deliveryAddress.city || "",
51
- state: A?.deliveryAddress.state || "",
52
- postalCode: A?.deliveryAddress.postalCode || "",
53
- country: A?.deliveryAddress.country || "USA"
54
+ street: k?.deliveryAddress.street || "",
55
+ city: k?.deliveryAddress.city || "",
56
+ state: k?.deliveryAddress.state || "",
57
+ postalCode: k?.deliveryAddress.postalCode || "",
58
+ country: k?.deliveryAddress.country || "USA"
54
59
  },
55
- items: A?.items || [],
56
- scheduledDelivery: T(A?.scheduledDelivery),
57
- specialInstructions: A?.specialInstructions || ""
58
- }), [W, G] = x(!1), [Ee, K] = x(null);
59
- b(() => {
60
- L && (V((e) => e?.id === L.id ? e : L), U((e) => e.customerId ? e : {
60
+ items: k?.items || [],
61
+ scheduledDelivery: C(k?.scheduledDelivery),
62
+ specialInstructions: k?.specialInstructions || ""
63
+ }), { route: Fe, isLoading: Ie } = c(U.routeId || void 0), [G, K] = b(!1), [Le, q] = b(null);
64
+ y(() => {
65
+ F && (H((e) => e?.id === F.id ? e : F), W((e) => e.customerId ? e : {
61
66
  ...e,
62
- customerId: L.id
67
+ customerId: F.id
63
68
  }));
64
- }, [L]), b(() => {
65
- A && U({
66
- customerId: A.customerId || "",
67
- priority: A.priority || "normal",
68
- routeId: A.routeId || "",
69
+ }, [F]), y(() => {
70
+ k && W({
71
+ customerId: k.customerId || "",
72
+ priority: k.priority || "normal",
73
+ routeId: k.routeId || "",
69
74
  pickupAddress: {
70
- street: A.pickupAddress.street || "",
71
- city: A.pickupAddress.city || "",
72
- state: A.pickupAddress.state || "",
73
- postalCode: A.pickupAddress.postalCode || "",
74
- country: A.pickupAddress.country || "USA"
75
+ street: k.pickupAddress.street || "",
76
+ city: k.pickupAddress.city || "",
77
+ state: k.pickupAddress.state || "",
78
+ postalCode: k.pickupAddress.postalCode || "",
79
+ country: k.pickupAddress.country || "USA"
75
80
  },
76
81
  deliveryAddress: {
77
- street: A.deliveryAddress.street || "",
78
- city: A.deliveryAddress.city || "",
79
- state: A.deliveryAddress.state || "",
80
- postalCode: A.deliveryAddress.postalCode || "",
81
- country: A.deliveryAddress.country || "USA"
82
+ street: k.deliveryAddress.street || "",
83
+ city: k.deliveryAddress.city || "",
84
+ state: k.deliveryAddress.state || "",
85
+ postalCode: k.deliveryAddress.postalCode || "",
86
+ country: k.deliveryAddress.country || "USA"
82
87
  },
83
- items: A.items || [],
84
- scheduledDelivery: T(A.scheduledDelivery),
85
- specialInstructions: A.specialInstructions || ""
88
+ items: k.items || [],
89
+ scheduledDelivery: C(k.scheduledDelivery),
90
+ specialInstructions: k.specialInstructions || ""
86
91
  });
87
- }, [A]);
88
- let q = () => {
89
- if (k) {
90
- if (!z && D) {
91
- k(o(O, `customers/${D}`));
92
+ }, [k]);
93
+ let J = () => {
94
+ if (O) {
95
+ if (!B && E) {
96
+ O(o(D, `customers/${E}`));
92
97
  return;
93
98
  }
94
- k(o(O, "orders"));
99
+ O(o(D, "orders"));
95
100
  }
96
- }, J = () => B ?? P.find((e) => e.id === H.customerId), De = () => !H.customerId || !J() ? I ? "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) => {
97
- e.preventDefault(), K(null);
98
- let t = De();
101
+ }, Y = () => V ?? j.find((e) => e.id === U.customerId), Re = () => !U.customerId || !Y() ? P ? "Customers could not be loaded. Retry or create a customer before continuing." : "Select a customer for this order." : U.pickupAddress.street.trim() ? U.deliveryAddress.street.trim() ? U.items.length === 0 ? "Add at least one item to the order." : U.scheduledDelivery && Number.isNaN(Date.parse(U.scheduledDelivery)) ? "Enter a valid scheduled delivery date and time." : null : "Enter a delivery street address." : "Enter a pickup street address.", X = async (e) => {
102
+ e.preventDefault(), q(null);
103
+ let t = Re();
99
104
  if (t) {
100
- K(t);
105
+ q(t);
101
106
  return;
102
107
  }
103
- let n = J();
108
+ let n = Y();
104
109
  if (!n) {
105
- K(I ? "Customers could not be loaded. Retry or create a customer before continuing." : "Select a customer for this order.");
110
+ q(P ? "Customers could not be loaded. Retry or create a customer before continuing." : "Select a customer for this order.");
106
111
  return;
107
112
  }
108
- G(!0);
113
+ K(!0);
109
114
  try {
110
115
  let e = {
111
- customerId: H.customerId,
116
+ customerId: U.customerId,
112
117
  customerInfo: {
113
118
  name: n.name,
114
119
  email: n.email,
115
120
  phone: n.phone,
116
121
  company: n.company
117
122
  },
118
- priority: H.priority,
119
- pickupAddress: H.pickupAddress,
120
- deliveryAddress: H.deliveryAddress,
121
- items: H.items,
122
- scheduledDelivery: H.scheduledDelivery ? new Date(H.scheduledDelivery) : null,
123
- routeId: H.routeId || void 0,
124
- specialInstructions: H.specialInstructions
123
+ priority: U.priority,
124
+ pickupAddress: U.pickupAddress,
125
+ deliveryAddress: U.deliveryAddress,
126
+ items: U.items,
127
+ scheduledDelivery: U.scheduledDelivery ? new Date(U.scheduledDelivery) : null,
128
+ routeId: U.routeId || void 0,
129
+ specialInstructions: U.specialInstructions
125
130
  };
126
- z && E ? (await M(E, e), k && k(o(O, `orders/${E}`))) : (await j(e), q());
131
+ B && w ? (await we(w, e), O && O(o(D, `orders/${w}`))) : (await A(e), J());
127
132
  } catch (e) {
128
- K(e instanceof Error ? e.message : z ? "Could not update the order. Please try again." : "Could not create the order. Please try again.");
133
+ q(e instanceof Error ? e.message : B ? "Could not update the order. Please try again." : "Could not create the order. Please try again.");
129
134
  } finally {
130
- G(!1);
135
+ K(!1);
131
136
  }
132
- }, X = (e, t) => {
133
- U((n) => ({
137
+ }, Z = (e, t) => {
138
+ W((n) => ({
134
139
  ...n,
135
140
  [e]: t
136
141
  }));
137
- }, Z = (e, t, n) => {
138
- U((r) => ({
142
+ }, Q = (e, t, n) => {
143
+ W((r) => ({
139
144
  ...r,
140
145
  [e]: {
141
146
  ...r[e],
142
147
  [t]: n
143
148
  }
144
149
  }));
145
- }, Oe = (e) => {
146
- if (e === "none") {
147
- X("routeId", "");
150
+ }, ze = (e) => {
151
+ if (!e) {
152
+ Z("routeId", "");
148
153
  return;
149
154
  }
150
- let t = R.find((t) => t.id === e);
155
+ let t = I.find((t) => t.id === e);
151
156
  if (!t) return;
152
157
  let n = t.stops.find((e) => e.type === "pickup")?.address, r = [...t.stops].reverse().find((e) => e.type === "delivery")?.address, i = (e, t) => t ? {
153
158
  street: e.street.trim() ? e.street : t.street,
@@ -156,14 +161,14 @@ function E() {
156
161
  postalCode: e.postalCode.trim() ? e.postalCode : t.postalCode,
157
162
  country: e.country.trim() ? e.country : t.country
158
163
  } : e;
159
- U((e) => ({
164
+ W((e) => ({
160
165
  ...e,
161
166
  routeId: t.id,
162
167
  pickupAddress: i(e.pickupAddress, n),
163
168
  deliveryAddress: i(e.deliveryAddress, r)
164
169
  }));
165
- }, Q = () => {
166
- U((e) => ({
170
+ }, $ = () => {
171
+ W((e) => ({
167
172
  ...e,
168
173
  items: [...e.items, {
169
174
  id: `item-${Date.now()}`,
@@ -181,13 +186,13 @@ function E() {
181
186
  sku: ""
182
187
  }]
183
188
  }));
184
- }, ke = (e) => {
185
- U((t) => ({
189
+ }, Be = (e) => {
190
+ W((t) => ({
186
191
  ...t,
187
192
  items: t.items.filter((t, n) => n !== e)
188
193
  }));
189
- }, $ = (e, t, n) => {
190
- U((r) => ({
194
+ }, Ve = (e, t, n) => {
195
+ W((r) => ({
191
196
  ...r,
192
197
  items: r.items.map((r, i) => i === e ? {
193
198
  ...r,
@@ -195,112 +200,111 @@ function E() {
195
200
  } : r)
196
201
  }));
197
202
  };
198
- return /* @__PURE__ */ w(y, {
199
- title: z ? "Edit Order" : "Create Order",
200
- subtitle: z ? `Editing ${A?.orderNumber}` : "Create a new delivery order",
201
- icon: /* @__PURE__ */ C(r, { size: 24 }),
202
- headerActions: /* @__PURE__ */ w("div", {
203
+ return /* @__PURE__ */ S(pe, {
204
+ title: B ? "Edit Order" : "Create Order",
205
+ subtitle: B ? `Editing ${k?.orderNumber}` : "Create a new delivery order",
206
+ icon: /* @__PURE__ */ x(r, { size: 24 }),
207
+ headerActions: /* @__PURE__ */ S("div", {
203
208
  className: "flex gap-2",
204
- children: [/* @__PURE__ */ w(s, {
209
+ children: [/* @__PURE__ */ S(u, {
205
210
  variant: "outline",
206
- onClick: q,
207
- children: [/* @__PURE__ */ C(e, { size: 16 }), "Cancel"]
208
- }), /* @__PURE__ */ w(s, {
209
- onClick: Y,
210
- disabled: W || F,
211
- children: [/* @__PURE__ */ C(ee, { size: 16 }), W ? "Saving..." : z ? "Save Changes" : "Create Order"]
211
+ onClick: J,
212
+ children: [/* @__PURE__ */ x(e, { size: 16 }), "Cancel"]
213
+ }), /* @__PURE__ */ S(u, {
214
+ onClick: X,
215
+ disabled: G || N,
216
+ children: [/* @__PURE__ */ x(ee, { size: 16 }), G ? "Saving..." : B ? "Save Changes" : "Create Order"]
212
217
  })]
213
218
  }),
214
219
  children: [
215
- /* @__PURE__ */ C(ye, {
216
- icon: /* @__PURE__ */ C(r, { size: 18 }),
217
- 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."
220
+ /* @__PURE__ */ x(Ce, {
221
+ icon: /* @__PURE__ */ x(r, { size: 18 }),
222
+ children: B ? "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
223
  }),
219
- /* @__PURE__ */ C(ve, {
224
+ /* @__PURE__ */ x(Se, {
220
225
  storageKey: "movethewheels-create-order",
221
226
  steps: [
222
227
  {
223
228
  id: "customer",
224
229
  label: "Pick the customer first",
225
230
  description: "Their saved contact details auto-fill the order.",
226
- icon: /* @__PURE__ */ C(ne, { size: 16 }),
227
- done: !!H.customerId,
231
+ icon: /* @__PURE__ */ x(te, { size: 16 }),
232
+ done: !!U.customerId,
228
233
  onClick: () => document.getElementById("customer")?.focus()
229
234
  },
230
235
  {
231
236
  id: "addresses",
232
237
  label: "Set pickup & delivery addresses",
233
238
  description: "Where the shipment is collected and dropped off.",
234
- icon: /* @__PURE__ */ C(n, { size: 16 }),
235
- done: !!H.pickupAddress.street && !!H.deliveryAddress.street,
239
+ icon: /* @__PURE__ */ x(n, { size: 16 }),
240
+ done: !!U.pickupAddress.street && !!U.deliveryAddress.street,
236
241
  onClick: () => document.getElementById("pickupStreet")?.focus()
237
242
  },
238
243
  {
239
244
  id: "items",
240
245
  label: "Add the items to ship",
241
246
  description: "List each product with its quantity and value.",
242
- icon: /* @__PURE__ */ C(r, { size: 16 }),
243
- done: H.items.length > 0,
244
- onClick: Q
247
+ icon: /* @__PURE__ */ x(r, { size: 16 }),
248
+ done: U.items.length > 0,
249
+ onClick: $
245
250
  }
246
251
  ]
247
252
  }),
248
- /* @__PURE__ */ w("form", {
249
- onSubmit: Y,
253
+ /* @__PURE__ */ S("form", {
254
+ onSubmit: X,
250
255
  className: "space-y-6",
251
256
  children: [
252
- /* @__PURE__ */ C(pe, { message: Ee }),
253
- /* @__PURE__ */ w(_e, { children: [/* @__PURE__ */ C("h2", {
257
+ /* @__PURE__ */ x(me, { message: Le }),
258
+ /* @__PURE__ */ S(xe, { children: [/* @__PURE__ */ x("h2", {
254
259
  className: "text-base font-semibold text-text-primary mb-4",
255
260
  children: "Order Details"
256
- }), /* @__PURE__ */ C("div", {
261
+ }), /* @__PURE__ */ x("div", {
257
262
  className: "space-y-4",
258
- children: /* @__PURE__ */ w("div", {
263
+ children: /* @__PURE__ */ S("div", {
259
264
  className: "grid grid-cols-1 md:grid-cols-2 gap-4",
260
- children: [/* @__PURE__ */ C(he, {
261
- customers: P,
262
- value: H.customerId,
265
+ children: [/* @__PURE__ */ x(ge, {
266
+ customers: j,
267
+ value: U.customerId,
263
268
  onValueChange: (e) => {
264
- e && (X("customerId", e), V(P.find((t) => t.id === e) ?? (B?.id === e ? B : null)), K(null));
269
+ e && (Z("customerId", e), H(j.find((t) => t.id === e) ?? (V?.id === e ? V : null)), q(null));
265
270
  },
266
271
  onCreated: (e) => {
267
- V(e), X("customerId", e.id), K(null);
272
+ H(e), Z("customerId", e.id), q(null);
268
273
  },
269
- createCustomer: Se,
270
- isLoading: F,
271
- error: I,
272
- onRetry: Ce,
274
+ createCustomer: M,
275
+ isLoading: N,
276
+ error: P,
277
+ onRetry: De,
273
278
  onOpenCustomers: () => {
274
- k && k(o(O, re(z && E ? `orders/${E}/edit` : "orders/new")));
279
+ O && O(o(D, ne(B && w ? `orders/${w}/edit` : "orders/new")));
275
280
  },
276
- selectedCustomer: B,
277
- searchQuery: N,
278
- onSearchQueryChange: xe
279
- }), /* @__PURE__ */ w("div", {
281
+ selectedCustomer: V,
282
+ onSearchQueryChange: Ee
283
+ }), /* @__PURE__ */ S("div", {
280
284
  className: "space-y-2",
281
- children: [/* @__PURE__ */ C(p, {
285
+ children: [/* @__PURE__ */ x(g, {
282
286
  htmlFor: "priority",
283
287
  children: "Priority"
284
- }), /* @__PURE__ */ w(m, {
285
- value: H.priority,
286
- onValueChange: (e) => X("priority", e),
287
- children: [/* @__PURE__ */ C(_, {
288
+ }), /* @__PURE__ */ S(ce, {
289
+ value: U.priority,
290
+ onValueChange: (e) => Z("priority", e),
291
+ children: [/* @__PURE__ */ x(v, {
288
292
  id: "priority",
289
- children: /* @__PURE__ */ C(v, {})
290
- }), /* @__PURE__ */ w(h, { children: [
291
- /* @__PURE__ */ C(g, {
293
+ children: /* @__PURE__ */ x(ue, {})
294
+ }), /* @__PURE__ */ S(le, { children: [
295
+ /* @__PURE__ */ x(_, {
292
296
  value: "low",
293
297
  children: "Low"
294
298
  }),
295
- /* @__PURE__ */ C(g, {
299
+ /* @__PURE__ */ x(_, {
296
300
  value: "normal",
297
301
  children: "Normal"
298
302
  }),
299
- /* @__PURE__ */ C(g, {
303
+ /* @__PURE__ */ x(_, {
300
304
  value: "high",
301
305
  children: "High"
302
306
  }),
303
- /* @__PURE__ */ C(g, {
307
+ /* @__PURE__ */ x(_, {
304
308
  value: "urgent",
305
309
  children: "Urgent"
306
310
  })
@@ -309,167 +313,173 @@ function E() {
309
313
  })]
310
314
  })
311
315
  })] }),
312
- /* @__PURE__ */ w(c, { children: [/* @__PURE__ */ C(u, { children: /* @__PURE__ */ w(d, {
316
+ /* @__PURE__ */ S(d, { children: [/* @__PURE__ */ x(p, { children: /* @__PURE__ */ S(m, {
313
317
  className: "flex items-center gap-2",
314
- children: [/* @__PURE__ */ C(a, { size: 18 }), "Saved Route (Optional)"]
315
- }) }), /* @__PURE__ */ w(l, {
318
+ children: [/* @__PURE__ */ x(a, { size: 18 }), "Saved Route (Optional)"]
319
+ }) }), /* @__PURE__ */ S(f, {
316
320
  className: "space-y-2",
317
- children: [/* @__PURE__ */ w(m, {
318
- value: H.routeId || "none",
319
- onValueChange: Oe,
320
- children: [/* @__PURE__ */ C(_, {
321
- id: "saved-route",
322
- children: /* @__PURE__ */ C(v, { placeholder: "Choose a saved route" })
323
- }), /* @__PURE__ */ w(h, { children: [/* @__PURE__ */ C(g, {
324
- value: "none",
325
- children: "No saved route"
326
- }), R.map((e) => /* @__PURE__ */ w(g, {
327
- value: e.id,
328
- children: [
329
- e.name,
330
- " · ",
331
- e.stops.length,
332
- " stops"
333
- ]
334
- }, e.id))] })]
335
- }), /* @__PURE__ */ C("p", {
321
+ children: [/* @__PURE__ */ x(he, {
322
+ id: "saved-route",
323
+ value: U.routeId,
324
+ onChange: ze,
325
+ options: I,
326
+ loading: L,
327
+ getId: (e) => e.id,
328
+ getLabel: (e) => `${e.name} · ${e.stops.length} stops`,
329
+ renderOption: (e) => /* @__PURE__ */ S(be, { children: [
330
+ e.name,
331
+ " · ",
332
+ e.stops.length,
333
+ " stops"
334
+ ] }),
335
+ selectedOption: Fe,
336
+ selectedLoading: Ie,
337
+ placeholder: "Choose a saved route",
338
+ searchPlaceholder: "Search saved routes",
339
+ emptyText: "No saved routes found.",
340
+ noneLabel: "No saved route",
341
+ error: R ? "Saved routes are unavailable" : void 0,
342
+ onSearchChange: ke,
343
+ hasMore: Ae,
344
+ totalCount: je
345
+ }), /* @__PURE__ */ x("p", {
336
346
  className: "text-xs text-text-secondary",
337
- children: we ? "Loading planned routes…" : Te ? "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."
347
+ 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."
338
348
  })]
339
349
  })] }),
340
- /* @__PURE__ */ w("div", {
350
+ /* @__PURE__ */ S("div", {
341
351
  className: "grid grid-cols-1 md:grid-cols-2 gap-6",
342
- children: [/* @__PURE__ */ w(c, { children: [/* @__PURE__ */ C(u, { children: /* @__PURE__ */ C(d, { children: "Pickup Address" }) }), /* @__PURE__ */ w(l, {
352
+ children: [/* @__PURE__ */ S(d, { children: [/* @__PURE__ */ x(p, { children: /* @__PURE__ */ x(m, { children: "Pickup Address" }) }), /* @__PURE__ */ S(f, {
343
353
  className: "space-y-4",
344
354
  children: [
345
- /* @__PURE__ */ w("div", {
355
+ /* @__PURE__ */ S("div", {
346
356
  className: "space-y-2",
347
- children: [/* @__PURE__ */ C(p, {
357
+ children: [/* @__PURE__ */ x(g, {
348
358
  htmlFor: "pickupStreet",
349
359
  children: "Street Address"
350
- }), /* @__PURE__ */ C(f, {
360
+ }), /* @__PURE__ */ x(h, {
351
361
  id: "pickupStreet",
352
- value: H.pickupAddress.street,
353
- onChange: (e) => Z("pickupAddress", "street", e.target.value),
362
+ value: U.pickupAddress.street,
363
+ onChange: (e) => Q("pickupAddress", "street", e.target.value),
354
364
  placeholder: "123 Main St"
355
365
  })]
356
366
  }),
357
- /* @__PURE__ */ w("div", {
367
+ /* @__PURE__ */ S("div", {
358
368
  className: "grid grid-cols-1 sm:grid-cols-2 gap-4",
359
- children: [/* @__PURE__ */ w("div", {
369
+ children: [/* @__PURE__ */ S("div", {
360
370
  className: "space-y-2",
361
- children: [/* @__PURE__ */ C(p, {
371
+ children: [/* @__PURE__ */ x(g, {
362
372
  htmlFor: "pickupCity",
363
373
  children: "City"
364
- }), /* @__PURE__ */ C(f, {
374
+ }), /* @__PURE__ */ x(h, {
365
375
  id: "pickupCity",
366
- value: H.pickupAddress.city,
367
- onChange: (e) => Z("pickupAddress", "city", e.target.value),
376
+ value: U.pickupAddress.city,
377
+ onChange: (e) => Q("pickupAddress", "city", e.target.value),
368
378
  placeholder: "San Francisco"
369
379
  })]
370
- }), /* @__PURE__ */ w("div", {
380
+ }), /* @__PURE__ */ S("div", {
371
381
  className: "space-y-2",
372
- children: [/* @__PURE__ */ C(p, {
382
+ children: [/* @__PURE__ */ x(g, {
373
383
  htmlFor: "pickupState",
374
384
  children: "State"
375
- }), /* @__PURE__ */ C(f, {
385
+ }), /* @__PURE__ */ x(h, {
376
386
  id: "pickupState",
377
- value: H.pickupAddress.state,
378
- onChange: (e) => Z("pickupAddress", "state", e.target.value),
387
+ value: U.pickupAddress.state,
388
+ onChange: (e) => Q("pickupAddress", "state", e.target.value),
379
389
  placeholder: "CA"
380
390
  })]
381
391
  })]
382
392
  }),
383
- /* @__PURE__ */ w("div", {
393
+ /* @__PURE__ */ S("div", {
384
394
  className: "grid grid-cols-1 sm:grid-cols-2 gap-4",
385
- children: [/* @__PURE__ */ w("div", {
395
+ children: [/* @__PURE__ */ S("div", {
386
396
  className: "space-y-2",
387
- children: [/* @__PURE__ */ C(p, {
397
+ children: [/* @__PURE__ */ x(g, {
388
398
  htmlFor: "pickupPostal",
389
399
  children: "Postal Code"
390
- }), /* @__PURE__ */ C(f, {
400
+ }), /* @__PURE__ */ x(h, {
391
401
  id: "pickupPostal",
392
- value: H.pickupAddress.postalCode,
393
- onChange: (e) => Z("pickupAddress", "postalCode", e.target.value),
402
+ value: U.pickupAddress.postalCode,
403
+ onChange: (e) => Q("pickupAddress", "postalCode", e.target.value),
394
404
  placeholder: "94103"
395
405
  })]
396
- }), /* @__PURE__ */ w("div", {
406
+ }), /* @__PURE__ */ S("div", {
397
407
  className: "space-y-2",
398
- children: [/* @__PURE__ */ C(p, {
408
+ children: [/* @__PURE__ */ x(g, {
399
409
  htmlFor: "pickupCountry",
400
410
  children: "Country"
401
- }), /* @__PURE__ */ C(f, {
411
+ }), /* @__PURE__ */ x(h, {
402
412
  id: "pickupCountry",
403
- value: H.pickupAddress.country,
404
- onChange: (e) => Z("pickupAddress", "country", e.target.value),
413
+ value: U.pickupAddress.country,
414
+ onChange: (e) => Q("pickupAddress", "country", e.target.value),
405
415
  placeholder: "USA"
406
416
  })]
407
417
  })]
408
418
  })
409
419
  ]
410
- })] }), /* @__PURE__ */ w(c, { children: [/* @__PURE__ */ C(u, { children: /* @__PURE__ */ C(d, { children: "Delivery Address" }) }), /* @__PURE__ */ w(l, {
420
+ })] }), /* @__PURE__ */ S(d, { children: [/* @__PURE__ */ x(p, { children: /* @__PURE__ */ x(m, { children: "Delivery Address" }) }), /* @__PURE__ */ S(f, {
411
421
  className: "space-y-4",
412
422
  children: [
413
- /* @__PURE__ */ w("div", {
423
+ /* @__PURE__ */ S("div", {
414
424
  className: "space-y-2",
415
- children: [/* @__PURE__ */ C(p, {
425
+ children: [/* @__PURE__ */ x(g, {
416
426
  htmlFor: "deliveryStreet",
417
427
  children: "Street Address"
418
- }), /* @__PURE__ */ C(f, {
428
+ }), /* @__PURE__ */ x(h, {
419
429
  id: "deliveryStreet",
420
- value: H.deliveryAddress.street,
421
- onChange: (e) => Z("deliveryAddress", "street", e.target.value),
430
+ value: U.deliveryAddress.street,
431
+ onChange: (e) => Q("deliveryAddress", "street", e.target.value),
422
432
  placeholder: "456 Oak Ave"
423
433
  })]
424
434
  }),
425
- /* @__PURE__ */ w("div", {
435
+ /* @__PURE__ */ S("div", {
426
436
  className: "grid grid-cols-1 sm:grid-cols-2 gap-4",
427
- children: [/* @__PURE__ */ w("div", {
437
+ children: [/* @__PURE__ */ S("div", {
428
438
  className: "space-y-2",
429
- children: [/* @__PURE__ */ C(p, {
439
+ children: [/* @__PURE__ */ x(g, {
430
440
  htmlFor: "deliveryCity",
431
441
  children: "City"
432
- }), /* @__PURE__ */ C(f, {
442
+ }), /* @__PURE__ */ x(h, {
433
443
  id: "deliveryCity",
434
- value: H.deliveryAddress.city,
435
- onChange: (e) => Z("deliveryAddress", "city", e.target.value),
444
+ value: U.deliveryAddress.city,
445
+ onChange: (e) => Q("deliveryAddress", "city", e.target.value),
436
446
  placeholder: "Los Angeles"
437
447
  })]
438
- }), /* @__PURE__ */ w("div", {
448
+ }), /* @__PURE__ */ S("div", {
439
449
  className: "space-y-2",
440
- children: [/* @__PURE__ */ C(p, {
450
+ children: [/* @__PURE__ */ x(g, {
441
451
  htmlFor: "deliveryState",
442
452
  children: "State"
443
- }), /* @__PURE__ */ C(f, {
453
+ }), /* @__PURE__ */ x(h, {
444
454
  id: "deliveryState",
445
- value: H.deliveryAddress.state,
446
- onChange: (e) => Z("deliveryAddress", "state", e.target.value),
455
+ value: U.deliveryAddress.state,
456
+ onChange: (e) => Q("deliveryAddress", "state", e.target.value),
447
457
  placeholder: "CA"
448
458
  })]
449
459
  })]
450
460
  }),
451
- /* @__PURE__ */ w("div", {
461
+ /* @__PURE__ */ S("div", {
452
462
  className: "grid grid-cols-1 sm:grid-cols-2 gap-4",
453
- children: [/* @__PURE__ */ w("div", {
463
+ children: [/* @__PURE__ */ S("div", {
454
464
  className: "space-y-2",
455
- children: [/* @__PURE__ */ C(p, {
465
+ children: [/* @__PURE__ */ x(g, {
456
466
  htmlFor: "deliveryPostal",
457
467
  children: "Postal Code"
458
- }), /* @__PURE__ */ C(f, {
468
+ }), /* @__PURE__ */ x(h, {
459
469
  id: "deliveryPostal",
460
- value: H.deliveryAddress.postalCode,
461
- onChange: (e) => Z("deliveryAddress", "postalCode", e.target.value),
470
+ value: U.deliveryAddress.postalCode,
471
+ onChange: (e) => Q("deliveryAddress", "postalCode", e.target.value),
462
472
  placeholder: "90210"
463
473
  })]
464
- }), /* @__PURE__ */ w("div", {
474
+ }), /* @__PURE__ */ S("div", {
465
475
  className: "space-y-2",
466
- children: [/* @__PURE__ */ C(p, {
476
+ children: [/* @__PURE__ */ x(g, {
467
477
  htmlFor: "deliveryCountry",
468
478
  children: "Country"
469
- }), /* @__PURE__ */ C(f, {
479
+ }), /* @__PURE__ */ x(h, {
470
480
  id: "deliveryCountry",
471
- value: H.deliveryAddress.country,
472
- onChange: (e) => Z("deliveryAddress", "country", e.target.value),
481
+ value: U.deliveryAddress.country,
482
+ onChange: (e) => Q("deliveryAddress", "country", e.target.value),
473
483
  placeholder: "USA"
474
484
  })]
475
485
  })]
@@ -477,125 +487,91 @@ function E() {
477
487
  ]
478
488
  })] })]
479
489
  }),
480
- /* @__PURE__ */ w(c, { children: [/* @__PURE__ */ w(u, {
490
+ /* @__PURE__ */ S(d, { children: [/* @__PURE__ */ S(p, {
481
491
  className: "flex flex-row items-center justify-between",
482
- children: [/* @__PURE__ */ C(d, { children: "Order Items" }), /* @__PURE__ */ w(s, {
492
+ children: [/* @__PURE__ */ x(m, { children: "Order Items" }), /* @__PURE__ */ S(u, {
483
493
  type: "button",
484
494
  variant: "outline",
485
495
  size: "sm",
486
- onClick: Q,
487
- children: [/* @__PURE__ */ C(i, { size: 16 }), "Add Item"]
496
+ onClick: $,
497
+ children: [/* @__PURE__ */ x(i, { size: 16 }), "Add Item"]
488
498
  })]
489
- }), /* @__PURE__ */ C(l, { children: H.items.length === 0 ? /* @__PURE__ */ C(fe, {
499
+ }), /* @__PURE__ */ x(f, { children: U.items.length === 0 ? /* @__PURE__ */ x(fe, {
490
500
  illustration: "empty-files",
491
501
  title: "No items added yet",
492
502
  description: "Add the products this order will ship — each with a name, SKU, quantity and value.",
493
- action: /* @__PURE__ */ w(s, {
503
+ action: /* @__PURE__ */ S(u, {
494
504
  type: "button",
495
505
  variant: "outline",
496
- onClick: Q,
497
- children: [/* @__PURE__ */ C(i, {
506
+ onClick: $,
507
+ children: [/* @__PURE__ */ x(i, {
498
508
  size: 16,
499
509
  className: "mr-1.5"
500
510
  }), "Add your first item"]
501
511
  })
502
- }) : /* @__PURE__ */ C("div", {
512
+ }) : /* @__PURE__ */ S("div", {
503
513
  className: "space-y-4",
504
- children: H.items.map((e, t) => /* @__PURE__ */ w("div", { children: [t > 0 && /* @__PURE__ */ C(ue, { className: "my-4" }), /* @__PURE__ */ w("div", {
505
- className: "grid grid-cols-1 md:grid-cols-7 gap-4",
514
+ children: [/* @__PURE__ */ S("div", {
515
+ className: "space-y-2",
506
516
  children: [
507
- /* @__PURE__ */ w("div", {
508
- className: "md:col-span-2 space-y-2",
509
- children: [/* @__PURE__ */ C(p, { children: "Item Name" }), /* @__PURE__ */ C(f, {
510
- value: e.name,
511
- onChange: (e) => $(t, "name", e.target.value),
512
- placeholder: "Product name"
513
- })]
514
- }),
515
- /* @__PURE__ */ w("div", {
516
- className: "space-y-2",
517
- children: [/* @__PURE__ */ C(p, { children: "SKU" }), /* @__PURE__ */ C(f, {
518
- value: e.sku,
519
- onChange: (e) => $(t, "sku", e.target.value),
520
- placeholder: "SKU-001"
521
- })]
517
+ /* @__PURE__ */ x(g, {
518
+ htmlFor: "item-product-search",
519
+ children: "Search product catalog"
522
520
  }),
523
- /* @__PURE__ */ w("div", {
524
- className: "space-y-2",
525
- children: [/* @__PURE__ */ C(p, { children: "Quantity" }), /* @__PURE__ */ C(f, {
526
- type: "number",
527
- min: "1",
528
- value: e.quantity,
529
- onChange: (e) => $(t, "quantity", parseInt(e.target.value) || 1)
530
- })]
521
+ /* @__PURE__ */ x(h, {
522
+ id: "item-product-search",
523
+ value: z,
524
+ onChange: (e) => Me(e.target.value),
525
+ placeholder: "Search by name or SKU"
531
526
  }),
532
- /* @__PURE__ */ w("div", {
533
- className: "space-y-2",
534
- children: [/* @__PURE__ */ C(p, { children: "Weight (kg)" }), /* @__PURE__ */ C(f, {
535
- type: "number",
536
- min: "0",
537
- step: "0.1",
538
- value: e.weight,
539
- onChange: (e) => $(t, "weight", parseFloat(e.target.value) || 0)
540
- })]
541
- }),
542
- /* @__PURE__ */ w("div", {
543
- className: "space-y-2",
544
- children: [/* @__PURE__ */ C(p, { children: "Value ($)" }), /* @__PURE__ */ C(f, {
545
- type: "number",
546
- min: "0",
547
- step: "0.01",
548
- value: e.value,
549
- onChange: (e) => $(t, "value", parseFloat(e.target.value) || 0)
550
- })]
551
- }),
552
- /* @__PURE__ */ C("div", {
553
- className: "flex items-end",
554
- children: /* @__PURE__ */ C(s, {
555
- type: "button",
556
- variant: "ghost",
557
- size: "icon",
558
- className: "text-status-error-text",
559
- onClick: () => ke(t),
560
- children: /* @__PURE__ */ C(te, { size: 16 })
561
- })
527
+ /* @__PURE__ */ x("p", {
528
+ className: "text-xs text-text-secondary",
529
+ children: "Narrows the \"Catalog item\" picker below for every row. Picking a catalog item fills in name, SKU, weight, and value — you can still edit them, or skip the picker and enter details manually."
562
530
  })
563
531
  ]
564
- })] }, e.id))
532
+ }), U.items.map((e, t) => /* @__PURE__ */ x(_e, {
533
+ item: e,
534
+ index: t,
535
+ isFirst: t === 0,
536
+ products: Ne,
537
+ productsLoading: Pe,
538
+ onUpdate: Ve,
539
+ onRemove: Be
540
+ }, e.id))]
565
541
  }) })] }),
566
- /* @__PURE__ */ w(c, { children: [/* @__PURE__ */ C(u, { children: /* @__PURE__ */ C(d, { children: "Scheduling & Handling" }) }), /* @__PURE__ */ C(l, { children: /* @__PURE__ */ w("div", {
542
+ /* @__PURE__ */ S(d, { children: [/* @__PURE__ */ x(p, { children: /* @__PURE__ */ x(m, { children: "Scheduling & Handling" }) }), /* @__PURE__ */ x(f, { children: /* @__PURE__ */ S("div", {
567
543
  className: "grid grid-cols-1 md:grid-cols-3 gap-6",
568
- children: [/* @__PURE__ */ w("div", {
544
+ children: [/* @__PURE__ */ S("div", {
569
545
  className: "space-y-2",
570
546
  children: [
571
- /* @__PURE__ */ w(p, {
547
+ /* @__PURE__ */ S(g, {
572
548
  htmlFor: "scheduledDelivery",
573
549
  className: "flex items-center gap-1.5",
574
- children: [/* @__PURE__ */ C(t, {
550
+ children: [/* @__PURE__ */ x(t, {
575
551
  size: 14,
576
552
  className: "text-text-secondary"
577
553
  }), "Scheduled Delivery"]
578
554
  }),
579
- /* @__PURE__ */ C(f, {
555
+ /* @__PURE__ */ x(h, {
580
556
  id: "scheduledDelivery",
581
557
  type: "datetime-local",
582
- value: H.scheduledDelivery,
583
- onChange: (e) => X("scheduledDelivery", e.target.value)
558
+ value: U.scheduledDelivery,
559
+ onChange: (e) => Z("scheduledDelivery", e.target.value)
584
560
  }),
585
- /* @__PURE__ */ C("p", {
561
+ /* @__PURE__ */ x("p", {
586
562
  className: "text-xs text-text-secondary",
587
563
  children: "The delivery window promised to the customer. Leave blank to dispatch as soon as a driver is free."
588
564
  })
589
565
  ]
590
- }), /* @__PURE__ */ w("div", {
566
+ }), /* @__PURE__ */ S("div", {
591
567
  className: "md:col-span-2 space-y-2",
592
- children: [/* @__PURE__ */ C(p, {
568
+ children: [/* @__PURE__ */ x(g, {
593
569
  htmlFor: "specialInstructions",
594
570
  children: "Special Instructions"
595
- }), /* @__PURE__ */ C(de, {
571
+ }), /* @__PURE__ */ x(de, {
596
572
  id: "specialInstructions",
597
- value: H.specialInstructions,
598
- onChange: (e) => X("specialInstructions", e.target.value),
573
+ value: U.specialInstructions,
574
+ onChange: (e) => Z("specialInstructions", e.target.value),
599
575
  placeholder: "Any special handling or delivery instructions...",
600
576
  rows: 4
601
577
  })]
@@ -607,4 +583,4 @@ function E() {
607
583
  });
608
584
  }
609
585
  //#endregion
610
- export { E as default };
586
+ export { w as default };