@medusajs/draft-order 2.11.3-snapshot-20251103115905 → 2.12.0-preview-20251103180145

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.
@@ -4654,6 +4654,9 @@ ZodReadonly.create = (type, params) => {
4654
4654
  ...processCreateParams(params)
4655
4655
  });
4656
4656
  };
4657
+ ({
4658
+ object: ZodObject.lazycreate
4659
+ });
4657
4660
  var ZodFirstPartyTypeKind;
4658
4661
  (function(ZodFirstPartyTypeKind2) {
4659
4662
  ZodFirstPartyTypeKind2["ZodString"] = "ZodString";
@@ -4700,6 +4703,7 @@ const anyType = ZodAny.create;
4700
4703
  ZodNever.create;
4701
4704
  const arrayType = ZodArray.create;
4702
4705
  const objectType = ZodObject.create;
4706
+ ZodObject.strictCreate;
4703
4707
  const unionType = ZodUnion.create;
4704
4708
  ZodIntersection.create;
4705
4709
  ZodTuple.create;
@@ -9758,6 +9762,27 @@ const BillingAddressForm = ({ order }) => {
9758
9762
  ) });
9759
9763
  };
9760
9764
  const schema$5 = addressSchema;
9765
+ const CustomItems = () => {
9766
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9767
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
9768
+ /* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
9769
+ ] });
9770
+ };
9771
+ const CustomItemsForm = () => {
9772
+ const form = reactHookForm.useForm({
9773
+ resolver: zod.zodResolver(schema$4)
9774
+ });
9775
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9776
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
9777
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
9778
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9779
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
9780
+ ] }) })
9781
+ ] }) });
9782
+ };
9783
+ const schema$4 = objectType({
9784
+ email: stringType().email()
9785
+ });
9761
9786
  const Email = () => {
9762
9787
  const { id } = reactRouterDom.useParams();
9763
9788
  const { order, isPending, isError, error } = useOrder(id, {
@@ -9780,7 +9805,7 @@ const EmailForm = ({ order }) => {
9780
9805
  defaultValues: {
9781
9806
  email: order.email ?? ""
9782
9807
  },
9783
- resolver: zod.zodResolver(schema$4)
9808
+ resolver: zod.zodResolver(schema$3)
9784
9809
  });
9785
9810
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9786
9811
  const { handleSuccess } = useRouteModal();
@@ -9823,27 +9848,6 @@ const EmailForm = ({ order }) => {
9823
9848
  }
9824
9849
  ) });
9825
9850
  };
9826
- const schema$4 = objectType({
9827
- email: stringType().email()
9828
- });
9829
- const CustomItems = () => {
9830
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9831
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
9832
- /* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
9833
- ] });
9834
- };
9835
- const CustomItemsForm = () => {
9836
- const form = reactHookForm.useForm({
9837
- resolver: zod.zodResolver(schema$3)
9838
- });
9839
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9840
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
9841
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
9842
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9843
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
9844
- ] }) })
9845
- ] }) });
9846
- };
9847
9851
  const schema$3 = objectType({
9848
9852
  email: stringType().email()
9849
9853
  });
@@ -11554,209 +11558,6 @@ const SalesChannelField = ({ control, order }) => {
11554
11558
  const schema$2 = objectType({
11555
11559
  sales_channel_id: stringType().min(1)
11556
11560
  });
11557
- const ShippingAddress = () => {
11558
- const { id } = reactRouterDom.useParams();
11559
- const { order, isPending, isError, error } = useOrder(id, {
11560
- fields: "+shipping_address"
11561
- });
11562
- if (isError) {
11563
- throw error;
11564
- }
11565
- const isReady = !isPending && !!order;
11566
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
11567
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
11568
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Shipping Address" }) }),
11569
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
11570
- ] }),
11571
- isReady && /* @__PURE__ */ jsxRuntime.jsx(ShippingAddressForm, { order })
11572
- ] });
11573
- };
11574
- const ShippingAddressForm = ({ order }) => {
11575
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
11576
- const form = reactHookForm.useForm({
11577
- defaultValues: {
11578
- first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
11579
- last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
11580
- company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
11581
- address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
11582
- address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
11583
- city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
11584
- province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
11585
- country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
11586
- postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
11587
- phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
11588
- },
11589
- resolver: zod.zodResolver(schema$1)
11590
- });
11591
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11592
- const { handleSuccess } = useRouteModal();
11593
- const onSubmit = form.handleSubmit(async (data) => {
11594
- await mutateAsync(
11595
- {
11596
- shipping_address: {
11597
- first_name: data.first_name,
11598
- last_name: data.last_name,
11599
- company: data.company,
11600
- address_1: data.address_1,
11601
- address_2: data.address_2,
11602
- city: data.city,
11603
- province: data.province,
11604
- country_code: data.country_code,
11605
- postal_code: data.postal_code,
11606
- phone: data.phone
11607
- }
11608
- },
11609
- {
11610
- onSuccess: () => {
11611
- handleSuccess();
11612
- },
11613
- onError: (error) => {
11614
- ui.toast.error(error.message);
11615
- }
11616
- }
11617
- );
11618
- });
11619
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
11620
- KeyboundForm,
11621
- {
11622
- className: "flex flex-1 flex-col overflow-hidden",
11623
- onSubmit,
11624
- children: [
11625
- /* @__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: [
11626
- /* @__PURE__ */ jsxRuntime.jsx(
11627
- Form$2.Field,
11628
- {
11629
- control: form.control,
11630
- name: "country_code",
11631
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11632
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
11633
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
11634
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11635
- ] })
11636
- }
11637
- ),
11638
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
11639
- /* @__PURE__ */ jsxRuntime.jsx(
11640
- Form$2.Field,
11641
- {
11642
- control: form.control,
11643
- name: "first_name",
11644
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11645
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
11646
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11647
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11648
- ] })
11649
- }
11650
- ),
11651
- /* @__PURE__ */ jsxRuntime.jsx(
11652
- Form$2.Field,
11653
- {
11654
- control: form.control,
11655
- name: "last_name",
11656
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11657
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
11658
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11659
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11660
- ] })
11661
- }
11662
- )
11663
- ] }),
11664
- /* @__PURE__ */ jsxRuntime.jsx(
11665
- Form$2.Field,
11666
- {
11667
- control: form.control,
11668
- name: "company",
11669
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11670
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
11671
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11672
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11673
- ] })
11674
- }
11675
- ),
11676
- /* @__PURE__ */ jsxRuntime.jsx(
11677
- Form$2.Field,
11678
- {
11679
- control: form.control,
11680
- name: "address_1",
11681
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11682
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
11683
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11684
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11685
- ] })
11686
- }
11687
- ),
11688
- /* @__PURE__ */ jsxRuntime.jsx(
11689
- Form$2.Field,
11690
- {
11691
- control: form.control,
11692
- name: "address_2",
11693
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11694
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
11695
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11696
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11697
- ] })
11698
- }
11699
- ),
11700
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
11701
- /* @__PURE__ */ jsxRuntime.jsx(
11702
- Form$2.Field,
11703
- {
11704
- control: form.control,
11705
- name: "postal_code",
11706
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11707
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
11708
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11709
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11710
- ] })
11711
- }
11712
- ),
11713
- /* @__PURE__ */ jsxRuntime.jsx(
11714
- Form$2.Field,
11715
- {
11716
- control: form.control,
11717
- name: "city",
11718
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11719
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
11720
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11721
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11722
- ] })
11723
- }
11724
- )
11725
- ] }),
11726
- /* @__PURE__ */ jsxRuntime.jsx(
11727
- Form$2.Field,
11728
- {
11729
- control: form.control,
11730
- name: "province",
11731
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11732
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
11733
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11734
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11735
- ] })
11736
- }
11737
- ),
11738
- /* @__PURE__ */ jsxRuntime.jsx(
11739
- Form$2.Field,
11740
- {
11741
- control: form.control,
11742
- name: "phone",
11743
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11744
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
11745
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11746
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11747
- ] })
11748
- }
11749
- )
11750
- ] }) }),
11751
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
11752
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11753
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
11754
- ] }) })
11755
- ]
11756
- }
11757
- ) });
11758
- };
11759
- const schema$1 = addressSchema;
11760
11561
  const STACKED_FOCUS_MODAL_ID = "shipping-form";
