@medusajs/draft-order 2.10.4-preview-20251014031441 → 2.10.4-preview-20251014060203

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.
@@ -9763,27 +9763,6 @@ const BillingAddressForm = ({ order }) => {
9763
9763
  ) });
9764
9764
  };
9765
9765
  const schema$5 = addressSchema;
9766
- const CustomItems = () => {
9767
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9768
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
9769
- /* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
9770
- ] });
9771
- };
9772
- const CustomItemsForm = () => {
9773
- const form = reactHookForm.useForm({
9774
- resolver: zod.zodResolver(schema$4)
9775
- });
9776
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9777
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
9778
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
9779
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9780
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
9781
- ] }) })
9782
- ] }) });
9783
- };
9784
- const schema$4 = objectType({
9785
- email: stringType().email()
9786
- });
9787
9766
  const Email = () => {
9788
9767
  const { id } = reactRouterDom.useParams();
9789
9768
  const { order, isPending, isError, error } = useOrder(id, {
@@ -9806,7 +9785,7 @@ const EmailForm = ({ order }) => {
9806
9785
  defaultValues: {
9807
9786
  email: order.email ?? ""
9808
9787
  },
9809
- resolver: zod.zodResolver(schema$3)
9788
+ resolver: zod.zodResolver(schema$4)
9810
9789
  });
9811
9790
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9812
9791
  const { handleSuccess } = useRouteModal();
@@ -9849,6 +9828,27 @@ const EmailForm = ({ order }) => {
9849
9828
  }
9850
9829
  ) });
9851
9830
  };
9831
+ const schema$4 = objectType({
9832
+ email: stringType().email()
9833
+ });
9834
+ const CustomItems = () => {
9835
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9836
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
9837
+ /* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
9838
+ ] });
9839
+ };
9840
+ const CustomItemsForm = () => {
9841
+ const form = reactHookForm.useForm({
9842
+ resolver: zod.zodResolver(schema$3)
9843
+ });
9844
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9845
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
9846
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
9847
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9848
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
9849
+ ] }) })
9850
+ ] }) });
9851
+ };
9852
9852
  const schema$3 = objectType({
9853
9853
  email: stringType().email()
9854
9854
  });
@@ -11453,112 +11453,6 @@ function getPromotionIds(items, shippingMethods) {
11453
11453
  }
11454
11454
  return Array.from(promotionIds);
11455
11455
  }
11456
- const SalesChannel = () => {
11457
- const { id } = reactRouterDom.useParams();
11458
- const { draft_order, isPending, isError, error } = useDraftOrder(
11459
- id,
11460
- {
11461
- fields: "+sales_channel_id"
11462
- },
11463
- {
11464
- enabled: !!id
11465
- }
11466
- );
11467
- if (isError) {
11468
- throw error;
11469
- }
11470
- const ISrEADY = !!draft_order && !isPending;
11471
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
11472
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
11473
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
11474
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
11475
- ] }),
11476
- ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
11477
- ] });
11478
- };
11479
- const SalesChannelForm = ({ order }) => {
11480
- const form = reactHookForm.useForm({
11481
- defaultValues: {
11482
- sales_channel_id: order.sales_channel_id || ""
11483
- },
11484
- resolver: zod.zodResolver(schema$2)
11485
- });
11486
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11487
- const { handleSuccess } = useRouteModal();
11488
- const onSubmit = form.handleSubmit(async (data) => {
11489
- await mutateAsync(
11490
- {
11491
- sales_channel_id: data.sales_channel_id
11492
- },
11493
- {
11494
- onSuccess: () => {
11495
- ui.toast.success("Sales channel updated");
11496
- handleSuccess();
11497
- },
11498
- onError: (error) => {
11499
- ui.toast.error(error.message);
11500
- }
11501
- }
11502
- );
11503
- });
11504
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
11505
- KeyboundForm,
11506
- {
11507
- className: "flex flex-1 flex-col overflow-hidden",
11508
- onSubmit,
11509
- children: [
11510
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
11511
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
11512
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11513
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
11514
- ] }) })
11515
- ]
11516
- }
11517
- ) });
11518
- };
11519
- const SalesChannelField = ({ control, order }) => {
11520
- const salesChannels = useComboboxData({
11521
- queryFn: async (params) => {
11522
- return await sdk.admin.salesChannel.list(params);
11523
- },
11524
- queryKey: ["sales-channels"],
11525
- getOptions: (data) => {
11526
- return data.sales_channels.map((salesChannel) => ({
11527
- label: salesChannel.name,
11528
- value: salesChannel.id
11529
- }));
11530
- },
11531
- defaultValue: order.sales_channel_id || void 0
11532
- });
11533
- return /* @__PURE__ */ jsxRuntime.jsx(
11534
- Form$2.Field,
11535
- {
11536
- control,
11537
- name: "sales_channel_id",
11538
- render: ({ field }) => {
11539
- return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11540
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
11541
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
11542
- Combobox,
11543
- {
11544
- options: salesChannels.options,
11545
- fetchNextPage: salesChannels.fetchNextPage,
11546
- isFetchingNextPage: salesChannels.isFetchingNextPage,
11547
- searchValue: salesChannels.searchValue,
11548
- onSearchValueChange: salesChannels.onSearchValueChange,
11549
- placeholder: "Select sales channel",
11550
- ...field
11551
- }
11552
- ) }),
11553
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11554
- ] });
11555
- }
11556
- }
11557
- );
11558
- };
11559
- const schema$2 = objectType({
11560
- sales_channel_id: stringType().min(1)
11561
- });
11562
11456
  const STACKED_FOCUS_MODAL_ID = "shipping-form";
