@medusajs/draft-order 2.10.4-snapshot-20250922165717 → 2.10.4-snapshot-20250923121159

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.
@@ -9656,196 +9656,6 @@ const EmailForm = ({ order }) => {
9656
9656
  const schema$4 = objectType({
9657
9657
  email: stringType().email()
9658
9658
  });
9659
- const BillingAddress = () => {
9660
- const { id } = useParams();
9661
- const { order, isPending, isError, error } = useOrder(id, {
9662
- fields: "+billing_address"
9663
- });
9664
- if (isError) {
9665
- throw error;
9666
- }
9667
- const isReady = !isPending && !!order;
9668
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
9669
- /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
9670
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Billing Address" }) }),
9671
- /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
9672
- ] }),
9673
- isReady && /* @__PURE__ */ jsx(BillingAddressForm, { order })
9674
- ] });
9675
- };
9676
- const BillingAddressForm = ({ order }) => {
9677
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
9678
- const form = useForm({
9679
- defaultValues: {
9680
- first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
9681
- last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
9682
- company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
9683
- address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
9684
- address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
9685
- city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
9686
- province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
9687
- country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
9688
- postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
9689
- phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
9690
- },
9691
- resolver: zodResolver(schema$3)
9692
- });
9693
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9694
- const { handleSuccess } = useRouteModal();
9695
- const onSubmit = form.handleSubmit(async (data) => {
9696
- await mutateAsync(
9697
- { billing_address: data },
9698
- {
9699
- onSuccess: () => {
9700
- handleSuccess();
9701
- },
9702
- onError: (error) => {
9703
- toast.error(error.message);
9704
- }
9705
- }
9706
- );
9707
- });
9708
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
9709
- KeyboundForm,
9710
- {
9711
- className: "flex flex-1 flex-col overflow-hidden",
9712
- onSubmit,
9713
- children: [
9714
- /* @__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: [
9715
- /* @__PURE__ */ jsx(
9716
- Form$2.Field,
9717
- {
9718
- control: form.control,
9719
- name: "country_code",
9720
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9721
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
9722
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
9723
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9724
- ] })
9725
- }
9726
- ),
9727
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
9728
- /* @__PURE__ */ jsx(
9729
- Form$2.Field,
9730
- {
9731
- control: form.control,
9732
- name: "first_name",
9733
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9734
- /* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
9735
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9736
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9737
- ] })
9738
- }
9739
- ),
9740
- /* @__PURE__ */ jsx(
9741
- Form$2.Field,
9742
- {
9743
- control: form.control,
9744
- name: "last_name",
9745
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9746
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
9747
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9748
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9749
- ] })
9750
- }
9751
- )
9752
- ] }),
9753
- /* @__PURE__ */ jsx(
9754
- Form$2.Field,
9755
- {
9756
- control: form.control,
9757
- name: "company",
9758
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9759
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
9760
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9761
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9762
- ] })
9763
- }
9764
- ),
9765
- /* @__PURE__ */ jsx(
9766
- Form$2.Field,
9767
- {
9768
- control: form.control,
9769
- name: "address_1",
9770
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9771
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
9772
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9773
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9774
- ] })
9775
- }
9776
- ),
9777
- /* @__PURE__ */ jsx(
9778
- Form$2.Field,
9779
- {
9780
- control: form.control,
9781
- name: "address_2",
9782
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9783
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
9784
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9785
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9786
- ] })
9787
- }
9788
- ),
9789
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
9790
- /* @__PURE__ */ jsx(
9791
- Form$2.Field,
9792
- {
9793
- control: form.control,
9794
- name: "postal_code",
9795
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9796
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
9797
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9798
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9799
- ] })
9800
- }
9801
- ),
9802
- /* @__PURE__ */ jsx(
9803
- Form$2.Field,
9804
- {
9805
- control: form.control,
9806
- name: "city",
9807
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9808
- /* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
9809
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9810
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9811
- ] })
9812
- }
9813
- )
9814
- ] }),
9815
- /* @__PURE__ */ jsx(
9816
- Form$2.Field,
9817
- {
9818
- control: form.control,
9819
- name: "province",
9820
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9821
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
9822
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9823
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9824
- ] })
9825
- }
9826
- ),
9827
- /* @__PURE__ */ jsx(
9828
- Form$2.Field,
9829
- {
9830
- control: form.control,
9831
- name: "phone",
9832
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9833
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
9834
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9835
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9836
- ] })
9837
- }
9838
- )
9839
- ] }) }),
9840
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
9841
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9842
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
9843
- ] }) })
9844
- ]
9845
- }
9846
- ) });
9847
- };
9848
- const schema$3 = addressSchema;
9849
9659
  const NumberInput = forwardRef(
9850
9660
  ({
9851
9661
  value,
@@ -11447,164 +11257,45 @@ function getPromotionIds(items, shippingMethods) {
11447
11257
  }
11448
11258
  return Array.from(promotionIds);
11449
11259
  }
11450
- const SalesChannel = () => {
11260
+ const BillingAddress = () => {
11451
11261
  const { id } = useParams();
11452
- const { draft_order, isPending, isError, error } = useDraftOrder(
11453
- id,
11454
- {
11455
- fields: "+sales_channel_id"
11456
- },
11457
- {
11458
- enabled: !!id
11459
- }
11460
- );
11262
+ const { order, isPending, isError, error } = useOrder(id, {
11263
+ fields: "+billing_address"
11264
+ });
11461
11265
  if (isError) {
11462
11266
  throw error;
11463
11267
  }
11464
- const ISrEADY = !!draft_order && !isPending;
11268
+ const isReady = !isPending && !!order;
11465
11269
  return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
11466
11270
  /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
11467
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
11468
- /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
11271
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Billing Address" }) }),
11272
+ /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
11469
11273
  ] }),
11470
- ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
11274
+ isReady && /* @__PURE__ */ jsx(BillingAddressForm, { order })
11471
11275
  ] });
