@medusajs/draft-order 2.15.5 → 2.15.6-preview-20260601073416

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,27 @@ const ID = () => {
9899
9899
  /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Outlet, {})
9900
9900
  ] });
9901
9901
  };
9902
+ const CustomItems = () => {
9903
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9904
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
9905
+ /* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
9906
+ ] });
9907
+ };
9908
+ const CustomItemsForm = () => {
9909
+ const form = reactHookForm.useForm({
9910
+ resolver: zod.zodResolver(schema$5)
9911
+ });
9912
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9913
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
9914
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
9915
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9916
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
9917
+ ] }) })
9918
+ ] }) });
9919
+ };
9920
+ const schema$5 = object({
9921
+ email: string().email()
9922
+ });
9902
9923
  const BillingAddress = () => {
9903
9924
  const { id } = reactRouterDom.useParams();
9904
9925
  const { order, isPending, isError, error } = useOrder(id, {
@@ -9931,7 +9952,7 @@ const BillingAddressForm = ({ order }) => {
9931
9952
  postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
9932
9953
  phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
9933
9954
  },
9934
- resolver: zod.zodResolver(schema$5)
9955
+ resolver: zod.zodResolver(schema$4)
9935
9956
  });
9936
9957
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9937
9958
  const { handleSuccess } = useRouteModal();
@@ -10088,28 +10109,7 @@ const BillingAddressForm = ({ order }) => {
10088
10109
  }
10089
10110
  ) });
10090
10111
  };
10091
- const schema$5 = addressSchema;
10092
- const CustomItems = () => {
10093
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
10094
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
10095
- /* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
10096
- ] });
10097
- };
10098
- const CustomItemsForm = () => {
10099
- const form = reactHookForm.useForm({
10100
- resolver: zod.zodResolver(schema$4)
10101
- });
10102
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
10103
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
10104
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
10105
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
10106
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
10107
- ] }) })
10108
- ] }) });
10109
- };
10110
- const schema$4 = object({
10111
- email: string().email()
10112
- });
10112
+ const schema$4 = addressSchema;
10113
10113
  const Email = () => {
10114
10114
  const { id } = reactRouterDom.useParams();
10115
10115
  const { order, isPending, isError, error } = useOrder(id, {
@@ -12692,209 +12692,6 @@ const CustomAmountField = ({
12692
12692
  }
12693
12693
  );
12694
12694
  };
12695
- const ShippingAddress = () => {
12696
- const { id } = reactRouterDom.useParams();
12697
- const { order, isPending, isError, error } = useOrder(id, {
12698
- fields: "+shipping_address"
12699
- });
12700
- if (isError) {
12701
- throw error;
12702
- }
12703
- const isReady = !isPending && !!order;
12704
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12705
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
12706
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Shipping Address" }) }),
12707
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
12708
- ] }),
12709
- isReady && /* @__PURE__ */ jsxRuntime.jsx(ShippingAddressForm, { order })
12710
- ] });
12711
- };
12712
- const ShippingAddressForm = ({ order }) => {
12713
- var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12714
- const form = reactHookForm.useForm({
12715
- defaultValues: {
12716
- first_name: ((_a2 = order.shipping_address) == null ? void 0 : _a2.first_name) ?? "",
12717
- last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
12718
- company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
12719
- address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
12720
- address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
12721
- city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
12722
- province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
12723
- country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
12724
- postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12725
- phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12726
- },
12727
- resolver: zod.zodResolver(schema$1)
12728
- });
12729
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12730
- const { handleSuccess } = useRouteModal();
12731
- const onSubmit = form.handleSubmit(async (data) => {
12732
- await mutateAsync(
12733
- {
12734
- shipping_address: {
12735
- first_name: data.first_name,
12736
- last_name: data.last_name,
12737
- company: data.company,
12738
- address_1: data.address_1,
12739
- address_2: data.address_2,
12740
- city: data.city,
12741
- province: data.province,
12742
- country_code: data.country_code,
12743
- postal_code: data.postal_code,
12744
- phone: data.phone
12745
- }
12746
- },
12747
- {
12748
- onSuccess: () => {
12749
- handleSuccess();
12750
- },
12751
- onError: (error) => {
12752
- ui.toast.error(error.message);
12753
- }
12754
- }
12755
- );
12756
- });
12757
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
12758
- KeyboundForm,
12759
- {
12760
- className: "flex flex-1 flex-col overflow-hidden",
12761
- onSubmit,
12762
- children: [
12763
- /* @__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: [
12764
- /* @__PURE__ */ jsxRuntime.jsx(
12765
- Form$2.Field,
12766
- {
12767
- control: form.control,
12768
- name: "country_code",
12769
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12770
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
12771
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
12772
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12773
- ] })
12774
- }
12775
- ),
12776
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12777
- /* @__PURE__ */ jsxRuntime.jsx(
12778
- Form$2.Field,
12779
- {
12780
- control: form.control,
12781
- name: "first_name",
12782
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12783
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
12784
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12785
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12786
- ] })
12787
- }
12788
- ),
12789
- /* @__PURE__ */ jsxRuntime.jsx(
12790
- Form$2.Field,
12791
- {
12792
- control: form.control,
12793
- name: "last_name",
12794
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12795
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
12796
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12797
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12798
- ] })
12799
- }
12800
- )
12801
- ] }),
12802
- /* @__PURE__ */ jsxRuntime.jsx(
12803
- Form$2.Field,
12804
- {
12805
- control: form.control,
12806
- name: "company",
12807
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12808
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
12809
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12810
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12811
- ] })
12812
- }
12813
- ),
12814
- /* @__PURE__ */ jsxRuntime.jsx(
12815
- Form$2.Field,
12816
- {
12817
- control: form.control,
12818
- name: "address_1",
12819
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12820
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
12821
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12822
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12823
- ] })
12824
- }
12825
- ),
12826
- /* @__PURE__ */ jsxRuntime.jsx(
12827
- Form$2.Field,
12828
- {
12829
- control: form.control,
12830
- name: "address_2",
12831
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12832
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
12833
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12834
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12835
- ] })
12836
- }
12837
- ),
12838
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12839
- /* @__PURE__ */ jsxRuntime.jsx(
12840
- Form$2.Field,
12841
- {
12842
- control: form.control,
12843
- name: "postal_code",
12844
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12845
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
12846
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12847
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12848
- ] })
12849
- }
12850
- ),
12851
- /* @__PURE__ */ jsxRuntime.jsx(
12852
- Form$2.Field,
12853
- {
12854
- control: form.control,
12855
- name: "city",
12856
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12857
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
12858
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12859
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12860
- ] })
12861
- }
12862
- )
12863
- ] }),
12864
- /* @__PURE__ */ jsxRuntime.jsx(
12865
- Form$2.Field,
12866
- {
12867
- control: form.control,
12868
- name: "province",
12869
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12870
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
12871
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12872
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12873
- ] })
12874
- }
12875
- ),
12876
- /* @__PURE__ */ jsxRuntime.jsx(
12877
- Form$2.Field,
12878
- {
12879
- control: form.control,
12880
- name: "phone",
12881
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12882
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
12883
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12884
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12885
- ] })
12886
- }
12887
- )
12888
- ] }) }),
12889
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
12890
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12891
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12892
- ] }) })
12893
- ]
12894
- }
12895
- ) });
12896
- };
12897
- const schema$1 = addressSchema;
12898
12695
  const TransferOwnership = () => {
12899
12696
  const { id } = reactRouterDom.useParams();
12900
12697
  const { draft_order, isPending, isError, error } = useDraftOrder(id, {
@@ -12918,7 +12715,7 @@ const TransferOwnershipForm = ({ order }) => {
12918
12715
  defaultValues: {
12919
12716
  customer_id: order.customer_id || ""
12920
12717
  },
12921
- resolver: zod.zodResolver(schema)
12718
+ resolver: zod.zodResolver(schema$1)
12922
12719
  });
12923
12720
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12924
12721
  const { handleSuccess } = useRouteModal();
@@ -13368,9 +13165,212 @@ const Illustration = () => {
13368
13165
  }
13369
13166
  );
13370
13167
  };
