@medusajs/draft-order 2.15.2-snapshot-20260513083227 → 2.15.2

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.
@@ -9899,6 +9899,196 @@ const ID = () => {
9899
9899
  /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Outlet, {})
9900
9900
  ] });
9901
9901
  };
9902
+ const BillingAddress = () => {
9903
+ const { id } = reactRouterDom.useParams();
9904
+ const { order, isPending, isError, error } = useOrder(id, {
9905
+ fields: "+billing_address"
9906
+ });
9907
+ if (isError) {
9908
+ throw error;
9909
+ }
9910
+ const isReady = !isPending && !!order;
9911
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9912
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
9913
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Billing Address" }) }),
9914
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
9915
+ ] }),
9916
+ isReady && /* @__PURE__ */ jsxRuntime.jsx(BillingAddressForm, { order })
9917
+ ] });
9918
+ };
9919
+ const BillingAddressForm = ({ order }) => {
9920
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j;
9921
+ const form = reactHookForm.useForm({
9922
+ defaultValues: {
9923
+ first_name: ((_a2 = order.billing_address) == null ? void 0 : _a2.first_name) ?? "",
9924
+ last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
9925
+ company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
9926
+ address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
9927
+ address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
9928
+ city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
9929
+ province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
9930
+ country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
9931
+ postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
9932
+ phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
9933
+ },
9934
+ resolver: zod.zodResolver(schema$5)
9935
+ });
9936
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9937
+ const { handleSuccess } = useRouteModal();
9938
+ const onSubmit = form.handleSubmit(async (data) => {
9939
+ await mutateAsync(
9940
+ { billing_address: data },
9941
+ {
9942
+ onSuccess: () => {
9943
+ handleSuccess();
9944
+ },
9945
+ onError: (error) => {
9946
+ ui.toast.error(error.message);
9947
+ }
9948
+ }
9949
+ );
9950
+ });
9951
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
9952
+ KeyboundForm,
9953
+ {
9954
+ className: "flex flex-1 flex-col overflow-hidden",
9955
+ onSubmit,
9956
+ children: [
9957
+ /* @__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: [
9958
+ /* @__PURE__ */ jsxRuntime.jsx(
9959
+ Form$2.Field,
9960
+ {
9961
+ control: form.control,
9962
+ name: "country_code",
9963
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9964
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
9965
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
9966
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9967
+ ] })
9968
+ }
9969
+ ),
9970
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
9971
+ /* @__PURE__ */ jsxRuntime.jsx(
9972
+ Form$2.Field,
9973
+ {
9974
+ control: form.control,
9975
+ name: "first_name",
9976
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9977
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
9978
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9979
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9980
+ ] })
9981
+ }
9982
+ ),
9983
+ /* @__PURE__ */ jsxRuntime.jsx(
9984
+ Form$2.Field,
9985
+ {
9986
+ control: form.control,
9987
+ name: "last_name",
9988
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9989
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
9990
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9991
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9992
+ ] })
9993
+ }
9994
+ )
9995
+ ] }),
9996
+ /* @__PURE__ */ jsxRuntime.jsx(
9997
+ Form$2.Field,
9998
+ {
9999
+ control: form.control,
10000
+ name: "company",
10001
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
10002
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
10003
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
10004
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
10005
+ ] })
10006
+ }
10007
+ ),
10008
+ /* @__PURE__ */ jsxRuntime.jsx(
10009
+ Form$2.Field,
10010
+ {
10011
+ control: form.control,
10012
+ name: "address_1",
10013
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
10014
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
10015
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
10016
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
10017
+ ] })
10018
+ }
10019
+ ),
10020
+ /* @__PURE__ */ jsxRuntime.jsx(
10021
+ Form$2.Field,
10022
+ {
10023
+ control: form.control,
10024
+ name: "address_2",
10025
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
10026
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
10027
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
10028
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
10029
+ ] })
10030
+ }
10031
+ ),
10032
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
10033
+ /* @__PURE__ */ jsxRuntime.jsx(
10034
+ Form$2.Field,
10035
+ {
10036
+ control: form.control,
10037
+ name: "postal_code",
10038
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
10039
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
10040
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
10041
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
10042
+ ] })
10043
+ }
10044
+ ),
10045
+ /* @__PURE__ */ jsxRuntime.jsx(
10046
+ Form$2.Field,
10047
+ {
10048
+ control: form.control,
10049
+ name: "city",
10050
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
10051
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
10052
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
10053
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
10054
+ ] })
10055
+ }
10056
+ )
10057
+ ] }),
10058
+ /* @__PURE__ */ jsxRuntime.jsx(
10059
+ Form$2.Field,
10060
+ {
10061
+ control: form.control,
10062
+ name: "province",
10063
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
10064
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
10065
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
10066
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
10067
+ ] })
10068
+ }
10069
+ ),
10070
+ /* @__PURE__ */ jsxRuntime.jsx(
10071
+ Form$2.Field,
10072
+ {
10073
+ control: form.control,
10074
+ name: "phone",
10075
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
10076
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
10077
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
10078
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
10079
+ ] })
10080
+ }
10081
+ )
10082
+ ] }) }),
10083
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
10084
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
10085
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
10086
+ ] }) })
10087
+ ]
10088
+ }
10089
+ ) });
10090
+ };
10091
+ const schema$5 = addressSchema;
9902
10092
  const CustomItems = () => {
9903
10093
  return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9904
10094
  /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
@@ -9907,7 +10097,7 @@ const CustomItems = () => {
9907
10097
  };
9908
10098
  const CustomItemsForm = () => {
9909
10099
  const form = reactHookForm.useForm({
9910
- resolver: zod.zodResolver(schema$5)
10100
+ resolver: zod.zodResolver(schema$4)
9911
10101
  });
9912
10102
  return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9913
10103
  /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
@@ -9917,7 +10107,7 @@ const CustomItemsForm = () => {
9917
10107
  ] }) })