11563
11457
  const Shipping = () => {
11564
11458
  var _a;
@@ -12366,44 +12260,60 @@ const CustomAmountField = ({
12366
12260
  }
12367
12261
  );
12368
12262
  };
12369
- const TransferOwnership = () => {
12263
+ const ShippingAddress = () => {
12370
12264
  const { id } = reactRouterDom.useParams();
12371
- const { draft_order, isPending, isError, error } = useDraftOrder(id, {
12372
- fields: "id,customer_id,customer.*"
12265
+ const { order, isPending, isError, error } = useOrder(id, {
12266
+ fields: "+shipping_address"
12373
12267
  });
12374
12268
  if (isError) {
12375
12269
  throw error;
12376
12270
  }
12377
- const isReady = !isPending && !!draft_order;
12271
+ const isReady = !isPending && !!order;
12378
12272
  return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12379
12273
  /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
12380
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Transfer Ownership" }) }),
12381
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Transfer the ownership of this draft order to a new customer" }) })
12274
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Shipping Address" }) }),
12275
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
12382
12276
  ] }),
12383
- isReady && /* @__PURE__ */ jsxRuntime.jsx(TransferOwnershipForm, { order: draft_order })
12277
+ isReady && /* @__PURE__ */ jsxRuntime.jsx(ShippingAddressForm, { order })
12384
12278
  ] });
12385
12279
  };