13371
- const schema = object({
13168
+ const schema$1 = object({
13372
13169
  customer_id: string().min(1)
13373
13170
  });
13171
+ const ShippingAddress = () => {
13172
+ const { id } = reactRouterDom.useParams();
13173
+ const { order, isPending, isError, error } = useOrder(id, {
13174
+ fields: "+shipping_address"
13175
+ });
13176
+ if (isError) {
13177
+ throw error;
13178
+ }
13179
+ const isReady = !isPending && !!order;
13180
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
13181
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
13182
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Shipping Address" }) }),
13183
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
13184
+ ] }),
13185
+ isReady && /* @__PURE__ */ jsxRuntime.jsx(ShippingAddressForm, { order })
13186
+ ] });
13187
+ };
13188
+ const ShippingAddressForm = ({ order }) => {
13189
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j;
13190
+ const form = reactHookForm.useForm({
13191
+ defaultValues: {
13192
+ first_name: ((_a2 = order.shipping_address) == null ? void 0 : _a2.first_name) ?? "",
13193
+ last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
13194
+ company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
13195
+ address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
13196
+ address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
13197
+ city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
13198
+ province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
13199
+ country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
13200
+ postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
13201
+ phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
13202
+ },
13203
+ resolver: zod.zodResolver(schema)
13204
+ });
13205
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
13206
+ const { handleSuccess } = useRouteModal();
13207
+ const onSubmit = form.handleSubmit(async (data) => {
13208
+ await mutateAsync(
13209
+ {
13210
+ shipping_address: {
13211
+ first_name: data.first_name,
13212
+ last_name: data.last_name,
13213
+ company: data.company,
13214
+ address_1: data.address_1,
13215
+ address_2: data.address_2,
13216
+ city: data.city,
13217
+ province: data.province,
13218
+ country_code: data.country_code,
13219
+ postal_code: data.postal_code,
13220
+ phone: data.phone
13221
+ }
13222
+ },
13223
+ {
13224
+ onSuccess: () => {
13225
+ handleSuccess();
13226
+ },
13227
+ onError: (error) => {
13228
+ ui.toast.error(error.message);
13229
+ }
13230
+ }
13231
+ );
13232
+ });
13233
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
13234
+ KeyboundForm,
13235
+ {
13236
+ className: "flex flex-1 flex-col overflow-hidden",
13237
+ onSubmit,
13238
+ children: [
13239
+ /* @__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: [
13240
+ /* @__PURE__ */ jsxRuntime.jsx(
13241
+ Form$2.Field,
13242
+ {
13243
+ control: form.control,
13244
+ name: "country_code",
13245
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
13246
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
13247
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
13248
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
13249
+ ] })
13250
+ }
13251
+ ),
13252
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
13253
+ /* @__PURE__ */ jsxRuntime.jsx(
13254
+ Form$2.Field,
13255
+ {
13256
+ control: form.control,
13257
+ name: "first_name",
13258
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
13259
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
13260
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
13261
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
13262
+ ] })
13263
+ }
13264
+ ),
13265
+ /* @__PURE__ */ jsxRuntime.jsx(
13266
+ Form$2.Field,
13267
+ {
13268
+ control: form.control,
13269
+ name: "last_name",
13270
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
13271
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
13272
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
13273
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
13274
+ ] })
13275
+ }
13276
+ )
13277
+ ] }),
13278
+ /* @__PURE__ */ jsxRuntime.jsx(
13279
+ Form$2.Field,
13280
+ {
13281
+ control: form.control,
13282
+ name: "company",
13283
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
13284
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
13285
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
13286
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
13287
+ ] })
13288
+ }
13289
+ ),
13290
+ /* @__PURE__ */ jsxRuntime.jsx(
13291
+ Form$2.Field,
13292
+ {
13293
+ control: form.control,
13294
+ name: "address_1",
13295
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
13296
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
13297
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
13298
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
13299
+ ] })
13300
+ }
13301
+ ),
13302
+ /* @__PURE__ */ jsxRuntime.jsx(
13303
+ Form$2.Field,
13304
+ {
13305
+ control: form.control,
13306
+ name: "address_2",
13307
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
13308
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
13309
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
13310
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
13311
+ ] })
13312
+ }
13313
+ ),
13314
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
13315
+ /* @__PURE__ */ jsxRuntime.jsx(
13316
+ Form$2.Field,
13317
+ {
13318
+ control: form.control,
13319
+ name: "postal_code",
13320
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
13321
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
13322
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
13323
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
13324
+ ] })
13325
+ }
13326
+ ),
13327
+ /* @__PURE__ */ jsxRuntime.jsx(
13328
+ Form$2.Field,
13329
+ {
13330
+ control: form.control,
13331
+ name: "city",
13332
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
13333
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
13334
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
13335
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
13336
+ ] })
13337
+ }
13338
+ )
13339
+ ] }),
13340
+ /* @__PURE__ */ jsxRuntime.jsx(
13341
+ Form$2.Field,
13342
+ {
13343
+ control: form.control,
13344
+ name: "province",
13345
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
13346
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
13347
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
13348
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
13349
+ ] })
13350
+ }
13351
+ ),
13352
+ /* @__PURE__ */ jsxRuntime.jsx(
13353
+ Form$2.Field,
13354
+ {
13355
+ control: form.control,
13356
+ name: "phone",
13357
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
13358
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
13359
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
13360
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
13361
+ ] })
13362
+ }
13363
+ )
13364
+ ] }) }),
13365
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
13366
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
13367
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
13368
+ ] }) })
13369
+ ]
13370
+ }
13371
+ ) });
13372
+ };
13373
+ const schema = addressSchema;
13374
13374
  const widgetModule = { widgets: [] };
