@medusajs/draft-order 2.10.2-snapshot-20250902105826 → 2.10.2-snapshot-20250902112534

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.
@@ -9750,6 +9750,27 @@ const BillingAddressForm = ({ order }) => {
9750
9750
  ) });
9751
9751
  };
9752
9752
  const schema$5 = addressSchema;
9753
+ const CustomItems = () => {
9754
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9755
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
9756
+ /* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
9757
+ ] });
9758
+ };
9759
+ const CustomItemsForm = () => {
9760
+ const form = reactHookForm.useForm({
9761
+ resolver: zod.zodResolver(schema$4)
9762
+ });
9763
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9764
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
9765
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
9766
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9767
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
9768
+ ] }) })
9769
+ ] }) });
9770
+ };
9771
+ const schema$4 = objectType({
9772
+ email: stringType().email()
9773
+ });
9753
9774
  const Email = () => {
9754
9775
  const { id } = reactRouterDom.useParams();
9755
9776
  const { order, isPending, isError, error } = useOrder(id, {
@@ -9772,7 +9793,7 @@ const EmailForm = ({ order }) => {
9772
9793
  defaultValues: {
9773
9794
  email: order.email ?? ""
9774
9795
  },
9775
- resolver: zod.zodResolver(schema$4)
9796
+ resolver: zod.zodResolver(schema$3)
9776
9797
  });
9777
9798
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9778
9799
  const { handleSuccess } = useRouteModal();
@@ -9815,7 +9836,7 @@ const EmailForm = ({ order }) => {
9815
9836
  }
9816
9837
  ) });
9817
9838
  };
9818
- const schema$4 = objectType({
9839
+ const schema$3 = objectType({
9819
9840
  email: stringType().email()
9820
9841
  });
9821
9842
  const NumberInput = React.forwardRef(
@@ -11419,60 +11440,46 @@ function getPromotionCodes(items, shippingMethods) {
11419
11440
  }
11420
11441
  return Array.from(codes);
11421
11442
  }
11422
- const ShippingAddress = () => {
11443
+ const SalesChannel = () => {
11423
11444
  const { id } = reactRouterDom.useParams();
11424
- const { order, isPending, isError, error } = useOrder(id, {
11425
- fields: "+shipping_address"
11426
- });
11445
+ const { draft_order, isPending, isError, error } = useDraftOrder(
11446
+ id,
11447
+ {
11448
+ fields: "+sales_channel_id"
11449
+ },
11450
+ {
11451
+ enabled: !!id
11452
+ }
11453
+ );
11427
11454
  if (isError) {
11428
11455
  throw error;
11429
11456
  }
11430
- const isReady = !isPending && !!order;
11457
+ const ISrEADY = !!draft_order && !isPending;
11431
11458
  return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
11432
11459
  /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
11433
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Shipping Address" }) }),
11434
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
11460
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
11461
+ /* @__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" }) })
11435
11462
  ] }),
11436
- isReady && /* @__PURE__ */ jsxRuntime.jsx(ShippingAddressForm, { order })
11463
+ ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
11437
11464
  ] });
11438
11465
  };
