@medusajs/draft-order 2.10.0-preview-20250827180155 → 2.10.0-preview-20250827210153

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.
@@ -9560,196 +9560,6 @@ const ID = () => {
9560
9560
  /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Outlet, {})
9561
9561
  ] });
9562
9562
  };
9563
- const BillingAddress = () => {
9564
- const { id } = reactRouterDom.useParams();
9565
- const { order, isPending, isError, error } = useOrder(id, {
9566
- fields: "+billing_address"
9567
- });
9568
- if (isError) {
9569
- throw error;
9570
- }
9571
- const isReady = !isPending && !!order;
9572
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9573
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
9574
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Billing Address" }) }),
9575
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
9576
- ] }),
9577
- isReady && /* @__PURE__ */ jsxRuntime.jsx(BillingAddressForm, { order })
9578
- ] });
9579
- };
9580
- const BillingAddressForm = ({ order }) => {
9581
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
9582
- const form = reactHookForm.useForm({
9583
- defaultValues: {
9584
- first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
9585
- last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
9586
- company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
9587
- address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
9588
- address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
9589
- city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
9590
- province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
9591
- country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
9592
- postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
9593
- phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
9594
- },
9595
- resolver: zod.zodResolver(schema$5)
9596
- });
9597
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9598
- const { handleSuccess } = useRouteModal();
9599
- const onSubmit = form.handleSubmit(async (data) => {
9600
- await mutateAsync(
9601
- { billing_address: data },
9602
- {
9603
- onSuccess: () => {
9604
- handleSuccess();
9605
- },
9606
- onError: (error) => {
9607
- ui.toast.error(error.message);
9608
- }
9609
- }
9610
- );
9611
- });
9612
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
9613
- KeyboundForm,
9614
- {
9615
- className: "flex flex-1 flex-col overflow-hidden",
9616
- onSubmit,
9617
- children: [
9618
- /* @__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: [
9619
- /* @__PURE__ */ jsxRuntime.jsx(
9620
- Form$2.Field,
9621
- {
9622
- control: form.control,
9623
- name: "country_code",
9624
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9625
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
9626
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
9627
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9628
- ] })
9629
- }
9630
- ),
9631
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
9632
- /* @__PURE__ */ jsxRuntime.jsx(
9633
- Form$2.Field,
9634
- {
9635
- control: form.control,
9636
- name: "first_name",
9637
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9638
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
9639
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9640
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9641
- ] })
9642
- }
9643
- ),
9644
- /* @__PURE__ */ jsxRuntime.jsx(
9645
- Form$2.Field,
9646
- {
9647
- control: form.control,
9648
- name: "last_name",
9649
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9650
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
9651
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9652
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9653
- ] })
9654
- }
9655
- )
9656
- ] }),
9657
- /* @__PURE__ */ jsxRuntime.jsx(
9658
- Form$2.Field,
9659
- {
9660
- control: form.control,
9661
- name: "company",
9662
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9663
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
9664
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9665
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9666
- ] })
9667
- }
9668
- ),
9669
- /* @__PURE__ */ jsxRuntime.jsx(
9670
- Form$2.Field,
9671
- {
9672
- control: form.control,
9673
- name: "address_1",
9674
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9675
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
9676
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9677
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9678
- ] })
9679
- }
9680
- ),
9681
- /* @__PURE__ */ jsxRuntime.jsx(
9682
- Form$2.Field,
9683
- {
9684
- control: form.control,
9685
- name: "address_2",
9686
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9687
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
9688
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9689
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9690
- ] })
9691
- }
9692
- ),
9693
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
9694
- /* @__PURE__ */ jsxRuntime.jsx(
9695
- Form$2.Field,
9696
- {
9697
- control: form.control,
9698
- name: "postal_code",
9699
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9700
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
9701
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9702
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9703
- ] })
9704
- }
9705
- ),
9706
- /* @__PURE__ */ jsxRuntime.jsx(
9707
- Form$2.Field,
9708
- {
9709
- control: form.control,
9710
- name: "city",
9711
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9712
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
9713
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9714
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9715
- ] })
9716
- }
9717
- )
9718
- ] }),
9719
- /* @__PURE__ */ jsxRuntime.jsx(
9720
- Form$2.Field,
9721
- {
9722
- control: form.control,
9723
- name: "province",
9724
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9725
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
9726
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9727
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9728
- ] })
9729
- }
9730
- ),
9731
- /* @__PURE__ */ jsxRuntime.jsx(
9732
- Form$2.Field,
9733
- {
9734
- control: form.control,
9735
- name: "phone",
9736
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9737
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
9738
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9739
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9740
- ] })
9741
- }
9742
- )
9743
- ] }) }),
9744
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
9745
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9746
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
9747
- ] }) })
9748
- ]
9749
- }
9750
- ) });
9751
- };
9752
- const schema$5 = addressSchema;
9753
9563
  const CustomItems = () => {
9754
9564
  return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9755
9565
  /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
@@ -9758,7 +9568,7 @@ const CustomItems = () => {
9758
9568
  };
9759
9569
  const CustomItemsForm = () => {
9760
9570
  const form = reactHookForm.useForm({
9761
- resolver: zod.zodResolver(schema$4)
9571
+ resolver: zod.zodResolver(schema$5)
9762
9572
  });
9763
9573
  return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9764
9574
  /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
@@ -9768,7 +9578,7 @@ const CustomItemsForm = () => {
9768
9578
  ] }) })