12386
- const TransferOwnershipForm = ({ order }) => {
12387
- var _a, _b;
12280
+ const ShippingAddressForm = ({ order }) => {
12281
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12388
12282
  const form = reactHookForm.useForm({
12389
12283
  defaultValues: {
12390
- customer_id: order.customer_id || ""
12284
+ first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
12285
+ last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
12286
+ company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
12287
+ address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
12288
+ address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
12289
+ city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
12290
+ province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
12291
+ country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
12292
+ postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12293
+ phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12391
12294
  },
12392
- resolver: zod.zodResolver(schema$1)
12295
+ resolver: zod.zodResolver(schema$2)
12393
12296
  });
12394
12297
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12395
12298
  const { handleSuccess } = useRouteModal();
12396
- const name = [(_a = order.customer) == null ? void 0 : _a.first_name, (_b = order.customer) == null ? void 0 : _b.last_name].filter(Boolean).join(" ");
12397
- const currentCustomer = order.customer ? {
12398
- label: name ? `${name} (${order.customer.email})` : order.customer.email,
12399
- value: order.customer.id
12400
- } : null;
12401
12299
  const onSubmit = form.handleSubmit(async (data) => {
12402
12300
  await mutateAsync(
12403
- { customer_id: data.customer_id },
12301
+ {
12302
+ shipping_address: {
12303
+ first_name: data.first_name,
12304
+ last_name: data.last_name,
12305
+ company: data.company,
12306
+ address_1: data.address_1,
12307
+ address_2: data.address_2,
12308
+ city: data.city,
12309
+ province: data.province,
12310
+ country_code: data.country_code,
12311
+ postal_code: data.postal_code,
12312
+ phone: data.phone
12313
+ }
12314
+ },
12404
12315
  {
12405
12316
  onSuccess: () => {
12406
- ui.toast.success("Customer updated");
12407
12317
  handleSuccess();
12408
12318
  },
12409
12319
  onError: (error) => {
@@ -12418,57 +12328,244 @@ const TransferOwnershipForm = ({ order }) => {
12418
12328
  className: "flex flex-1 flex-col overflow-hidden",
12419
12329
  onSubmit,
12420
12330
  children: [
12421
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: [
12422
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center bg-ui-bg-component rounded-md border", children: /* @__PURE__ */ jsxRuntime.jsx(Illustration, {}) }),
12423
- currentCustomer && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col space-y-3", children: [
12424
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
12425
- /* @__PURE__ */ jsxRuntime.jsx(ui.Label, { size: "small", weight: "plus", htmlFor: "current-customer", children: "Current owner" }),
12426
- /* @__PURE__ */ jsxRuntime.jsx(ui.Hint, { children: "The customer that is currently associated with this draft order." })
12427
- ] }),
12428
- /* @__PURE__ */ jsxRuntime.jsxs(ui.Select, { disabled: true, value: currentCustomer.value, children: [
12429
- /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Trigger, { id: "current-customer", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Value, {}) }),
12430
- /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Item, { value: currentCustomer.value, children: currentCustomer.label }) })
12431
- ] })
12432
- ] }),
12331
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-y-4", children: [
12433
12332
  /* @__PURE__ */ jsxRuntime.jsx(
12434
- CustomerField,
12333
+ Form$2.Field,
12435
12334
  {
12436
12335
  control: form.control,
12437
- currentCustomerId: order.customer_id
12336
+ name: "country_code",
12337
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12338
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
12339
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
12340
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12341
+ ] })
12438
12342
  }