13375
13375
  const routeModule = {
13376
13376
  routes: [
@@ -13391,14 +13391,14 @@ const routeModule = {
13391
13391
  handle,
13392
13392
  loader,
13393
13393
  children: [
13394
- {
13395
- Component: BillingAddress,
13396
- path: "/draft-orders/:id/billing-address"
13397
- },
13398
13394
  {
13399
13395
  Component: CustomItems,
13400
13396
  path: "/draft-orders/:id/custom-items"
13401
13397
  },
13398
+ {
13399
+ Component: BillingAddress,
13400
+ path: "/draft-orders/:id/billing-address"
13401
+ },
13402
13402
  {
13403
13403
  Component: Email,
13404
13404
  path: "/draft-orders/:id/email"
@@ -13423,13 +13423,13 @@ const routeModule = {
13423
13423
  Component: Shipping,
13424
13424
  path: "/draft-orders/:id/shipping"
13425
13425
  },
13426
- {
13427
- Component: ShippingAddress,
13428
- path: "/draft-orders/:id/shipping-address"
13429
- },
13430
13426
  {
13431
13427
  Component: TransferOwnership,
13432
13428
  path: "/draft-orders/:id/transfer-ownership"
13429
+ },
13430
+ {
13431
+ Component: ShippingAddress,
13432
+ path: "/draft-orders/:id/shipping-address"
13433
13433
  }
13434
13434
  ]
13435
13435
  }
@@ -9892,6 +9892,27 @@ const ID = () => {
9892
9892
  /* @__PURE__ */ jsx(Outlet, {})
9893
9893
  ] });
9894
9894
  };
