@medusajs/draft-order 2.10.4-snapshot-20251009080820 → 2.10.4-snapshot-20251009122659

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.
@@ -9757,27 +9757,6 @@ const BillingAddressForm = ({ order }) => {
9757
9757
  ) });
9758
9758
  };
9759
9759
  const schema$5 = addressSchema;
9760
- const CustomItems = () => {
9761
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
9762
- /* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
9763
- /* @__PURE__ */ jsx(CustomItemsForm, {})
9764
- ] });
9765
- };
9766
- const CustomItemsForm = () => {
9767
- const form = useForm({
9768
- resolver: zodResolver(schema$4)
9769
- });
9770
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9771
- /* @__PURE__ */ jsx(RouteDrawer.Body, {}),
9772
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
9773
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9774
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
9775
- ] }) })
9776
- ] }) });
9777
- };
9778
- const schema$4 = objectType({
9779
- email: stringType().email()
9780
- });
9781
9760
  const Email = () => {
9782
9761
  const { id } = useParams();
9783
9762
  const { order, isPending, isError, error } = useOrder(id, {
@@ -9800,7 +9779,7 @@ const EmailForm = ({ order }) => {
9800
9779
  defaultValues: {
9801
9780
  email: order.email ?? ""
9802
9781
  },
9803
- resolver: zodResolver(schema$3)
9782
+ resolver: zodResolver(schema$4)
9804
9783
  });
9805
9784
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9806
9785
  const { handleSuccess } = useRouteModal();
@@ -9843,7 +9822,7 @@ const EmailForm = ({ order }) => {
9843
9822
  }
9844
9823
  ) });
9845
9824
  };
9846
- const schema$3 = objectType({
9825
+ const schema$4 = objectType({
9847
9826
  email: stringType().email()
9848
9827
  });
9849
9828
  const NumberInput = forwardRef(
@@ -11447,60 +11426,46 @@ function getPromotionIds(items, shippingMethods) {
11447
11426
  }
11448
11427
  return Array.from(promotionIds);
11449
11428
  }
11450
- const ShippingAddress = () => {
11429
+ const SalesChannel = () => {
11451
11430
  const { id } = useParams();
11452
- const { order, isPending, isError, error } = useOrder(id, {
11453
- fields: "+shipping_address"
11454
- });
11431
+ const { draft_order, isPending, isError, error } = useDraftOrder(
11432
+ id,
11433
+ {
11434
+ fields: "+sales_channel_id"
11435
+ },
11436
+ {
11437
+ enabled: !!id
11438
+ }
11439
+ );
11455
11440
  if (isError) {
11456
11441
  throw error;
11457
11442
  }
11458
- const isReady = !isPending && !!order;
11443
+ const ISrEADY = !!draft_order && !isPending;
11459
11444
  return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
11460
11445
  /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
11461
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Shipping Address" }) }),
11462
- /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
11446
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
11447
+ /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
11463
11448
  ] }),
11464
- isReady && /* @__PURE__ */ jsx(ShippingAddressForm, { order })
11449
+ ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
11465
11450
  ] });
11466
11451
  };