11439
- const ShippingAddressForm = ({ order }) => {
11440
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
11466
+ const SalesChannelForm = ({ order }) => {
11441
11467
  const form = reactHookForm.useForm({
11442
11468
  defaultValues: {
11443
- first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
11444
- last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
11445
- company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
11446
- address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
11447
- address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
11448
- city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
11449
- province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
11450
- country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
11451
- postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
11452
- phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
11469
+ sales_channel_id: order.sales_channel_id || ""
11453
11470
  },
11454
- resolver: zod.zodResolver(schema$3)
11471
+ resolver: zod.zodResolver(schema$2)
11455
11472
  });
11456
11473
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11457
11474
  const { handleSuccess } = useRouteModal();
11458
11475
  const onSubmit = form.handleSubmit(async (data) => {
11459
11476
  await mutateAsync(
11460
11477
  {
11461
- shipping_address: {
11462
- first_name: data.first_name,
11463
- last_name: data.last_name,
11464
- company: data.company,
11465
- address_1: data.address_1,
11466
- address_2: data.address_2,
11467
- city: data.city,
11468
- province: data.province,
11469
- country_code: data.country_code,
11470
- postal_code: data.postal_code,
11471
- phone: data.phone
11472
- }
11478
+ sales_channel_id: data.sales_channel_id
11473
11479
  },
11474
11480
  {
11475
11481
  onSuccess: () => {
11482
+ ui.toast.success("Sales channel updated");
11476
11483
  handleSuccess();
11477
11484
  },
11478
11485
  onError: (error) => {
@@ -11487,132 +11494,7 @@ const ShippingAddressForm = ({ order }) => {
11487
11494
  className: "flex flex-1 flex-col overflow-hidden",
11488
11495
  onSubmit,
11489
11496
  children: [
11490
- /* @__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: [
11491
- /* @__PURE__ */ jsxRuntime.jsx(
11492
- Form$2.Field,
11493
- {
11494
- control: form.control,
11495
- name: "country_code",
11496
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11497
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
11498
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
11499
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11500
- ] })
11501
- }
11502
- ),
11503
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
11504
- /* @__PURE__ */ jsxRuntime.jsx(
11505
- Form$2.Field,
11506
- {
11507
- control: form.control,
11508
- name: "first_name",
11509
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11510
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
11511
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11512
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11513
- ] })
11514
- }
11515
- ),
11516
- /* @__PURE__ */ jsxRuntime.jsx(
11517
- Form$2.Field,
11518
- {
11519
- control: form.control,
11520
- name: "last_name",
11521
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11522
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
11523
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11524
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11525
- ] })
11526
- }
11527
- )
11528
- ] }),
11529
- /* @__PURE__ */ jsxRuntime.jsx(
11530
- Form$2.Field,
11531
- {
11532
- control: form.control,
11533
- name: "company",
11534
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11535
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
11536
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11537
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11538
- ] })
11539
- }
11540
- ),
11541
- /* @__PURE__ */ jsxRuntime.jsx(
11542
- Form$2.Field,
11543
- {
11544
- control: form.control,
11545
- name: "address_1",
11546
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11547
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
11548
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11549
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11550
- ] })
11551
- }
11552
- ),
11553
- /* @__PURE__ */ jsxRuntime.jsx(
11554
- Form$2.Field,
11555
- {
11556
- control: form.control,
11557
- name: "address_2",
11558
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11559
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
11560
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11561
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11562
- ] })
11563
- }
11564
- ),
11565
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
11566
- /* @__PURE__ */ jsxRuntime.jsx(
11567
- Form$2.Field,
11568
- {
11569
- control: form.control,
11570
- name: "postal_code",
11571
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11572
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
11573
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11574
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11575
- ] })
11576
- }
11577
- ),
11578
- /* @__PURE__ */ jsxRuntime.jsx(
11579
- Form$2.Field,
11580
- {
11581
- control: form.control,
11582
- name: "city",
11583
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11584
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
11585
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11586
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11587
- ] })
11588
- }
11589
- )
11590
- ] }),
11591
- /* @__PURE__ */ jsxRuntime.jsx(
11592
- Form$2.Field,
11593
- {
11594
- control: form.control,
11595
- name: "province",
11596
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11597
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
11598
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11599
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11600
- ] })
11601
- }
11602
- ),
11603
- /* @__PURE__ */ jsxRuntime.jsx(
11604
- Form$2.Field,
11605
- {
11606
- control: form.control,
11607
- name: "phone",
11608
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11609
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
11610
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11611
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11612
- ] })
11613
- }
11614
- )
11615
- ] }) }),
11497
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
11616
11498
  /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
11617
11499
  /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11618
11500
  /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
@@ -11621,7 +11503,49 @@ const ShippingAddressForm = ({ order }) => {
11621
11503
  }
11622
11504
  ) });
11623
11505
  };
11624
- const schema$3 = addressSchema;
11506
+ const SalesChannelField = ({ control, order }) => {
11507
+ const salesChannels = useComboboxData({
11508
+ queryFn: async (params) => {
11509
+ return await sdk.admin.salesChannel.list(params);
11510
+ },
11511
+ queryKey: ["sales-channels"],
11512
+ getOptions: (data) => {
11513
+ return data.sales_channels.map((salesChannel) => ({
11514
+ label: salesChannel.name,
11515
+ value: salesChannel.id
11516
+ }));
11517
+ },
11518
+ defaultValue: order.sales_channel_id || void 0
11519
+ });
11520
+ return /* @__PURE__ */ jsxRuntime.jsx(
11521
+ Form$2.Field,
11522
+ {
11523
+ control,
11524
+ name: "sales_channel_id",
11525
+ render: ({ field }) => {
11526
+ return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11527
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
11528
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
11529
+ Combobox,
11530
+ {
11531
+ options: salesChannels.options,
11532
+ fetchNextPage: salesChannels.fetchNextPage,
11533
+ isFetchingNextPage: salesChannels.isFetchingNextPage,
11534
+ searchValue: salesChannels.searchValue,
11535
+ onSearchValueChange: salesChannels.onSearchValueChange,
11536
+ placeholder: "Select sales channel",
11537
+ ...field
11538
+ }
11539
+ ) }),
11540
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11541
+ ] });
11542
+ }
11543
+ }
11544
+ );
11545
+ };
11546
+ const schema$2 = objectType({
11547
+ sales_channel_id: stringType().min(1)
11548
+ });
11625
11549
  const STACKED_FOCUS_MODAL_ID = "shipping-form";