9895
+ const CustomItems = () => {
9896
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
9897
+ /* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
9898
+ /* @__PURE__ */ jsx(CustomItemsForm, {})
9899
+ ] });
9900
+ };
9901
+ const CustomItemsForm = () => {
9902
+ const form = useForm({
9903
+ resolver: zodResolver(schema$5)
9904
+ });
9905
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9906
+ /* @__PURE__ */ jsx(RouteDrawer.Body, {}),
9907
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
9908
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9909
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
9910
+ ] }) })
9911
+ ] }) });
9912
+ };
9913
+ const schema$5 = object({
9914
+ email: string().email()
9915
+ });
9895
9916
  const BillingAddress = () => {
9896
9917
  const { id } = useParams();
9897
9918
  const { order, isPending, isError, error } = useOrder(id, {
@@ -9924,7 +9945,7 @@ const BillingAddressForm = ({ order }) => {
9924
9945
  postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
9925
9946
  phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
9926
9947
  },
9927
- resolver: zodResolver(schema$5)
9948
+ resolver: zodResolver(schema$4)
9928
9949
  });
9929
9950
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9930
9951
  const { handleSuccess } = useRouteModal();
@@ -10081,28 +10102,7 @@ const BillingAddressForm = ({ order }) => {
10081
10102
  }
10082
10103
  ) });
