@medusajs/draft-order 2.11.1-preview-20251024031436 → 2.11.1-preview-20251024060204

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.
@@ -9571,6 +9571,196 @@ const ID = () => {
9571
9571
  /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Outlet, {})
9572
9572
  ] });
9573
9573
  };
9574
+ const BillingAddress = () => {
9575
+ const { id } = reactRouterDom.useParams();
9576
+ const { order, isPending, isError, error } = useOrder(id, {
9577
+ fields: "+billing_address"
9578
+ });
9579
+ if (isError) {
9580
+ throw error;
9581
+ }
9582
+ const isReady = !isPending && !!order;
9583
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9584
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
9585
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Billing Address" }) }),
9586
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
9587
+ ] }),
9588
+ isReady && /* @__PURE__ */ jsxRuntime.jsx(BillingAddressForm, { order })
9589
+ ] });
9590
+ };
9591
+ const BillingAddressForm = ({ order }) => {
9592
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
9593
+ const form = reactHookForm.useForm({
9594
+ defaultValues: {
9595
+ first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
9596
+ last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
9597
+ company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
9598
+ address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
9599
+ address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
9600
+ city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
9601
+ province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
9602
+ country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
9603
+ postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
9604
+ phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
9605
+ },
9606
+ resolver: zod.zodResolver(schema$5)
9607
+ });
9608
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9609
+ const { handleSuccess } = useRouteModal();
9610
+ const onSubmit = form.handleSubmit(async (data) => {
9611
+ await mutateAsync(
9612
+ { billing_address: data },
9613
+ {
9614
+ onSuccess: () => {
9615
+ handleSuccess();
9616
+ },
9617
+ onError: (error) => {
9618
+ ui.toast.error(error.message);
9619
+ }
9620
+ }
9621
+ );
9622
+ });
9623
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
9624
+ KeyboundForm,
9625
+ {
9626
+ className: "flex flex-1 flex-col overflow-hidden",
9627
+ onSubmit,
9628
+ children: [
9629
+ /* @__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: [
9630
+ /* @__PURE__ */ jsxRuntime.jsx(
9631
+ Form$2.Field,
9632
+ {
9633
+ control: form.control,
9634
+ name: "country_code",
9635
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9636
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
9637
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
9638
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9639
+ ] })
9640
+ }
9641
+ ),
9642
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
9643
+ /* @__PURE__ */ jsxRuntime.jsx(
9644
+ Form$2.Field,
9645
+ {
9646
+ control: form.control,
9647
+ name: "first_name",
9648
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9649
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
9650
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9651
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9652
+ ] })
9653
+ }
9654
+ ),
9655
+ /* @__PURE__ */ jsxRuntime.jsx(
9656
+ Form$2.Field,
9657
+ {
9658
+ control: form.control,
9659
+ name: "last_name",
9660
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9661
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
9662
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9663
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9664
+ ] })
9665
+ }
9666
+ )
9667
+ ] }),
9668
+ /* @__PURE__ */ jsxRuntime.jsx(
9669
+ Form$2.Field,
9670
+ {
9671
+ control: form.control,
9672
+ name: "company",
9673
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9674
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
9675
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9676
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9677
+ ] })
9678
+ }
9679
+ ),
9680
+ /* @__PURE__ */ jsxRuntime.jsx(
9681
+ Form$2.Field,
9682
+ {
9683
+ control: form.control,
9684
+ name: "address_1",
9685
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9686
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
9687
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9688
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9689
+ ] })
9690
+ }
9691
+ ),
9692
+ /* @__PURE__ */ jsxRuntime.jsx(
9693
+ Form$2.Field,
9694
+ {
9695
+ control: form.control,
9696
+ name: "address_2",
9697
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9698
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
9699
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9700
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9701
+ ] })
9702
+ }
9703
+ ),
9704
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
9705
+ /* @__PURE__ */ jsxRuntime.jsx(
9706
+ Form$2.Field,
9707
+ {
9708
+ control: form.control,
9709
+ name: "postal_code",
9710
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9711
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
9712
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9713
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9714
+ ] })
9715
+ }
9716
+ ),
9717
+ /* @__PURE__ */ jsxRuntime.jsx(
9718
+ Form$2.Field,
9719
+ {
9720
+ control: form.control,
9721
+ name: "city",
9722
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9723
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
9724
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9725
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9726
+ ] })
9727
+ }
9728
+ )
9729
+ ] }),
9730
+ /* @__PURE__ */ jsxRuntime.jsx(
9731
+ Form$2.Field,
9732
+ {
9733
+ control: form.control,
9734
+ name: "province",
9735
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9736
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
9737
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9738
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9739
+ ] })
9740
+ }
9741
+ ),
9742
+ /* @__PURE__ */ jsxRuntime.jsx(
9743
+ Form$2.Field,
9744
+ {
9745
+ control: form.control,
9746
+ name: "phone",
9747
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9748
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
9749
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9750
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9751
+ ] })
9752
+ }
9753
+ )
9754
+ ] }) }),
9755
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
9756
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9757
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
9758
+ ] }) })
9759
+ ]
9760
+ }
9761
+ ) });
9762
+ };
9763
+ const schema$5 = addressSchema;
9574
9764
  const CustomItems = () => {
9575
9765
  return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9576
9766
  /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
@@ -9579,7 +9769,7 @@ const CustomItems = () => {
9579
9769
  };
9580
9770
  const CustomItemsForm = () => {
9581
9771
  const form = reactHookForm.useForm({
9582
- resolver: zod.zodResolver(schema$5)
9772
+ resolver: zod.zodResolver(schema$4)
9583
9773
  });
9584
9774
  return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9585
9775
  /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
@@ -9589,7 +9779,7 @@ const CustomItemsForm = () => {
9589
9779
  ] }) })
