@medusajs/draft-order 2.10.4-snapshot-20251009074418 → 2.10.4-snapshot-20251009094748

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