12439
- )
12440
- ] }),
12441
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
12442
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "secondary", size: "small", children: "Cancel" }) }),
12443
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12444
- ] }) })
12445
- ]
12446
- }
12447
- ) });
12448
- };
12449
- const CustomerField = ({ control, currentCustomerId }) => {
12450
- const customers = useComboboxData({
12451
- queryFn: async (params) => {
12452
- return await sdk.admin.customer.list({
12453
- ...params,
12454
- id: currentCustomerId ? { $nin: [currentCustomerId] } : void 0
12455
- });
12456
- },
12457
- queryKey: ["customers"],
12458
- getOptions: (data) => {
12459
- return data.customers.map((customer) => {
12460
- const name = [customer.first_name, customer.last_name].filter(Boolean).join(" ");
12461
- return {
12462
- label: name ? `${name} (${customer.email})` : customer.email,
12463
- value: customer.id
12464
- };
12465
- });
12466
- }
12467
- });
12468
- return /* @__PURE__ */ jsxRuntime.jsx(
12469
- Form$2.Field,
12470
- {
12471
- name: "customer_id",
12343
+ ),
12344
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12345
+ /* @__PURE__ */ jsxRuntime.jsx(
12346
+ Form$2.Field,
12347
+ {
12348
+ control: form.control,
12349
+ name: "first_name",
12350
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12351
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
12352
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12353
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12354
+ ] })
12355
+ }
12356
+ ),
12357
+ /* @__PURE__ */ jsxRuntime.jsx(
12358
+ Form$2.Field,
12359
+ {
12360
+ control: form.control,
12361
+ name: "last_name",
12362
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12363
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
12364
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12365
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12366
+ ] })
12367
+ }
12368
+ )
12369
+ ] }),
12370
+ /* @__PURE__ */ jsxRuntime.jsx(
12371
+ Form$2.Field,
12372
+ {
12373
+ control: form.control,
12374
+ name: "company",
12375
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12376
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
12377
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12378
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12379
+ ] })
12380
+ }
12381
+ ),
12382
+ /* @__PURE__ */ jsxRuntime.jsx(
12383
+ Form$2.Field,
12384
+ {
12385
+ control: form.control,
12386
+ name: "address_1",
12387
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12388
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
12389
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12390
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12391
+ ] })
12392
+ }
12393
+ ),
12394
+ /* @__PURE__ */ jsxRuntime.jsx(
12395
+ Form$2.Field,
12396
+ {
12397
+ control: form.control,
12398
+ name: "address_2",
12399
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12400
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
12401
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12402
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12403
+ ] })
12404
+ }
12405
+ ),
12406
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12407
+ /* @__PURE__ */ jsxRuntime.jsx(
12408
+ Form$2.Field,
12409
+ {
12410
+ control: form.control,
12411
+ name: "postal_code",
12412
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12413
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
12414
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12415
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12416
+ ] })
12417
+ }
12418
+ ),
12419
+ /* @__PURE__ */ jsxRuntime.jsx(
12420
+ Form$2.Field,
12421
+ {
12422
+ control: form.control,
12423
+ name: "city",
12424
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12425
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
12426
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12427
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12428
+ ] })
12429
+ }
12430
+ )
12431
+ ] }),
12432
+ /* @__PURE__ */ jsxRuntime.jsx(
12433
+ Form$2.Field,
12434
+ {
12435
+ control: form.control,
12436
+ name: "province",
12437
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12438
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
12439
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12440
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12441
+ ] })
12442
+ }
12443
+ ),
12444
+ /* @__PURE__ */ jsxRuntime.jsx(
12445
+ Form$2.Field,
12446
+ {
12447
+ control: form.control,
12448
+ name: "phone",
12449
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12450
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
12451
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12452
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12453
+ ] })
12454
+ }
12455
+ )
12456
+ ] }) }),
12457
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
12458
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12459
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12460
+ ] }) })
12461
+ ]
12462
+ }
12463
+ ) });
12464
+ };
12465
+ const schema$2 = addressSchema;
12466
+ const TransferOwnership = () => {
12467
+ const { id } = reactRouterDom.useParams();
12468
+ const { draft_order, isPending, isError, error } = useDraftOrder(id, {
12469
+ fields: "id,customer_id,customer.*"
12470
+ });
12471
+ if (isError) {
12472
+ throw error;
12473
+ }
12474
+ const isReady = !isPending && !!draft_order;
12475
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12476
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
12477
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Transfer Ownership" }) }),
12478
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Transfer the ownership of this draft order to a new customer" }) })
12479
+ ] }),
12480
+ isReady && /* @__PURE__ */ jsxRuntime.jsx(TransferOwnershipForm, { order: draft_order })
12481
+ ] });
12482
+ };
12483
+ const TransferOwnershipForm = ({ order }) => {
12484
+ var _a, _b;
12485
+ const form = reactHookForm.useForm({
12486
+ defaultValues: {
12487
+ customer_id: order.customer_id || ""
12488
+ },
12489
+ resolver: zod.zodResolver(schema$1)
12490
+ });
12491
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12492
+ const { handleSuccess } = useRouteModal();
12493
+ const name = [(_a = order.customer) == null ? void 0 : _a.first_name, (_b = order.customer) == null ? void 0 : _b.last_name].filter(Boolean).join(" ");
12494
+ const currentCustomer = order.customer ? {
12495
+ label: name ? `${name} (${order.customer.email})` : order.customer.email,
12496
+ value: order.customer.id
12497
+ } : null;
12498
+ const onSubmit = form.handleSubmit(async (data) => {
12499
+ await mutateAsync(
12500
+ { customer_id: data.customer_id },
12501
+ {
12502
+ onSuccess: () => {
12503
+ ui.toast.success("Customer updated");
12504
+ handleSuccess();
12505
+ },
12506
+ onError: (error) => {
12507
+ ui.toast.error(error.message);
12508
+ }
12509
+ }
12510
+ );
12511
+ });
12512
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
12513
+ KeyboundForm,
12514
+ {
12515
+ className: "flex flex-1 flex-col overflow-hidden",
12516
+ onSubmit,
12517
+ children: [
12518
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: [
12519
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center bg-ui-bg-component rounded-md border", children: /* @__PURE__ */ jsxRuntime.jsx(Illustration, {}) }),
12520
+ currentCustomer && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col space-y-3", children: [
12521
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
12522
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Label, { size: "small", weight: "plus", htmlFor: "current-customer", children: "Current owner" }),
12523
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Hint, { children: "The customer that is currently associated with this draft order." })
12524
+ ] }),
12525
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.Select, { disabled: true, value: currentCustomer.value, children: [
12526
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Trigger, { id: "current-customer", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Value, {}) }),
12527
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Select.Item, { value: currentCustomer.value, children: currentCustomer.label }) })
12528
+ ] })
12529
+ ] }),
12530
+ /* @__PURE__ */ jsxRuntime.jsx(
12531
+ CustomerField,
12532
+ {
12533
+ control: form.control,
12534
+ currentCustomerId: order.customer_id
12535
+ }
12536
+ )
12537
+ ] }),
12538
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-end gap-x-2", children: [
12539
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "secondary", size: "small", children: "Cancel" }) }),
12540
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12541
+ ] }) })
12542
+ ]
12543
+ }
12544
+ ) });
12545
+ };
12546
+ const CustomerField = ({ control, currentCustomerId }) => {
12547
+ const customers = useComboboxData({
12548
+ queryFn: async (params) => {
12549
+ return await sdk.admin.customer.list({
12550
+ ...params,
12551
+ id: currentCustomerId ? { $nin: [currentCustomerId] } : void 0
12552
+ });
12553
+ },
12554
+ queryKey: ["customers"],
12555
+ getOptions: (data) => {
12556
+ return data.customers.map((customer) => {
12557
+ const name = [customer.first_name, customer.last_name].filter(Boolean).join(" ");
12558
+ return {
12559
+ label: name ? `${name} (${customer.email})` : customer.email,
12560
+ value: customer.id
12561
+ };
12562
+ });
12563
+ }
12564
+ });
12565
+ return /* @__PURE__ */ jsxRuntime.jsx(
12566
+ Form$2.Field,
12567
+ {
12568
+ name: "customer_id",
12472
12569
  control,
12473
12570
  render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { className: "space-y-3", children: [
12474
12571
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col", children: [
@@ -12842,37 +12939,33 @@ const Illustration = () => {
12842
12939
  const schema$1 = objectType({
12843
12940
  customer_id: stringType().min(1)
12844
12941
  });
12845
- const ShippingAddress = () => {
12942
+ const SalesChannel = () => {
12846
12943
  const { id } = reactRouterDom.useParams();
12847
- const { order, isPending, isError, error } = useOrder(id, {
12848
- fields: "+shipping_address"
12849
- });
12944
+ const { draft_order, isPending, isError, error } = useDraftOrder(
12945
+ id,
12946
+ {
12947
+ fields: "+sales_channel_id"
12948
+ },
12949
+ {
12950
+ enabled: !!id
12951
+ }
12952
+ );
12850
12953
  if (isError) {
12851
12954
  throw error;
12852
12955
  }
12853
- const isReady = !isPending && !!order;
12956
+ const ISrEADY = !!draft_order && !isPending;
12854
12957
  return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12855
12958
  /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
12856
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Shipping Address" }) }),
12857
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
12959
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
12960
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
12858
12961
  ] }),
12859
- isReady && /* @__PURE__ */ jsxRuntime.jsx(ShippingAddressForm, { order })
12962
+ ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
12860
12963
  ] });
12861
12964
  };
12862
- const ShippingAddressForm = ({ order }) => {
12863
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12965
+ const SalesChannelForm = ({ order }) => {
12864
12966
  const form = reactHookForm.useForm({
12865
12967
  defaultValues: {
12866
- first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
12867
- last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
12868
- company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
12869
- address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
12870
- address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
12871
- city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
12872
- province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
12873
- country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
12874
- postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12875
- phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12968
+ sales_channel_id: order.sales_channel_id || ""
12876
12969
  },
12877
12970
  resolver: zod.zodResolver(schema)
12878
12971
  });
@@ -12881,21 +12974,11 @@ const ShippingAddressForm = ({ order }) => {
12881
12974
  const onSubmit = form.handleSubmit(async (data) => {
12882
12975
  await mutateAsync(
12883
12976
  {
12884
- shipping_address: {
12885
- first_name: data.first_name,
12886
- last_name: data.last_name,
12887
- company: data.company,
12888
- address_1: data.address_1,
12889
- address_2: data.address_2,
12890
- city: data.city,
12891
- province: data.province,
12892
- country_code: data.country_code,
12893
- postal_code: data.postal_code,
12894
- phone: data.phone
12895
- }
12977
+ sales_channel_id: data.sales_channel_id
12896
12978
  },
12897
12979
  {
12898
12980
  onSuccess: () => {
12981
+ ui.toast.success("Sales channel updated");
12899
12982
  handleSuccess();
12900
12983
  },
12901
12984
  onError: (error) => {
@@ -12910,132 +12993,7 @@ const ShippingAddressForm = ({ order }) => {
12910
12993
  className: "flex flex-1 flex-col overflow-hidden",
12911
12994
  onSubmit,
12912
12995
  children: [
12913
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-y-4", children: [
12914
- /* @__PURE__ */ jsxRuntime.jsx(
12915
- Form$2.Field,
12916
- {
12917
- control: form.control,
12918
- name: "country_code",
12919
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12920
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
12921
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
12922
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12923
- ] })
12924
- }
12925
- ),
12926
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12927
- /* @__PURE__ */ jsxRuntime.jsx(
12928
- Form$2.Field,
12929
- {
12930
- control: form.control,
12931
- name: "first_name",
12932
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12933
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
12934
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12935
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12936
- ] })
12937
- }
12938
- ),
12939
- /* @__PURE__ */ jsxRuntime.jsx(
12940
- Form$2.Field,
12941
- {
12942
- control: form.control,
12943
- name: "last_name",
12944
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12945
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
12946
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12947
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12948
- ] })
12949
- }
12950
- )
12951
- ] }),
12952
- /* @__PURE__ */ jsxRuntime.jsx(
12953
- Form$2.Field,
12954
- {
12955
- control: form.control,
12956
- name: "company",
12957
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12958
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
12959
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12960
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12961
- ] })
12962
- }
12963
- ),
12964
- /* @__PURE__ */ jsxRuntime.jsx(
12965
- Form$2.Field,
12966
- {
12967
- control: form.control,
12968
- name: "address_1",
12969
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12970
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
12971
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12972
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12973
- ] })
12974
- }
12975
- ),
12976
- /* @__PURE__ */ jsxRuntime.jsx(
12977
- Form$2.Field,
12978
- {
12979
- control: form.control,
12980
- name: "address_2",
12981
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12982
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
12983
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12984
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12985
- ] })
12986
- }
12987
- ),
12988
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12989
- /* @__PURE__ */ jsxRuntime.jsx(
12990
- Form$2.Field,
12991
- {
12992
- control: form.control,
12993
- name: "postal_code",
12994
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12995
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
12996
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12997
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12998
- ] })
12999
- }
13000
- ),
13001
- /* @__PURE__ */ jsxRuntime.jsx(
13002
- Form$2.Field,
13003
- {
13004
- control: form.control,
13005
- name: "city",
13006
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
13007
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
13008
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
13009
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
13010
- ] })
13011
- }
13012
- )
13013
- ] }),
13014
- /* @__PURE__ */ jsxRuntime.jsx(
13015
- Form$2.Field,
13016
- {
13017
- control: form.control,
13018
- name: "province",
13019
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
13020
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
13021
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
13022
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
13023
- ] })
13024
- }
13025
- ),
13026
- /* @__PURE__ */ jsxRuntime.jsx(
13027
- Form$2.Field,
13028
- {
13029
- control: form.control,
13030
- name: "phone",
13031
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
13032
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
13033
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
13034
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
13035
- ] })
13036
- }
13037
- )
13038
- ] }) }),
12996
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
13039
12997
  /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