10083
10104
  };
10084
- const schema$5 = addressSchema;
10085
- const CustomItems = () => {
10086
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
10087
- /* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
10088
- /* @__PURE__ */ jsx(CustomItemsForm, {})
10089
- ] });
10090
- };
10091
- const CustomItemsForm = () => {
10092
- const form = useForm({
10093
- resolver: zodResolver(schema$4)
10094
- });
10095
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
10096
- /* @__PURE__ */ jsx(RouteDrawer.Body, {}),
10097
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
10098
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
10099
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
10100
- ] }) })
10101
- ] }) });
10102
- };
10103
- const schema$4 = object({
10104
- email: string().email()
10105
- });
10105
+ const schema$4 = addressSchema;
10106
10106
  const Email = () => {
10107
10107
  const { id } = useParams();
10108
10108
  const { order, isPending, isError, error } = useOrder(id, {
@@ -12685,209 +12685,6 @@ const CustomAmountField = ({
12685
12685
  }
12686
12686
  );
12687
12687
  };
12688
- const ShippingAddress = () => {
12689
- const { id } = useParams();
12690
- const { order, isPending, isError, error } = useOrder(id, {
12691
- fields: "+shipping_address"
12692
- });
12693
- if (isError) {
12694
- throw error;
12695
- }
12696
- const isReady = !isPending && !!order;
12697
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
12698
- /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
12699
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Shipping Address" }) }),
12700
- /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
12701
- ] }),
12702
- isReady && /* @__PURE__ */ jsx(ShippingAddressForm, { order })
12703
- ] });
12704
- };
12705
- const ShippingAddressForm = ({ order }) => {
12706
- var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12707
- const form = useForm({
12708
- defaultValues: {
12709
- first_name: ((_a2 = order.shipping_address) == null ? void 0 : _a2.first_name) ?? "",
12710
- last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
12711
- company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
12712
- address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
12713
- address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
12714
- city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
12715
- province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
12716
- country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
12717
- postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12718
- phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12719
- },
12720
- resolver: zodResolver(schema$1)
12721
- });
12722
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12723
- const { handleSuccess } = useRouteModal();
12724
- const onSubmit = form.handleSubmit(async (data) => {
12725
- await mutateAsync(
12726
- {
12727
- shipping_address: {
12728
- first_name: data.first_name,
12729
- last_name: data.last_name,
12730
- company: data.company,
12731
- address_1: data.address_1,
12732
- address_2: data.address_2,
12733
- city: data.city,
12734
- province: data.province,
12735
- country_code: data.country_code,
12736
- postal_code: data.postal_code,
12737
- phone: data.phone
12738
- }
12739
- },
12740
- {
12741
- onSuccess: () => {
12742
- handleSuccess();
12743
- },
12744
- onError: (error) => {
12745
- toast.error(error.message);
12746
- }
12747
- }
12748
- );
12749
- });
12750
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
12751
- KeyboundForm,
12752
- {
12753
- className: "flex flex-1 flex-col overflow-hidden",
12754
- onSubmit,
12755
- children: [
12756
- /* @__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: [
12757
- /* @__PURE__ */ jsx(
12758
- Form$2.Field,
12759
- {
12760
- control: form.control,
12761
- name: "country_code",
12762
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12763
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
12764
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
12765
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12766
- ] })
12767
- }
12768
- ),
12769
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12770
- /* @__PURE__ */ jsx(
12771
- Form$2.Field,
12772
- {
12773
- control: form.control,
12774
- name: "first_name",
12775
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12776
- /* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
12777
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12778
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12779
- ] })
12780
- }
12781
- ),
12782
- /* @__PURE__ */ jsx(
12783
- Form$2.Field,
12784
- {
12785
- control: form.control,
12786
- name: "last_name",
12787
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12788
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
12789
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12790
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12791
- ] })
12792
- }
12793
- )
12794
- ] }),
12795
- /* @__PURE__ */ jsx(
12796
- Form$2.Field,
12797
- {
12798
- control: form.control,
12799
- name: "company",
12800
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12801
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
12802
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12803
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12804
- ] })
12805
- }
12806
- ),
12807
- /* @__PURE__ */ jsx(
12808
- Form$2.Field,
12809
- {
12810
- control: form.control,
12811
- name: "address_1",
12812
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12813
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
12814
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12815
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12816
- ] })
12817
- }
12818
- ),
12819
- /* @__PURE__ */ jsx(
12820
- Form$2.Field,
12821
- {
12822
- control: form.control,
12823
- name: "address_2",
12824
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12825
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
12826
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12827
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12828
- ] })
12829
- }
12830
- ),
12831
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12832
- /* @__PURE__ */ jsx(
12833
- Form$2.Field,
12834
- {
12835
- control: form.control,
12836
- name: "postal_code",
12837
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12838
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
12839
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12840
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12841
- ] })
12842
- }
12843
- ),
12844
- /* @__PURE__ */ jsx(
12845
- Form$2.Field,
12846
- {
12847
- control: form.control,
12848
- name: "city",
12849
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12850
- /* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
12851
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12852
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12853
- ] })
12854
- }
12855
- )
12856
- ] }),
12857
- /* @__PURE__ */ jsx(
12858
- Form$2.Field,
12859
- {
12860
- control: form.control,
12861
- name: "province",
12862
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12863
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
12864
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12865
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12866
- ] })
12867
- }
12868
- ),
12869
- /* @__PURE__ */ jsx(
12870
- Form$2.Field,
12871
- {
12872
- control: form.control,
12873
- name: "phone",
12874
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12875
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
12876
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12877
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12878
- ] })
12879
- }
12880
- )
12881
- ] }) }),
12882
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
12883
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12884
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12885
- ] }) })
12886
- ]
12887
- }
12888
- ) });
12889
- };
12890
- const schema$1 = addressSchema;
12891
12688
  const TransferOwnership = () => {
12892
12689
  const { id } = useParams();
12893
12690
  const { draft_order, isPending, isError, error } = useDraftOrder(id, {
@@ -12911,7 +12708,7 @@ const TransferOwnershipForm = ({ order }) => {
12911
12708
  defaultValues: {
12912
12709
  customer_id: order.customer_id || ""
12913
12710
  },
12914
- resolver: zodResolver(schema)
12711
+ resolver: zodResolver(schema$1)
12915
12712
  });
12916
12713
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12917
12714
  const { handleSuccess } = useRouteModal();
@@ -13361,9 +13158,212 @@ const Illustration = () => {
13361
13158
  }
13362
13159
  );
13363
13160
  };