11626
11550
  const Shipping = () => {
11627
11551
  var _a;
@@ -12429,19 +12353,222 @@ const CustomAmountField = ({
12429
12353
  }
12430
12354
  );
12431
12355
  };
12432
- const TransferOwnership = () => {
12356
+ const ShippingAddress = () => {
12433
12357
  const { id } = reactRouterDom.useParams();
12434
- const { draft_order, isPending, isError, error } = useDraftOrder(id, {
12435
- fields: "id,customer_id,customer.*"
12358
+ const { order, isPending, isError, error } = useOrder(id, {
12359
+ fields: "+shipping_address"
12436
12360
  });
12437
12361
  if (isError) {
12438
12362
  throw error;
12439
12363
  }
12440
- const isReady = !isPending && !!draft_order;
12364
+ const isReady = !isPending && !!order;
12441
12365
  return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12442
12366
  /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
12443
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Transfer Ownership" }) }),
12444
- /* @__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" }) })
12367
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Shipping Address" }) }),
12368
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
12369
+ ] }),
12370
+ isReady && /* @__PURE__ */ jsxRuntime.jsx(ShippingAddressForm, { order })
12371
+ ] });
12372
+ };
12373
+ const ShippingAddressForm = ({ order }) => {
12374
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12375
+ const form = reactHookForm.useForm({
12376
+ defaultValues: {
12377
+ first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
12378
+ last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
12379
+ company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
12380
+ address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
12381
+ address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
12382
+ city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
12383
+ province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
12384
+ country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
12385
+ postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12386
+ phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12387
+ },
12388
+ resolver: zod.zodResolver(schema$1)
12389
+ });
12390
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12391
+ const { handleSuccess } = useRouteModal();
12392
+ const onSubmit = form.handleSubmit(async (data) => {
12393
+ await mutateAsync(
12394
+ {
12395
+ shipping_address: {
12396
+ first_name: data.first_name,
12397
+ last_name: data.last_name,
12398
+ company: data.company,
12399
+ address_1: data.address_1,
12400
+ address_2: data.address_2,
12401
+ city: data.city,
12402
+ province: data.province,
12403
+ country_code: data.country_code,
12404
+ postal_code: data.postal_code,
12405
+ phone: data.phone
12406
+ }
12407
+ },
12408
+ {
12409
+ onSuccess: () => {
12410
+ handleSuccess();
12411
+ },
12412
+ onError: (error) => {
12413
+ ui.toast.error(error.message);
12414
+ }
12415
+ }
12416
+ );
12417
+ });
12418
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
12419
+ KeyboundForm,
12420
+ {
12421
+ className: "flex flex-1 flex-col overflow-hidden",
12422
+ onSubmit,
12423
+ children: [
12424
+ /* @__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: [
12425
+ /* @__PURE__ */ jsxRuntime.jsx(
12426
+ Form$2.Field,
12427
+ {
12428
+ control: form.control,
12429
+ name: "country_code",
12430
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12431
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
12432
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
12433
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12434
+ ] })
12435
+ }
12436
+ ),
12437
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12438
+ /* @__PURE__ */ jsxRuntime.jsx(
12439
+ Form$2.Field,
12440
+ {
12441
+ control: form.control,
12442
+ name: "first_name",
12443
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12444
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
12445
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12446
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12447
+ ] })
12448
+ }
12449
+ ),
12450
+ /* @__PURE__ */ jsxRuntime.jsx(
12451
+ Form$2.Field,
12452
+ {
12453
+ control: form.control,
12454
+ name: "last_name",
12455
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12456
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
12457
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12458
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12459
+ ] })
12460
+ }
12461
+ )
12462
+ ] }),
12463
+ /* @__PURE__ */ jsxRuntime.jsx(
12464
+ Form$2.Field,
12465
+ {
12466
+ control: form.control,
12467
+ name: "company",
12468
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12469
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
12470
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12471
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12472
+ ] })
12473
+ }
12474
+ ),
12475
+ /* @__PURE__ */ jsxRuntime.jsx(
12476
+ Form$2.Field,
12477
+ {
12478
+ control: form.control,
12479
+ name: "address_1",
12480
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12481
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
12482
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12483
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12484
+ ] })
12485
+ }
12486
+ ),
12487
+ /* @__PURE__ */ jsxRuntime.jsx(
12488
+ Form$2.Field,
12489
+ {
12490
+ control: form.control,
12491
+ name: "address_2",
12492
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12493
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
12494
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12495
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12496
+ ] })
12497
+ }
12498
+ ),
12499
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12500
+ /* @__PURE__ */ jsxRuntime.jsx(
12501
+ Form$2.Field,
12502
+ {
12503
+ control: form.control,
12504
+ name: "postal_code",
12505
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12506
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
12507
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12508
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12509
+ ] })
12510
+ }
12511
+ ),
12512
+ /* @__PURE__ */ jsxRuntime.jsx(
12513
+ Form$2.Field,
12514
+ {
12515
+ control: form.control,
12516
+ name: "city",
12517
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12518
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
12519
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12520
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12521
+ ] })
12522
+ }
12523
+ )
12524
+ ] }),
12525
+ /* @__PURE__ */ jsxRuntime.jsx(
12526
+ Form$2.Field,
12527
+ {
12528
+ control: form.control,
12529
+ name: "province",
12530
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12531
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
12532
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12533
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12534
+ ] })
12535
+ }
12536
+ ),
12537
+ /* @__PURE__ */ jsxRuntime.jsx(
12538
+ Form$2.Field,
12539
+ {
12540
+ control: form.control,
12541
+ name: "phone",
12542
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12543
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
12544
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12545
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12546
+ ] })
12547
+ }
12548
+ )
12549
+ ] }) }),
12550
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
12551
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12552
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12553
+ ] }) })
12554
+ ]
12555
+ }
12556
+ ) });
12557
+ };
12558
+ const schema$1 = addressSchema;
12559
+ const TransferOwnership = () => {
12560
+ const { id } = reactRouterDom.useParams();
12561
+ const { draft_order, isPending, isError, error } = useDraftOrder(id, {
12562
+ fields: "id,customer_id,customer.*"
12563
+ });
12564
+ if (isError) {
12565
+ throw error;
12566
+ }
12567
+ const isReady = !isPending && !!draft_order;
12568
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12569
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
12570
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Transfer Ownership" }) }),
12571
+ /* @__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" }) })
12445
12572
  ] }),
12446
12573
  isReady && /* @__PURE__ */ jsxRuntime.jsx(TransferOwnershipForm, { order: draft_order })
12447
12574
  ] });