11761
11562
  const Shipping = () => {
11762
11563
  var _a;
@@ -12564,6 +12365,209 @@ const CustomAmountField = ({
12564
12365
  }
12565
12366
  );
12566
12367
  };
12368
+ const ShippingAddress = () => {
12369
+ const { id } = reactRouterDom.useParams();
12370
+ const { order, isPending, isError, error } = useOrder(id, {
12371
+ fields: "+shipping_address"
12372
+ });
12373
+ if (isError) {
12374
+ throw error;
12375
+ }
12376
+ const isReady = !isPending && !!order;
12377
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12378
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
12379
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Shipping Address" }) }),
12380
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
12381
+ ] }),
12382
+ isReady && /* @__PURE__ */ jsxRuntime.jsx(ShippingAddressForm, { order })
12383
+ ] });
12384
+ };
12385
+ const ShippingAddressForm = ({ order }) => {
12386
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12387
+ const form = reactHookForm.useForm({
12388
+ defaultValues: {
12389
+ first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
12390
+ last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
12391
+ company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
12392
+ address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
12393
+ address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
12394
+ city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
12395
+ province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
12396
+ country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
12397
+ postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12398
+ phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12399
+ },
12400
+ resolver: zod.zodResolver(schema$1)
12401
+ });
12402
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12403
+ const { handleSuccess } = useRouteModal();
12404
+ const onSubmit = form.handleSubmit(async (data) => {
12405
+ await mutateAsync(
12406
+ {
12407
+ shipping_address: {
12408
+ first_name: data.first_name,
12409
+ last_name: data.last_name,
12410
+ company: data.company,
12411
+ address_1: data.address_1,
12412
+ address_2: data.address_2,
12413
+ city: data.city,
12414
+ province: data.province,
12415
+ country_code: data.country_code,
12416
+ postal_code: data.postal_code,
12417
+ phone: data.phone
12418
+ }
12419
+ },
12420
+ {
12421
+ onSuccess: () => {
12422
+ handleSuccess();
12423
+ },
12424
+ onError: (error) => {
12425
+ ui.toast.error(error.message);
12426
+ }
12427
+ }
12428
+ );
12429
+ });
12430
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
12431
+ KeyboundForm,
12432
+ {
12433
+ className: "flex flex-1 flex-col overflow-hidden",
12434
+ onSubmit,
12435
+ children: [
12436
+ /* @__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: [
12437
+ /* @__PURE__ */ jsxRuntime.jsx(
12438
+ Form$2.Field,
12439
+ {
12440
+ control: form.control,
12441
+ name: "country_code",
12442
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12443
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
12444
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
12445
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12446
+ ] })
12447
+ }
12448
+ ),
12449
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12450
+ /* @__PURE__ */ jsxRuntime.jsx(
12451
+ Form$2.Field,
12452
+ {
12453
+ control: form.control,
12454
+ name: "first_name",
12455
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12456
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
12457
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12458
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12459
+ ] })
12460
+ }
12461
+ ),
12462
+ /* @__PURE__ */ jsxRuntime.jsx(
12463
+ Form$2.Field,
12464
+ {
12465
+ control: form.control,
12466
+ name: "last_name",
12467
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12468
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
12469
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12470
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12471
+ ] })
12472
+ }
12473
+ )
12474
+ ] }),
12475
+ /* @__PURE__ */ jsxRuntime.jsx(
12476
+ Form$2.Field,
12477
+ {
12478
+ control: form.control,
12479
+ name: "company",
12480
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12481
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
12482
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12483
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12484
+ ] })
12485
+ }
12486
+ ),
12487
+ /* @__PURE__ */ jsxRuntime.jsx(
12488
+ Form$2.Field,
12489
+ {
12490
+ control: form.control,
12491
+ name: "address_1",
12492
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12493
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
12494
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12495
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12496
+ ] })
12497
+ }
12498
+ ),
12499
+ /* @__PURE__ */ jsxRuntime.jsx(
12500
+ Form$2.Field,
12501
+ {
12502
+ control: form.control,
12503
+ name: "address_2",
12504
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12505
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
12506
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12507
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12508
+ ] })
12509
+ }
12510
+ ),
12511
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12512
+ /* @__PURE__ */ jsxRuntime.jsx(
12513
+ Form$2.Field,
12514
+ {
12515
+ control: form.control,
12516
+ name: "postal_code",
12517
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12518
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
12519
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12520
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12521
+ ] })
12522
+ }
12523
+ ),
12524
+ /* @__PURE__ */ jsxRuntime.jsx(
12525
+ Form$2.Field,
12526
+ {
12527
+ control: form.control,
12528
+ name: "city",
12529
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12530
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
12531
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12532
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12533
+ ] })
12534
+ }
12535
+ )
12536
+ ] }),
12537
+ /* @__PURE__ */ jsxRuntime.jsx(
12538
+ Form$2.Field,
12539
+ {
12540
+ control: form.control,
12541
+ name: "province",
12542
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12543
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
12544
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12545
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12546
+ ] })
12547
+ }
12548
+ ),
12549
+ /* @__PURE__ */ jsxRuntime.jsx(
12550
+ Form$2.Field,
12551
+ {
12552
+ control: form.control,
12553
+ name: "phone",
12554
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12555
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
12556
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12557
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12558
+ ] })
12559
+ }
12560
+ )
12561
+ ] }) }),
12562
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
12563
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12564
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12565
+ ] }) })
12566
+ ]
12567
+ }
12568
+ ) });
12569
+ };
12570
+ const schema$1 = addressSchema;
12567
12571
  const TransferOwnership = () => {
12568
12572
  const { id } = reactRouterDom.useParams();
12569
12573
  const { draft_order, isPending, isError, error } = useDraftOrder(id, {
@@ -13064,14 +13068,14 @@ const routeModule = {
13064
13068
  Component: BillingAddress,
13065
13069
  path: "/draft-orders/:id/billing-address"
13066
13070
  },
13067
- {
13068
- Component: Email,
13069
- path: "/draft-orders/:id/email"
13070
- },
13071
13071
  {
13072
13072
  Component: CustomItems,
13073
13073
  path: "/draft-orders/:id/custom-items"
13074
13074
  },
13075
+ {
13076
+ Component: Email,
13077
+ path: "/draft-orders/:id/email"
13078
+ },
13075
13079
  {
13076
13080
  Component: Items,
13077
13081
  path: "/draft-orders/:id/items"
@@ -13088,14 +13092,14 @@ const routeModule = {
13088
13092
  Component: SalesChannel,
13089
13093
  path: "/draft-orders/:id/sales-channel"
13090
13094
  },
13091
- {
13092
- Component: ShippingAddress,
13093
- path: "/draft-orders/:id/shipping-address"
13094
- },
13095
13095
  {
13096
13096
  Component: Shipping,
13097
13097
  path: "/draft-orders/:id/shipping"
13098
13098
  },
13099
+ {
13100
+ Component: ShippingAddress,
13101
+ path: "/draft-orders/:id/shipping-address"
13102
+ },
13099
13103
  {
13100
13104
  Component: TransferOwnership,
13101
13105
  path: "/draft-orders/:id/transfer-ownership"
@@ -9,7 +9,7 @@ import Medusa from "@medusajs/js-sdk";
9
9
  import { format, formatDistance, sub, subDays, subMonths } from "date-fns";
10
10
  import { enUS } from "date-fns/locale";
11
11
  import { zodResolver } from "@hookform/resolvers/zod";
12
- import { FormProvider, useFormContext, useFormState, Controller, useForm, useWatch, useFieldArray } from "react-hook-form";
12
+ import { FormProvider, Controller, useFormContext, useFormState, useForm, useWatch, useFieldArray } from "react-hook-form";
13
13
  import { Slot, Collapsible, Accordion } from "radix-ui";
14
14
  import { ComboboxProvider, Combobox as Combobox$1, ComboboxDisclosure, ComboboxPopover, ComboboxItem, ComboboxItemCheck, ComboboxItemValue, Separator } from "@ariakit/react";
15
15
  import { matchSorter } from "match-sorter";
@@ -4647,6 +4647,9 @@ ZodReadonly.create = (type, params) => {
4647
4647
  ...processCreateParams(params)
4648
4648
  });
4649
4649
  };
4650
+ ({
4651
+ object: ZodObject.lazycreate
4652
+ });
4650
4653
  var ZodFirstPartyTypeKind;
4651
4654
  (function(ZodFirstPartyTypeKind2) {
4652
4655
  ZodFirstPartyTypeKind2["ZodString"] = "ZodString";
@@ -4693,6 +4696,7 @@ const anyType = ZodAny.create;
4693
4696
  ZodNever.create;
4694
4697
  const arrayType = ZodArray.create;
4695
4698
  const objectType = ZodObject.create;
4699
+ ZodObject.strictCreate;
4696
4700
  const unionType = ZodUnion.create;
4697
4701
  ZodIntersection.create;
4698
4702
  ZodTuple.create;
@@ -9751,6 +9755,27 @@ const BillingAddressForm = ({ order }) => {
9751
9755
  ) });
9752
9756
  };
9753
9757
  const schema$5 = addressSchema;
9758
+ const CustomItems = () => {
9759
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
9760
+ /* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
9761
+ /* @__PURE__ */ jsx(CustomItemsForm, {})
9762
+ ] });
9763
+ };
9764
+ const CustomItemsForm = () => {
9765
+ const form = useForm({
9766
+ resolver: zodResolver(schema$4)
9767
+ });
9768
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9769
+ /* @__PURE__ */ jsx(RouteDrawer.Body, {}),
9770
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
9771
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9772
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
9773
+ ] }) })
9774
+ ] }) });
9775
+ };
9776
+ const schema$4 = objectType({
9777
+ email: stringType().email()
9778
+ });
9754
9779
  const Email = () => {
9755
9780
  const { id } = useParams();
9756
9781
  const { order, isPending, isError, error } = useOrder(id, {
@@ -9773,7 +9798,7 @@ const EmailForm = ({ order }) => {
9773
9798
  defaultValues: {
9774
9799
  email: order.email ?? ""
9775
9800
  },
9776
- resolver: zodResolver(schema$4)
9801
+ resolver: zodResolver(schema$3)
9777
9802
  });
9778
9803
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9779
9804
  const { handleSuccess } = useRouteModal();
@@ -9816,27 +9841,6 @@ const EmailForm = ({ order }) => {
9816
9841
  }
9817
9842
  ) });