9918
10108
  ] }) });
9919
10109
  };
9920
- const schema$5 = object({
10110
+ const schema$4 = object({
9921
10111
  email: string().email()
9922
10112
  });
9923
10113
  const Email = () => {
@@ -9942,7 +10132,7 @@ const EmailForm = ({ order }) => {
9942
10132
  defaultValues: {
9943
10133
  email: order.email ?? ""
9944
10134
  },
9945
- resolver: zod.zodResolver(schema$4)
10135
+ resolver: zod.zodResolver(schema$3)
9946
10136
  });
9947
10137
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9948
10138
  const { handleSuccess } = useRouteModal();
@@ -9985,7 +10175,7 @@ const EmailForm = ({ order }) => {
9985
10175
  }
9986
10176
  ) });
9987
10177
  };
9988
- const schema$4 = object({
10178
+ const schema$3 = object({
9989
10179
  email: string().email()
9990
10180
  });
9991
10181
  const NumberInput = React.forwardRef(
@@ -11589,47 +11779,46 @@ function getPromotionIds(items, shippingMethods) {
11589
11779
  }
11590
11780
  return Array.from(promotionIds);
11591
11781
  }
11592
- const BillingAddress = () => {
11782
+ const SalesChannel = () => {
11593
11783
  const { id } = reactRouterDom.useParams();
11594
- const { order, isPending, isError, error } = useOrder(id, {
11595
- fields: "+billing_address"
11596
- });
11784
+ const { draft_order, isPending, isError, error } = useDraftOrder(
11785
+ id,
11786
+ {
11787
+ fields: "+sales_channel_id"
11788
+ },
11789
+ {
11790
+ enabled: !!id
11791
+ }
11792
+ );
11597
11793
  if (isError) {
11598
11794
  throw error;
11599
11795
  }
11600
- const isReady = !isPending && !!order;
11796
+ const ISrEADY = !!draft_order && !isPending;
11601
11797
  return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
11602
11798
  /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
11603
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Billing Address" }) }),
11604
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
11799
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
11800
+ /* @__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" }) })
11605
11801
  ] }),
11606
- isReady && /* @__PURE__ */ jsxRuntime.jsx(BillingAddressForm, { order })
11802
+ ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
11607
11803
  ] });
11608
11804
  };
