@medusajs/draft-order 2.11.3-preview-20251101180137 → 2.11.3-preview-20251102000316

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.
@@ -9572,6 +9572,196 @@ const ID = () => {
9572
9572
  /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Outlet, {})
9573
9573
  ] });
9574
9574
  };
9575
+ const BillingAddress = () => {
9576
+ const { id } = reactRouterDom.useParams();
9577
+ const { order, isPending, isError, error } = useOrder(id, {
9578
+ fields: "+billing_address"
9579
+ });
9580
+ if (isError) {
9581
+ throw error;
9582
+ }
9583
+ const isReady = !isPending && !!order;
9584
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9585
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
9586
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Billing Address" }) }),
9587
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
9588
+ ] }),
9589
+ isReady && /* @__PURE__ */ jsxRuntime.jsx(BillingAddressForm, { order })
9590
+ ] });
9591
+ };
9592
+ const BillingAddressForm = ({ order }) => {
9593
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
9594
+ const form = reactHookForm.useForm({
9595
+ defaultValues: {
9596
+ first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
9597
+ last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
9598
+ company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
9599
+ address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
9600
+ address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
9601
+ city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
9602
+ province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
9603
+ country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
9604
+ postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
9605
+ phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
9606
+ },
9607
+ resolver: zod.zodResolver(schema$5)
9608
+ });
9609
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9610
+ const { handleSuccess } = useRouteModal();
9611
+ const onSubmit = form.handleSubmit(async (data) => {
9612
+ await mutateAsync(
9613
+ { billing_address: data },
9614
+ {
9615
+ onSuccess: () => {
9616
+ handleSuccess();
9617
+ },
9618
+ onError: (error) => {
9619
+ ui.toast.error(error.message);
9620
+ }
9621
+ }
9622
+ );
9623
+ });
9624
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
9625
+ KeyboundForm,
9626
+ {
9627
+ className: "flex flex-1 flex-col overflow-hidden",
9628
+ onSubmit,
9629
+ children: [
9630
+ /* @__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: [
9631
+ /* @__PURE__ */ jsxRuntime.jsx(
9632
+ Form$2.Field,
9633
+ {
9634
+ control: form.control,
9635
+ name: "country_code",
9636
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9637
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
9638
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
9639
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9640
+ ] })
9641
+ }
9642
+ ),
9643
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
9644
+ /* @__PURE__ */ jsxRuntime.jsx(
9645
+ Form$2.Field,
9646
+ {
9647
+ control: form.control,
9648
+ name: "first_name",
9649
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9650
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First 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
+ /* @__PURE__ */ jsxRuntime.jsx(
9657
+ Form$2.Field,
9658
+ {
9659
+ control: form.control,
9660
+ name: "last_name",
9661
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9662
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
9663
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9664
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9665
+ ] })
9666
+ }
9667
+ )
9668
+ ] }),
9669
+ /* @__PURE__ */ jsxRuntime.jsx(
9670
+ Form$2.Field,
9671
+ {
9672
+ control: form.control,
9673
+ name: "company",
9674
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9675
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
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_1",
9686
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9687
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
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.jsx(
9694
+ Form$2.Field,
9695
+ {
9696
+ control: form.control,
9697
+ name: "address_2",
9698
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9699
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
9700
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9701
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9702
+ ] })
9703
+ }
9704
+ ),
9705
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
9706
+ /* @__PURE__ */ jsxRuntime.jsx(
9707
+ Form$2.Field,
9708
+ {
9709
+ control: form.control,
9710
+ name: "postal_code",
9711
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9712
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
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
+ /* @__PURE__ */ jsxRuntime.jsx(
9719
+ Form$2.Field,
9720
+ {
9721
+ control: form.control,
9722
+ name: "city",
9723
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9724
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
9725
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9726
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9727
+ ] })
9728
+ }
9729
+ )
9730
+ ] }),
9731
+ /* @__PURE__ */ jsxRuntime.jsx(
9732
+ Form$2.Field,
9733
+ {
9734
+ control: form.control,
9735
+ name: "province",
9736
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9737
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
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
+ /* @__PURE__ */ jsxRuntime.jsx(
9744
+ Form$2.Field,
9745
+ {
9746
+ control: form.control,
9747
+ name: "phone",
9748
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9749
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
9750
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9751
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9752
+ ] })
9753
+ }
9754
+ )
9755
+ ] }) }),
9756
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
9757
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9758
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
9759
+ ] }) })
9760
+ ]
9761
+ }
9762
+ ) });
9763
+ };
9764
+ const schema$5 = addressSchema;
9575
9765
  const CustomItems = () => {
9576
9766
  return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9577
9767
  /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
@@ -9580,7 +9770,7 @@ const CustomItems = () => {
9580
9770
  };
9581
9771
  const CustomItemsForm = () => {
9582
9772
  const form = reactHookForm.useForm({
9583
- resolver: zod.zodResolver(schema$5)
9773
+ resolver: zod.zodResolver(schema$4)
9584
9774
  });
9585
9775
  return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9586
9776
  /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
@@ -9590,7 +9780,7 @@ const CustomItemsForm = () => {
9590
9780
  ] }) })