@@ -12452,7 +12579,7 @@ const TransferOwnershipForm = ({ order }) => {
12452
12579
  defaultValues: {
12453
12580
  customer_id: order.customer_id || ""
12454
12581
  },
12455
- resolver: zod.zodResolver(schema$2)
12582
+ resolver: zod.zodResolver(schema)
12456
12583
  });
12457
12584
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12458
12585
  const { handleSuccess } = useRouteModal();
@@ -12902,135 +13029,8 @@ const Illustration = () => {
12902
13029
  }
12903
13030
  );
12904
13031
  };
12905
- const schema$2 = objectType({
12906
- customer_id: stringType().min(1)
12907
- });
12908
- const CustomItems = () => {
12909
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12910
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
12911
- /* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
12912
- ] });
12913
- };
12914
- const CustomItemsForm = () => {
12915
- const form = reactHookForm.useForm({
12916
- resolver: zod.zodResolver(schema$1)
12917
- });
12918
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
12919
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
12920
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
12921
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12922
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
12923
- ] }) })
12924
- ] }) });
12925
- };
12926
- const schema$1 = objectType({
12927
- email: stringType().email()
12928
- });
12929
- const SalesChannel = () => {
12930
- const { id } = reactRouterDom.useParams();
12931
- const { draft_order, isPending, isError, error } = useDraftOrder(
12932
- id,
12933
- {
12934
- fields: "+sales_channel_id"
12935
- },
12936
- {
12937
- enabled: !!id
12938
- }
12939
- );
12940
- if (isError) {
12941
- throw error;
12942
- }
12943
- const ISrEADY = !!draft_order && !isPending;
12944
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12945
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
12946
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
12947
- /* @__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" }) })
12948
- ] }),
12949
- ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
12950
- ] });
12951
- };
12952
- const SalesChannelForm = ({ order }) => {
12953
- const form = reactHookForm.useForm({
12954
- defaultValues: {
12955
- sales_channel_id: order.sales_channel_id || ""
12956
- },
12957
- resolver: zod.zodResolver(schema)
12958
- });
12959
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12960
- const { handleSuccess } = useRouteModal();
12961
- const onSubmit = form.handleSubmit(async (data) => {
12962
- await mutateAsync(
12963
- {
12964
- sales_channel_id: data.sales_channel_id
12965
- },
12966
- {
12967
- onSuccess: () => {
12968
- ui.toast.success("Sales channel updated");
12969
- handleSuccess();
12970
- },
12971
- onError: (error) => {
12972
- ui.toast.error(error.message);
12973
- }
12974
- }
12975
- );
12976
- });
12977
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
12978
- KeyboundForm,
12979
- {
12980
- className: "flex flex-1 flex-col overflow-hidden",
12981
- onSubmit,
12982
- children: [
12983
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
12984
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
12985
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12986
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12987
- ] }) })
12988
- ]
12989
- }
12990
- ) });
12991
- };
12992
- const SalesChannelField = ({ control, order }) => {
12993
- const salesChannels = useComboboxData({
12994
- queryFn: async (params) => {
12995
- return await sdk.admin.salesChannel.list(params);
12996
- },
12997
- queryKey: ["sales-channels"],
12998
- getOptions: (data) => {
12999
- return data.sales_channels.map((salesChannel) => ({
13000
- label: salesChannel.name,
13001
- value: salesChannel.id
13002
- }));
13003
- },
13004
- defaultValue: order.sales_channel_id || void 0
13005
- });
13006
- return /* @__PURE__ */ jsxRuntime.jsx(
13007
- Form$2.Field,
13008
- {
13009
- control,
13010
- name: "sales_channel_id",
13011
- render: ({ field }) => {
13012
- return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
13013
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
13014
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
13015
- Combobox,
13016
- {
13017
- options: salesChannels.options,
13018
- fetchNextPage: salesChannels.fetchNextPage,
13019
- isFetchingNextPage: salesChannels.isFetchingNextPage,
13020
- searchValue: salesChannels.searchValue,
13021
- onSearchValueChange: salesChannels.onSearchValueChange,
13022
- placeholder: "Select sales channel",
13023
- ...field
13024
- }
13025
- ) }),
13026
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
13027
- ] });
13028
- }
13029
- }
13030
- );
13031
- };
13032
13032
  const schema = objectType({
13033
- sales_channel_id: stringType().min(1)
13033
+ customer_id: stringType().min(1)
13034
13034
  });