11467
- const ShippingAddressForm = ({ order }) => {
11468
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
11452
+ const SalesChannelForm = ({ order }) => {
11469
11453
  const form = useForm({
11470
11454
  defaultValues: {
11471
- first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
11472
- last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
11473
- company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
11474
- address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
11475
- address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
11476
- city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
11477
- province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
11478
- country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
11479
- postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
11480
- phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
11455
+ sales_channel_id: order.sales_channel_id || ""
11481
11456
  },
11482
- resolver: zodResolver(schema$2)
11457
+ resolver: zodResolver(schema$3)
11483
11458
  });
11484
11459
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11485
11460
  const { handleSuccess } = useRouteModal();
11486
11461
  const onSubmit = form.handleSubmit(async (data) => {
11487
11462
  await mutateAsync(
11488
11463
  {
11489
- shipping_address: {
11490
- first_name: data.first_name,
11491
- last_name: data.last_name,
11492
- company: data.company,
11493
- address_1: data.address_1,
11494
- address_2: data.address_2,
11495
- city: data.city,
11496
- province: data.province,
11497
- country_code: data.country_code,
11498
- postal_code: data.postal_code,
11499
- phone: data.phone
11500
- }
11464
+ sales_channel_id: data.sales_channel_id
11501
11465
  },
11502
11466
  {
11503
11467
  onSuccess: () => {
11468
+ toast.success("Sales channel updated");
11504
11469
  handleSuccess();
11505
11470
  },
11506
11471
  onError: (error) => {
@@ -11515,132 +11480,7 @@ const ShippingAddressForm = ({ order }) => {
11515
11480
  className: "flex flex-1 flex-col overflow-hidden",
11516
11481
  onSubmit,
11517
11482
  children: [
11518
- /* @__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: [
11519
- /* @__PURE__ */ jsx(
11520
- Form$2.Field,
11521
- {
11522
- control: form.control,
11523
- name: "country_code",
11524
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11525
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
11526
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
11527
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11528
- ] })
11529
- }
11530
- ),
11531
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
11532
- /* @__PURE__ */ jsx(
11533
- Form$2.Field,
11534
- {
11535
- control: form.control,
11536
- name: "first_name",
11537
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11538
- /* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
11539
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11540
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11541
- ] })
11542
- }
11543
- ),
11544
- /* @__PURE__ */ jsx(
11545
- Form$2.Field,
11546
- {
11547
- control: form.control,
11548
- name: "last_name",
11549
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11550
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
11551
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11552
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11553
- ] })
11554
- }
11555
- )
11556
- ] }),
11557
- /* @__PURE__ */ jsx(
11558
- Form$2.Field,
11559
- {
11560
- control: form.control,
11561
- name: "company",
11562
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11563
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
11564
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11565
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11566
- ] })
11567
- }
11568
- ),
11569
- /* @__PURE__ */ jsx(
11570
- Form$2.Field,
11571
- {
11572
- control: form.control,
11573
- name: "address_1",
11574
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11575
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
11576
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11577
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11578
- ] })
11579
- }
11580
- ),
11581
- /* @__PURE__ */ jsx(
11582
- Form$2.Field,
11583
- {
11584
- control: form.control,
11585
- name: "address_2",
11586
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11587
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
11588
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11589
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11590
- ] })
11591
- }
11592
- ),
11593
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
11594
- /* @__PURE__ */ jsx(
11595
- Form$2.Field,
11596
- {
11597
- control: form.control,
11598
- name: "postal_code",
11599
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11600
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
11601
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11602
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11603
- ] })
11604
- }
11605
- ),
11606
- /* @__PURE__ */ jsx(
11607
- Form$2.Field,
11608
- {
11609
- control: form.control,
11610
- name: "city",
11611
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11612
- /* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
11613
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11614
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11615
- ] })
11616
- }
11617
- )
11618
- ] }),
11619
- /* @__PURE__ */ jsx(
11620
- Form$2.Field,
11621
- {
11622
- control: form.control,
11623
- name: "province",
11624
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11625
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
11626
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11627
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11628
- ] })
11629
- }
11630
- ),
11631
- /* @__PURE__ */ jsx(
11632
- Form$2.Field,
11633
- {
11634
- control: form.control,
11635
- name: "phone",
11636
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11637
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
11638
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11639
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11640
- ] })
11641
- }
11642
- )
11643
- ] }) }),
11483
+ /* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
11644
11484
  /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
11645
11485
  /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11646
11486
  /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
@@ -11649,7 +11489,49 @@ const ShippingAddressForm = ({ order }) => {
11649
11489
  }
11650
11490
  ) });
11651
11491
  };
11652
- const schema$2 = addressSchema;
11492
+ const SalesChannelField = ({ control, order }) => {
11493
+ const salesChannels = useComboboxData({
11494
+ queryFn: async (params) => {
11495
+ return await sdk.admin.salesChannel.list(params);
11496
+ },
11497
+ queryKey: ["sales-channels"],
11498
+ getOptions: (data) => {
11499
+ return data.sales_channels.map((salesChannel) => ({
11500
+ label: salesChannel.name,
11501
+ value: salesChannel.id
11502
+ }));
11503
+ },
11504
+ defaultValue: order.sales_channel_id || void 0
11505
+ });
11506
+ return /* @__PURE__ */ jsx(
11507
+ Form$2.Field,
11508
+ {
11509
+ control,
11510
+ name: "sales_channel_id",
11511
+ render: ({ field }) => {
11512
+ return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11513
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
11514
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
11515
+ Combobox,
11516
+ {
11517
+ options: salesChannels.options,
11518
+ fetchNextPage: salesChannels.fetchNextPage,
11519
+ isFetchingNextPage: salesChannels.isFetchingNextPage,
11520
+ searchValue: salesChannels.searchValue,
11521
+ onSearchValueChange: salesChannels.onSearchValueChange,
11522
+ placeholder: "Select sales channel",
11523
+ ...field
11524
+ }
11525
+ ) }),
11526
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11527
+ ] });
11528
+ }
11529
+ }
11530
+ );
11531
+ };
11532
+ const schema$3 = objectType({
11533
+ sales_channel_id: stringType().min(1)
11534
+ });
11653
11535
  const STACKED_FOCUS_MODAL_ID = "shipping-form";
