@burdenoff/microfe-movethewheels 2026.924.1 → 2026.925.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.
@@ -1,151 +1,160 @@
1
1
  import { ArrowLeft as e } from "../node_modules/lucide-react/dist/esm/icons/arrow-left.js";
2
- import { CalendarClock as t } from "../node_modules/lucide-react/dist/esm/icons/calendar-clock.js";
3
- import { MapPin as n } from "../node_modules/lucide-react/dist/esm/icons/map-pin.js";
4
- import { Package as r } from "../node_modules/lucide-react/dist/esm/icons/package.js";
5
- import { Plus as i } from "../node_modules/lucide-react/dist/esm/icons/plus.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";
8
- import { Trash2 as ee } from "../node_modules/lucide-react/dist/esm/icons/trash-2.js";
2
+ import { ArrowRight as t } from "../node_modules/lucide-react/dist/esm/icons/arrow-right.js";
3
+ import { CalendarClock as n } from "../node_modules/lucide-react/dist/esm/icons/calendar-clock.js";
4
+ import { MapPin as r } from "../node_modules/lucide-react/dist/esm/icons/map-pin.js";
5
+ import { Package as i } from "../node_modules/lucide-react/dist/esm/icons/package.js";
6
+ import { Plus as a } from "../node_modules/lucide-react/dist/esm/icons/plus.js";
7
+ import { Save as ee } from "../node_modules/lucide-react/dist/esm/icons/save.js";
9
8
  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";
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 re, useRoutes as ie } from "../hooks/useRoutes.js";
12
+ import { useOrder as ae, useOrders as oe } from "../hooks/useOrders.js";
13
+ import { useProducts as se } from "../hooks/useInventory.js";
14
+ import { useCustomer as ce, useCustomers as le } from "../hooks/useCustomers.js";
15
+ import { Badge as c, Button as l, Card as u, CardContent as d, CardDescription as f, CardHeader as p, CardTitle as m, Input as h, Label as g, Select as ue, SelectContent as de, SelectItem as _, SelectTrigger as fe, SelectValue as pe, Separator as me, Textarea as he } from "../components/ui.js";
16
+ import { EmptyState as ge, PageLayout as _e } from "../components/PageLayout.js";
17
+ import { FormError as ve } from "../components/FormError.js";
18
+ import { EntityCombobox as ye } from "../components/EntityCombobox.js";
19
+ import { CustomerPicker as v } from "../components/CustomerPicker.js";
20
+ import { OrderItemRow as y } from "../components/OrderItemRow.js";
20
21
  import { useEffect as b, useState as x } from "react";
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
+ import { useParams as be, useSearchParams as xe } from "react-router";
23
+ import { Fragment as Se, jsx as S, jsxs as C } from "react/jsx-runtime";
24
+ import { EmphasisPanel as Ce, PagePurpose as we, Stepper as Te } from "@burdenoff/fe-libs/ui";
25
+ import { FormSection as w } from "@burdenoff/fe-libs/form";
24
26
  //#region src/movethewheels/pages/CreateOrderPage.tsx