13035
13035
  const widgetModule = { widgets: [] };
13036
13036
  const routeModule = {
@@ -13056,6 +13056,10 @@ const routeModule = {
13056
13056
  Component: BillingAddress,
13057
13057
  path: "/draft-orders/:id/billing-address"
13058
13058
  },
13059
+ {
13060
+ Component: CustomItems,
13061
+ path: "/draft-orders/:id/custom-items"
13062
+ },
13059
13063
  {
13060
13064
  Component: Email,
13061
13065
  path: "/draft-orders/:id/email"
@@ -13073,24 +13077,20 @@ const routeModule = {
13073
13077
  path: "/draft-orders/:id/promotions"
13074
13078
  },
13075
13079
  {
13076
- Component: ShippingAddress,
13077
- path: "/draft-orders/:id/shipping-address"
13080
+ Component: SalesChannel,
13081
+ path: "/draft-orders/:id/sales-channel"
13078
13082
  },
13079
13083
  {
13080
13084
  Component: Shipping,
13081
13085
  path: "/draft-orders/:id/shipping"
13082
13086
  },
13083
13087
  {
13084
- Component: TransferOwnership,
13085
- path: "/draft-orders/:id/transfer-ownership"
13086
- },
13087
- {
13088
- Component: CustomItems,
13089
- path: "/draft-orders/:id/custom-items"
13088
+ Component: ShippingAddress,
13089
+ path: "/draft-orders/:id/shipping-address"
13090
13090
  },
13091
13091
  {
13092
- Component: SalesChannel,
13093
- path: "/draft-orders/:id/sales-channel"
13092
+ Component: TransferOwnership,
13093
+ path: "/draft-orders/:id/transfer-ownership"
13094
13094
  }
13095
13095
  ]
13096
13096
  }