11654
11536
  const Shipping = () => {
11655
11537
  var _a;
@@ -12457,46 +12339,60 @@ const CustomAmountField = ({
12457
12339
  }
12458
12340
  );
12459
12341
  };
12460
- const SalesChannel = () => {
12342
+ const ShippingAddress = () => {
12461
12343
  const { id } = useParams();
12462
- const { draft_order, isPending, isError, error } = useDraftOrder(
12463
- id,
12464
- {
12465
- fields: "+sales_channel_id"
12466
- },
12467
- {
12468
- enabled: !!id
12469
- }
12470
- );
12344
+ const { order, isPending, isError, error } = useOrder(id, {
12345
+ fields: "+shipping_address"
12346
+ });
12471
12347
  if (isError) {
12472
12348
  throw error;
12473
12349
  }
12474
- const ISrEADY = !!draft_order && !isPending;
12350
+ const isReady = !isPending && !!order;
12475
12351
  return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
12476
12352
  /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
12477
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
12478
- /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
12353
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Shipping Address" }) }),
12354
+ /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
12479
12355
  ] }),
12480
- ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
12356
+ isReady && /* @__PURE__ */ jsx(ShippingAddressForm, { order })
12481
12357
  ] });
12482
12358
  };
12483
- const SalesChannelForm = ({ order }) => {
12359
+ const ShippingAddressForm = ({ order }) => {
12360
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12484
12361
  const form = useForm({
12485
12362
  defaultValues: {
12486
- sales_channel_id: order.sales_channel_id || ""
12363
+ first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
12364
+ last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
12365
+ company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
12366
+ address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
12367
+ address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
12368
+ city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
12369
+ province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
12370
+ country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
12371
+ postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12372
+ phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12487
12373
  },
12488
- resolver: zodResolver(schema$1)
12374
+ resolver: zodResolver(schema$2)
12489
12375
  });
12490
12376
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12491
12377
  const { handleSuccess } = useRouteModal();
12492
12378
  const onSubmit = form.handleSubmit(async (data) => {
12493
12379
  await mutateAsync(
12494
12380
  {
12495
- sales_channel_id: data.sales_channel_id
12381
+ shipping_address: {
12382
+ first_name: data.first_name,
12383
+ last_name: data.last_name,
12384
+ company: data.company,
12385
+ address_1: data.address_1,
12386
+ address_2: data.address_2,
12387
+ city: data.city,
12388
+ province: data.province,
12389
+ country_code: data.country_code,
12390
+ postal_code: data.postal_code,
12391
+ phone: data.phone
12392
+ }
12496
12393
  },
12497
12394
  {
12498
12395
  onSuccess: () => {
12499
- toast.success("Sales channel updated");
12500
12396
  handleSuccess();
12501
12397
  },
12502
12398
  onError: (error) => {
@@ -12511,7 +12407,132 @@ const SalesChannelForm = ({ order }) => {
12511
12407
  className: "flex flex-1 flex-col overflow-hidden",
12512
12408
  onSubmit,
12513
12409
  children: [
12514
- /* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
12410
+ /* @__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: [
12411
+ /* @__PURE__ */ jsx(
12412
+ Form$2.Field,
12413
+ {
12414
+ control: form.control,
12415
+ name: "country_code",
12416
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12417
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
12418
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
12419
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12420
+ ] })
12421
+ }
12422
+ ),
12423
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12424
+ /* @__PURE__ */ jsx(
12425
+ Form$2.Field,
12426
+ {
12427
+ control: form.control,
12428
+ name: "first_name",
12429
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12430
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
12431
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12432
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12433
+ ] })
12434
+ }
12435
+ ),
12436
+ /* @__PURE__ */ jsx(
12437
+ Form$2.Field,
12438
+ {
12439
+ control: form.control,
12440
+ name: "last_name",
12441
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12442
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
12443
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12444
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12445
+ ] })
12446
+ }
12447
+ )
12448
+ ] }),
12449
+ /* @__PURE__ */ jsx(
12450
+ Form$2.Field,
12451
+ {
12452
+ control: form.control,
12453
+ name: "company",
12454
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12455
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
12456
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12457
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12458
+ ] })
12459
+ }
12460
+ ),
12461
+ /* @__PURE__ */ jsx(
12462
+ Form$2.Field,
12463
+ {
12464
+ control: form.control,
12465
+ name: "address_1",
12466
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12467
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
12468
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12469
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12470
+ ] })
12471
+ }
12472
+ ),
12473
+ /* @__PURE__ */ jsx(
12474
+ Form$2.Field,
12475
+ {
12476
+ control: form.control,
12477
+ name: "address_2",
12478
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12479
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
12480
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12481
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12482
+ ] })
12483
+ }
12484
+ ),
12485
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12486
+ /* @__PURE__ */ jsx(
12487
+ Form$2.Field,
12488
+ {
12489
+ control: form.control,
12490
+ name: "postal_code",
12491
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12492
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
12493
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12494
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12495
+ ] })
12496
+ }
12497
+ ),
12498
+ /* @__PURE__ */ jsx(
12499
+ Form$2.Field,
12500
+ {
12501
+ control: form.control,
12502
+ name: "city",
12503
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12504
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
12505
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12506
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12507
+ ] })
12508
+ }
12509
+ )
12510
+ ] }),
12511
+ /* @__PURE__ */ jsx(
12512
+ Form$2.Field,
12513
+ {
12514
+ control: form.control,
12515
+ name: "province",
12516
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12517
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
12518
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12519
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12520
+ ] })
12521
+ }
12522
+ ),
12523
+ /* @__PURE__ */ jsx(
12524
+ Form$2.Field,
12525
+ {
12526
+ control: form.control,
12527
+ name: "phone",
12528
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12529
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
12530
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12531
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12532
+ ] })
12533
+ }
12534
+ )
12535
+ ] }) }),
12515
12536
  /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