9590
9780
  ] }) });
9591
9781
  };
9592
- const schema$5 = objectType({
9782
+ const schema$4 = objectType({
9593
9783
  email: stringType().email()
9594
9784
  });
9595
9785
  const Email = () => {
@@ -9614,7 +9804,7 @@ const EmailForm = ({ order }) => {
9614
9804
  defaultValues: {
9615
9805
  email: order.email ?? ""
9616
9806
  },
9617
- resolver: zod.zodResolver(schema$4)
9807
+ resolver: zod.zodResolver(schema$3)
9618
9808
  });
9619
9809
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9620
9810
  const { handleSuccess } = useRouteModal();
@@ -9657,7 +9847,7 @@ const EmailForm = ({ order }) => {
9657
9847
  }
9658
9848
  ) });
9659
9849
  };
9660
- const schema$4 = objectType({
9850
+ const schema$3 = objectType({
9661
9851
  email: stringType().email()
9662
9852
  });
9663
9853
  const NumberInput = React.forwardRef(
@@ -11289,7 +11479,7 @@ const SalesChannelForm = ({ order }) => {
11289
11479
  defaultValues: {
11290
11480
  sales_channel_id: order.sales_channel_id || ""
11291
11481
  },
11292
- resolver: zod.zodResolver(schema$3)
11482
+ resolver: zod.zodResolver(schema$2)
11293
11483
  });
11294
11484
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11295
11485
  const { handleSuccess } = useRouteModal();
@@ -11364,212 +11554,9 @@ const SalesChannelField = ({ control, order }) => {
11364
11554
  }
11365
11555
  );
11366
11556
  };