13364
- const schema = object({
13161
+ const schema$1 = object({
13365
13162
  customer_id: string().min(1)
13366
13163
  });
13164
+ const ShippingAddress = () => {
13165
+ const { id } = useParams();
13166
+ const { order, isPending, isError, error } = useOrder(id, {
13167
+ fields: "+shipping_address"
13168
+ });
13169
+ if (isError) {
13170
+ throw error;
13171
+ }
13172
+ const isReady = !isPending && !!order;
13173
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
13174
+ /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
13175
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Shipping Address" }) }),
13176
+ /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
13177
+ ] }),
13178
+ isReady && /* @__PURE__ */ jsx(ShippingAddressForm, { order })
13179
+ ] });
13180
+ };
13181
+ const ShippingAddressForm = ({ order }) => {
13182
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j;
13183
+ const form = useForm({
13184
+ defaultValues: {
13185
+ first_name: ((_a2 = order.shipping_address) == null ? void 0 : _a2.first_name) ?? "",
13186
+ last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
13187
+ company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
13188
+ address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
13189
+ address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
13190
+ city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
13191
+ province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
13192
+ country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
13193
+ postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
13194
+ phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
13195
+ },
13196
+ resolver: zodResolver(schema)
13197
+ });
13198
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
13199
+ const { handleSuccess } = useRouteModal();
13200
+ const onSubmit = form.handleSubmit(async (data) => {
13201
+ await mutateAsync(
13202
+ {
13203
+ shipping_address: {
13204
+ first_name: data.first_name,
13205
+ last_name: data.last_name,
13206
+ company: data.company,
13207
+ address_1: data.address_1,
13208
+ address_2: data.address_2,
13209
+ city: data.city,
13210
+ province: data.province,
13211
+ country_code: data.country_code,
13212
+ postal_code: data.postal_code,
13213
+ phone: data.phone
13214
+ }
13215
+ },
13216
+ {
13217
+ onSuccess: () => {
13218
+ handleSuccess();
13219
+ },
13220
+ onError: (error) => {
13221
+ toast.error(error.message);
13222
+ }
13223
+ }
13224
+ );
13225
+ });
13226
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
13227
+ KeyboundForm,
13228
+ {
13229
+ className: "flex flex-1 flex-col overflow-hidden",
13230
+ onSubmit,
13231
+ children: [
13232
+ /* @__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: [
13233
+ /* @__PURE__ */ jsx(
13234
+ Form$2.Field,
13235
+ {
13236
+ control: form.control,
13237
+ name: "country_code",
13238
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
13239
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
13240
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
13241
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
13242
+ ] })
13243
+ }
13244
+ ),
13245
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
13246
+ /* @__PURE__ */ jsx(
13247
+ Form$2.Field,
13248
+ {
13249
+ control: form.control,
13250
+ name: "first_name",
13251
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
13252
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
13253
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
13254
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
13255
+ ] })
13256
+ }
13257
+ ),
13258
+ /* @__PURE__ */ jsx(
13259
+ Form$2.Field,
13260
+ {
13261
+ control: form.control,
13262
+ name: "last_name",
13263
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
13264
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
13265
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
13266
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
13267
+ ] })
13268
+ }
13269
+ )
13270
+ ] }),
13271
+ /* @__PURE__ */ jsx(
13272
+ Form$2.Field,
13273
+ {
13274
+ control: form.control,
13275
+ name: "company",
13276
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
13277
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
13278
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
13279
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
13280
+ ] })
13281
+ }
13282
+ ),
13283
+ /* @__PURE__ */ jsx(
13284
+ Form$2.Field,
13285
+ {
13286
+ control: form.control,
13287
+ name: "address_1",
13288
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
13289
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
13290
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
13291
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
13292
+ ] })
13293
+ }
13294
+ ),
13295
+ /* @__PURE__ */ jsx(
13296
+ Form$2.Field,
13297
+ {
13298
+ control: form.control,
13299
+ name: "address_2",
13300
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
13301
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
13302
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
13303
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
13304
+ ] })
13305
+ }
13306
+ ),
13307
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
13308
+ /* @__PURE__ */ jsx(
13309
+ Form$2.Field,
13310
+ {
13311
+ control: form.control,
13312
+ name: "postal_code",
13313
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
13314
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
13315
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
13316
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
13317
+ ] })
13318
+ }
13319
+ ),
13320
+ /* @__PURE__ */ jsx(
13321
+ Form$2.Field,
13322
+ {
13323
+ control: form.control,
13324
+ name: "city",
13325
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
13326
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
13327
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
13328
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
13329
+ ] })
13330
+ }
13331
+ )
13332
+ ] }),
13333
+ /* @__PURE__ */ jsx(
13334
+ Form$2.Field,
13335
+ {
13336
+ control: form.control,
13337
+ name: "province",
13338
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
13339
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
13340
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
13341
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
13342
+ ] })
13343
+ }
13344
+ ),
13345
+ /* @__PURE__ */ jsx(
13346
+ Form$2.Field,
13347
+ {
13348
+ control: form.control,
13349
+ name: "phone",
13350
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
13351
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
13352
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
13353
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
13354
+ ] })
13355
+ }
13356
+ )
13357
+ ] }) }),
13358
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
13359
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
13360
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
13361
+ ] }) })
13362
+ ]
13363
+ }
13364
+ ) });
13365
+ };
13366
+ const schema = addressSchema;
13367
13367
  const widgetModule = { widgets: [] };