25
- function w(e) {
27
+ function T(e) {
26
28
  if (!e || Number.isNaN(e.getTime())) return "";
27
29
  let t = (e) => String(e).padStart(2, "0");
28
30
  return `${e.getFullYear()}-${t(e.getMonth() + 1)}-${t(e.getDate())}T${t(e.getHours())}:${t(e.getMinutes())}`;
29
31
  }
30
- function T() {
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({
32
+ function E() {
33
+ let { orderId: E } = be(), [D] = xe(), O = D.get("customerId")?.trim() || void 0, { basePath: k, navigate: A } = s(), { order: j } = ae(E), { createOrder: Ee, updateOrder: De } = oe(), [Oe, ke] = x(""), { customers: M, createCustomer: Ae, isLoading: N, error: P, refetch: je } = le({
32
34
  limit: 20,
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
+ filters: { search: Oe || void 0 }
36
+ }), { customer: F } = ce(O ?? j?.customerId), [Me, Ne] = x(""), { routes: I, isLoading: L, error: R, hasMore: Pe, totalRoutes: Fe } = ie({
35
37
  status: "planned",
36
- search: Oe || void 0,
38
+ search: Me || void 0,
37
39
  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 || "",
40
+ }), [z, Ie] = x(""), { products: Le, isLoading: Re } = se({
41
+ search: z || void 0,
42
+ limit: 20
43
+ }), B = !!E && !!j, [V, H] = x(null), [U, W] = x({
44
+ customerId: O || j?.customerId || "",
45
+ priority: j?.priority || "normal",
46
+ routeId: j?.routeId || "",
42
47
  pickupAddress: {
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"
48
+ street: j?.pickupAddress.street || "",
49
+ city: j?.pickupAddress.city || "",
50
+ state: j?.pickupAddress.state || "",
51
+ postalCode: j?.pickupAddress.postalCode || "",
52
+ country: j?.pickupAddress.country || "USA"
48
53
  },
49
54
  deliveryAddress: {
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"
55
+ street: j?.deliveryAddress.street || "",
56
+ city: j?.deliveryAddress.city || "",
57
+ state: j?.deliveryAddress.state || "",
58
+ postalCode: j?.deliveryAddress.postalCode || "",
59
+ country: j?.deliveryAddress.country || "USA"
55
60
  },
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);
61
+ items: j?.items || [],
62
+ scheduledDelivery: T(j?.scheduledDelivery),
63
+ specialInstructions: j?.specialInstructions || ""
64
+ }), { route: ze, isLoading: Be } = re(U.routeId || void 0), [G, K] = x(!1), [Ve, q] = x(null);
60
65
  b(() => {
61
- F && (V((e) => e?.id === F.id ? e : F), U((e) => e.customerId ? e : {
66
+ F && (H((e) => e?.id === F.id ? e : F), W((e) => e.customerId ? e : {
62
67
  ...e,
63
68
  customerId: F.id
64
69
  }));
65
70
  }, [F]), b(() => {
66
- A && U({
67
- customerId: A.customerId || "",
68
- priority: A.priority || "normal",
69
- routeId: A.routeId || "",
71
+ j && W({
72
+ customerId: j.customerId || "",
73
+ priority: j.priority || "normal",
74
+ routeId: j.routeId || "",
70
75
  pickupAddress: {
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"
76
+ street: j.pickupAddress.street || "",
77
+ city: j.pickupAddress.city || "",
78
+ state: j.pickupAddress.state || "",
79
+ postalCode: j.pickupAddress.postalCode || "",
80
+ country: j.pickupAddress.country || "USA"
76
81
  },
77
82
  deliveryAddress: {
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"
83
+ street: j.deliveryAddress.street || "",
84
+ city: j.deliveryAddress.city || "",
85
+ state: j.deliveryAddress.state || "",
86
+ postalCode: j.deliveryAddress.postalCode || "",
87
+ country: j.deliveryAddress.country || "USA"
83
88
  },
84
- items: A.items || [],
85
- scheduledDelivery: w(A.scheduledDelivery),
86
- specialInstructions: A.specialInstructions || ""
89
+ items: j.items || [],
90
+ scheduledDelivery: T(j.scheduledDelivery),
91
+ specialInstructions: j.specialInstructions || ""
87
92
  });
88
- }, [A]);
89
- let q = () => {
90
- if (k) {
91
- if (!z && D) {
92
- k(s(O, `customers/${D}`));
93
+ }, [j]);
94
+ let J = () => {
95
+ if (A) {
96
+ if (!B && O) {
97
+ A(o(k, `customers/${O}`));
93
98
  return;
94
99
  }
95
- k(s(O, "orders"));
100
+ A(o(k, "orders"));
96
101
  }
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();
102
+ }, Y = () => V ?? M.find((e) => e.id === U.customerId), He = () => !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) => {
103
+ e.preventDefault(), q(null);
104
+ let t = He();
100
105
  if (t) {
101
- K(t);
106
+ q(t);
102
107
  return;
103
108
  }
104
- let n = J();
109
+ let n = Y();
105
110
  if (!n) {
106
- K(P ? "Customers could not be loaded. Retry or create a customer before continuing." : "Select a customer for this order.");
111
+ q(P ? "Customers could not be loaded. Retry or create a customer before continuing." : "Select a customer for this order.");
107
112
  return;
108
113
  }
109
- G(!0);
114
+ K(!0);
110
115
  try {
111
116
  let e = {
112
- customerId: H.customerId,
117
+ customerId: U.customerId,
113
118
  customerInfo: {
114
119
  name: n.name,
115
120
  email: n.email,
116
121
  phone: n.phone,
117
122
  company: n.company
118
123
  },
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
124
+ priority: U.priority,
125
+ pickupAddress: U.pickupAddress,
126
+ deliveryAddress: U.deliveryAddress,
127
+ items: U.items,
128
+ scheduledDelivery: U.scheduledDelivery ? new Date(U.scheduledDelivery) : null,
129
+ routeId: U.routeId || void 0,
130
+ specialInstructions: U.specialInstructions
126
131
  };
127
- z && T ? (await Ce(T, e), k && k(s(O, `orders/${T}`))) : (await j(e), q());
132
+ if (B && E) await De(E, e), A && A(o(k, `orders/${E}`));
133
+ else {
134
+ let t = await Ee(e);
135
+ A ? A(o(k, `orders/${t.id}`)) : J();
136
+ }
128
137
  } catch (e) {
129
- K(e instanceof Error ? e.message : z ? "Could not update the order. Please try again." : "Could not create the order. Please try again.");
138
+ q(e instanceof Error ? e.message : B ? "Could not update the order. Please try again." : "Could not create the order. Please try again.");
130
139
  } finally {
131
- G(!1);
140
+ K(!1);
132
141
  }
133
- }, X = (e, t) => {
134
- U((n) => ({
142
+ }, Z = (e, t) => {
143
+ W((n) => ({
135
144
  ...n,
136
145
  [e]: t
137
146
  }));
138
- }, Z = (e, t, n) => {
139
- U((r) => ({
147
+ }, Q = (e, t, n) => {
148
+ W((r) => ({
140
149
  ...r,
141
150
  [e]: {
142
151
  ...r[e],
143
152
  [t]: n
144
153
  }
145
154
  }));
146
- }, Ie = (e) => {
155
+ }, Ue = (e) => {
147
156
  if (!e) {
148
- X("routeId", "");
157
+ Z("routeId", "");
149
158
  return;
150
159
  }
151
160
  let t = I.find((t) => t.id === e);
@@ -157,14 +166,14 @@ function T() {
157
166
  postalCode: e.postalCode.trim() ? e.postalCode : t.postalCode,
158
167
  country: e.country.trim() ? e.country : t.country
159
168
  } : e;
160
- U((e) => ({
169
+ W((e) => ({
161
170
  ...e,
162
171
  routeId: t.id,
163
172
  pickupAddress: i(e.pickupAddress, n),
164
173
  deliveryAddress: i(e.deliveryAddress, r)
165
174
  }));
166
- }, Q = () => {
167
- U((e) => ({
175
+ }, $ = () => {
176
+ W((e) => ({
168
177
  ...e,
169
178
  items: [...e.items, {
170
179
  id: `item-${Date.now()}`,
@@ -182,435 +191,573 @@ function T() {
182
191
  sku: ""
183
192
  }]
184
193
  }));
185
- }, Le = (e) => {
186
- U((t) => ({
194
+ }, We = (e) => {
195
+ W((t) => ({
187
196
  ...t,
188
197
  items: t.items.filter((t, n) => n !== e)
189
198
  }));
190
- }, $ = (e, t, n) => {
191
- U((r) => ({
199
+ }, Ge = (e, t, n) => {
200
+ W((r) => ({
192
201
  ...r,
193
202
  items: r.items.map((r, i) => i === e ? {
194
203
  ...r,
195
204
  [t]: n
196
205
  } : r)
197
206
  }));
198
- };
199
- return /* @__PURE__ */ C(pe, {
200
- title: z ? "Edit Order" : "Create Order",
201
- subtitle: z ? `Editing ${A?.orderNumber}` : "Create a new delivery order",
202
- icon: /* @__PURE__ */ S(r, { size: 24 }),
207
+ }, Ke = () => {
208
+ A && A(o(k, ne(B && E ? `orders/${E}/edit` : "orders/new")));
209
+ }, qe = U.customerId ? !U.pickupAddress.street || !U.deliveryAddress.street ? 1 : U.items.length === 0 ? 2 : 3 : 0;
210
+ return /* @__PURE__ */ C(_e, {
211
+ title: B ? "Edit Order" : "Create Order",
212
+ subtitle: B ? `Editing ${j?.orderNumber}` : "Create a new delivery order",
213
+ icon: /* @__PURE__ */ S(i, { size: 24 }),
214
+ maxWidth: "2xl",
203
215
  headerActions: /* @__PURE__ */ C("div", {
204
- className: "flex gap-2",
205
- children: [/* @__PURE__ */ C(d, {
216
+ className: "flex w-full flex-col-reverse gap-2 sm:w-auto sm:flex-row",
217
+ children: [/* @__PURE__ */ C(l, {
218
+ type: "button",
206
219
  variant: "outline",
207
- onClick: q,
220
+ onClick: J,
221
+ disabled: G,
208
222
  children: [/* @__PURE__ */ S(e, { size: 16 }), "Cancel"]
209
- }), /* @__PURE__ */ C(d, {
210
- onClick: Y,
211
- disabled: W || N,
212
- children: [/* @__PURE__ */ S(o, { size: 16 }), W ? "Saving..." : z ? "Save Changes" : "Create Order"]
223
+ }), /* @__PURE__ */ C(l, {
224
+ type: "submit",
225
+ form: "order-form",
226
+ disabled: G || N,
227
+ children: [/* @__PURE__ */ S(ee, { size: 16 }), G ? "Saving..." : B ? "Save Changes" : "Create Order"]
213
228
  })]
214
229
  }),
215
230
  children: [
216
- /* @__PURE__ */ S(Se, {
217
- icon: /* @__PURE__ */ S(r, { size: 18 }),
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."
231
+ /* @__PURE__ */ S(we, {
232
+ icon: /* @__PURE__ */ S(i, { size: 18 }),
233
+ children: B ? "Update the customer, delivery plan, shipment contents, or handling details before saving." : "Set the customer and delivery plan, add what is being shipped, then choose any timing or handling preferences."
219
234
  }),
220
- /* @__PURE__ */ S(xe, {
221
- storageKey: "movethewheels-create-order",
235
+ /* @__PURE__ */ S(Te, {
222
236
  steps: [
223
237
  {
224
- id: "customer",
225
- label: "Pick the customer first",
226
- description: "Their saved contact details auto-fill the order.",
227
- icon: /* @__PURE__ */ S(te, { size: 16 }),
228
- done: !!H.customerId,
229
- onClick: () => document.getElementById("customer")?.focus()
238
+ key: "customer",
239
+ label: "Customer & priority",
240
+ description: "Who is receiving this delivery?"
230
241
  },
231
242
  {
232
- id: "addresses",
233
- label: "Set pickup & delivery addresses",
234
- description: "Where the shipment is collected and dropped off.",
235
- icon: /* @__PURE__ */ S(n, { size: 16 }),
236
- done: !!H.pickupAddress.street && !!H.deliveryAddress.street,
237
- onClick: () => document.getElementById("pickupStreet")?.focus()
243
+ key: "locations",
244
+ label: "Route & addresses",
245
+ description: "Where should it be collected and delivered?"
238
246
  },
239
247
  {
240
- id: "items",
241
- label: "Add the items to ship",
242
- description: "List each product with its quantity and value.",
243
- icon: /* @__PURE__ */ S(r, { size: 16 }),
244
- done: H.items.length > 0,
245
- onClick: Q
248
+ key: "items",
249
+ label: "Shipment contents",
250
+ description: "What is being shipped?"
251
+ },
252
+ {
253
+ key: "preferences",
254
+ label: "Timing & handling",
255
+ description: "Add optional delivery instructions."
246
256
  }
247
- ]
257
+ ],
258
+ active: qe,
259
+ onStepClick: (e) => {
260
+ let t = document.getElementById([
261
+ "customer",
262
+ "pickupStreet",
263
+ "items-section",
264
+ "scheduledDelivery"
265
+ ][e]);
266
+ if (t instanceof HTMLInputElement || t instanceof HTMLTextAreaElement) {
267
+ t.focus();
268
+ return;
269
+ }
270
+ t?.scrollIntoView({
271
+ behavior: "smooth",
272
+ block: "start"
273
+ });
274
+ },
275
+ allowSkipAhead: !0
248
276
  }),
249
277
  /* @__PURE__ */ C("form", {
250
- onSubmit: Y,
278
+ id: "order-form",
279
+ onSubmit: X,
251
280
  className: "space-y-6",
252
281
  children: [
253
- /* @__PURE__ */ S(me, { message: Pe }),
254
- /* @__PURE__ */ C(be, { children: [/* @__PURE__ */ S("h2", {
255
- className: "text-base font-semibold text-text-primary mb-4",
256
- children: "Order Details"
257
- }), /* @__PURE__ */ S("div", {
258
- className: "space-y-4",
259
- children: /* @__PURE__ */ C("div", {
260
- className: "grid grid-cols-1 md:grid-cols-2 gap-4",
261
- children: [/* @__PURE__ */ S(ge, {
262
- customers: M,
263
- value: H.customerId,
264
- onValueChange: (e) => {
265
- e && (X("customerId", e), V(M.find((t) => t.id === e) ?? (B?.id === e ? B : null)), K(null));
266
- },
267
- onCreated: (e) => {
268
- V(e), X("customerId", e.id), K(null);
269
- },
270
- createCustomer: Ee,
271
- isLoading: N,
272
- error: P,
273
- onRetry: De,
274
- onOpenCustomers: () => {
275
- k && k(s(O, ne(z && T ? `orders/${T}/edit` : "orders/new")));
276
- },
277
- selectedCustomer: B,
278
- onSearchQueryChange: Te
282
+ /* @__PURE__ */ S(ve, { message: Ve }),
283
+ /* @__PURE__ */ S("section", {
284
+ "aria-labelledby": "order-details-title",
285
+ children: /* @__PURE__ */ C(Ce, {
286
+ className: "space-y-5",
287
+ children: [/* @__PURE__ */ C("div", {
288
+ className: "flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",
289
+ children: [/* @__PURE__ */ C("div", {
290
+ className: "flex items-start gap-3",
291
+ children: [/* @__PURE__ */ S("div", {
292
+ className: "rounded-xl bg-action-primary-bg/10 p-2 text-action-primary-bg",
293
+ children: /* @__PURE__ */ S(te, {
294
+ size: 18,
295
+ "aria-hidden": "true"
296
+ })
297
+ }), /* @__PURE__ */ C("div", { children: [/* @__PURE__ */ S("h2", {
298
+ id: "order-details-title",
299
+ className: "text-base font-semibold text-text-primary",
300
+ children: "Customer & priority"
301
+ }), /* @__PURE__ */ S("p", {
302
+ className: "mt-1 text-sm text-text-secondary",
303
+ children: "Choose who this delivery is for and how urgently it should be handled."
304
+ })] })]
305
+ }), /* @__PURE__ */ S(c, {
306
+ variant: "outline",
307
+ children: "Required"
308
+ })]
279
309
  }), /* @__PURE__ */ C("div", {
280
- className: "space-y-2",
281
- children: [/* @__PURE__ */ S(_, {
282
- htmlFor: "priority",
283
- children: "Priority"
284
- }), /* @__PURE__ */ C(se, {
285
- value: H.priority,
286
- onValueChange: (e) => X("priority", e),
287
- children: [/* @__PURE__ */ S(le, {
288
- id: "priority",
289
- children: /* @__PURE__ */ S(ue, {})
290
- }), /* @__PURE__ */ C(ce, { children: [
291
- /* @__PURE__ */ S(v, {
292
- value: "low",
293
- children: "Low"
294
- }),
295
- /* @__PURE__ */ S(v, {
296
- value: "normal",
297
- children: "Normal"
310
+ className: "grid grid-cols-1 gap-4 md:grid-cols-2",
311
+ children: [/* @__PURE__ */ S(v, {
312
+ customers: M,
313
+ value: U.customerId,
314
+ onValueChange: (e) => {
315
+ e && (Z("customerId", e), H(M.find((t) => t.id === e) ?? (V?.id === e ? V : null)), q(null));
316
+ },
317
+ onCreated: (e) => {
318
+ H(e), Z("customerId", e.id), q(null);
319
+ },
320
+ createCustomer: Ae,
321
+ isLoading: N,
322
+ error: P,
323
+ onRetry: je,
324
+ onOpenCustomers: Ke,
325
+ selectedCustomer: V,
326
+ onSearchQueryChange: ke
327
+ }), /* @__PURE__ */ C("div", {
328
+ className: "space-y-2",
329
+ children: [
330
+ /* @__PURE__ */ S(g, {
331
+ htmlFor: "priority",
332
+ children: "Priority"
298
333
  }),
299
- /* @__PURE__ */ S(v, {
300
- value: "high",
301
- children: "High"
334
+ /* @__PURE__ */ C(ue, {
335
+ value: U.priority,
336
+ onValueChange: (e) => Z("priority", e),
337
+ children: [/* @__PURE__ */ S(fe, {
338
+ id: "priority",
339
+ children: /* @__PURE__ */ S(pe, {})
340
+ }), /* @__PURE__ */ C(de, { children: [
341
+ /* @__PURE__ */ S(_, {
342
+ value: "low",
343
+ children: "Low"
344
+ }),
345
+ /* @__PURE__ */ S(_, {
346
+ value: "normal",
347
+ children: "Normal"
348
+ }),
349
+ /* @__PURE__ */ S(_, {
350
+ value: "high",
351
+ children: "High"
352
+ }),
353
+ /* @__PURE__ */ S(_, {
354
+ value: "urgent",
355
+ children: "Urgent"
356
+ })
357
+ ] })]
302
358
  }),
303
- /* @__PURE__ */ S(v, {
304
- value: "urgent",
305
- children: "Urgent"
359
+ /* @__PURE__ */ S("p", {
360
+ className: "text-xs text-text-secondary",
361
+ children: "Normal is selected by default."
306
362
  })
307
- ] })]
363
+ ]
308
364
  })]
309
365
  })]
310
366
  })
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
- })] }),
346
- /* @__PURE__ */ C("div", {
347
- className: "grid grid-cols-1 md:grid-cols-2 gap-6",
348
- children: [/* @__PURE__ */ C(f, { children: [/* @__PURE__ */ S(m, { children: /* @__PURE__ */ S(h, { children: "Pickup Address" }) }), /* @__PURE__ */ C(p, {
349
- className: "space-y-4",
350
- children: [
351
- /* @__PURE__ */ C("div", {
352
- className: "space-y-2",
353
- children: [/* @__PURE__ */ S(_, {
354
- htmlFor: "pickupStreet",
355
- children: "Street Address"
356
- }), /* @__PURE__ */ S(g, {
357
- id: "pickupStreet",
358
- value: H.pickupAddress.street,
359
- onChange: (e) => Z("pickupAddress", "street", e.target.value),
360
- placeholder: "123 Main St"
361
- })]
362
- }),
363
- /* @__PURE__ */ C("div", {
364
- className: "grid grid-cols-1 sm:grid-cols-2 gap-4",
365
- children: [/* @__PURE__ */ C("div", {
366
- className: "space-y-2",
367
- children: [/* @__PURE__ */ S(_, {
368
- htmlFor: "pickupCity",
369
- children: "City"
370
- }), /* @__PURE__ */ S(g, {
371
- id: "pickupCity",
372
- value: H.pickupAddress.city,
373
- onChange: (e) => Z("pickupAddress", "city", e.target.value),
374
- placeholder: "San Francisco"
375
- })]
376
- }), /* @__PURE__ */ C("div", {
377
- className: "space-y-2",
378
- children: [/* @__PURE__ */ S(_, {
379
- htmlFor: "pickupState",
380
- children: "State"
381
- }), /* @__PURE__ */ S(g, {
382
- id: "pickupState",
383
- value: H.pickupAddress.state,
384
- onChange: (e) => Z("pickupAddress", "state", e.target.value),
385
- placeholder: "CA"
386
- })]
387
- })]
388
- }),
389
- /* @__PURE__ */ C("div", {
390
- className: "grid grid-cols-1 sm:grid-cols-2 gap-4",
391
- children: [/* @__PURE__ */ C("div", {
392
- className: "space-y-2",
393
- children: [/* @__PURE__ */ S(_, {
394
- htmlFor: "pickupPostal",
395
- children: "Postal Code"
396
- }), /* @__PURE__ */ S(g, {
397
- id: "pickupPostal",
398
- value: H.pickupAddress.postalCode,
399
- onChange: (e) => Z("pickupAddress", "postalCode", e.target.value),
400
- placeholder: "94103"
401
- })]
402
- }), /* @__PURE__ */ C("div", {
403
- className: "space-y-2",
404
- children: [/* @__PURE__ */ S(_, {
405
- htmlFor: "pickupCountry",
406
- children: "Country"
407
- }), /* @__PURE__ */ S(g, {
408
- id: "pickupCountry",
409
- value: H.pickupAddress.country,
410
- onChange: (e) => Z("pickupAddress", "country", e.target.value),
411
- placeholder: "USA"
412
- })]
413
- })]
414
- })
415
- ]
416
- })] }), /* @__PURE__ */ C(f, { children: [/* @__PURE__ */ S(m, { children: /* @__PURE__ */ S(h, { children: "Delivery Address" }) }), /* @__PURE__ */ C(p, {
417
- className: "space-y-4",
367
+ }),
368
+ /* @__PURE__ */ S("div", {
369
+ id: "locations-section",
370
+ children: /* @__PURE__ */ C(w, {
371
+ title: /* @__PURE__ */ C("span", {
372
+ className: "flex items-center gap-2",
373
+ children: [/* @__PURE__ */ S(r, {
374
+ size: 18,
375
+ "aria-hidden": "true"
376
+ }), "Route & addresses"]
377
+ }),
378
+ description: "Choose an optional saved route, then review or enter the collection and destination details.",
418
379
  children: [
419
380
  /* @__PURE__ */ C("div", {
420
- className: "space-y-2",
421
- children: [/* @__PURE__ */ S(_, {
422
- htmlFor: "deliveryStreet",
423
- children: "Street Address"
424
- }), /* @__PURE__ */ S(g, {
425
- id: "deliveryStreet",
426
- value: H.deliveryAddress.street,
427
- onChange: (e) => Z("deliveryAddress", "street", e.target.value),
428
- placeholder: "456 Oak Ave"
429
- })]
430
- }),
431
- /* @__PURE__ */ C("div", {
432
- className: "grid grid-cols-1 sm:grid-cols-2 gap-4",
433
- children: [/* @__PURE__ */ C("div", {
434
- className: "space-y-2",
435
- children: [/* @__PURE__ */ S(_, {
436
- htmlFor: "deliveryCity",
437
- children: "City"
438
- }), /* @__PURE__ */ S(g, {
439
- id: "deliveryCity",
440
- value: H.deliveryAddress.city,
441
- onChange: (e) => Z("deliveryAddress", "city", e.target.value),
442
- placeholder: "Los Angeles"
443
- })]
444
- }), /* @__PURE__ */ C("div", {
445
- className: "space-y-2",
446
- children: [/* @__PURE__ */ S(_, {
447
- htmlFor: "deliveryState",
448
- children: "State"
449
- }), /* @__PURE__ */ S(g, {
450
- id: "deliveryState",
451
- value: H.deliveryAddress.state,
452
- onChange: (e) => Z("deliveryAddress", "state", e.target.value),
453
- placeholder: "CA"
454
- })]
455
- })]
381
+ className: "rounded-card border border-border-subtle bg-bg-sunken/40 p-4",
382
+ children: [
383
+ /* @__PURE__ */ C("div", {
384
+ className: "mb-3 flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between",
385
+ children: [/* @__PURE__ */ C("div", { children: [/* @__PURE__ */ S("h3", {
386
+ className: "text-sm font-semibold text-text-primary",
387
+ children: "Use a saved route"
388
+ }), /* @__PURE__ */ S("p", {
389
+ className: "mt-1 text-xs text-text-secondary",
390
+ children: "Optional — fills only blank address fields; you can always edit them below."
391
+ })] }), /* @__PURE__ */ S(c, {
392
+ variant: "secondary",
393
+ children: "Optional"
394
+ })]
395
+ }),
396
+ /* @__PURE__ */ S(ye, {
397
+ id: "saved-route",
398
+ value: U.routeId,
399
+ onChange: Ue,
400
+ options: I,
401
+ loading: L,
402
+ getId: (e) => e.id,
403
+ getLabel: (e) => `${e.name} · ${e.stops.length} stops`,
404
+ renderOption: (e) => /* @__PURE__ */ C(Se, { children: [
405
+ e.name,
406
+ " · ",
407
+ e.stops.length,
408
+ " stops"
409
+ ] }),
410
+ selectedOption: ze,
411
+ selectedLoading: Be,
412
+ placeholder: "Choose a saved route",
413
+ searchPlaceholder: "Search saved routes",
414
+ emptyText: "No saved routes found.",
415
+ noneLabel: "No saved route",
416
+ error: R ? "Saved routes are unavailable" : void 0,
417
+ onSearchChange: Ne,
418
+ hasMore: Pe,
419
+ totalCount: Fe
420
+ }),
421
+ /* @__PURE__ */ S("p", {
422
+ className: "mt-2 text-xs text-text-secondary",
423
+ role: "status",
424
+ children: L ? "Loading planned routes…" : R ? "Saved routes are unavailable; enter pickup and delivery addresses manually." : "Manual values always remain authoritative when a route is selected."
425
+ })
426
+ ]
456
427
  }),
428
+ /* @__PURE__ */ S(me, {}),
457
429
  /* @__PURE__ */ C("div", {
458
- className: "grid grid-cols-1 sm:grid-cols-2 gap-4",
459
- children: [/* @__PURE__ */ C("div", {
460
- className: "space-y-2",
461
- children: [/* @__PURE__ */ S(_, {
462
- htmlFor: "deliveryPostal",
463
- children: "Postal Code"
464
- }), /* @__PURE__ */ S(g, {
465
- id: "deliveryPostal",
466
- value: H.deliveryAddress.postalCode,
467
- onChange: (e) => Z("deliveryAddress", "postalCode", e.target.value),
468
- placeholder: "90210"
469
- })]
470
- }), /* @__PURE__ */ C("div", {
471
- className: "space-y-2",
472
- children: [/* @__PURE__ */ S(_, {
473
- htmlFor: "deliveryCountry",
474
- children: "Country"
475
- }), /* @__PURE__ */ S(g, {
476
- id: "deliveryCountry",
477
- value: H.deliveryAddress.country,
478
- onChange: (e) => Z("deliveryAddress", "country", e.target.value),
479
- placeholder: "USA"
480
- })]
481
- })]
430
+ className: "grid grid-cols-1 gap-4 lg:grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] lg:items-stretch",
431
+ children: [
432
+ /* @__PURE__ */ C(u, {
433
+ className: "border-border-seam shadow-none",
434
+ children: [/* @__PURE__ */ C(p, { children: [/* @__PURE__ */ C(m, {
435
+ className: "flex items-center gap-2 text-base",
436
+ children: [
437
+ /* @__PURE__ */ S(r, {
438
+ size: 17,
439
+ className: "text-text-secondary",
440
+ "aria-hidden": "true"
441
+ }),
442
+ "Pickup address ",
443
+ /* @__PURE__ */ S("span", {
444
+ className: "text-status-error-text",
445
+ children: "*"
446
+ })
447
+ ]
448
+ }), /* @__PURE__ */ S(f, { children: "Where the shipment is collected." })] }), /* @__PURE__ */ S(d, {
449
+ className: "space-y-4",
450
+ children: /* @__PURE__ */ C("fieldset", {
451
+ className: "space-y-4",
452
+ children: [
453
+ /* @__PURE__ */ S("legend", {
454
+ className: "sr-only",
455
+ children: "Pickup address details"
456
+ }),
457
+ /* @__PURE__ */ C("div", {
458
+ className: "space-y-2",
459
+ children: [/* @__PURE__ */ C(g, {
460
+ htmlFor: "pickupStreet",
461
+ children: ["Street address ", /* @__PURE__ */ S("span", {
462
+ className: "text-status-error-text",
463
+ children: "*"
464
+ })]
465
+ }), /* @__PURE__ */ S(h, {
466
+ id: "pickupStreet",
467
+ value: U.pickupAddress.street,
468
+ onChange: (e) => Q("pickupAddress", "street", e.target.value),
469
+ placeholder: "123 Main St",
470
+ "aria-required": "true"
471
+ })]
472
+ }),
473
+ /* @__PURE__ */ C("div", {
474
+ className: "grid grid-cols-1 sm:grid-cols-2 gap-4",
475
+ children: [/* @__PURE__ */ C("div", {
476
+ className: "space-y-2",
477
+ children: [/* @__PURE__ */ S(g, {
478
+ htmlFor: "pickupCity",
479
+ children: "City"
480
+ }), /* @__PURE__ */ S(h, {
481
+ id: "pickupCity",
482
+ value: U.pickupAddress.city,
483
+ onChange: (e) => Q("pickupAddress", "city", e.target.value),
484
+ placeholder: "San Francisco"
485
+ })]
486
+ }), /* @__PURE__ */ C("div", {
487
+ className: "space-y-2",
488
+ children: [/* @__PURE__ */ S(g, {
489
+ htmlFor: "pickupState",
490
+ children: "State"
491
+ }), /* @__PURE__ */ S(h, {
492
+ id: "pickupState",
493
+ value: U.pickupAddress.state,
494
+ onChange: (e) => Q("pickupAddress", "state", e.target.value),
495
+ placeholder: "CA"
496
+ })]
497
+ })]
498
+ }),
499
+ /* @__PURE__ */ C("div", {
500
+ className: "grid grid-cols-1 sm:grid-cols-2 gap-4",
501
+ children: [/* @__PURE__ */ C("div", {
502
+ className: "space-y-2",
503
+ children: [/* @__PURE__ */ S(g, {
504
+ htmlFor: "pickupPostal",
505
+ children: "Postal Code"
506
+ }), /* @__PURE__ */ S(h, {
507
+ id: "pickupPostal",
508
+ value: U.pickupAddress.postalCode,
509
+ onChange: (e) => Q("pickupAddress", "postalCode", e.target.value),
510
+ placeholder: "94103"
511
+ })]
512
+ }), /* @__PURE__ */ C("div", {
513
+ className: "space-y-2",
514
+ children: [/* @__PURE__ */ S(g, {
515
+ htmlFor: "pickupCountry",
516
+ children: "Country"
517
+ }), /* @__PURE__ */ S(h, {
518
+ id: "pickupCountry",
519
+ value: U.pickupAddress.country,
520
+ onChange: (e) => Q("pickupAddress", "country", e.target.value),
521
+ placeholder: "USA"
522
+ })]
523
+ })]
524
+ })
525
+ ]
526
+ })
527
+ })]
528
+ }),
529
+ /* @__PURE__ */ S("div", {
530
+ className: "hidden items-center justify-center lg:flex",
531
+ "aria-hidden": "true",
532
+ children: /* @__PURE__ */ S(t, {
533
+ size: 18,
534
+ className: "text-text-muted"
535
+ })
536
+ }),
537
+ /* @__PURE__ */ C(u, {
538
+ className: "border-border-seam shadow-none",
539
+ children: [/* @__PURE__ */ C(p, { children: [/* @__PURE__ */ C(m, {
540
+ className: "flex items-center gap-2 text-base",
541
+ children: [
542
+ /* @__PURE__ */ S(r, {
543
+ size: 17,
544
+ className: "text-text-secondary",
545
+ "aria-hidden": "true"
546
+ }),
547
+ "Delivery address ",
548
+ /* @__PURE__ */ S("span", {
549
+ className: "text-status-error-text",
550
+ children: "*"
551
+ })
552
+ ]
553
+ }), /* @__PURE__ */ S(f, { children: "Where the shipment is delivered." })] }), /* @__PURE__ */ S(d, {
554
+ className: "space-y-4",
555
+ children: /* @__PURE__ */ C("fieldset", {
556
+ className: "space-y-4",
557
+ children: [
558
+ /* @__PURE__ */ S("legend", {
559
+ className: "sr-only",
560
+ children: "Delivery address details"
561
+ }),
562
+ /* @__PURE__ */ C("div", {
563
+ className: "space-y-2",
564
+ children: [/* @__PURE__ */ C(g, {
565
+ htmlFor: "deliveryStreet",
566
+ children: ["Street address ", /* @__PURE__ */ S("span", {
567
+ className: "text-status-error-text",
568
+ children: "*"
569
+ })]
570
+ }), /* @__PURE__ */ S(h, {
571
+ id: "deliveryStreet",
572
+ value: U.deliveryAddress.street,
573
+ onChange: (e) => Q("deliveryAddress", "street", e.target.value),
574
+ placeholder: "456 Oak Ave",
575
+ "aria-required": "true"
576
+ })]
577
+ }),
578
+ /* @__PURE__ */ C("div", {
579
+ className: "grid grid-cols-1 gap-4 sm:grid-cols-2",
580
+ children: [/* @__PURE__ */ C("div", {
581
+ className: "space-y-2",
582
+ children: [/* @__PURE__ */ S(g, {
583
+ htmlFor: "deliveryCity",
584
+ children: "City"
585
+ }), /* @__PURE__ */ S(h, {
586
+ id: "deliveryCity",
587
+ value: U.deliveryAddress.city,
588
+ onChange: (e) => Q("deliveryAddress", "city", e.target.value),
589
+ placeholder: "Los Angeles"
590
+ })]
591
+ }), /* @__PURE__ */ C("div", {
592
+ className: "space-y-2",
593
+ children: [/* @__PURE__ */ S(g, {
594
+ htmlFor: "deliveryState",
595
+ children: "State"
596
+ }), /* @__PURE__ */ S(h, {
597
+ id: "deliveryState",
598
+ value: U.deliveryAddress.state,
599
+ onChange: (e) => Q("deliveryAddress", "state", e.target.value),
600
+ placeholder: "CA"
601
+ })]
602
+ })]
603
+ }),
604
+ /* @__PURE__ */ C("div", {
605
+ className: "grid grid-cols-1 gap-4 sm:grid-cols-2",
606
+ children: [/* @__PURE__ */ C("div", {
607
+ className: "space-y-2",
608
+ children: [/* @__PURE__ */ S(g, {
609
+ htmlFor: "deliveryPostal",
610
+ children: "Postal code"
611
+ }), /* @__PURE__ */ S(h, {
612
+ id: "deliveryPostal",
613
+ value: U.deliveryAddress.postalCode,
614
+ onChange: (e) => Q("deliveryAddress", "postalCode", e.target.value),
615
+ placeholder: "90210"
616
+ })]
617
+ }), /* @__PURE__ */ C("div", {
618
+ className: "space-y-2",
619
+ children: [/* @__PURE__ */ S(g, {
620
+ htmlFor: "deliveryCountry",
621
+ children: "Country"
622
+ }), /* @__PURE__ */ S(h, {
623
+ id: "deliveryCountry",
624
+ value: U.deliveryAddress.country,
625
+ onChange: (e) => Q("deliveryAddress", "country", e.target.value),
626
+ placeholder: "USA"
627
+ })]
628
+ })]
629
+ })
630
+ ]
631
+ })
632
+ })]
633
+ })
634
+ ]
482
635
  })
483
636
  ]
484
- })] })]
485
- }),
486
- /* @__PURE__ */ C(f, { children: [/* @__PURE__ */ C(m, {
487
- className: "flex flex-row items-center justify-between",
488
- children: [/* @__PURE__ */ S(h, { children: "Order Items" }), /* @__PURE__ */ C(d, {
489
- type: "button",
490
- variant: "outline",
491
- size: "sm",
492
- onClick: Q,
493
- children: [/* @__PURE__ */ S(i, { size: 16 }), "Add Item"]
494
- })]
495
- }), /* @__PURE__ */ S(p, { children: H.items.length === 0 ? /* @__PURE__ */ S(fe, {
496
- illustration: "empty-files",
497
- title: "No items added yet",
498
- description: "Add the products this order will ship — each with a name, SKU, quantity and value.",
499
- action: /* @__PURE__ */ C(d, {
500
- type: "button",
501
- variant: "outline",
502
- onClick: Q,
503
- children: [/* @__PURE__ */ S(i, {
504
- size: 16,
505
- className: "mr-1.5"
506
- }), "Add your first item"]
507
637
  })
508
- }) : /* @__PURE__ */ S("div", {
509
- className: "space-y-4",
510
- children: H.items.map((e, t) => /* @__PURE__ */ C("div", { children: [t > 0 && /* @__PURE__ */ S(de, { className: "my-4" }), /* @__PURE__ */ C("div", {
511
- className: "grid grid-cols-1 md:grid-cols-7 gap-4",
512
- children: [
513
- /* @__PURE__ */ C("div", {
514
- className: "md:col-span-2 space-y-2",
515
- children: [/* @__PURE__ */ S(_, { children: "Item Name" }), /* @__PURE__ */ S(g, {
516
- value: e.name,
517
- onChange: (e) => $(t, "name", e.target.value),
518
- placeholder: "Product name"
519
- })]
520
- }),
521
- /* @__PURE__ */ C("div", {
522
- className: "space-y-2",
523
- children: [/* @__PURE__ */ S(_, { children: "SKU" }), /* @__PURE__ */ S(g, {
524
- value: e.sku,
525
- onChange: (e) => $(t, "sku", e.target.value),
526
- placeholder: "SKU-001"
527
- })]
528
- }),
529
- /* @__PURE__ */ C("div", {
530
- className: "space-y-2",
531
- children: [/* @__PURE__ */ S(_, { children: "Quantity" }), /* @__PURE__ */ S(g, {
532
- type: "number",
533
- min: "1",
534
- value: e.quantity,
535
- onChange: (e) => $(t, "quantity", parseInt(e.target.value) || 1)
536
- })]
537
- }),
538
- /* @__PURE__ */ C("div", {
539
- className: "space-y-2",
540
- children: [/* @__PURE__ */ S(_, { children: "Weight (kg)" }), /* @__PURE__ */ S(g, {
541
- type: "number",
542
- min: "0",
543
- step: "0.1",
544
- value: e.weight,
545
- onChange: (e) => $(t, "weight", parseFloat(e.target.value) || 0)
546
- })]
547
- }),
548
- /* @__PURE__ */ C("div", {
549
- className: "space-y-2",
550
- children: [/* @__PURE__ */ S(_, { children: "Value ($)" }), /* @__PURE__ */ S(g, {
551
- type: "number",
552
- min: "0",
553
- step: "0.01",
554
- value: e.value,
555
- onChange: (e) => $(t, "value", parseFloat(e.target.value) || 0)
556
- })]
557
- }),
558
- /* @__PURE__ */ S("div", {
559
- className: "flex items-end",
560
- children: /* @__PURE__ */ S(d, {
561
- type: "button",
562
- variant: "ghost",
563
- size: "icon",
564
- className: "text-status-error-text",
565
- onClick: () => Le(t),
566
- children: /* @__PURE__ */ S(ee, { size: 16 })
638
+ }),
639
+ /* @__PURE__ */ S("div", {
640
+ id: "items-section",
641
+ children: /* @__PURE__ */ S(w, {
642
+ title: /* @__PURE__ */ C("span", {
643
+ className: "flex items-center gap-2",
644
+ children: [
645
+ /* @__PURE__ */ S(i, {
646
+ size: 18,
647
+ "aria-hidden": "true"
648
+ }),
649
+ "Shipment contents ",
650
+ /* @__PURE__ */ S(c, {
651
+ variant: "secondary",
652
+ children: U.items.length
567
653
  })
654
+ ]
655
+ }),
656
+ description: "Add each item being shipped. Use the catalog to prefill details or enter a one-off item manually.",
657
+ actions: /* @__PURE__ */ C(l, {
658
+ type: "button",
659
+ variant: "outline",
660
+ size: "sm",
661
+ onClick: $,
662
+ children: [/* @__PURE__ */ S(a, { size: 16 }), "Add item"]
663
+ }),
664
+ children: U.items.length === 0 ? /* @__PURE__ */ S(ge, {
665
+ illustration: "empty-files",
666
+ title: "No items added yet",
667
+ description: "Add the products this order will ship — each with a name, SKU, quantity and value.",
668
+ action: /* @__PURE__ */ C(l, {
669
+ type: "button",
670
+ variant: "outline",
671
+ onClick: $,
672
+ children: [/* @__PURE__ */ S(a, {
673
+ size: 16,
674
+ className: "mr-1.5"
675
+ }), "Add your first item"]
568
676
  })
569
- ]
570
- })] }, e.id))
571
- }) })] }),
572
- /* @__PURE__ */ C(f, { children: [/* @__PURE__ */ S(m, { children: /* @__PURE__ */ S(h, { children: "Scheduling & Handling" }) }), /* @__PURE__ */ S(p, { children: /* @__PURE__ */ C("div", {
573
- className: "grid grid-cols-1 md:grid-cols-3 gap-6",
574
- children: [/* @__PURE__ */ C("div", {
575
- className: "space-y-2",
576
- children: [
577
- /* @__PURE__ */ C(_, {
578
- htmlFor: "scheduledDelivery",
579
- className: "flex items-center gap-1.5",
580
- children: [/* @__PURE__ */ S(t, {
581
- size: 14,
582
- className: "text-text-secondary"
583
- }), "Scheduled Delivery"]
584
- }),
585
- /* @__PURE__ */ S(g, {
586
- id: "scheduledDelivery",
587
- type: "datetime-local",
588
- value: H.scheduledDelivery,
589
- onChange: (e) => X("scheduledDelivery", e.target.value)
590
- }),
591
- /* @__PURE__ */ S("p", {
592
- className: "text-xs text-text-secondary",
593
- children: "The delivery window promised to the customer. Leave blank to dispatch as soon as a driver is free."
594
- })
595
- ]
596
- }), /* @__PURE__ */ C("div", {
597
- className: "md:col-span-2 space-y-2",
598
- children: [/* @__PURE__ */ S(_, {
599
- htmlFor: "specialInstructions",
600
- children: "Special Instructions"
601
- }), /* @__PURE__ */ S(y, {
602
- id: "specialInstructions",
603
- value: H.specialInstructions,
604
- onChange: (e) => X("specialInstructions", e.target.value),
605
- placeholder: "Any special handling or delivery instructions...",
606
- rows: 4
677
+ }) : /* @__PURE__ */ C("div", {
678
+ className: "space-y-4",
679
+ children: [/* @__PURE__ */ C("div", {
680
+ className: "rounded-card border border-border-subtle bg-bg-sunken/40 p-4",
681
+ children: [
682
+ /* @__PURE__ */ S(g, {
683
+ htmlFor: "item-product-search",
684
+ children: "Search product catalog"
685
+ }),
686
+ /* @__PURE__ */ S(h, {
687
+ id: "item-product-search",
688
+ value: z,
689
+ onChange: (e) => Ie(e.target.value),
690
+ placeholder: "Search by name or SKU",
691
+ className: "mt-2"
692
+ }),
693
+ /* @__PURE__ */ S("p", {
694
+ className: "mt-2 text-xs text-text-secondary",
695
+ children: "This filters the catalog picker for every item below. You can still edit any autofilled value or enter item details manually."
696
+ })
697
+ ]
698
+ }), /* @__PURE__ */ S("ol", {
699
+ className: "space-y-4",
700
+ "aria-label": "Shipment items",
701
+ children: U.items.map((e, t) => /* @__PURE__ */ S("li", { children: /* @__PURE__ */ S(y, {
702
+ item: e,
703
+ index: t,
704
+ products: Le,
705
+ productsLoading: Re,
706
+ onUpdate: Ge,
707
+ onRemove: We
708
+ }) }, e.id))
709
+ })]
710
+ })
711
+ })
712
+ }),
713
+ /* @__PURE__ */ S(w, {
714
+ title: /* @__PURE__ */ C("span", {
715
+ className: "flex items-center gap-2",
716
+ children: [/* @__PURE__ */ S(n, {
717
+ size: 18,
718
+ "aria-hidden": "true"
719
+ }), "Timing & handling"]
720
+ }),
721
+ description: "Optional delivery timing and instructions for the carrier.",
722
+ children: /* @__PURE__ */ C("div", {
723
+ className: "grid grid-cols-1 gap-6 lg:grid-cols-3",
724
+ children: [/* @__PURE__ */ C("div", {
725
+ className: "space-y-2",
726
+ children: [
727
+ /* @__PURE__ */ S(g, {
728
+ htmlFor: "scheduledDelivery",
729
+ children: "Scheduled delivery"
730
+ }),
731
+ /* @__PURE__ */ S(h, {
732
+ id: "scheduledDelivery",
733
+ type: "datetime-local",
734
+ value: U.scheduledDelivery,
735
+ onChange: (e) => Z("scheduledDelivery", e.target.value)
736
+ }),
737
+ /* @__PURE__ */ S("p", {
738
+ className: "text-xs text-text-secondary",
739
+ children: "Leave blank to dispatch as soon as a driver is available."
740
+ })
741
+ ]
742
+ }), /* @__PURE__ */ C("div", {
743
+ className: "space-y-2 lg:col-span-2",
744
+ children: [/* @__PURE__ */ S(g, {
745
+ htmlFor: "specialInstructions",
746
+ children: "Special instructions"
747
+ }), /* @__PURE__ */ S(he, {
748
+ id: "specialInstructions",
749
+ value: U.specialInstructions,
750
+ onChange: (e) => Z("specialInstructions", e.target.value),
751
+ placeholder: "Any special handling or delivery instructions...",
752
+ rows: 4
753
+ })]
607
754
  })]
608
- })]
609
- }) })] })
755
+ })
756
+ })
610
757
  ]
611
758
  })
612
759
  ]
613
760
  });
614
761
  }
615
762
  //#endregion
616
- export { T as default };
763
+ export { E as default };