11367
- const schema$3 = objectType({
11557
+ const schema$2 = objectType({
11368
11558
  sales_channel_id: stringType().min(1)
11369
11559
  });
11370
- const ShippingAddress = () => {
11371
- const { id } = reactRouterDom.useParams();
11372
- const { order, isPending, isError, error } = useOrder(id, {
11373
- fields: "+shipping_address"
11374
- });
11375
- if (isError) {
11376
- throw error;
11377
- }
11378
- const isReady = !isPending && !!order;
11379
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
11380
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
11381
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Shipping Address" }) }),
11382
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
11383
- ] }),
11384
- isReady && /* @__PURE__ */ jsxRuntime.jsx(ShippingAddressForm, { order })
11385
- ] });
11386
- };
11387
- const ShippingAddressForm = ({ order }) => {
11388
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
11389
- const form = reactHookForm.useForm({
11390
- defaultValues: {
11391
- first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
11392
- last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
11393
- company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
11394
- address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
11395
- address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
11396
- city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
11397
- province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
11398
- country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
11399
- postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
11400
- phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
11401
- },
11402
- resolver: zod.zodResolver(schema$2)
11403
- });
11404
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11405
- const { handleSuccess } = useRouteModal();
11406
- const onSubmit = form.handleSubmit(async (data) => {
11407
- await mutateAsync(
11408
- {
11409
- shipping_address: {
11410
- first_name: data.first_name,
11411
- last_name: data.last_name,
11412
- company: data.company,
11413
- address_1: data.address_1,
11414
- address_2: data.address_2,
11415
- city: data.city,
11416
- province: data.province,
11417
- country_code: data.country_code,
11418
- postal_code: data.postal_code,
11419
- phone: data.phone
11420
- }
11421
- },
11422
- {
11423
- onSuccess: () => {
11424
- handleSuccess();
11425
- },
11426
- onError: (error) => {
11427
- ui.toast.error(error.message);
11428
- }
11429
- }
11430
- );
11431
- });
11432
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
11433
- KeyboundForm,
11434
- {
11435
- className: "flex flex-1 flex-col overflow-hidden",
11436
- onSubmit,
11437
- children: [
11438
- /* @__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: [
11439
- /* @__PURE__ */ jsxRuntime.jsx(
11440
- Form$2.Field,
11441
- {
11442
- control: form.control,
11443
- name: "country_code",
11444
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11445
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
11446
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
11447
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11448
- ] })
11449
- }
11450
- ),
11451
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
11452
- /* @__PURE__ */ jsxRuntime.jsx(
11453
- Form$2.Field,
11454
- {
11455
- control: form.control,
11456
- name: "first_name",
11457
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11458
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
11459
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11460
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11461
- ] })
11462
- }
11463
- ),
11464
- /* @__PURE__ */ jsxRuntime.jsx(
11465
- Form$2.Field,
11466
- {
11467
- control: form.control,
11468
- name: "last_name",
11469
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11470
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
11471
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11472
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11473
- ] })
11474
- }
11475
- )
11476
- ] }),
11477
- /* @__PURE__ */ jsxRuntime.jsx(
11478
- Form$2.Field,
11479
- {
11480
- control: form.control,
11481
- name: "company",
11482
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11483
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
11484
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11485
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11486
- ] })
11487
- }
11488
- ),
11489
- /* @__PURE__ */ jsxRuntime.jsx(
11490
- Form$2.Field,
11491
- {
11492
- control: form.control,
11493
- name: "address_1",
11494
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11495
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
11496
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11497
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11498
- ] })
11499
- }
11500
- ),
11501
- /* @__PURE__ */ jsxRuntime.jsx(
11502
- Form$2.Field,
11503
- {
11504
- control: form.control,
11505
- name: "address_2",
11506
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11507
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
11508
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11509
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11510
- ] })
11511
- }
11512
- ),
11513
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
11514
- /* @__PURE__ */ jsxRuntime.jsx(
11515
- Form$2.Field,
11516
- {
11517
- control: form.control,
11518
- name: "postal_code",
11519
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11520
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
11521
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11522
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11523
- ] })
11524
- }
11525
- ),
11526
- /* @__PURE__ */ jsxRuntime.jsx(
11527
- Form$2.Field,
11528
- {
11529
- control: form.control,
11530
- name: "city",
11531
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11532
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
11533
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11534
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11535
- ] })
11536
- }
11537
- )
11538
- ] }),
11539
- /* @__PURE__ */ jsxRuntime.jsx(
11540
- Form$2.Field,
11541
- {
11542
- control: form.control,
11543
- name: "province",
11544
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11545
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
11546
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11547
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11548
- ] })
11549
- }
11550
- ),
11551
- /* @__PURE__ */ jsxRuntime.jsx(
11552
- Form$2.Field,
11553
- {
11554
- control: form.control,
11555
- name: "phone",
11556
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11557
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
11558
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11559
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11560
- ] })
11561
- }
11562
- )
11563
- ] }) }),
11564
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
11565
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11566
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
11567
- ] }) })
11568
- ]
11569
- }
11570
- ) });
11571
- };
11572
- const schema$2 = addressSchema;
11573
11560
  const STACKED_FOCUS_MODAL_ID = "shipping-form";