9769
9579
  ] }) });
9770
9580
  };
9771
- const schema$4 = objectType({
9581
+ const schema$5 = objectType({
9772
9582
  email: stringType().email()
9773
9583
  });
9774
9584
  const Email = () => {
@@ -9793,7 +9603,7 @@ const EmailForm = ({ order }) => {
9793
9603
  defaultValues: {
9794
9604
  email: order.email ?? ""
9795
9605
  },
9796
- resolver: zod.zodResolver(schema$3)
9606
+ resolver: zod.zodResolver(schema$4)
9797
9607
  });
9798
9608
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9799
9609
  const { handleSuccess } = useRouteModal();
@@ -9836,7 +9646,7 @@ const EmailForm = ({ order }) => {
9836
9646
  }
9837
9647
  ) });
9838
9648
  };
9839
- const schema$3 = objectType({
9649
+ const schema$4 = objectType({
9840
9650
  email: stringType().email()
9841
9651
  });
9842
9652
  const NumberInput = React.forwardRef(
@@ -11152,17 +10962,207 @@ function parseValues(values) {
11152
10962
  update[key] = value;
11153
10963
  }
11154
10964
  }
11155
- });
11156
- return update;
11157
- }
11158
- function getHasUneditableRows(metadata) {
11159
- if (!metadata) {
11160
- return false;
11161
- }
11162
- return Object.values(metadata).some(
11163
- (value) => !EDITABLE_TYPES.includes(typeof value)
11164
- );
11165
- }
10965
+ });
10966
+ return update;
10967
+ }
10968
+ function getHasUneditableRows(metadata) {
10969
+ if (!metadata) {
10970
+ return false;
10971
+ }
10972
+ return Object.values(metadata).some(
10973
+ (value) => !EDITABLE_TYPES.includes(typeof value)
10974
+ );
10975
+ }
10976
+ const BillingAddress = () => {
10977
+ const { id } = reactRouterDom.useParams();
10978
+ const { order, isPending, isError, error } = useOrder(id, {
10979
+ fields: "+billing_address"
10980
+ });
10981
+ if (isError) {
10982
+ throw error;
10983
+ }
10984
+ const isReady = !isPending && !!order;
10985
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
10986
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
10987
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Billing Address" }) }),
10988
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
10989
+ ] }),
10990
+ isReady && /* @__PURE__ */ jsxRuntime.jsx(BillingAddressForm, { order })
10991
+ ] });
10992
+ };
10993
+ const BillingAddressForm = ({ order }) => {
10994
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
10995
+ const form = reactHookForm.useForm({
10996
+ defaultValues: {
10997
+ first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
10998
+ last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
10999
+ company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
11000
+ address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
11001
+ address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
11002
+ city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
11003
+ province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
11004
+ country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
11005
+ postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
11006
+ phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
11007
+ },
11008
+ resolver: zod.zodResolver(schema$3)
11009
+ });
11010
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11011
+ const { handleSuccess } = useRouteModal();
11012
+ const onSubmit = form.handleSubmit(async (data) => {
11013
+ await mutateAsync(
11014
+ { billing_address: data },
11015
+ {
11016
+ onSuccess: () => {
11017
+ handleSuccess();
11018
+ },
11019
+ onError: (error) => {
11020
+ ui.toast.error(error.message);
11021
+ }
11022
+ }
11023
+ );
11024
+ });
11025
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
11026
+ KeyboundForm,
11027
+ {
11028
+ className: "flex flex-1 flex-col overflow-hidden",
11029
+ onSubmit,
11030
+ children: [
11031
+ /* @__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: [
11032
+ /* @__PURE__ */ jsxRuntime.jsx(
11033
+ Form$2.Field,
11034
+ {
11035
+ control: form.control,
11036
+ name: "country_code",
11037
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11038
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
11039
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
11040
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11041
+ ] })
11042
+ }
11043
+ ),
11044
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
11045
+ /* @__PURE__ */ jsxRuntime.jsx(
11046
+ Form$2.Field,
11047
+ {
11048
+ control: form.control,
11049
+ name: "first_name",
11050
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11051
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
11052
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11053
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11054
+ ] })
11055
+ }
11056
+ ),
11057
+ /* @__PURE__ */ jsxRuntime.jsx(
11058
+ Form$2.Field,
11059
+ {
11060
+ control: form.control,
11061
+ name: "last_name",
11062
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11063
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
11064
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11065
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11066
+ ] })
11067
+ }
11068
+ )
11069
+ ] }),
11070
+ /* @__PURE__ */ jsxRuntime.jsx(
11071
+ Form$2.Field,
11072
+ {
11073
+ control: form.control,
11074
+ name: "company",
11075
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11076
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
11077
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11078
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11079
+ ] })
11080
+ }
11081
+ ),
11082
+ /* @__PURE__ */ jsxRuntime.jsx(
11083
+ Form$2.Field,
11084
+ {
11085
+ control: form.control,
11086
+ name: "address_1",
11087
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11088
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
11089
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11090
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11091
+ ] })
11092
+ }
11093
+ ),
11094
+ /* @__PURE__ */ jsxRuntime.jsx(
11095
+ Form$2.Field,
11096
+ {
11097
+ control: form.control,
11098
+ name: "address_2",
11099
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11100
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
11101
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11102
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11103
+ ] })
11104
+ }
11105
+ ),
11106
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
11107
+ /* @__PURE__ */ jsxRuntime.jsx(
11108
+ Form$2.Field,
11109
+ {
11110
+ control: form.control,
11111
+ name: "postal_code",
11112
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11113
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
11114
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11115
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11116
+ ] })
11117
+ }
11118
+ ),
11119
+ /* @__PURE__ */ jsxRuntime.jsx(
11120
+ Form$2.Field,
11121
+ {
11122
+ control: form.control,
11123
+ name: "city",
11124
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11125
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
11126
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11127
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11128
+ ] })
11129
+ }
11130
+ )
11131
+ ] }),
11132
+ /* @__PURE__ */ jsxRuntime.jsx(
11133
+ Form$2.Field,
11134
+ {
11135
+ control: form.control,
11136
+ name: "province",
11137
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11138
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
11139
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11140
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11141
+ ] })
11142
+ }
11143
+ ),
11144
+ /* @__PURE__ */ jsxRuntime.jsx(
11145
+ Form$2.Field,
11146
+ {
11147
+ control: form.control,
11148
+ name: "phone",
11149
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11150
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
11151
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11152
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11153
+ ] })
11154
+ }
11155
+ )
11156
+ ] }) }),
11157
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
11158
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11159
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
11160
+ ] }) })
11161
+ ]
11162
+ }
11163
+ ) });
11164
+ };
11165
+ const schema$3 = addressSchema;
11166
11166
  const PROMOTION_QUERY_KEY = "promotions";