11609
- const BillingAddressForm = ({ order }) => {
11610
- var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j;
11805
+ const SalesChannelForm = ({ order }) => {
11611
11806
  const form = reactHookForm.useForm({
11612
11807
  defaultValues: {
11613
- first_name: ((_a2 = order.billing_address) == null ? void 0 : _a2.first_name) ?? "",
11614
- last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
11615
- company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
11616
- address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
11617
- address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
11618
- city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
11619
- province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
11620
- country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
11621
- postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
11622
- phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
11808
+ sales_channel_id: order.sales_channel_id || ""
11623
11809
  },
11624
- resolver: zod.zodResolver(schema$3)
11810
+ resolver: zod.zodResolver(schema$2)
11625
11811
  });
11626
11812
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11627
11813
  const { handleSuccess } = useRouteModal();
11628
11814
  const onSubmit = form.handleSubmit(async (data) => {
11629
11815
  await mutateAsync(
11630
- { billing_address: data },
11816
+ {
11817
+ sales_channel_id: data.sales_channel_id
11818
+ },
11631
11819
  {
11632
11820
  onSuccess: () => {
11821
+ ui.toast.success("Sales channel updated");
11633
11822
  handleSuccess();
11634
11823
  },
11635
11824
  onError: (error) => {
@@ -11644,132 +11833,7 @@ const BillingAddressForm = ({ order }) => {
11644
11833
  className: "flex flex-1 flex-col overflow-hidden",
11645
11834
  onSubmit,
11646
11835
  children: [
11647
- /* @__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: [
11648
- /* @__PURE__ */ jsxRuntime.jsx(
11649
- Form$2.Field,
11650
- {
11651
- control: form.control,
11652
- name: "country_code",
11653
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11654
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
11655
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
11656
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11657
- ] })
11658
- }
11659
- ),
11660
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
11661
- /* @__PURE__ */ jsxRuntime.jsx(
11662
- Form$2.Field,
11663
- {
11664
- control: form.control,
11665
- name: "first_name",
11666
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11667
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
11668
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11669
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11670
- ] })
11671
- }
11672
- ),
11673
- /* @__PURE__ */ jsxRuntime.jsx(
11674
- Form$2.Field,
11675
- {
11676
- control: form.control,
11677
- name: "last_name",
11678
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11679
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
11680
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11681
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11682
- ] })
11683
- }
11684
- )
11685
- ] }),
11686
- /* @__PURE__ */ jsxRuntime.jsx(
11687
- Form$2.Field,
11688
- {
11689
- control: form.control,
11690
- name: "company",
11691
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11692
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
11693
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11694
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11695
- ] })
11696
- }
11697
- ),
11698
- /* @__PURE__ */ jsxRuntime.jsx(
11699
- Form$2.Field,
11700
- {
11701
- control: form.control,
11702
- name: "address_1",
11703
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11704
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
11705
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11706
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11707
- ] })
11708
- }
11709
- ),
11710
- /* @__PURE__ */ jsxRuntime.jsx(
11711
- Form$2.Field,
11712
- {
11713
- control: form.control,
11714
- name: "address_2",
11715
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11716
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
11717
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11718
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11719
- ] })
11720
- }
11721
- ),
11722
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
11723
- /* @__PURE__ */ jsxRuntime.jsx(
11724
- Form$2.Field,
11725
- {
11726
- control: form.control,
11727
- name: "postal_code",
11728
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11729
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
11730
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11731
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11732
- ] })
11733
- }
11734
- ),
11735
- /* @__PURE__ */ jsxRuntime.jsx(
11736
- Form$2.Field,
11737
- {
11738
- control: form.control,
11739
- name: "city",
11740
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11741
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
11742
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11743
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11744
- ] })
11745
- }
11746
- )
11747
- ] }),
11748
- /* @__PURE__ */ jsxRuntime.jsx(
11749
- Form$2.Field,
11750
- {
11751
- control: form.control,
11752
- name: "province",
11753
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11754
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
11755
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11756
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11757
- ] })
11758
- }
11759
- ),
11760
- /* @__PURE__ */ jsxRuntime.jsx(
11761
- Form$2.Field,
11762
- {
11763
- control: form.control,
11764
- name: "phone",
11765
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11766
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
11767
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11768
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11769
- ] })
11770
- }
11771
- )
11772
- ] }) }),
11836
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
11773
11837
  /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