11574
11561
  const Shipping = () => {
11575
11562
  var _a;
@@ -12853,10 +12840,10 @@ const Illustration = () => {
12853
12840
  const schema$1 = objectType({
12854
12841
  customer_id: stringType().min(1)
12855
12842
  });
12856
- const BillingAddress = () => {
12843
+ const ShippingAddress = () => {
12857
12844
  const { id } = reactRouterDom.useParams();
12858
12845
  const { order, isPending, isError, error } = useOrder(id, {
12859
- fields: "+billing_address"
12846
+ fields: "+shipping_address"
12860
12847
  });
12861
12848
  if (isError) {
12862
12849
  throw error;
@@ -12864,26 +12851,26 @@ const BillingAddress = () => {
12864
12851
  const isReady = !isPending && !!order;
12865
12852
  return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12866
12853
  /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
12867
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Billing Address" }) }),
12868
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
12854
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Shipping Address" }) }),
12855
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
12869
12856
  ] }),
12870
- isReady && /* @__PURE__ */ jsxRuntime.jsx(BillingAddressForm, { order })
12857
+ isReady && /* @__PURE__ */ jsxRuntime.jsx(ShippingAddressForm, { order })
12871
12858
  ] });
12872
12859
  };
12873
- const BillingAddressForm = ({ order }) => {
12860
+ const ShippingAddressForm = ({ order }) => {
12874
12861
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12875
12862
  const form = reactHookForm.useForm({
12876
12863
  defaultValues: {
12877
- first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
12878
- last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
12879
- company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
12880
- address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
12881
- address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
12882
- city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
12883
- province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
12884
- country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
12885
- postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
12886
- phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
12864
+ first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
12865
+ last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
12866
+ company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
12867
+ address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
12868
+ address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
12869
+ city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
12870
+ province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
12871
+ country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
12872
+ postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12873
+ phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12887
12874
  },
12888
12875
  resolver: zod.zodResolver(schema)
12889
12876
  });
@@ -12891,7 +12878,20 @@ const BillingAddressForm = ({ order }) => {
12891
12878
  const { handleSuccess } = useRouteModal();
12892
12879
  const onSubmit = form.handleSubmit(async (data) => {
12893
12880
  await mutateAsync(
12894
- { billing_address: data },
12881
+ {
12882
+ shipping_address: {
12883
+ first_name: data.first_name,
12884
+ last_name: data.last_name,
12885
+ company: data.company,
12886
+ address_1: data.address_1,
12887
+ address_2: data.address_2,
12888
+ city: data.city,
12889
+ province: data.province,
12890
+ country_code: data.country_code,
12891
+ postal_code: data.postal_code,
12892
+ phone: data.phone
12893
+ }
12894
+ },
12895
12895
  {
12896
12896
  onSuccess: () => {
12897
12897
  handleSuccess();
@@ -13063,6 +13063,10 @@ const routeModule = {
13063
13063
  handle,
13064
13064
  loader,
13065
13065
  children: [
13066
+ {
13067
+ Component: BillingAddress,
13068
+ path: "/draft-orders/:id/billing-address"
13069
+ },
13066
13070
  {
13067
13071
  Component: CustomItems,
13068
13072
  path: "/draft-orders/:id/custom-items"
@@ -13087,10 +13091,6 @@ const routeModule = {
13087
13091
  Component: SalesChannel,
13088
13092
  path: "/draft-orders/:id/sales-channel"
13089
13093
  },
13090
- {
13091
- Component: ShippingAddress,
13092
- path: "/draft-orders/:id/shipping-address"
13093
- },
13094
13094
  {
13095
13095
  Component: Shipping,
13096
13096
  path: "/draft-orders/:id/shipping"
@@ -13100,8 +13100,8 @@ const routeModule = {
13100
13100
  path: "/draft-orders/:id/transfer-ownership"
13101
13101
  },
13102
13102
  {
13103
- Component: BillingAddress,
13104
- path: "/draft-orders/:id/billing-address"
13103
+ Component: ShippingAddress,
13104
+ path: "/draft-orders/:id/shipping-address"
13105
13105
  }
13106
13106
  ]
13107
13107
  }
@@ -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,212 +11548,9 @@ 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
- const ShippingAddress = () => {
11365
- const { id } = useParams();
11366
- const { order, isPending, isError, error } = useOrder(id, {
11367
- fields: "+shipping_address"
11368
- });
11369
- if (isError) {
11370
- throw error;
11371
- }
11372
- const isReady = !isPending && !!order;
11373
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
11374
- /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
11375
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Shipping Address" }) }),
11376
- /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
11377
- ] }),
11378
- isReady && /* @__PURE__ */ jsx(ShippingAddressForm, { order })
11379
- ] });
11380
- };
11381
- const ShippingAddressForm = ({ order }) => {
11382
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
11383
- const form = useForm({
11384
- defaultValues: {
11385
- first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
11386
- last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
11387
- company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
11388
- address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
11389
- address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
11390
- city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
11391
- province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
11392
- country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
11393
- postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
11394
- phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
11395
- },
11396
- resolver: zodResolver(schema$2)
11397
- });
11398
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11399
- const { handleSuccess } = useRouteModal();
11400
- const onSubmit = form.handleSubmit(async (data) => {
11401
- await mutateAsync(
11402
- {
11403
- shipping_address: {
11404
- first_name: data.first_name,
11405
- last_name: data.last_name,
11406
- company: data.company,
11407
- address_1: data.address_1,
11408
- address_2: data.address_2,
11409
- city: data.city,
11410
- province: data.province,
11411
- country_code: data.country_code,
11412
- postal_code: data.postal_code,
11413
- phone: data.phone
11414
- }
11415
- },
11416
- {
11417
- onSuccess: () => {
11418
- handleSuccess();
11419
- },
11420
- onError: (error) => {
11421
- toast.error(error.message);
11422
- }
11423
- }
11424
- );
11425
- });
11426
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
11427
- KeyboundForm,
11428
- {
11429
- className: "flex flex-1 flex-col overflow-hidden",
11430
- onSubmit,
11431
- children: [
11432
- /* @__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: [
11433
- /* @__PURE__ */ jsx(
11434
- Form$2.Field,
11435
- {
11436
- control: form.control,
11437
- name: "country_code",
11438
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11439
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
11440
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
11441
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11442
- ] })
11443
- }
11444
- ),
11445
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
11446
- /* @__PURE__ */ jsx(
11447
- Form$2.Field,
11448
- {
11449
- control: form.control,
11450
- name: "first_name",
11451
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11452
- /* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
11453
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11454
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11455
- ] })
11456
- }
11457
- ),
11458
- /* @__PURE__ */ jsx(
11459
- Form$2.Field,
11460
- {
11461
- control: form.control,
11462
- name: "last_name",
11463
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11464
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
11465
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11466
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11467
- ] })
11468
- }
11469
- )
11470
- ] }),
11471
- /* @__PURE__ */ jsx(
11472
- Form$2.Field,
11473
- {
11474
- control: form.control,
11475
- name: "company",
11476
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11477
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
11478
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11479
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11480
- ] })
11481
- }
11482
- ),
11483
- /* @__PURE__ */ jsx(
11484
- Form$2.Field,
11485
- {
11486
- control: form.control,
11487
- name: "address_1",
11488
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11489
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
11490
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11491
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11492
- ] })
11493
- }
11494
- ),
11495
- /* @__PURE__ */ jsx(
11496
- Form$2.Field,
11497
- {
11498
- control: form.control,
11499
- name: "address_2",
11500
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11501
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
11502
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11503
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11504
- ] })
11505
- }
11506
- ),
11507
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
11508
- /* @__PURE__ */ jsx(
11509
- Form$2.Field,
11510
- {
11511
- control: form.control,
11512
- name: "postal_code",
11513
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11514
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
11515
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11516
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11517
- ] })
11518
- }
11519
- ),
11520
- /* @__PURE__ */ jsx(
11521
- Form$2.Field,
11522
- {
11523
- control: form.control,
11524
- name: "city",
11525
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11526
- /* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
11527
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11528
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11529
- ] })
11530
- }
11531
- )
11532
- ] }),
11533
- /* @__PURE__ */ jsx(
11534
- Form$2.Field,
11535
- {
11536
- control: form.control,
11537
- name: "province",
11538
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11539
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
11540
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11541
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11542
- ] })
11543
- }
11544
- ),
11545
- /* @__PURE__ */ jsx(
11546
- Form$2.Field,
11547
- {
11548
- control: form.control,
11549
- name: "phone",
11550
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11551
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
11552
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11553
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11554
- ] })
11555
- }
11556
- )
11557
- ] }) }),
11558
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
11559
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11560
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
11561
- ] }) })
11562
- ]
11563
- }
11564
- ) });
11565
- };
11566
- const schema$2 = addressSchema;
11567
11554
  const STACKED_FOCUS_MODAL_ID = "shipping-form";
