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