13368
13368
  const routeModule = {
13369
13369
  routes: [
@@ -13384,14 +13384,14 @@ const routeModule = {
13384
13384
  handle,
13385
13385
  loader,
13386
13386
  children: [
13387
- {
13388
- Component: BillingAddress,
13389
- path: "/draft-orders/:id/billing-address"
13390
- },
13391
13387
  {
13392
13388
  Component: CustomItems,
13393
13389
  path: "/draft-orders/:id/custom-items"
13394
13390
  },
13391
+ {
13392
+ Component: BillingAddress,
13393
+ path: "/draft-orders/:id/billing-address"
13394
+ },
13395
13395
  {
13396
13396
  Component: Email,
13397
13397
  path: "/draft-orders/:id/email"
@@ -13416,13 +13416,13 @@ const routeModule = {
13416
13416
  Component: Shipping,
13417
13417
  path: "/draft-orders/:id/shipping"
13418
13418
  },
13419
- {
13420
- Component: ShippingAddress,
13421
- path: "/draft-orders/:id/shipping-address"
13422
- },
13423
13419
  {
13424
13420
  Component: TransferOwnership,
13425
13421
  path: "/draft-orders/:id/transfer-ownership"
13422
+ },
13423
+ {
13424
+ Component: ShippingAddress,
13425
+ path: "/draft-orders/:id/shipping-address"
13426
13426
  }
13427
13427
  ]
13428
13428
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medusajs/draft-order",
3
- "version": "2.15.5",
3
+ "version": "2.15.6-preview-20260601073416",
4
4
  "description": "A draft order plugin for Medusa.",
5
5
  "author": "Medusa (https://medusajs.com)",
6
6
  "license": "MIT",
@@ -42,7 +42,7 @@
42
42
  "@ariakit/react": "^0.4.15",
43
43
  "@babel/runtime": "^7.26.10",
44
44
  "@hookform/resolvers": "3.4.2",
45
- "@medusajs/js-sdk": "2.15.5",
45
+ "@medusajs/js-sdk": "2.15.6-preview-20260601073416",
46
46
  "@tanstack/react-query": "5.64.2",
47
47
  "@uiw/react-json-view": "^2.0.0-alpha.17",
48
48
  "date-fns": "^3.6.0",
@@ -53,22 +53,22 @@
53
53
  "react-hook-form": "7.49.1"
54
54
  },
55
55
  "devDependencies": {
56
- "@medusajs/admin-sdk": "2.15.5",
57
- "@medusajs/cli": "2.15.5",
58
- "@medusajs/framework": "2.15.5",
59
- "@medusajs/icons": "2.15.5",
60
- "@medusajs/test-utils": "2.15.5",
61
- "@medusajs/types": "2.15.5",
62
- "@medusajs/ui": "4.1.15",
63
- "@medusajs/ui-preset": "2.15.5"
56
+ "@medusajs/admin-sdk": "2.15.6-preview-20260601073416",
57
+ "@medusajs/cli": "2.15.6-preview-20260601073416",
58
+ "@medusajs/framework": "2.15.6-preview-20260601073416",
59
+ "@medusajs/icons": "2.15.6-preview-20260601073416",
60
+ "@medusajs/test-utils": "2.15.6-preview-20260601073416",
61
+ "@medusajs/types": "2.15.6-preview-20260601073416",
62
+ "@medusajs/ui": "4.1.16-preview-20260601073416",
63
+ "@medusajs/ui-preset": "2.15.6-preview-20260601073416"
64
64
  },
65
65
  "peerDependencies": {
66
- "@medusajs/admin-sdk": "2.15.5",
67
- "@medusajs/cli": "2.15.5",
68
- "@medusajs/framework": "2.15.5",
69
- "@medusajs/icons": "2.15.5",
70
- "@medusajs/test-utils": "2.15.5",
71
- "@medusajs/ui": "4.1.15",
66
+ "@medusajs/admin-sdk": "2.15.6-preview-20260601073416",
67
+ "@medusajs/cli": "2.15.6-preview-20260601073416",
68
+ "@medusajs/framework": "2.15.6-preview-20260601073416",
69
+ "@medusajs/icons": "2.15.6-preview-20260601073416",
70
+ "@medusajs/test-utils": "2.15.6-preview-20260601073416",
71
+ "@medusajs/ui": "4.1.16-preview-20260601073416",
72
72
  "react": "^18.3.1",
73
73
  "react-dom": "^18.3.1",
74
74
  "react-router-dom": "6.30.3"