11167
11167
  const promotionsQueryKeys = {
11168
11168
  list: (query2) => [
@@ -11440,6 +11440,112 @@ function getPromotionCodes(items, shippingMethods) {
11440
11440
  }
11441
11441
  return Array.from(codes);
11442
11442
  }
11443
+ const SalesChannel = () => {
11444
+ const { id } = reactRouterDom.useParams();
11445
+ const { draft_order, isPending, isError, error } = useDraftOrder(
11446
+ id,
11447
+ {
11448
+ fields: "+sales_channel_id"
11449
+ },
11450
+ {
11451
+ enabled: !!id
11452
+ }
11453
+ );
11454
+ if (isError) {
11455
+ throw error;
11456
+ }
11457
+ const ISrEADY = !!draft_order && !isPending;
11458
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
11459
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
11460
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
11461
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
11462
+ ] }),
11463
+ ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
11464
+ ] });
11465
+ };
11466
+ const SalesChannelForm = ({ order }) => {
11467
+ const form = reactHookForm.useForm({
11468
+ defaultValues: {
11469
+ sales_channel_id: order.sales_channel_id || ""
11470
+ },
11471
+ resolver: zod.zodResolver(schema$2)
11472
+ });
11473
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11474
+ const { handleSuccess } = useRouteModal();
11475
+ const onSubmit = form.handleSubmit(async (data) => {
11476
+ await mutateAsync(
11477
+ {
11478
+ sales_channel_id: data.sales_channel_id
11479
+ },
11480
+ {
11481
+ onSuccess: () => {
11482
+ ui.toast.success("Sales channel updated");
11483
+ handleSuccess();
11484
+ },
11485
+ onError: (error) => {
11486
+ ui.toast.error(error.message);
11487
+ }
11488
+ }
11489
+ );
11490
+ });
11491
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
11492
+ KeyboundForm,
11493
+ {
11494
+ className: "flex flex-1 flex-col overflow-hidden",
11495
+ onSubmit,
11496
+ children: [
11497
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
11498
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
11499
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11500
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
11501
+ ] }) })
11502
+ ]
11503
+ }
11504
+ ) });
11505
+ };
11506
+ const SalesChannelField = ({ control, order }) => {
11507
+ const salesChannels = useComboboxData({
11508
+ queryFn: async (params) => {
11509
+ return await sdk.admin.salesChannel.list(params);
11510
+ },
11511
+ queryKey: ["sales-channels"],
11512
+ getOptions: (data) => {
11513
+ return data.sales_channels.map((salesChannel) => ({
11514
+ label: salesChannel.name,
11515
+ value: salesChannel.id
11516
+ }));
11517
+ },
11518
+ defaultValue: order.sales_channel_id || void 0
11519
+ });
11520
+ return /* @__PURE__ */ jsxRuntime.jsx(
11521
+ Form$2.Field,
11522
+ {
11523
+ control,
11524
+ name: "sales_channel_id",
11525
+ render: ({ field }) => {
11526
+ return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11527
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
11528
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
11529
+ Combobox,
11530
+ {
11531
+ options: salesChannels.options,
11532
+ fetchNextPage: salesChannels.fetchNextPage,
11533
+ isFetchingNextPage: salesChannels.isFetchingNextPage,
11534
+ searchValue: salesChannels.searchValue,
11535
+ onSearchValueChange: salesChannels.onSearchValueChange,
11536
+ placeholder: "Select sales channel",
11537
+ ...field
11538
+ }
11539
+ ) }),
11540
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11541
+ ] });
11542
+ }
11543
+ }
11544
+ );
11545
+ };
11546
+ const schema$2 = objectType({
11547
+ sales_channel_id: stringType().min(1)
11548
+ });
11443
11549
  const STACKED_FOCUS_MODAL_ID = "shipping-form";