9591
9781
  ] }) });
9592
9782
  };
9593
- const schema$5 = objectType({
9783
+ const schema$4 = objectType({
9594
9784
  email: stringType().email()
9595
9785
  });
9596
9786
  const Email = () => {
@@ -9615,7 +9805,7 @@ const EmailForm = ({ order }) => {
9615
9805
  defaultValues: {
9616
9806
  email: order.email ?? ""
9617
9807
  },
9618
- resolver: zod.zodResolver(schema$4)
9808
+ resolver: zod.zodResolver(schema$3)
9619
9809
  });
9620
9810
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9621
9811
  const { handleSuccess } = useRouteModal();
@@ -9658,7 +9848,7 @@ const EmailForm = ({ order }) => {
9658
9848
  }
9659
9849
  ) });
9660
9850
  };
9661
- const schema$4 = objectType({
9851
+ const schema$3 = objectType({
9662
9852
  email: stringType().email()
9663
9853
  });
9664
9854
  const NumberInput = React.forwardRef(
@@ -11290,7 +11480,7 @@ const SalesChannelForm = ({ order }) => {
11290
11480
  defaultValues: {
11291
11481
  sales_channel_id: order.sales_channel_id || ""
11292
11482
  },
11293
- resolver: zod.zodResolver(schema$3)
11483
+ resolver: zod.zodResolver(schema$2)
11294
11484
  });
11295
11485
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11296
11486
  const { handleSuccess } = useRouteModal();
@@ -11365,7 +11555,7 @@ const SalesChannelField = ({ control, order }) => {
11365
11555
  }
11366
11556
  );
11367
11557
  };