11568
11555
  const Shipping = () => {
11569
11556
  var _a;
@@ -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"
@@ -13081,10 +13085,6 @@ const routeModule = {
13081
13085
  Component: SalesChannel,
13082
13086
  path: "/draft-orders/:id/sales-channel"
13083
13087
  },
13084
- {
13085
- Component: ShippingAddress,
13086
- path: "/draft-orders/:id/shipping-address"
13087
- },
13088
13088
  {
13089
13089
  Component: Shipping,
13090
13090
  path: "/draft-orders/:id/shipping"
@@ -13094,8 +13094,8 @@ const routeModule = {
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.1-preview-20251024031436",
3
+ "version": "2.11.1-preview-20251024060204",
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.11.1-preview-20251024031436",
39
+ "@medusajs/js-sdk": "2.11.1-preview-20251024060204",
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.11.1-preview-20251024031436",
49
- "@medusajs/cli": "2.11.1-preview-20251024031436",
50
- "@medusajs/framework": "2.11.1-preview-20251024031436",
51
- "@medusajs/icons": "2.11.1-preview-20251024031436",
52
- "@medusajs/test-utils": "2.11.1-preview-20251024031436",
53
- "@medusajs/types": "2.11.1-preview-20251024031436",
54
- "@medusajs/ui": "4.0.25-preview-20251024031436",
55
- "@medusajs/ui-preset": "2.11.1-preview-20251024031436",
48
+ "@medusajs/admin-sdk": "2.11.1-preview-20251024060204",
49
+ "@medusajs/cli": "2.11.1-preview-20251024060204",
50
+ "@medusajs/framework": "2.11.1-preview-20251024060204",
51
+ "@medusajs/icons": "2.11.1-preview-20251024060204",
52
+ "@medusajs/test-utils": "2.11.1-preview-20251024060204",
53
+ "@medusajs/types": "2.11.1-preview-20251024060204",
54
+ "@medusajs/ui": "4.0.25-preview-20251024060204",
55
+ "@medusajs/ui-preset": "2.11.1-preview-20251024060204",
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.11.1-preview-20251024031436",
73
- "@medusajs/cli": "2.11.1-preview-20251024031436",
74
- "@medusajs/framework": "2.11.1-preview-20251024031436",
75
- "@medusajs/icons": "2.11.1-preview-20251024031436",
76
- "@medusajs/test-utils": "2.11.1-preview-20251024031436",
77
- "@medusajs/ui": "4.0.25-preview-20251024031436",
72
+ "@medusajs/admin-sdk": "2.11.1-preview-20251024060204",
73
+ "@medusajs/cli": "2.11.1-preview-20251024060204",
74
+ "@medusajs/framework": "2.11.1-preview-20251024060204",
75
+ "@medusajs/icons": "2.11.1-preview-20251024060204",
76
+ "@medusajs/test-utils": "2.11.1-preview-20251024060204",
77
+ "@medusajs/ui": "4.0.25-preview-20251024060204",
78
78
  "lodash": "^4.17.21",
79
79
  "react-router-dom": "6.20.1"
80
80
  },