11472
11276
  };
11473
- const SalesChannelForm = ({ order }) => {
11277
+ const BillingAddressForm = ({ order }) => {
11278
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
11474
11279
  const form = useForm({
11475
11280
  defaultValues: {
11476
- sales_channel_id: order.sales_channel_id || ""
11281
+ first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
11282
+ last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
11283
+ company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
11284
+ address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
11285
+ address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
11286
+ city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
11287
+ province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
11288
+ country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
11289
+ postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
11290
+ phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
11477
11291
  },
11478
- resolver: zodResolver(schema$2)
11292
+ resolver: zodResolver(schema$3)
11479
11293
  });
11480
11294
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11481
11295
  const { handleSuccess } = useRouteModal();
11482
11296
  const onSubmit = form.handleSubmit(async (data) => {
11483
11297
  await mutateAsync(
11484
- {
11485
- sales_channel_id: data.sales_channel_id
11486
- },
11487
- {
11488
- onSuccess: () => {
11489
- toast.success("Sales channel updated");
11490
- handleSuccess();
11491
- },
11492
- onError: (error) => {
11493
- toast.error(error.message);
11494
- }
11495
- }
11496
- );
11497
- });
11498
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
11499
- KeyboundForm,
11500
- {
11501
- className: "flex flex-1 flex-col overflow-hidden",
11502
- onSubmit,
11503
- children: [
11504
- /* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
11505
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
11506
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11507
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
11508
- ] }) })
11509
- ]
11510
- }
11511
- ) });
11512
- };
11513
- const SalesChannelField = ({ control, order }) => {
11514
- const salesChannels = useComboboxData({
11515
- queryFn: async (params) => {
11516
- return await sdk.admin.salesChannel.list(params);
11517
- },
11518
- queryKey: ["sales-channels"],
11519
- getOptions: (data) => {
11520
- return data.sales_channels.map((salesChannel) => ({
11521
- label: salesChannel.name,
11522
- value: salesChannel.id
11523
- }));
11524
- },
11525
- defaultValue: order.sales_channel_id || void 0
11526
- });
11527
- return /* @__PURE__ */ jsx(
11528
- Form$2.Field,
11529
- {
11530
- control,
11531
- name: "sales_channel_id",
11532
- render: ({ field }) => {
11533
- return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11534
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
11535
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
11536
- Combobox,
11537
- {
11538
- options: salesChannels.options,
11539
- fetchNextPage: salesChannels.fetchNextPage,
11540
- isFetchingNextPage: salesChannels.isFetchingNextPage,
11541
- searchValue: salesChannels.searchValue,
11542
- onSearchValueChange: salesChannels.onSearchValueChange,
11543
- placeholder: "Select sales channel",
11544
- ...field
11545
- }
11546
- ) }),
11547
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11548
- ] });
11549
- }
11550
- }
11551
- );
11552
- };
11553
- const schema$2 = objectType({
11554
- sales_channel_id: stringType().min(1)
11555
- });
11556
- const ShippingAddress = () => {
11557
- const { id } = useParams();
11558
- const { order, isPending, isError, error } = useOrder(id, {
11559
- fields: "+shipping_address"
11560
- });
11561
- if (isError) {
11562
- throw error;
11563
- }
11564
- const isReady = !isPending && !!order;
11565
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
11566
- /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
11567
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Shipping Address" }) }),
11568
- /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
11569
- ] }),
11570
- isReady && /* @__PURE__ */ jsx(ShippingAddressForm, { order })
11571
- ] });
11572
- };
11573
- const ShippingAddressForm = ({ order }) => {
11574
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
11575
- const form = useForm({
11576
- defaultValues: {
11577
- first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
11578
- last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
11579
- company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
11580
- address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
11581
- address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
11582
- city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
11583
- province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
11584
- country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
11585
- postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
11586
- phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
11587
- },
11588
- resolver: zodResolver(schema$1)
11589
- });
11590
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11591
- const { handleSuccess } = useRouteModal();
11592
- const onSubmit = form.handleSubmit(async (data) => {
11593
- await mutateAsync(
11594
- {
11595
- shipping_address: {
11596
- first_name: data.first_name,
11597
- last_name: data.last_name,
11598
- company: data.company,
11599
- address_1: data.address_1,
11600
- address_2: data.address_2,
11601
- city: data.city,
11602
- province: data.province,
11603
- country_code: data.country_code,
11604
- postal_code: data.postal_code,
11605
- phone: data.phone
11606
- }
11607
- },
11298
+ { billing_address: data },
11608
11299
  {
11609
11300
  onSuccess: () => {
11610
11301
  handleSuccess();
@@ -11755,7 +11446,113 @@ const ShippingAddressForm = ({ order }) => {
11755
11446
  }
11756
11447
  ) });
11757
11448
  };
11758
- const schema$1 = addressSchema;
11449
+ const schema$3 = addressSchema;
11450
+ const SalesChannel = () => {
11451
+ const { id } = useParams();
11452
+ const { draft_order, isPending, isError, error } = useDraftOrder(
11453
+ id,
11454
+ {
11455
+ fields: "+sales_channel_id"
11456
+ },
11457
+ {
11458
+ enabled: !!id
11459
+ }
11460
+ );
11461
+ if (isError) {
11462
+ throw error;
11463
+ }
11464
+ const ISrEADY = !!draft_order && !isPending;
11465
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
11466
+ /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
11467
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Sales Channel" }) }),
11468
+ /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
11469
+ ] }),
11470
+ ISrEADY && /* @__PURE__ */ jsx(SalesChannelForm, { order: draft_order })
11471
+ ] });
11472
+ };
11473
+ const SalesChannelForm = ({ order }) => {
11474
+ const form = useForm({
11475
+ defaultValues: {
11476
+ sales_channel_id: order.sales_channel_id || ""
11477
+ },
11478
+ resolver: zodResolver(schema$2)
11479
+ });
11480
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11481
+ const { handleSuccess } = useRouteModal();
11482
+ const onSubmit = form.handleSubmit(async (data) => {
11483
+ await mutateAsync(
11484
+ {
11485
+ sales_channel_id: data.sales_channel_id
11486
+ },
11487
+ {
11488
+ onSuccess: () => {
11489
+ toast.success("Sales channel updated");
11490
+ handleSuccess();
11491
+ },
11492
+ onError: (error) => {
11493
+ toast.error(error.message);
11494
+ }
11495
+ }
11496
+ );
11497
+ });
11498
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
11499
+ KeyboundForm,
11500
+ {
11501
+ className: "flex flex-1 flex-col overflow-hidden",
11502
+ onSubmit,
11503
+ children: [
11504
+ /* @__PURE__ */ jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsx(SalesChannelField, { control: form.control, order }) }),
11505
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
11506
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11507
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
11508
+ ] }) })
11509
+ ]
11510
+ }
11511
+ ) });
11512
+ };
11513
+ const SalesChannelField = ({ control, order }) => {
11514
+ const salesChannels = useComboboxData({
11515
+ queryFn: async (params) => {
11516
+ return await sdk.admin.salesChannel.list(params);
11517
+ },
11518
+ queryKey: ["sales-channels"],
11519
+ getOptions: (data) => {
11520
+ return data.sales_channels.map((salesChannel) => ({
11521
+ label: salesChannel.name,
11522
+ value: salesChannel.id
11523
+ }));
11524
+ },
11525
+ defaultValue: order.sales_channel_id || void 0
11526
+ });
11527
+ return /* @__PURE__ */ jsx(
11528
+ Form$2.Field,
11529
+ {
11530
+ control,
11531
+ name: "sales_channel_id",
11532
+ render: ({ field }) => {
11533
+ return /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11534
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Sales Channel" }),
11535
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(
11536
+ Combobox,
11537
+ {
11538
+ options: salesChannels.options,
11539
+ fetchNextPage: salesChannels.fetchNextPage,
11540
+ isFetchingNextPage: salesChannels.isFetchingNextPage,
11541
+ searchValue: salesChannels.searchValue,
11542
+ onSearchValueChange: salesChannels.onSearchValueChange,
11543
+ placeholder: "Select sales channel",
11544
+ ...field
11545
+ }
11546
+ ) }),
11547
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11548
+ ] });
11549
+ }
11550
+ }
11551
+ );
11552
+ };
11553
+ const schema$2 = objectType({
11554
+ sales_channel_id: stringType().min(1)
11555
+ });
11759
11556
  const STACKED_FOCUS_MODAL_ID = "shipping-form";