11774
11838
  /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11775
11839
  /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
@@ -11778,7 +11842,49 @@ const BillingAddressForm = ({ order }) => {
11778
11842
  }
11779
11843
  ) });
11780
11844
  };
11781
- const schema$3 = addressSchema;
11845
+ const SalesChannelField = ({ control, order }) => {
11846
+ const salesChannels = useComboboxData({
11847
+ queryFn: async (params) => {
11848
+ return await sdk.admin.salesChannel.list(params);
11849
+ },
11850
+ queryKey: ["sales-channels"],
11851
+ getOptions: (data) => {
11852
+ return data.sales_channels.map((salesChannel) => ({
11853
+ label: salesChannel.name,
11854
+ value: salesChannel.id
11855
+ }));
11856
+ },
11857
+ defaultValue: order.sales_channel_id || void 0
11858
+ });
11859
+ return /* @__PURE__ */ jsxRuntime.jsx(
11860
+ Form$2.Field,
11861
+ {
11862
+ control,
11863
+ name: "sales_channel_id",
11864
+ render: ({ field }) => {
11865
+ return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11866
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
11867
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
11868
+ Combobox,
11869
+ {
11870
+ options: salesChannels.options,
11871
+ fetchNextPage: salesChannels.fetchNextPage,
11872
+ isFetchingNextPage: salesChannels.isFetchingNextPage,
11873
+ searchValue: salesChannels.searchValue,
11874
+ onSearchValueChange: salesChannels.onSearchValueChange,
11875
+ placeholder: "Select sales channel",
11876
+ ...field
11877
+ }
11878
+ ) }),
11879
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11880
+ ] });
11881
+ }
11882
+ }
11883
+ );
11884
+ };
11885
+ const schema$2 = object({
11886
+ sales_channel_id: string().min(1)
11887
+ });
11782
11888
  const STACKED_FOCUS_MODAL_ID = "shipping-form";
11783
11889
  const Shipping = () => {
11784
11890
  var _a2;
@@ -12618,7 +12724,7 @@ const ShippingAddressForm = ({ order }) => {
12618
12724
  postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12619
12725
  phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12620
12726
  },
12621
- resolver: zod.zodResolver(schema$2)
12727
+ resolver: zod.zodResolver(schema$1)
12622
12728
  });
12623
12729
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12624
12730
  const { handleSuccess } = useRouteModal();
@@ -12788,7 +12894,7 @@ const ShippingAddressForm = ({ order }) => {
12788
12894
  }
12789
12895
  ) });
12790
12896
  };
12791
- const schema$2 = addressSchema;
12897
+ const schema$1 = addressSchema;
12792
12898
  const TransferOwnership = () => {
12793
12899
  const { id } = reactRouterDom.useParams();
12794
12900
  const { draft_order, isPending, isError, error } = useDraftOrder(id, {
@@ -12812,7 +12918,7 @@ const TransferOwnershipForm = ({ order }) => {
12812
12918
  defaultValues: {
12813
12919
  customer_id: order.customer_id || ""
12814
12920
  },
12815
- resolver: zod.zodResolver(schema$1)
12921
+ resolver: zod.zodResolver(schema)
12816
12922
  });
12817
12923
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12818
12924
  const { handleSuccess } = useRouteModal();
@@ -13262,114 +13368,8 @@ const Illustration = () => {
13262
13368
  }
13263
13369
  );
13264
13370
  };