11368
- const schema$3 = objectType({
11558
+ const schema$2 = objectType({
11369
11559
  sales_channel_id: stringType().min(1)
11370
11560
  });
11371
11561
  const STACKED_FOCUS_MODAL_ID = "shipping-form";
@@ -12175,209 +12365,6 @@ const CustomAmountField = ({
12175
12365
  }
12176
12366
  );
12177
12367
  };
12178
- const ShippingAddress = () => {
12179
- const { id } = reactRouterDom.useParams();
12180
- const { order, isPending, isError, error } = useOrder(id, {
12181
- fields: "+shipping_address"
12182
- });
12183
- if (isError) {
12184
- throw error;
12185
- }
12186
- const isReady = !isPending && !!order;
12187
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12188
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
12189
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Shipping Address" }) }),
12190
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
12191
- ] }),
12192
- isReady && /* @__PURE__ */ jsxRuntime.jsx(ShippingAddressForm, { order })
12193
- ] });
12194
- };
12195
- const ShippingAddressForm = ({ order }) => {
12196
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12197
- const form = reactHookForm.useForm({
12198
- defaultValues: {
12199
- first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
12200
- last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
12201
- company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
12202
- address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
12203
- address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
12204
- city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
12205
- province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
12206
- country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
12207
- postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12208
- phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12209
- },
12210
- resolver: zod.zodResolver(schema$2)
12211
- });
12212
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12213
- const { handleSuccess } = useRouteModal();
12214
- const onSubmit = form.handleSubmit(async (data) => {
12215
- await mutateAsync(
12216
- {
12217
- shipping_address: {
12218
- first_name: data.first_name,
12219
- last_name: data.last_name,
12220
- company: data.company,
12221
- address_1: data.address_1,
12222
- address_2: data.address_2,
12223
- city: data.city,
12224
- province: data.province,
12225
- country_code: data.country_code,
12226
- postal_code: data.postal_code,
12227
- phone: data.phone
12228
- }
12229
- },
12230
- {
12231
- onSuccess: () => {
12232
- handleSuccess();
12233
- },
12234
- onError: (error) => {
12235
- ui.toast.error(error.message);
12236
- }
12237
- }
12238
- );
12239
- });
12240
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
12241
- KeyboundForm,
12242
- {
12243
- className: "flex flex-1 flex-col overflow-hidden",
12244
- onSubmit,
12245
- children: [
12246
- /* @__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: [
12247
- /* @__PURE__ */ jsxRuntime.jsx(
12248
- Form$2.Field,
12249
- {
12250
- control: form.control,
12251
- name: "country_code",
12252
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12253
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
12254
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
12255
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12256
- ] })
12257
- }
12258
- ),
12259
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12260
- /* @__PURE__ */ jsxRuntime.jsx(
12261
- Form$2.Field,
12262
- {
12263
- control: form.control,
12264
- name: "first_name",
12265
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12266
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
12267
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12268
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12269
- ] })
12270
- }
12271
- ),
12272
- /* @__PURE__ */ jsxRuntime.jsx(
12273
- Form$2.Field,
12274
- {
12275
- control: form.control,
12276
- name: "last_name",
12277
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12278
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
12279
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12280
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12281
- ] })
12282
- }
12283
- )
12284
- ] }),
12285
- /* @__PURE__ */ jsxRuntime.jsx(
12286
- Form$2.Field,
12287
- {
12288
- control: form.control,
12289
- name: "company",
12290
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12291
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
12292
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12293
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12294
- ] })
12295
- }
12296
- ),
12297
- /* @__PURE__ */ jsxRuntime.jsx(
12298
- Form$2.Field,
12299
- {
12300
- control: form.control,
12301
- name: "address_1",
12302
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12303
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
12304
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12305
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12306
- ] })
12307
- }
12308
- ),
12309
- /* @__PURE__ */ jsxRuntime.jsx(
12310
- Form$2.Field,
12311
- {
12312
- control: form.control,
12313
- name: "address_2",
12314
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12315
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
12316
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12317
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12318
- ] })
12319
- }
12320
- ),
12321
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12322
- /* @__PURE__ */ jsxRuntime.jsx(
12323
- Form$2.Field,
12324
- {
12325
- control: form.control,
12326
- name: "postal_code",
12327
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12328
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
12329
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12330
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12331
- ] })
12332
- }
12333
- ),
12334
- /* @__PURE__ */ jsxRuntime.jsx(
12335
- Form$2.Field,
12336
- {
12337
- control: form.control,
12338
- name: "city",
12339
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12340
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
12341
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12342
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12343
- ] })
12344
- }
12345
- )
12346
- ] }),
12347
- /* @__PURE__ */ jsxRuntime.jsx(
12348
- Form$2.Field,
12349
- {
12350
- control: form.control,
12351
- name: "province",
12352
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12353
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
12354
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12355
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12356
- ] })
12357
- }
12358
- ),
12359
- /* @__PURE__ */ jsxRuntime.jsx(
12360
- Form$2.Field,
12361
- {
12362
- control: form.control,
12363
- name: "phone",
12364
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12365
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
12366
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12367
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12368
- ] })
12369
- }
12370
- )
12371
- ] }) }),
12372
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
12373
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12374
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12375
- ] }) })
12376
- ]
12377
- }
12378
- ) });
12379
- };
12380
- const schema$2 = addressSchema;
12381
12368
  const TransferOwnership = () => {
12382
12369
  const { id } = reactRouterDom.useParams();
12383
12370
  const { draft_order, isPending, isError, error } = useDraftOrder(id, {
@@ -12854,10 +12841,10 @@ const Illustration = () => {
12854
12841
  const schema$1 = objectType({
12855
12842
  customer_id: stringType().min(1)
12856
12843
  });
12857
- const BillingAddress = () => {
12844
+ const ShippingAddress = () => {
12858
12845
  const { id } = reactRouterDom.useParams();
12859
12846
  const { order, isPending, isError, error } = useOrder(id, {
12860
- fields: "+billing_address"
12847
+ fields: "+shipping_address"
12861
12848
  });
12862
12849
  if (isError) {
12863
12850
  throw error;
@@ -12865,26 +12852,26 @@ const BillingAddress = () => {
12865
12852
  const isReady = !isPending && !!order;
12866
12853
  return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12867
12854
  /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
12868
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Billing Address" }) }),
12869
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
12855
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Shipping Address" }) }),
12856
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
12870
12857
  ] }),
12871
- isReady && /* @__PURE__ */ jsxRuntime.jsx(BillingAddressForm, { order })
12858
+ isReady && /* @__PURE__ */ jsxRuntime.jsx(ShippingAddressForm, { order })
12872
12859
  ] });
12873
12860
  };
12874
- const BillingAddressForm = ({ order }) => {
12861
+ const ShippingAddressForm = ({ order }) => {
12875
12862
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12876
12863
  const form = reactHookForm.useForm({
12877
12864
  defaultValues: {
12878
- first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
12879
- last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
12880
- company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
12881
- address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
12882
- address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
12883
- city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
12884
- province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
12885
- country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
12886
- postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
12887
- phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
12865
+ first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
12866
+ last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
12867
+ company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
12868
+ address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
12869
+ address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
12870
+ city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
12871
+ province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
12872
+ country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
12873
+ postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12874
+ phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12888
12875
  },
12889
12876
  resolver: zod.zodResolver(schema)
12890
12877
  });
@@ -12892,7 +12879,20 @@ const BillingAddressForm = ({ order }) => {
12892
12879
  const { handleSuccess } = useRouteModal();
12893
12880
  const onSubmit = form.handleSubmit(async (data) => {
12894
12881
  await mutateAsync(
12895
- { billing_address: data },
12882
+ {
12883
+ shipping_address: {
12884
+ first_name: data.first_name,
12885
+ last_name: data.last_name,
12886
+ company: data.company,
12887
+ address_1: data.address_1,
12888
+ address_2: data.address_2,
12889
+ city: data.city,
12890
+ province: data.province,
12891
+ country_code: data.country_code,
12892
+ postal_code: data.postal_code,
12893
+ phone: data.phone
12894
+ }
12895
+ },
12896
12896
  {
12897
12897
  onSuccess: () => {
12898
12898
  handleSuccess();
@@ -13064,6 +13064,10 @@ const routeModule = {
13064
13064
  handle,
13065
13065
  loader,
13066
13066
  children: [
13067
+ {
13068
+ Component: BillingAddress,
13069
+ path: "/draft-orders/:id/billing-address"
13070
+ },
13067
13071
  {
13068
13072
  Component: CustomItems,
13069
13073
  path: "/draft-orders/:id/custom-items"
@@ -13092,17 +13096,13 @@ const routeModule = {
13092
13096
  Component: Shipping,
13093
13097
  path: "/draft-orders/:id/shipping"
13094
13098
  },
13095
- {
13096
- Component: ShippingAddress,
13097
- path: "/draft-orders/:id/shipping-address"
13098
- },
13099
13099
  {
13100
13100
  Component: TransferOwnership,
13101
13101
  path: "/draft-orders/:id/transfer-ownership"
13102
13102
  },
13103
13103
  {
13104
- Component: BillingAddress,
13105
- path: "/draft-orders/:id/billing-address"
13104
+ Component: ShippingAddress,
13105
+ path: "/draft-orders/:id/shipping-address"
13106
13106
  }
13107
13107
  ]
13108
13108
  }
@@ -9565,6 +9565,196 @@ const ID = () => {
9565
9565
  /* @__PURE__ */ jsx(Outlet, {})
9566
9566
  ] });
9567
9567
  };
9568
+ const BillingAddress = () => {
9569
+ const { id } = useParams();
9570
+ const { order, isPending, isError, error } = useOrder(id, {
9571
+ fields: "+billing_address"
9572
+ });
9573
+ if (isError) {
9574
+ throw error;
9575
+ }
9576
+ const isReady = !isPending && !!order;
9577
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
9578
+ /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
9579
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Billing Address" }) }),
9580
+ /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
9581
+ ] }),
9582
+ isReady && /* @__PURE__ */ jsx(BillingAddressForm, { order })
9583
+ ] });
9584
+ };
9585
+ const BillingAddressForm = ({ order }) => {
9586
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
9587
+ const form = useForm({
9588
+ defaultValues: {
9589
+ first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
9590
+ last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
9591
+ company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
9592
+ address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
9593
+ address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
9594
+ city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
9595
+ province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
9596
+ country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
9597
+ postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
9598
+ phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
9599
+ },
9600
+ resolver: zodResolver(schema$5)
9601
+ });
9602
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9603
+ const { handleSuccess } = useRouteModal();
9604
+ const onSubmit = form.handleSubmit(async (data) => {
9605
+ await mutateAsync(
9606
+ { billing_address: data },
9607
+ {
9608
+ onSuccess: () => {
9609
+ handleSuccess();
9610
+ },
9611
+ onError: (error) => {
9612
+ toast.error(error.message);
9613
+ }
9614
+ }
9615
+ );
9616
+ });
9617
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
9618
+ KeyboundForm,
9619
+ {
9620
+ className: "flex flex-1 flex-col overflow-hidden",
9621
+ onSubmit,
9622
+ children: [
9623
+ /* @__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: [
9624
+ /* @__PURE__ */ jsx(
9625
+ Form$2.Field,
9626
+ {
9627
+ control: form.control,
9628
+ name: "country_code",
9629
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9630
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
9631
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
9632
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9633
+ ] })
9634
+ }
9635
+ ),
9636
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
9637
+ /* @__PURE__ */ jsx(
9638
+ Form$2.Field,
9639
+ {
9640
+ control: form.control,
9641
+ name: "first_name",
9642
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9643
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
9644
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9645
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9646
+ ] })
9647
+ }
9648
+ ),
9649
+ /* @__PURE__ */ jsx(
9650
+ Form$2.Field,
9651
+ {
9652
+ control: form.control,
9653
+ name: "last_name",
9654
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9655
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
9656
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9657
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9658
+ ] })
9659
+ }
9660
+ )
9661
+ ] }),
9662
+ /* @__PURE__ */ jsx(
9663
+ Form$2.Field,
9664
+ {
9665
+ control: form.control,
9666
+ name: "company",
9667
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9668
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
9669
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9670
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9671
+ ] })
9672
+ }
9673
+ ),
9674
+ /* @__PURE__ */ jsx(
9675
+ Form$2.Field,
9676
+ {
9677
+ control: form.control,
9678
+ name: "address_1",
9679
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9680
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
9681
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9682
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9683
+ ] })
9684
+ }
9685
+ ),
9686
+ /* @__PURE__ */ jsx(
9687
+ Form$2.Field,
9688
+ {
9689
+ control: form.control,
9690
+ name: "address_2",
9691
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9692
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
9693
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9694
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9695
+ ] })
9696
+ }
9697
+ ),
9698
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
9699
+ /* @__PURE__ */ jsx(
9700
+ Form$2.Field,
9701
+ {
9702
+ control: form.control,
9703
+ name: "postal_code",
9704
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9705
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
9706
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9707
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9708
+ ] })
9709
+ }
9710
+ ),
9711
+ /* @__PURE__ */ jsx(
9712
+ Form$2.Field,
9713
+ {
9714
+ control: form.control,
9715
+ name: "city",
9716
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9717
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
9718
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9719
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9720
+ ] })
9721
+ }
9722
+ )
9723
+ ] }),
9724
+ /* @__PURE__ */ jsx(
9725
+ Form$2.Field,
9726
+ {
9727
+ control: form.control,
9728
+ name: "province",
9729
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9730
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
9731
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9732
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9733
+ ] })
9734
+ }
9735
+ ),
9736
+ /* @__PURE__ */ jsx(
9737
+ Form$2.Field,
9738
+ {
9739
+ control: form.control,
9740
+ name: "phone",
9741
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9742
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
9743
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9744
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9745
+ ] })
9746
+ }
9747
+ )
9748
+ ] }) }),
9749
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
9750
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9751
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
9752
+ ] }) })
9753
+ ]
9754
+ }
9755
+ ) });
9756
+ };
9757
+ const schema$5 = addressSchema;
9568
9758
  const CustomItems = () => {
9569
9759
  return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
9570
9760
  /* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
@@ -9573,7 +9763,7 @@ const CustomItems = () => {
9573
9763
  };
9574
9764
  const CustomItemsForm = () => {
9575
9765
  const form = useForm({
9576
- resolver: zodResolver(schema$5)
9766
+ resolver: zodResolver(schema$4)
9577
9767
  });
9578
9768
  return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9579
9769
  /* @__PURE__ */ jsx(RouteDrawer.Body, {}),
@@ -9583,7 +9773,7 @@ const CustomItemsForm = () => {
9583
9773
  ] }) })