11444
11550
  const Shipping = () => {
11445
11551
  var _a;
@@ -12279,7 +12385,7 @@ const ShippingAddressForm = ({ order }) => {
12279
12385
  postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12280
12386
  phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12281
12387
  },
12282
- resolver: zod.zodResolver(schema$2)
12388
+ resolver: zod.zodResolver(schema$1)
12283
12389
  });
12284
12390
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12285
12391
  const { handleSuccess } = useRouteModal();
@@ -12449,7 +12555,7 @@ const ShippingAddressForm = ({ order }) => {
12449
12555
  }
12450
12556
  ) });
12451
12557
  };
12452
- const schema$2 = addressSchema;
12558
+ const schema$1 = addressSchema;
12453
12559
  const TransferOwnership = () => {
12454
12560
  const { id } = reactRouterDom.useParams();
12455
12561
  const { draft_order, isPending, isError, error } = useDraftOrder(id, {
@@ -12473,7 +12579,7 @@ const TransferOwnershipForm = ({ order }) => {
12473
12579
  defaultValues: {
12474
12580
  customer_id: order.customer_id || ""
12475
12581
  },
12476
- resolver: zod.zodResolver(schema$1)
12582
+ resolver: zod.zodResolver(schema)
12477
12583
  });
12478
12584
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12479
12585
  const { handleSuccess } = useRouteModal();
@@ -12923,114 +13029,8 @@ const Illustration = () => {
12923
13029
  }
12924
13030
  );
12925
13031
  };