9818
9843
  };
9819
- const schema$4 = objectType({
9820
- email: stringType().email()
9821
- });
9822
- const CustomItems = () => {
9823
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
9824
- /* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
9825
- /* @__PURE__ */ jsx(CustomItemsForm, {})
9826
- ] });
9827
- };
9828
- const CustomItemsForm = () => {
9829
- const form = useForm({
9830
- resolver: zodResolver(schema$3)
9831
- });
9832
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9833
- /* @__PURE__ */ jsx(RouteDrawer.Body, {}),
9834
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
9835
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9836
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
9837
- ] }) })
9838
- ] }) });
9839
- };
9840
9844
  const schema$3 = objectType({
9841
9845
  email: stringType().email()
9842
9846
  });
@@ -11547,209 +11551,6 @@ const SalesChannelField = ({ control, order }) => {
11547
11551
  const schema$2 = objectType({
11548
11552
  sales_channel_id: stringType().min(1)
11549
11553
  });
11550
- const ShippingAddress = () => {
11551
- const { id } = useParams();
11552
- const { order, isPending, isError, error } = useOrder(id, {
11553
- fields: "+shipping_address"
11554
- });
11555
- if (isError) {
11556
- throw error;
11557
- }
11558
- const isReady = !isPending && !!order;
11559
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
11560
- /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
11561
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Shipping Address" }) }),
11562
- /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
11563
- ] }),
11564
- isReady && /* @__PURE__ */ jsx(ShippingAddressForm, { order })
11565
- ] });
11566
- };
11567
- const ShippingAddressForm = ({ order }) => {
11568
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
11569
- const form = useForm({
11570
- defaultValues: {
11571
- first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
11572
- last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
11573
- company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
11574
- address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
11575
- address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
11576
- city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
11577
- province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
11578
- country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
11579
- postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
11580
- phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
11581
- },
11582
- resolver: zodResolver(schema$1)
11583
- });
11584
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11585
- const { handleSuccess } = useRouteModal();
11586
- const onSubmit = form.handleSubmit(async (data) => {
11587
- await mutateAsync(
11588
- {
11589
- shipping_address: {
11590
- first_name: data.first_name,
11591
- last_name: data.last_name,
11592
- company: data.company,
11593
- address_1: data.address_1,
11594
- address_2: data.address_2,
11595
- city: data.city,
11596
- province: data.province,
11597
- country_code: data.country_code,
11598
- postal_code: data.postal_code,
11599
- phone: data.phone
11600
- }
11601
- },
11602
- {
11603
- onSuccess: () => {
11604
- handleSuccess();
11605
- },
11606
- onError: (error) => {
11607
- toast.error(error.message);
11608
- }
11609
- }
11610
- );
11611
- });
11612
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
11613
- KeyboundForm,
11614
- {
11615
- className: "flex flex-1 flex-col overflow-hidden",
11616
- onSubmit,
11617
- children: [
11618
- /* @__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: [
11619
- /* @__PURE__ */ jsx(
11620
- Form$2.Field,
11621
- {
11622
- control: form.control,
11623
- name: "country_code",
11624
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11625
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
11626
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
11627
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11628
- ] })
11629
- }
11630
- ),
11631
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
11632
- /* @__PURE__ */ jsx(
11633
- Form$2.Field,
11634
- {
11635
- control: form.control,
11636
- name: "first_name",
11637
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11638
- /* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
11639
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11640
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11641
- ] })
11642
- }
11643
- ),
11644
- /* @__PURE__ */ jsx(
11645
- Form$2.Field,
11646
- {
11647
- control: form.control,
11648
- name: "last_name",
11649
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11650
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
11651
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11652
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11653
- ] })
11654
- }
11655
- )
11656
- ] }),
11657
- /* @__PURE__ */ jsx(
11658
- Form$2.Field,
11659
- {
11660
- control: form.control,
11661
- name: "company",
11662
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11663
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
11664
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11665
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11666
- ] })
11667
- }
11668
- ),
11669
- /* @__PURE__ */ jsx(
11670
- Form$2.Field,
11671
- {
11672
- control: form.control,
11673
- name: "address_1",
11674
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11675
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
11676
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11677
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11678
- ] })
11679
- }
11680
- ),
11681
- /* @__PURE__ */ jsx(
11682
- Form$2.Field,
11683
- {
11684
- control: form.control,
11685
- name: "address_2",
11686
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11687
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
11688
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11689
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11690
- ] })
11691
- }
11692
- ),
11693
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
11694
- /* @__PURE__ */ jsx(
11695
- Form$2.Field,
11696
- {
11697
- control: form.control,
11698
- name: "postal_code",
11699
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11700
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
11701
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11702
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11703
- ] })
11704
- }
11705
- ),
11706
- /* @__PURE__ */ jsx(
11707
- Form$2.Field,
11708
- {
11709
- control: form.control,
11710
- name: "city",
11711
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11712
- /* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
11713
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11714
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11715
- ] })
11716
- }
11717
- )
11718
- ] }),
11719
- /* @__PURE__ */ jsx(
11720
- Form$2.Field,
11721
- {
11722
- control: form.control,
11723
- name: "province",
11724
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11725
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
11726
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11727
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11728
- ] })
11729
- }
11730
- ),
11731
- /* @__PURE__ */ jsx(
11732
- Form$2.Field,
11733
- {
11734
- control: form.control,
11735
- name: "phone",
11736
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11737
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
11738
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11739
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11740
- ] })
11741
- }
11742
- )
11743
- ] }) }),
11744
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
11745
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11746
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
11747
- ] }) })
11748
- ]
11749
- }
11750
- ) });
11751
- };
11752
- const schema$1 = addressSchema;
11753
11554
  const STACKED_FOCUS_MODAL_ID = "shipping-form";