9584
9774
  ] }) });
9585
9775
  };
9586
- const schema$5 = objectType({
9776
+ const schema$4 = objectType({
9587
9777
  email: stringType().email()
9588
9778
  });
9589
9779
  const Email = () => {
@@ -9608,7 +9798,7 @@ const EmailForm = ({ order }) => {
9608
9798
  defaultValues: {
9609
9799
  email: order.email ?? ""
9610
9800
  },
9611
- resolver: zodResolver(schema$4)
9801
+ resolver: zodResolver(schema$3)
9612
9802
  });
9613
9803
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9614
9804
  const { handleSuccess } = useRouteModal();
@@ -9651,7 +9841,7 @@ const EmailForm = ({ order }) => {
9651
9841
  }
9652
9842
  ) });
9653
9843
  };
9654
- const schema$4 = objectType({
9844
+ const schema$3 = objectType({
9655
9845
  email: stringType().email()
9656
9846
  });
9657
9847
  const NumberInput = forwardRef(
@@ -11283,7 +11473,7 @@ const SalesChannelForm = ({ order }) => {
11283
11473
  defaultValues: {
11284
11474
  sales_channel_id: order.sales_channel_id || ""
11285
11475
  },
11286
- resolver: zodResolver(schema$3)
11476
+ resolver: zodResolver(schema$2)
11287
11477
  });
11288
11478
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11289
11479
  const { handleSuccess } = useRouteModal();
@@ -11358,7 +11548,7 @@ const SalesChannelField = ({ control, order }) => {
11358
11548
  }
11359
11549
  );
11360
11550
  };