13040
12998
  /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
13041
12999
  /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
@@ -13044,7 +13002,49 @@ const ShippingAddressForm = ({ order }) => {
13044
13002
  }
13045
13003
  ) });
13046
13004
  };
13047
- const schema = addressSchema;
13005
+ const SalesChannelField = ({ control, order }) => {
13006
+ const salesChannels = useComboboxData({
13007
+ queryFn: async (params) => {
13008
+ return await sdk.admin.salesChannel.list(params);
13009
+ },
13010
+ queryKey: ["sales-channels"],
13011
+ getOptions: (data) => {
13012
+ return data.sales_channels.map((salesChannel) => ({
13013
+ label: salesChannel.name,
13014
+ value: salesChannel.id
13015
+ }));
13016
+ },
13017
+ defaultValue: order.sales_channel_id || void 0
13018
+ });
13019
+ return /* @__PURE__ */ jsxRuntime.jsx(
13020
+ Form$2.Field,
13021
+ {
13022
+ control,
13023
+ name: "sales_channel_id",
13024
+ render: ({ field }) => {
13025
+ return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
13026
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
13027
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
13028
+ Combobox,
13029
+ {
13030
+ options: salesChannels.options,
13031
+ fetchNextPage: salesChannels.fetchNextPage,
13032
+ isFetchingNextPage: salesChannels.isFetchingNextPage,
13033
+ searchValue: salesChannels.searchValue,
13034
+ onSearchValueChange: salesChannels.onSearchValueChange,
13035
+ placeholder: "Select sales channel",
13036
+ ...field
13037
+ }
13038
+ ) }),
13039
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
13040
+ ] });
13041
+ }
13042
+ }
13043
+ );
13044
+ };
13045
+ const schema = objectType({
13046
+ sales_channel_id: stringType().min(1)
13047
+ });
13048
13048
  const widgetModule = { widgets: [] };
