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