11754
11555
  const Shipping = () => {
11755
11556
  var _a;
@@ -12557,6 +12358,209 @@ const CustomAmountField = ({
12557
12358
  }
12558
12359
  );
12559
12360
  };
12361
+ const ShippingAddress = () => {
12362
+ const { id } = useParams();
12363
+ const { order, isPending, isError, error } = useOrder(id, {
12364
+ fields: "+shipping_address"
12365
+ });
12366
+ if (isError) {
12367
+ throw error;
12368
+ }
12369
+ const isReady = !isPending && !!order;
12370
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
12371
+ /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
12372
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Shipping Address" }) }),
12373
+ /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
12374
+ ] }),
12375
+ isReady && /* @__PURE__ */ jsx(ShippingAddressForm, { order })
12376
+ ] });
12377
+ };
12378
+ const ShippingAddressForm = ({ order }) => {
12379
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12380
+ const form = useForm({
12381
+ defaultValues: {
12382
+ first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
12383
+ last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
12384
+ company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
12385
+ address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
12386
+ address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
12387
+ city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
12388
+ province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
12389
+ country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
12390
+ postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12391
+ phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12392
+ },
12393
+ resolver: zodResolver(schema$1)
12394
+ });
12395
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12396
+ const { handleSuccess } = useRouteModal();
12397
+ const onSubmit = form.handleSubmit(async (data) => {
12398
+ await mutateAsync(
12399
+ {
12400
+ shipping_address: {
12401
+ first_name: data.first_name,
12402
+ last_name: data.last_name,
12403
+ company: data.company,
12404
+ address_1: data.address_1,
12405
+ address_2: data.address_2,
12406
+ city: data.city,
12407
+ province: data.province,
12408
+ country_code: data.country_code,
12409
+ postal_code: data.postal_code,
12410
+ phone: data.phone
12411
+ }
12412
+ },
12413
+ {
12414
+ onSuccess: () => {
12415
+ handleSuccess();
12416
+ },
12417
+ onError: (error) => {
12418
+ toast.error(error.message);
12419
+ }
12420
+ }
12421
+ );
12422
+ });
12423
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
12424
+ KeyboundForm,
12425
+ {
12426
+ className: "flex flex-1 flex-col overflow-hidden",
12427
+ onSubmit,
12428
+ children: [
12429
+ /* @__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: [
12430
+ /* @__PURE__ */ jsx(
12431
+ Form$2.Field,
12432
+ {
12433
+ control: form.control,
12434
+ name: "country_code",
12435
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12436
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
12437
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
12438
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12439
+ ] })
12440
+ }
12441
+ ),
12442
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12443
+ /* @__PURE__ */ jsx(
12444
+ Form$2.Field,
12445
+ {
12446
+ control: form.control,
12447
+ name: "first_name",
12448
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12449
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
12450
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12451
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12452
+ ] })
12453
+ }
12454
+ ),
12455
+ /* @__PURE__ */ jsx(
12456
+ Form$2.Field,
12457
+ {
12458
+ control: form.control,
12459
+ name: "last_name",
12460
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12461
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
12462
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12463
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12464
+ ] })
12465
+ }
12466
+ )
12467
+ ] }),
12468
+ /* @__PURE__ */ jsx(
12469
+ Form$2.Field,
12470
+ {
12471
+ control: form.control,
12472
+ name: "company",
12473
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12474
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
12475
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12476
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12477
+ ] })
12478
+ }
12479
+ ),
12480
+ /* @__PURE__ */ jsx(
12481
+ Form$2.Field,
12482
+ {
12483
+ control: form.control,
12484
+ name: "address_1",
12485
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12486
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
12487
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12488
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12489
+ ] })
12490
+ }
12491
+ ),
12492
+ /* @__PURE__ */ jsx(
12493
+ Form$2.Field,
12494
+ {
12495
+ control: form.control,
12496
+ name: "address_2",
12497
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12498
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
12499
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12500
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12501
+ ] })
12502
+ }
12503
+ ),
12504
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12505
+ /* @__PURE__ */ jsx(
12506
+ Form$2.Field,
12507
+ {
12508
+ control: form.control,
12509
+ name: "postal_code",
12510
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12511
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
12512
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12513
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12514
+ ] })
12515
+ }
12516
+ ),
12517
+ /* @__PURE__ */ jsx(
12518
+ Form$2.Field,
12519
+ {
12520
+ control: form.control,
12521
+ name: "city",
12522
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12523
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
12524
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12525
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12526
+ ] })
12527
+ }
12528
+ )
12529
+ ] }),
12530
+ /* @__PURE__ */ jsx(
12531
+ Form$2.Field,
12532
+ {
12533
+ control: form.control,
12534
+ name: "province",
12535
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12536
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
12537
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12538
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12539
+ ] })
12540
+ }
12541
+ ),
12542
+ /* @__PURE__ */ jsx(
12543
+ Form$2.Field,
12544
+ {
12545
+ control: form.control,
12546
+ name: "phone",
12547
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12548
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
12549
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12550
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12551
+ ] })
12552
+ }
12553
+ )
12554
+ ] }) }),
12555
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
12556
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
12557
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
12558
+ ] }) })
12559
+ ]
12560
+ }
12561
+ ) });
12562
+ };
12563
+ const schema$1 = addressSchema;
12560
12564
  const TransferOwnership = () => {
12561
12565
  const { id } = useParams();
12562
12566
  const { draft_order, isPending, isError, error } = useDraftOrder(id, {
@@ -13057,14 +13061,14 @@ const routeModule = {
13057
13061
  Component: BillingAddress,
13058
13062
  path: "/draft-orders/:id/billing-address"
13059
13063
  },
13060
- {
13061
- Component: Email,
13062
- path: "/draft-orders/:id/email"
13063
- },
13064
13064
  {
13065
13065
  Component: CustomItems,
13066
13066
  path: "/draft-orders/:id/custom-items"
13067
13067
  },
13068
+ {
13069
+ Component: Email,
13070
+ path: "/draft-orders/:id/email"
13071
+ },
13068
13072
  {
13069
13073
  Component: Items,
13070
13074
  path: "/draft-orders/:id/items"
@@ -13081,14 +13085,14 @@ 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"
13091
13091
  },
13092
+ {
13093
+ Component: ShippingAddress,
13094
+ path: "/draft-orders/:id/shipping-address"
13095
+ },
13092
13096
  {
13093
13097
  Component: TransferOwnership,
13094
13098
  path: "/draft-orders/:id/transfer-ownership"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medusajs/draft-order",
3
- "version": "2.11.3-snapshot-20251103115905",
3
+ "version": "2.12.0-preview-20251103180145",
4
4
  "description": "A starter for Medusa plugins.",
5
5
  "author": "Medusa (https://medusajs.com)",
6
6
  "license": "MIT",
@@ -37,7 +37,7 @@
37
37
  "@ariakit/react": "^0.4.15",
38
38
  "@babel/runtime": "^7.26.10",
39
39
  "@hookform/resolvers": "3.4.2",
40
- "@medusajs/js-sdk": "2.11.3-snapshot-20251103115905",
40
+ "@medusajs/js-sdk": "2.12.0-preview-20251103180145",
41
41
  "@tanstack/react-query": "5.64.2",
42
42
  "@uiw/react-json-view": "^2.0.0-alpha.17",
43
43
  "date-fns": "^3.6.0",
@@ -48,22 +48,37 @@
48
48
  "react-hook-form": "7.49.1"
49
49
  },
50
50
  "devDependencies": {
51
- "@medusajs/admin-sdk": "2.11.3-snapshot-20251103115905",
52
- "@medusajs/cli": "2.11.3-snapshot-20251103115905",
53
- "@medusajs/framework": "2.11.3-snapshot-20251103115905",
54
- "@medusajs/icons": "2.11.3-snapshot-20251103115905",
55
- "@medusajs/test-utils": "2.11.3-snapshot-20251103115905",
56
- "@medusajs/types": "2.11.3-snapshot-20251103115905",
57
- "@medusajs/ui": "4.0.27-snapshot-20251103115905",
58
- "@medusajs/ui-preset": "2.11.3-snapshot-20251103115905"
51
+ "@medusajs/admin-sdk": "2.12.0-preview-20251103180145",
52
+ "@medusajs/cli": "2.12.0-preview-20251103180145",
53
+ "@medusajs/framework": "2.12.0-preview-20251103180145",
54
+ "@medusajs/icons": "2.12.0-preview-20251103180145",
55
+ "@medusajs/test-utils": "2.12.0-preview-20251103180145",
56
+ "@medusajs/types": "2.12.0-preview-20251103180145",
57
+ "@medusajs/ui": "4.0.27-preview-20251103180145",
58
+ "@medusajs/ui-preset": "2.12.0-preview-20251103180145",
59
+ "@swc/core": "^1.7.28",
60
+ "@types/lodash": "^4.17.15",
61
+ "@types/lodash.debounce": "^4.0.9",
62
+ "@types/lodash.isequal": "^4.5.8",
63
+ "@types/node": "^20.12.11",
64
+ "@types/react": "^18.3.2",
65
+ "@types/react-dom": "^18.2.25",
66
+ "react": "^18.3.1",
67
+ "react-dom": "^18.3.1",
68
+ "react-router-dom": "6.20.1",
69
+ "ts-node": "^10.9.2",
70
+ "tsup": "^8.4.0",
71
+ "typescript": "^5.6.2",
72
+ "vite": "^5.4.14",
73
+ "yalc": "^1.0.0-pre.53"
59
74
  },
60
75
  "peerDependencies": {
61
- "@medusajs/admin-sdk": "2.11.3-snapshot-20251103115905",
62
- "@medusajs/cli": "2.11.3-snapshot-20251103115905",
63
- "@medusajs/framework": "2.11.3-snapshot-20251103115905",
64
- "@medusajs/icons": "2.11.3-snapshot-20251103115905",
65
- "@medusajs/test-utils": "2.11.3-snapshot-20251103115905",
66
- "@medusajs/ui": "4.0.27-snapshot-20251103115905",
76
+ "@medusajs/admin-sdk": "2.12.0-preview-20251103180145",
77
+ "@medusajs/cli": "2.12.0-preview-20251103180145",
78
+ "@medusajs/framework": "2.12.0-preview-20251103180145",
79
+ "@medusajs/icons": "2.12.0-preview-20251103180145",
80
+ "@medusajs/test-utils": "2.12.0-preview-20251103180145",
81
+ "@medusajs/ui": "4.0.27-preview-20251103180145",
67
82
  "react": "^18.3.1",
68
83
  "react-dom": "^18.3.1",
69
84
  "react-router-dom": "6.20.1"