12516
12537
  /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12517
12538
  /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
@@ -12520,49 +12541,7 @@ const SalesChannelForm = ({ order }) => {
12520
12541
  }
12521
12542
  ) });
12522
12543
  };
12523
- const SalesChannelField = ({ control, order }) => {
12524
- const salesChannels = useComboboxData({
12525
- queryFn: async (params) => {
12526
- return await sdk.admin.salesChannel.list(params);
12527
- },
12528
- queryKey: ["sales-channels"],
12529
- getOptions: (data) => {
12530
- return data.sales_channels.map((salesChannel) => ({
12531
- label: salesChannel.name,
12532
- value: salesChannel.id
12533
- }));
12534
- },
12535
- defaultValue: order.sales_channel_id || void 0
12536
- });
12537
- return /* @__PURE__ */ jsx(
12538
- Form$2.Field,
12539
- {
12540
- control,
12541
- name: "sales_channel_id",
12542
- render: ({ field }) => {
12543
- return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12544
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
12545
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
12546
- Combobox,
12547
- {
12548
- options: salesChannels.options,
12549
- fetchNextPage: salesChannels.fetchNextPage,
12550
- isFetchingNextPage: salesChannels.isFetchingNextPage,
12551
- searchValue: salesChannels.searchValue,
12552
- onSearchValueChange: salesChannels.onSearchValueChange,
12553
- placeholder: "Select sales channel",
12554
- ...field
12555
- }
12556
- ) }),
12557
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12558
- ] });
12559
- }
12560
- }
12561
- );
12562
- };
12563
- const schema$1 = objectType({
12564
- sales_channel_id: stringType().min(1)
12565
- });
12544
+ const schema$2 = addressSchema;
12566
12545
  const TransferOwnership = () => {
12567
12546
  const { id } = useParams();
12568
12547
  const { draft_order, isPending, isError, error } = useDraftOrder(id, {
@@ -12586,7 +12565,7 @@ const TransferOwnershipForm = ({ order }) => {
12586
12565
  defaultValues: {
12587
12566
  customer_id: order.customer_id || ""
12588
12567
  },
12589
- resolver: zodResolver(schema)
12568
+ resolver: zodResolver(schema$1)
12590
12569
  });
12591
12570
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12592
12571
  const { handleSuccess } = useRouteModal();
@@ -13036,9 +13015,30 @@ const Illustration = () => {
13036
13015
  }
13037
13016
  );
13038
13017
  };