12926
- const schema$1 = objectType({
12927
- customer_id: stringType().min(1)
12928
- });
12929
- const SalesChannel = () => {
12930
- const { id } = reactRouterDom.useParams();
12931
- const { draft_order, isPending, isError, error } = useDraftOrder(
12932
- id,
12933
- {
12934
- fields: "+sales_channel_id"
12935
- },
12936
- {
12937
- enabled: !!id
12938
- }
12939
- );
12940
- if (isError) {
12941
- throw error;
12942
- }
12943
- const ISrEADY = !!draft_order && !isPending;
12944
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12945
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
12946
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Sales Channel" }) }),
12947
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Update which sales channel the draft order is associated with" }) })
12948
- ] }),
12949
- ISrEADY && /* @__PURE__ */ jsxRuntime.jsx(SalesChannelForm, { order: draft_order })
12950
- ] });
12951
- };
12952
- const SalesChannelForm = ({ order }) => {
12953
- const form = reactHookForm.useForm({
12954
- defaultValues: {
12955
- sales_channel_id: order.sales_channel_id || ""
12956
- },
12957
- resolver: zod.zodResolver(schema)
12958
- });
12959
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12960
- const { handleSuccess } = useRouteModal();
12961
- const onSubmit = form.handleSubmit(async (data) => {
12962
- await mutateAsync(
12963
- {
12964
- sales_channel_id: data.sales_channel_id
12965
- },
12966
- {
12967
- onSuccess: () => {
12968
- ui.toast.success("Sales channel updated");
12969
- handleSuccess();
12970
- },
12971
- onError: (error) => {
12972
- ui.toast.error(error.message);
12973
- }
12974
- }
12975
- );
12976
- });
12977
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
12978
- KeyboundForm,
12979
- {
12980
- className: "flex flex-1 flex-col overflow-hidden",
12981
- onSubmit,
12982
- children: [
12983
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, { className: "flex flex-col gap-y-6 overflow-y-auto", children: /* @__PURE__ */ jsxRuntime.jsx(SalesChannelField, { control: form.control, order }) }),
12984
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
12985
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12986
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12987
- ] }) })
12988
- ]
12989
- }
12990
- ) });
12991
- };
12992
- const SalesChannelField = ({ control, order }) => {
12993
- const salesChannels = useComboboxData({
12994
- queryFn: async (params) => {
12995
- return await sdk.admin.salesChannel.list(params);
12996
- },
12997
- queryKey: ["sales-channels"],
12998
- getOptions: (data) => {
12999
- return data.sales_channels.map((salesChannel) => ({
13000
- label: salesChannel.name,
13001
- value: salesChannel.id
13002
- }));
13003
- },
13004
- defaultValue: order.sales_channel_id || void 0
13005
- });
13006
- return /* @__PURE__ */ jsxRuntime.jsx(
13007
- Form$2.Field,
13008
- {
13009
- control,
13010
- name: "sales_channel_id",
13011
- render: ({ field }) => {
13012
- return /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
13013
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Sales Channel" }),
13014
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(
13015
- Combobox,
13016
- {
13017
- options: salesChannels.options,
13018
- fetchNextPage: salesChannels.fetchNextPage,
13019
- isFetchingNextPage: salesChannels.isFetchingNextPage,
13020
- searchValue: salesChannels.searchValue,
13021
- onSearchValueChange: salesChannels.onSearchValueChange,
13022
- placeholder: "Select sales channel",
13023
- ...field
13024
- }
13025
- ) }),
13026
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
13027
- ] });
13028
- }
13029
- }
13030
- );
13031
- };
13032
13032
  const schema = objectType({
13033
- sales_channel_id: stringType().min(1)
13033
+ customer_id: stringType().min(1)
13034
13034
  });
13035
13035
  const widgetModule = { widgets: [] };
13036
13036
  const routeModule = {
@@ -13052,10 +13052,6 @@ const routeModule = {
13052
13052
  handle,
13053
13053
  loader,
13054
13054
  children: [
13055
- {
13056
- Component: BillingAddress,
13057
- path: "/draft-orders/:id/billing-address"
13058
- },
13059
13055
  {
13060
13056
  Component: CustomItems,
13061
13057
  path: "/draft-orders/:id/custom-items"
@@ -13072,10 +13068,18 @@ const routeModule = {
13072
13068
  Component: Metadata,
13073
13069
  path: "/draft-orders/:id/metadata"
13074
13070
  },
13071
+ {
13072
+ Component: BillingAddress,
13073
+ path: "/draft-orders/:id/billing-address"
13074
+ },
13075
13075
  {
13076
13076
  Component: Promotions,
13077
13077
  path: "/draft-orders/:id/promotions"
13078
13078
  },
13079
+ {
13080
+ Component: SalesChannel,
13081
+ path: "/draft-orders/:id/sales-channel"
13082
+ },
13079
13083
  {
13080
13084
  Component: Shipping,
13081
13085
  path: "/draft-orders/:id/shipping"
@@ -13087,10 +13091,6 @@ const routeModule = {
13087
13091
  {
13088
13092
  Component: TransferOwnership,
13089
13093
  path: "/draft-orders/:id/transfer-ownership"
13090
- },
13091
- {
13092
- Component: SalesChannel,
13093
- path: "/draft-orders/:id/sales-channel"
13094
13094
  }
13095
13095
  ]
13096
13096
  }