13049
13049
  const routeModule = {
13050
13050
  routes: [
@@ -13069,14 +13069,14 @@ const routeModule = {
13069
13069
  Component: BillingAddress,
13070
13070
  path: "/draft-orders/:id/billing-address"
13071
13071
  },
13072
- {
13073
- Component: CustomItems,
13074
- path: "/draft-orders/:id/custom-items"
13075
- },
13076
13072
  {
13077
13073
  Component: Email,
13078
13074
  path: "/draft-orders/:id/email"
13079
13075
  },
13076
+ {
13077
+ Component: CustomItems,
13078
+ path: "/draft-orders/:id/custom-items"
13079
+ },
13080
13080
  {
13081
13081
  Component: Items,
13082
13082
  path: "/draft-orders/:id/items"
@@ -13089,21 +13089,21 @@ const routeModule = {
13089
13089
  Component: Promotions,
13090
13090
  path: "/draft-orders/:id/promotions"
13091
13091
  },
13092
- {
13093
- Component: SalesChannel,
13094
- path: "/draft-orders/:id/sales-channel"
13095
- },
13096
13092
  {
13097
13093
  Component: Shipping,
13098
13094
  path: "/draft-orders/:id/shipping"
13099
13095
  },
13096
+ {
13097
+ Component: ShippingAddress,
13098
+ path: "/draft-orders/:id/shipping-address"
13099
+ },
13100
13100
  {
13101
13101
  Component: TransferOwnership,
13102
13102
  path: "/draft-orders/:id/transfer-ownership"
13103
13103
  },
13104
13104
  {
13105
- Component: ShippingAddress,
13106
- path: "/draft-orders/:id/shipping-address"
13105
+ Component: SalesChannel,
13106
+ path: "/draft-orders/:id/sales-channel"
13107
13107
  }
13108
13108
  ]
13109
13109
  }