13265
- const schema$1 = object({
13266
- customer_id: string().min(1)
13267
- });
13268
- const SalesChannel = () => {
13269
- const { id } = reactRouterDom.useParams();
13270
- const { draft_order, isPending, isError, error } = useDraftOrder(
13271
- id,
13272
- {
13273
- fields: "+sales_channel_id"
13274
- },
13275
- {
13276
- enabled: !!id
13277
- }
13278
- );
13279
- if (isError) {
13280
- throw error;
13281
- }
13282
- const ISrEADY = !!draft_order && !isPending;
13283
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
13284
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
13285
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
13286
- /* @__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" }) })
13287
- ] }),
13288
- ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
13289
- ] });
13290
- };
13291
- const SalesChannelForm = ({ order }) => {
13292
- const form = reactHookForm.useForm({
13293
- defaultValues: {
13294
- sales_channel_id: order.sales_channel_id || ""
13295
- },
13296
- resolver: zod.zodResolver(schema)
13297
- });
13298
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
13299
- const { handleSuccess } = useRouteModal();
13300
- const onSubmit = form.handleSubmit(async (data) => {
13301
- await mutateAsync(
13302
- {
13303
- sales_channel_id: data.sales_channel_id
13304
- },
13305
- {
13306
- onSuccess: () => {
13307
- ui.toast.success("Sales channel updated");
13308
- handleSuccess();
13309
- },
13310
- onError: (error) => {
13311
- ui.toast.error(error.message);
13312
- }
13313
- }
13314
- );
13315
- });
13316
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
13317
- KeyboundForm,
13318
- {
13319
- className: "flex flex-1 flex-col overflow-hidden",
13320
- onSubmit,
13321
- children: [
13322
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
13323
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
13324
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
13325
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
13326
- ] }) })
13327
- ]
13328
- }
13329
- ) });
13330
- };
13331
- const SalesChannelField = ({ control, order }) => {
13332
- const salesChannels = useComboboxData({
13333
- queryFn: async (params) => {
13334
- return await sdk.admin.salesChannel.list(params);
13335
- },
13336
- queryKey: ["sales-channels"],
13337
- getOptions: (data) => {
13338
- return data.sales_channels.map((salesChannel) => ({
13339
- label: salesChannel.name,
13340
- value: salesChannel.id
13341
- }));
13342
- },
13343
- defaultValue: order.sales_channel_id || void 0
13344
- });
13345
- return /* @__PURE__ */ jsxRuntime.jsx(
13346
- Form$2.Field,
13347
- {
13348
- control,
13349
- name: "sales_channel_id",
13350
- render: ({ field }) => {
13351
- return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
13352
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
13353
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
13354
- Combobox,
13355
- {
13356
- options: salesChannels.options,
13357
- fetchNextPage: salesChannels.fetchNextPage,
13358
- isFetchingNextPage: salesChannels.isFetchingNextPage,
13359
- searchValue: salesChannels.searchValue,
13360
- onSearchValueChange: salesChannels.onSearchValueChange,
13361
- placeholder: "Select sales channel",
13362
- ...field
13363
- }
13364
- ) }),
13365
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
13366
- ] });
13367
- }
13368
- }
13369
- );
13370
- };
13371
13371
  const schema = object({
13372
- sales_channel_id: string().min(1)
13372
+ customer_id: string().min(1)
13373
13373
  });
13374
13374
  const widgetModule = { widgets: [] };
13375
13375
  const routeModule = {
@@ -13391,6 +13391,10 @@ const routeModule = {
13391
13391
  handle,
13392
13392
  loader,
13393
13393
  children: [
13394
+ {
13395
+ Component: BillingAddress,
13396
+ path: "/draft-orders/:id/billing-address"
13397
+ },
13394
13398
  {
13395
13399
  Component: CustomItems,
13396
13400
  path: "/draft-orders/:id/custom-items"
@@ -13412,8 +13416,8 @@ const routeModule = {
13412
13416
  path: "/draft-orders/:id/promotions"
13413
13417
  },
13414
13418
  {
13415
- Component: BillingAddress,
13416
- path: "/draft-orders/:id/billing-address"
13419
+ Component: SalesChannel,
13420
+ path: "/draft-orders/:id/sales-channel"
13417
13421
  },
13418
13422
  {
13419
13423
  Component: Shipping,
@@ -13426,10 +13430,6 @@ const routeModule = {
13426
13430
  {
13427
13431
  Component: TransferOwnership,
13428
13432
  path: "/draft-orders/:id/transfer-ownership"
13429
- },
13430
- {
13431
- Component: SalesChannel,
13432
- path: "/draft-orders/:id/sales-channel"
13433
13433
  }
13434
13434
  ]
13435
13435
  }