13039
- const schema = objectType({
13018
+ const schema$1 = objectType({
13040
13019
  customer_id: stringType().min(1)
13041
13020
  });
13021
+ const CustomItems = () => {
13022
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
13023
+ /* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
13024
+ /* @__PURE__ */ jsx(CustomItemsForm, {})
13025
+ ] });
13026
+ };
13027
+ const CustomItemsForm = () => {
13028
+ const form = useForm({
13029
+ resolver: zodResolver(schema)
13030
+ });
13031
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
13032
+ /* @__PURE__ */ jsx(RouteDrawer.Body, {}),
13033
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
13034
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
13035
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
13036
+ ] }) })
13037
+ ] }) });
13038
+ };
13039
+ const schema = objectType({
13040
+ email: stringType().email()
13041
+ });
13042
13042
  const widgetModule = { widgets: [] };
13043
13043
  const routeModule = {
13044
13044
  routes: [
@@ -13063,10 +13063,6 @@ const routeModule = {
13063
13063
  Component: BillingAddress,
13064
13064
  path: "/draft-orders/:id/billing-address"
13065
13065
  },
13066
- {
13067
- Component: CustomItems,
13068
- path: "/draft-orders/:id/custom-items"
13069
- },
13070
13066
  {
13071
13067
  Component: Email,
13072
13068
  path: "/draft-orders/:id/email"
@@ -13084,20 +13080,24 @@ const routeModule = {
13084
13080
  path: "/draft-orders/:id/promotions"
13085
13081
  },
13086
13082
  {
13087
- Component: ShippingAddress,
13088
- path: "/draft-orders/:id/shipping-address"
13083
+ Component: SalesChannel,
13084
+ path: "/draft-orders/:id/sales-channel"
13089
13085
  },
13090
13086
  {
13091
13087
  Component: Shipping,
13092
13088
  path: "/draft-orders/:id/shipping"
13093
13089
  },
13094
13090
  {
13095
- Component: SalesChannel,
13096
- path: "/draft-orders/:id/sales-channel"
13091
+ Component: ShippingAddress,
13092
+ path: "/draft-orders/:id/shipping-address"
13097
13093
  },
13098
13094
  {
13099
13095
  Component: TransferOwnership,
13100
13096
  path: "/draft-orders/:id/transfer-ownership"
13097
+ },
13098
+ {
13099
+ Component: CustomItems,
13100
+ path: "/draft-orders/:id/custom-items"
13101
13101
  }
13102
13102
  ]
13103
13103
  }