11361
- const schema$3 = objectType({
11551
+ const schema$2 = objectType({
11362
11552
  sales_channel_id: stringType().min(1)
11363
11553
  });
11364
11554
  const STACKED_FOCUS_MODAL_ID = "shipping-form";
@@ -12168,209 +12358,6 @@ const CustomAmountField = ({
12168
12358
  }
12169
12359
  );
12170
12360
  };
12171
- const ShippingAddress = () => {
12172
- const { id } = useParams();
12173
- const { order, isPending, isError, error } = useOrder(id, {
12174
- fields: "+shipping_address"
12175
- });
12176
- if (isError) {
12177
- throw error;
12178
- }
12179
- const isReady = !isPending && !!order;
12180
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
12181
- /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
12182
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Shipping Address" }) }),
12183
- /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
12184
- ] }),
12185
- isReady && /* @__PURE__ */ jsx(ShippingAddressForm, { order })
12186
- ] });
12187
- };
12188
- const ShippingAddressForm = ({ order }) => {
12189
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12190
- const form = useForm({
12191
- defaultValues: {
12192
- first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
12193
- last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
12194
- company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
12195
- address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
12196
- address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
12197
- city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
12198
- province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
12199
- country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
12200
- postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12201
- phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12202
- },
12203
- resolver: zodResolver(schema$2)
12204
- });
12205
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12206
- const { handleSuccess } = useRouteModal();
12207
- const onSubmit = form.handleSubmit(async (data) => {
12208
- await mutateAsync(
12209
- {
12210
- shipping_address: {
12211
- first_name: data.first_name,
12212
- last_name: data.last_name,
12213
- company: data.company,
12214
- address_1: data.address_1,
12215
- address_2: data.address_2,
12216
- city: data.city,
12217
- province: data.province,
12218
- country_code: data.country_code,
12219
- postal_code: data.postal_code,
12220
- phone: data.phone
12221
- }
12222
- },
12223
- {
12224
- onSuccess: () => {
12225
- handleSuccess();
12226
- },
12227
- onError: (error) => {
12228
- toast.error(error.message);
12229
- }
12230
- }
12231
- );
12232
- });
12233
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
12234
- KeyboundForm,
12235
- {
12236
- className: "flex flex-1 flex-col overflow-hidden",
12237
- onSubmit,
12238
- children: [
12239
- /* @__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: [
12240
- /* @__PURE__ */ jsx(
12241
- Form$2.Field,
12242
- {
12243
- control: form.control,
12244
- name: "country_code",
12245
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12246
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
12247
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
12248
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12249
- ] })
12250
- }
12251
- ),
12252
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12253
- /* @__PURE__ */ jsx(
12254
- Form$2.Field,
12255
- {
12256
- control: form.control,
12257
- name: "first_name",
12258
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12259
- /* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
12260
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12261
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12262
- ] })
12263
- }
12264
- ),
12265
- /* @__PURE__ */ jsx(
12266
- Form$2.Field,
12267
- {
12268
- control: form.control,
12269
- name: "last_name",
12270
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12271
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
12272
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12273
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12274
- ] })
12275
- }
12276
- )
12277
- ] }),
12278
- /* @__PURE__ */ jsx(
12279
- Form$2.Field,
12280
- {
12281
- control: form.control,
12282
- name: "company",
12283
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12284
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
12285
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12286
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12287
- ] })
12288
- }
12289
- ),
12290
- /* @__PURE__ */ jsx(
12291
- Form$2.Field,
12292
- {
12293
- control: form.control,
12294
- name: "address_1",
12295
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12296
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
12297
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12298
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12299
- ] })
12300
- }
12301
- ),
12302
- /* @__PURE__ */ jsx(
12303
- Form$2.Field,
12304
- {
12305
- control: form.control,
12306
- name: "address_2",
12307
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12308
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
12309
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12310
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12311
- ] })
12312
- }
12313
- ),
12314
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12315
- /* @__PURE__ */ jsx(
12316
- Form$2.Field,
12317
- {
12318
- control: form.control,
12319
- name: "postal_code",
12320
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12321
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
12322
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12323
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12324
- ] })
12325
- }
12326
- ),
12327
- /* @__PURE__ */ jsx(
12328
- Form$2.Field,
12329
- {
12330
- control: form.control,
12331
- name: "city",
12332
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12333
- /* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
12334
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12335
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12336
- ] })
12337
- }
12338
- )
12339
- ] }),
12340
- /* @__PURE__ */ jsx(
12341
- Form$2.Field,
12342
- {
12343
- control: form.control,
12344
- name: "province",
12345
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12346
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
12347
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12348
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12349
- ] })
12350
- }
12351
- ),
12352
- /* @__PURE__ */ jsx(
12353
- Form$2.Field,
12354
- {
12355
- control: form.control,
12356
- name: "phone",
12357
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12358
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
12359
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12360
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12361
- ] })
12362
- }
12363
- )
12364
- ] }) }),
12365
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
12366
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12367
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12368
- ] }) })
12369
- ]
12370
- }
12371
- ) });
12372
- };
12373
- const schema$2 = addressSchema;
12374
12361
  const TransferOwnership = () => {
12375
12362
  const { id } = useParams();
12376
12363
  const { draft_order, isPending, isError, error } = useDraftOrder(id, {
@@ -12847,10 +12834,10 @@ const Illustration = () => {
12847
12834
  const schema$1 = objectType({
12848
12835
  customer_id: stringType().min(1)
12849
12836
  });
12850
- const BillingAddress = () => {
12837
+ const ShippingAddress = () => {
12851
12838
  const { id } = useParams();
12852
12839
  const { order, isPending, isError, error } = useOrder(id, {
12853
- fields: "+billing_address"
12840
+ fields: "+shipping_address"
12854
12841
  });
12855
12842
  if (isError) {
12856
12843
  throw error;
@@ -12858,26 +12845,26 @@ const BillingAddress = () => {
12858
12845
  const isReady = !isPending && !!order;
12859
12846
  return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
12860
12847
  /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
12861
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Billing Address" }) }),
12862
- /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
12848
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Shipping Address" }) }),
12849
+ /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
12863
12850
  ] }),
12864
- isReady && /* @__PURE__ */ jsx(BillingAddressForm, { order })
12851
+ isReady && /* @__PURE__ */ jsx(ShippingAddressForm, { order })
12865
12852
  ] });
12866
12853
  };
12867
- const BillingAddressForm = ({ order }) => {
12854
+ const ShippingAddressForm = ({ order }) => {
12868
12855
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12869
12856
  const form = useForm({
12870
12857
  defaultValues: {
12871
- first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
12872
- last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
12873
- company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
12874
- address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
12875
- address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
12876
- city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
12877
- province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
12878
- country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
12879
- postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
12880
- phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
12858
+ first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
12859
+ last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
12860
+ company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
12861
+ address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
12862
+ address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
12863
+ city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
12864
+ province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
12865
+ country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
12866
+ postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12867
+ phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12881
12868
  },
12882
12869
  resolver: zodResolver(schema)
12883
12870
  });
@@ -12885,7 +12872,20 @@ const BillingAddressForm = ({ order }) => {
12885
12872
  const { handleSuccess } = useRouteModal();
12886
12873
  const onSubmit = form.handleSubmit(async (data) => {
12887
12874
  await mutateAsync(
12888
- { billing_address: data },
12875
+ {
12876
+ shipping_address: {
12877
+ first_name: data.first_name,
12878
+ last_name: data.last_name,
12879
+ company: data.company,
12880
+ address_1: data.address_1,
12881
+ address_2: data.address_2,
12882
+ city: data.city,
12883
+ province: data.province,
12884
+ country_code: data.country_code,
12885
+ postal_code: data.postal_code,
12886
+ phone: data.phone
12887
+ }
12888
+ },
12889
12889
  {
12890
12890
  onSuccess: () => {
12891
12891
  handleSuccess();
@@ -13057,6 +13057,10 @@ const routeModule = {
13057
13057
  handle,
13058
13058
  loader,
13059
13059
  children: [
13060
+ {
13061
+ Component: BillingAddress,
13062
+ path: "/draft-orders/:id/billing-address"
13063
+ },
13060
13064
  {
13061
13065
  Component: CustomItems,
13062
13066
  path: "/draft-orders/:id/custom-items"
@@ -13085,17 +13089,13 @@ const routeModule = {
13085
13089
  Component: Shipping,
13086
13090
  path: "/draft-orders/:id/shipping"
13087
13091
  },
13088
- {
13089
- Component: ShippingAddress,
13090
- path: "/draft-orders/:id/shipping-address"
13091
- },
13092
13092
  {
13093
13093
  Component: TransferOwnership,
13094
13094
  path: "/draft-orders/:id/transfer-ownership"
13095
13095
  },
13096
13096
  {
13097
- Component: BillingAddress,
13098
- path: "/draft-orders/:id/billing-address"
13097
+ Component: ShippingAddress,
13098
+ path: "/draft-orders/:id/shipping-address"
13099
13099
  }
13100
13100
  ]
13101
13101
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medusajs/draft-order",
3
- "version": "2.11.3-preview-20251101180137",
3
+ "version": "2.11.3-preview-20251102000316",
4
4
  "description": "A starter for Medusa plugins.",
5
5
  "author": "Medusa (https://medusajs.com)",
6
6
  "license": "MIT",
@@ -37,7 +37,7 @@
37
37
  "@ariakit/react": "^0.4.15",
38
38
  "@babel/runtime": "^7.26.10",
39
39
  "@hookform/resolvers": "3.4.2",
40
- "@medusajs/js-sdk": "2.11.3-preview-20251101180137",
40
+ "@medusajs/js-sdk": "2.11.3-preview-20251102000316",
41
41
  "@tanstack/react-query": "5.64.2",
42
42
  "@uiw/react-json-view": "^2.0.0-alpha.17",
43
43
  "date-fns": "^3.6.0",
@@ -48,14 +48,14 @@
48
48
  "react-hook-form": "7.49.1"
49
49
  },
50
50
  "devDependencies": {
51
- "@medusajs/admin-sdk": "2.11.3-preview-20251101180137",
52
- "@medusajs/cli": "2.11.3-preview-20251101180137",
53
- "@medusajs/framework": "2.11.3-preview-20251101180137",
54
- "@medusajs/icons": "2.11.3-preview-20251101180137",
55
- "@medusajs/test-utils": "2.11.3-preview-20251101180137",
56
- "@medusajs/types": "2.11.3-preview-20251101180137",
57
- "@medusajs/ui": "4.0.27-preview-20251101180137",
58
- "@medusajs/ui-preset": "2.11.3-preview-20251101180137",
51
+ "@medusajs/admin-sdk": "2.11.3-preview-20251102000316",
52
+ "@medusajs/cli": "2.11.3-preview-20251102000316",
53
+ "@medusajs/framework": "2.11.3-preview-20251102000316",
54
+ "@medusajs/icons": "2.11.3-preview-20251102000316",
55
+ "@medusajs/test-utils": "2.11.3-preview-20251102000316",
56
+ "@medusajs/types": "2.11.3-preview-20251102000316",
57
+ "@medusajs/ui": "4.0.27-preview-20251102000316",
58
+ "@medusajs/ui-preset": "2.11.3-preview-20251102000316",
59
59
  "@swc/core": "^1.7.28",
60
60
  "@types/lodash": "^4.17.15",
61
61
  "@types/lodash.debounce": "^4.0.9",
@@ -73,12 +73,12 @@
73
73
  "yalc": "^1.0.0-pre.53"
74
74
  },
75
75
  "peerDependencies": {
76
- "@medusajs/admin-sdk": "2.11.3-preview-20251101180137",
77
- "@medusajs/cli": "2.11.3-preview-20251101180137",
78
- "@medusajs/framework": "2.11.3-preview-20251101180137",
79
- "@medusajs/icons": "2.11.3-preview-20251101180137",
80
- "@medusajs/test-utils": "2.11.3-preview-20251101180137",
81
- "@medusajs/ui": "4.0.27-preview-20251101180137",
76
+ "@medusajs/admin-sdk": "2.11.3-preview-20251102000316",
77
+ "@medusajs/cli": "2.11.3-preview-20251102000316",
78
+ "@medusajs/framework": "2.11.3-preview-20251102000316",
79
+ "@medusajs/icons": "2.11.3-preview-20251102000316",
80
+ "@medusajs/test-utils": "2.11.3-preview-20251102000316",
81
+ "@medusajs/ui": "4.0.27-preview-20251102000316",
82
82
  "react": "^18.3.1",
83
83
  "react-dom": "^18.3.1",
84
84
  "react-router-dom": "6.20.1"