11760
11557
  const Shipping = () => {
11761
11558
  var _a;
@@ -12563,6 +12360,209 @@ const CustomAmountField = ({
12563
12360
  }
12564
12361
  );
12565
12362
  };
12363
+ const ShippingAddress = () => {
12364
+ const { id } = useParams();
12365
+ const { order, isPending, isError, error } = useOrder(id, {
12366
+ fields: "+shipping_address"
12367
+ });
12368
+ if (isError) {
12369
+ throw error;
12370
+ }
12371
+ const isReady = !isPending && !!order;
12372
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
12373
+ /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
12374
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Shipping Address" }) }),
12375
+ /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
12376
+ ] }),
12377
+ isReady && /* @__PURE__ */ jsx(ShippingAddressForm, { order })
12378
+ ] });
12379
+ };
12380
+ const ShippingAddressForm = ({ order }) => {
12381
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12382
+ const form = useForm({
12383
+ defaultValues: {
12384
+ first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
12385
+ last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
12386
+ company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
12387
+ address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
12388
+ address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
12389
+ city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
12390
+ province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
12391
+ country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
12392
+ postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12393
+ phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12394
+ },
12395
+ resolver: zodResolver(schema$1)
12396
+ });
12397
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12398
+ const { handleSuccess } = useRouteModal();
12399
+ const onSubmit = form.handleSubmit(async (data) => {
12400
+ await mutateAsync(
12401
+ {
12402
+ shipping_address: {
12403
+ first_name: data.first_name,
12404
+ last_name: data.last_name,
12405
+ company: data.company,
12406
+ address_1: data.address_1,
12407
+ address_2: data.address_2,
12408
+ city: data.city,
12409
+ province: data.province,
12410
+ country_code: data.country_code,
12411
+ postal_code: data.postal_code,
12412
+ phone: data.phone
12413
+ }
12414
+ },
12415
+ {
12416
+ onSuccess: () => {
12417
+ handleSuccess();
12418
+ },
12419
+ onError: (error) => {
12420
+ toast.error(error.message);
12421
+ }
12422
+ }
12423
+ );
12424
+ });
12425
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
12426
+ KeyboundForm,
12427
+ {
12428
+ className: "flex flex-1 flex-col overflow-hidden",
12429
+ onSubmit,
12430
+ children: [
12431
+ /* @__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: [
12432
+ /* @__PURE__ */ jsx(
12433
+ Form$2.Field,
12434
+ {
12435
+ control: form.control,
12436
+ name: "country_code",
12437
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12438
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
12439
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
12440
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12441
+ ] })
12442
+ }
12443
+ ),
12444
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12445
+ /* @__PURE__ */ jsx(
12446
+ Form$2.Field,
12447
+ {
12448
+ control: form.control,
12449
+ name: "first_name",
12450
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12451
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
12452
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12453
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12454
+ ] })
12455
+ }
12456
+ ),
12457
+ /* @__PURE__ */ jsx(
12458
+ Form$2.Field,
12459
+ {
12460
+ control: form.control,
12461
+ name: "last_name",
12462
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12463
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
12464
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12465
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12466
+ ] })
12467
+ }
12468
+ )
12469
+ ] }),
12470
+ /* @__PURE__ */ jsx(
12471
+ Form$2.Field,
12472
+ {
12473
+ control: form.control,
12474
+ name: "company",
12475
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12476
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
12477
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12478
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12479
+ ] })
12480
+ }
12481
+ ),
12482
+ /* @__PURE__ */ jsx(
12483
+ Form$2.Field,
12484
+ {
12485
+ control: form.control,
12486
+ name: "address_1",
12487
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12488
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
12489
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12490
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12491
+ ] })
12492
+ }
12493
+ ),
12494
+ /* @__PURE__ */ jsx(
12495
+ Form$2.Field,
12496
+ {
12497
+ control: form.control,
12498
+ name: "address_2",
12499
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12500
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
12501
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12502
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12503
+ ] })
12504
+ }
12505
+ ),
12506
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12507
+ /* @__PURE__ */ jsx(
12508
+ Form$2.Field,
12509
+ {
12510
+ control: form.control,
12511
+ name: "postal_code",
12512
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12513
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
12514
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12515
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12516
+ ] })
12517
+ }
12518
+ ),
12519
+ /* @__PURE__ */ jsx(
12520
+ Form$2.Field,
12521
+ {
12522
+ control: form.control,
12523
+ name: "city",
12524
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12525
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
12526
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12527
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12528
+ ] })
12529
+ }
12530
+ )
12531
+ ] }),
12532
+ /* @__PURE__ */ jsx(
12533
+ Form$2.Field,
12534
+ {
12535
+ control: form.control,
12536
+ name: "province",
12537
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12538
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
12539
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12540
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12541
+ ] })
12542
+ }
12543
+ ),
12544
+ /* @__PURE__ */ jsx(
12545
+ Form$2.Field,
12546
+ {
12547
+ control: form.control,
12548
+ name: "phone",
12549
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12550
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
12551
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12552
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12553
+ ] })
12554
+ }
12555
+ )
12556
+ ] }) }),
12557
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
12558
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12559
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12560
+ ] }) })
12561
+ ]
12562
+ }
12563
+ ) });
12564
+ };
12565
+ const schema$1 = addressSchema;
12566
12566
  const TransferOwnership = () => {
12567
12567
  const { id } = useParams();
12568
12568
  const { draft_order, isPending, isError, error } = useDraftOrder(id, {
@@ -13067,10 +13067,6 @@ const routeModule = {
13067
13067
  Component: Email,
13068
13068
  path: "/draft-orders/:id/email"
13069
13069
  },
13070
- {
13071
- Component: BillingAddress,
13072
- path: "/draft-orders/:id/billing-address"
13073
- },
13074
13070
  {
13075
13071
  Component: Items,
13076
13072
  path: "/draft-orders/:id/items"
@@ -13084,17 +13080,21 @@ const routeModule = {
13084
13080
  path: "/draft-orders/:id/promotions"
13085
13081
  },
13086
13082
  {
13087
- Component: SalesChannel,
13088
- path: "/draft-orders/:id/sales-channel"
13083
+ Component: BillingAddress,
13084
+ path: "/draft-orders/:id/billing-address"
13089
13085
  },
13090
13086
  {
13091
- Component: ShippingAddress,
13092
- path: "/draft-orders/:id/shipping-address"
13087
+ Component: SalesChannel,
13088
+ path: "/draft-orders/:id/sales-channel"
13093
13089
  },
13094
13090
  {
13095
13091
  Component: Shipping,
13096
13092
  path: "/draft-orders/:id/shipping"
13097
13093
  },
13094
+ {
13095
+ Component: ShippingAddress,
13096
+ path: "/draft-orders/:id/shipping-address"
13097
+ },
13098
13098
  {
13099
13099
  Component: TransferOwnership,
13100
13100
  path: "/draft-orders/:id/transfer-ownership"