@medusajs/draft-order 2.11.2-preview-20251029000331 → 2.11.2-preview-20251029060154

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,27 +9571,6 @@ const ID = () => {
9571
9571
  /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Outlet, {})
9572
9572
  ] });
9573
9573
  };
9574
- const CustomItems = () => {
9575
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9576
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
9577
- /* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
9578
- ] });
9579
- };
9580
- const CustomItemsForm = () => {
9581
- const form = reactHookForm.useForm({
9582
- resolver: zod.zodResolver(schema$5)
9583
- });
9584
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9585
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
9586
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
9587
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9588
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
9589
- ] }) })
9590
- ] }) });
9591
- };
9592
- const schema$5 = objectType({
9593
- email: stringType().email()
9594
- });
9595
9574
  const Email = () => {
9596
9575
  const { id } = reactRouterDom.useParams();
9597
9576
  const { order, isPending, isError, error } = useOrder(id, {
@@ -9614,7 +9593,7 @@ const EmailForm = ({ order }) => {
9614
9593
  defaultValues: {
9615
9594
  email: order.email ?? ""
9616
9595
  },
9617
- resolver: zod.zodResolver(schema$4)
9596
+ resolver: zod.zodResolver(schema$5)
9618
9597
  });
9619
9598
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9620
9599
  const { handleSuccess } = useRouteModal();
@@ -9657,9 +9636,199 @@ const EmailForm = ({ order }) => {
9657
9636
  }
9658
9637
  ) });
9659
9638
  };
9660
- const schema$4 = objectType({
9639
+ const schema$5 = objectType({
9661
9640
  email: stringType().email()
9662
9641
  });
9642
+ const BillingAddress = () => {
9643
+ const { id } = reactRouterDom.useParams();
9644
+ const { order, isPending, isError, error } = useOrder(id, {
9645
+ fields: "+billing_address"
9646
+ });
9647
+ if (isError) {
9648
+ throw error;
9649
+ }
9650
+ const isReady = !isPending && !!order;
9651
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9652
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
9653
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Billing Address" }) }),
9654
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
9655
+ ] }),
9656
+ isReady && /* @__PURE__ */ jsxRuntime.jsx(BillingAddressForm, { order })
9657
+ ] });
9658
+ };
9659
+ const BillingAddressForm = ({ order }) => {
9660
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
9661
+ const form = reactHookForm.useForm({
9662
+ defaultValues: {
9663
+ first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
9664
+ last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
9665
+ company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
9666
+ address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
9667
+ address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
9668
+ city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
9669
+ province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
9670
+ country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
9671
+ postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
9672
+ phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
9673
+ },
9674
+ resolver: zod.zodResolver(schema$4)
9675
+ });
9676
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9677
+ const { handleSuccess } = useRouteModal();
9678
+ const onSubmit = form.handleSubmit(async (data) => {
9679
+ await mutateAsync(
9680
+ { billing_address: data },
9681
+ {
9682
+ onSuccess: () => {
9683
+ handleSuccess();
9684
+ },
9685
+ onError: (error) => {
9686
+ ui.toast.error(error.message);
9687
+ }
9688
+ }
9689
+ );
9690
+ });
9691
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
9692
+ KeyboundForm,
9693
+ {
9694
+ className: "flex flex-1 flex-col overflow-hidden",
9695
+ onSubmit,
9696
+ children: [
9697
+ /* @__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: [
9698
+ /* @__PURE__ */ jsxRuntime.jsx(
9699
+ Form$2.Field,
9700
+ {
9701
+ control: form.control,
9702
+ name: "country_code",
9703
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9704
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
9705
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
9706
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9707
+ ] })
9708
+ }
9709
+ ),
9710
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
9711
+ /* @__PURE__ */ jsxRuntime.jsx(
9712
+ Form$2.Field,
9713
+ {
9714
+ control: form.control,
9715
+ name: "first_name",
9716
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9717
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
9718
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9719
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9720
+ ] })
9721
+ }
9722
+ ),
9723
+ /* @__PURE__ */ jsxRuntime.jsx(
9724
+ Form$2.Field,
9725
+ {
9726
+ control: form.control,
9727
+ name: "last_name",
9728
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9729
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
9730
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9731
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9732
+ ] })
9733
+ }
9734
+ )
9735
+ ] }),
9736
+ /* @__PURE__ */ jsxRuntime.jsx(
9737
+ Form$2.Field,
9738
+ {
9739
+ control: form.control,
9740
+ name: "company",
9741
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9742
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
9743
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9744
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9745
+ ] })
9746
+ }
9747
+ ),
9748
+ /* @__PURE__ */ jsxRuntime.jsx(
9749
+ Form$2.Field,
9750
+ {
9751
+ control: form.control,
9752
+ name: "address_1",
9753
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9754
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
9755
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9756
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9757
+ ] })
9758
+ }
9759
+ ),
9760
+ /* @__PURE__ */ jsxRuntime.jsx(
9761
+ Form$2.Field,
9762
+ {
9763
+ control: form.control,
9764
+ name: "address_2",
9765
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9766
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
9767
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9768
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9769
+ ] })
9770
+ }
9771
+ ),
9772
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
9773
+ /* @__PURE__ */ jsxRuntime.jsx(
9774
+ Form$2.Field,
9775
+ {
9776
+ control: form.control,
9777
+ name: "postal_code",
9778
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9779
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
9780
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9781
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9782
+ ] })
9783
+ }
9784
+ ),
9785
+ /* @__PURE__ */ jsxRuntime.jsx(
9786
+ Form$2.Field,
9787
+ {
9788
+ control: form.control,
9789
+ name: "city",
9790
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9791
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
9792
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9793
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9794
+ ] })
9795
+ }
9796
+ )
9797
+ ] }),
9798
+ /* @__PURE__ */ jsxRuntime.jsx(
9799
+ Form$2.Field,
9800
+ {
9801
+ control: form.control,
9802
+ name: "province",
9803
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9804
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
9805
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9806
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9807
+ ] })
9808
+ }
9809
+ ),
9810
+ /* @__PURE__ */ jsxRuntime.jsx(
9811
+ Form$2.Field,
9812
+ {
9813
+ control: form.control,
9814
+ name: "phone",
9815
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9816
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
9817
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9818
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9819
+ ] })
9820
+ }
9821
+ )
9822
+ ] }) }),
9823
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
9824
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9825
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
9826
+ ] }) })
9827
+ ]
9828
+ }
9829
+ ) });
9830
+ };
9831
+ const schema$4 = addressSchema;
9663
9832
  const NumberInput = React.forwardRef(
9664
9833
  ({
9665
9834
  value,
@@ -11261,6 +11430,27 @@ function getPromotionIds(items, shippingMethods) {
11261
11430
  }
11262
11431
  return Array.from(promotionIds);
11263
11432
  }
11433
+ const CustomItems = () => {
11434
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
11435
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
11436
+ /* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
11437
+ ] });
11438
+ };
11439
+ const CustomItemsForm = () => {
11440
+ const form = reactHookForm.useForm({
11441
+ resolver: zod.zodResolver(schema$3)
11442
+ });
11443
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
11444
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
11445
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
11446
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11447
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
11448
+ ] }) })
11449
+ ] }) });
11450
+ };
11451
+ const schema$3 = objectType({
11452
+ email: stringType().email()
11453
+ });
11264
11454
  const SalesChannel = () => {
11265
11455
  const { id } = reactRouterDom.useParams();
11266
11456
  const { draft_order, isPending, isError, error } = useDraftOrder(
@@ -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,7 +11554,7 @@ 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
11560
  const STACKED_FOCUS_MODAL_ID = "shipping-form";
@@ -12206,7 +12396,7 @@ const ShippingAddressForm = ({ order }) => {
12206
12396
  postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12207
12397
  phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12208
12398
  },
12209
- resolver: zod.zodResolver(schema$2)
12399
+ resolver: zod.zodResolver(schema$1)
12210
12400
  });
12211
12401
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12212
12402
  const { handleSuccess } = useRouteModal();
@@ -12376,7 +12566,7 @@ const ShippingAddressForm = ({ order }) => {
12376
12566
  }
12377
12567
  ) });
12378
12568
  };
12379
- const schema$2 = addressSchema;
12569
+ const schema$1 = addressSchema;
12380
12570
  const TransferOwnership = () => {
12381
12571
  const { id } = reactRouterDom.useParams();
12382
12572
  const { draft_order, isPending, isError, error } = useDraftOrder(id, {
@@ -12400,7 +12590,7 @@ const TransferOwnershipForm = ({ order }) => {
12400
12590
  defaultValues: {
12401
12591
  customer_id: order.customer_id || ""
12402
12592
  },
12403
- resolver: zod.zodResolver(schema$1)
12593
+ resolver: zod.zodResolver(schema)
12404
12594
  });
12405
12595
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12406
12596
  const { handleSuccess } = useRouteModal();
@@ -12850,199 +13040,9 @@ const Illustration = () => {
12850
13040
  }
12851
13041
  );
12852
13042
  };
12853
- const schema$1 = objectType({
13043
+ const schema = objectType({
12854
13044
  customer_id: stringType().min(1)
12855
13045
  });
12856
- const BillingAddress = () => {
12857
- const { id } = reactRouterDom.useParams();
12858
- const { order, isPending, isError, error } = useOrder(id, {
12859
- fields: "+billing_address"
12860
- });
12861
- if (isError) {
12862
- throw error;
12863
- }
12864
- const isReady = !isPending && !!order;
12865
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12866
- /* @__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" }) })
12869
- ] }),
12870
- isReady && /* @__PURE__ */ jsxRuntime.jsx(BillingAddressForm, { order })
12871
- ] });
12872
- };
12873
- const BillingAddressForm = ({ order }) => {
12874
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12875
- const form = reactHookForm.useForm({
12876
- 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) ?? ""
12887
- },
12888
- resolver: zod.zodResolver(schema)
12889
- });
12890
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12891
- const { handleSuccess } = useRouteModal();
12892
- const onSubmit = form.handleSubmit(async (data) => {
12893
- await mutateAsync(
12894
- { billing_address: data },
12895
- {
12896
- onSuccess: () => {
12897
- handleSuccess();
12898
- },
12899
- onError: (error) => {
12900
- ui.toast.error(error.message);
12901
- }
12902
- }
12903
- );
12904
- });
12905
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
12906
- KeyboundForm,
12907
- {
12908
- className: "flex flex-1 flex-col overflow-hidden",
12909
- onSubmit,
12910
- children: [
12911
- /* @__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: [
12912
- /* @__PURE__ */ jsxRuntime.jsx(
12913
- Form$2.Field,
12914
- {
12915
- control: form.control,
12916
- name: "country_code",
12917
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12918
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
12919
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
12920
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12921
- ] })
12922
- }
12923
- ),
12924
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12925
- /* @__PURE__ */ jsxRuntime.jsx(
12926
- Form$2.Field,
12927
- {
12928
- control: form.control,
12929
- name: "first_name",
12930
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12931
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
12932
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12933
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12934
- ] })
12935
- }
12936
- ),
12937
- /* @__PURE__ */ jsxRuntime.jsx(
12938
- Form$2.Field,
12939
- {
12940
- control: form.control,
12941
- name: "last_name",
12942
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12943
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
12944
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12945
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12946
- ] })
12947
- }
12948
- )
12949
- ] }),
12950
- /* @__PURE__ */ jsxRuntime.jsx(
12951
- Form$2.Field,
12952
- {
12953
- control: form.control,
12954
- name: "company",
12955
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12956
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
12957
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12958
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12959
- ] })
12960
- }
12961
- ),
12962
- /* @__PURE__ */ jsxRuntime.jsx(
12963
- Form$2.Field,
12964
- {
12965
- control: form.control,
12966
- name: "address_1",
12967
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12968
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
12969
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12970
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12971
- ] })
12972
- }
12973
- ),
12974
- /* @__PURE__ */ jsxRuntime.jsx(
12975
- Form$2.Field,
12976
- {
12977
- control: form.control,
12978
- name: "address_2",
12979
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12980
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
12981
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12982
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12983
- ] })
12984
- }
12985
- ),
12986
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12987
- /* @__PURE__ */ jsxRuntime.jsx(
12988
- Form$2.Field,
12989
- {
12990
- control: form.control,
12991
- name: "postal_code",
12992
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12993
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
12994
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12995
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12996
- ] })
12997
- }
12998
- ),
12999
- /* @__PURE__ */ jsxRuntime.jsx(
13000
- Form$2.Field,
13001
- {
13002
- control: form.control,
13003
- name: "city",
13004
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
13005
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
13006
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
13007
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
13008
- ] })
13009
- }
13010
- )
13011
- ] }),
13012
- /* @__PURE__ */ jsxRuntime.jsx(
13013
- Form$2.Field,
13014
- {
13015
- control: form.control,
13016
- name: "province",
13017
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
13018
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
13019
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
13020
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
13021
- ] })
13022
- }
13023
- ),
13024
- /* @__PURE__ */ jsxRuntime.jsx(
13025
- Form$2.Field,
13026
- {
13027
- control: form.control,
13028
- name: "phone",
13029
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
13030
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
13031
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
13032
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
13033
- ] })
13034
- }
13035
- )
13036
- ] }) }),
13037
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
13038
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
13039
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
13040
- ] }) })
13041
- ]
13042
- }
13043
- ) });
13044
- };
13045
- const schema = addressSchema;
13046
13046
  const widgetModule = { widgets: [] };
13047
13047
  const routeModule = {
13048
13048
  routes: [
@@ -13063,14 +13063,14 @@ const routeModule = {
13063
13063
  handle,
13064
13064
  loader,
13065
13065
  children: [
13066
- {
13067
- Component: CustomItems,
13068
- path: "/draft-orders/:id/custom-items"
13069
- },
13070
13066
  {
13071
13067
  Component: Email,
13072
13068
  path: "/draft-orders/:id/email"
13073
13069
  },
13070
+ {
13071
+ Component: BillingAddress,
13072
+ path: "/draft-orders/:id/billing-address"
13073
+ },
13074
13074
  {
13075
13075
  Component: Items,
13076
13076
  path: "/draft-orders/:id/items"
@@ -13083,6 +13083,10 @@ const routeModule = {
13083
13083
  Component: Promotions,
13084
13084
  path: "/draft-orders/:id/promotions"
13085
13085
  },
13086
+ {
13087
+ Component: CustomItems,
13088
+ path: "/draft-orders/:id/custom-items"
13089
+ },
13086
13090
  {
13087
13091
  Component: SalesChannel,
13088
13092
  path: "/draft-orders/:id/sales-channel"
@@ -13098,10 +13102,6 @@ const routeModule = {
13098
13102
  {
13099
13103
  Component: TransferOwnership,
13100
13104
  path: "/draft-orders/:id/transfer-ownership"
13101
- },
13102
- {
13103
- Component: BillingAddress,
13104
- path: "/draft-orders/:id/billing-address"
13105
13105
  }
13106
13106
  ]
13107
13107
  }
@@ -9565,27 +9565,6 @@ const ID = () => {
9565
9565
  /* @__PURE__ */ jsx(Outlet, {})
9566
9566
  ] });
9567
9567
  };
9568
- const CustomItems = () => {
9569
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
9570
- /* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
9571
- /* @__PURE__ */ jsx(CustomItemsForm, {})
9572
- ] });
9573
- };
9574
- const CustomItemsForm = () => {
9575
- const form = useForm({
9576
- resolver: zodResolver(schema$5)
9577
- });
9578
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9579
- /* @__PURE__ */ jsx(RouteDrawer.Body, {}),
9580
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
9581
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9582
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
9583
- ] }) })
9584
- ] }) });
9585
- };
9586
- const schema$5 = objectType({
9587
- email: stringType().email()
9588
- });
9589
9568
  const Email = () => {
9590
9569
  const { id } = useParams();
9591
9570
  const { order, isPending, isError, error } = useOrder(id, {
@@ -9608,7 +9587,7 @@ const EmailForm = ({ order }) => {
9608
9587
  defaultValues: {
9609
9588
  email: order.email ?? ""
9610
9589
  },
9611
- resolver: zodResolver(schema$4)
9590
+ resolver: zodResolver(schema$5)
9612
9591
  });
9613
9592
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9614
9593
  const { handleSuccess } = useRouteModal();
@@ -9651,9 +9630,199 @@ const EmailForm = ({ order }) => {
9651
9630
  }
9652
9631
  ) });
9653
9632
  };
9654
- const schema$4 = objectType({
9633
+ const schema$5 = objectType({
9655
9634
  email: stringType().email()
9656
9635
  });
9636
+ const BillingAddress = () => {
9637
+ const { id } = useParams();
9638
+ const { order, isPending, isError, error } = useOrder(id, {
9639
+ fields: "+billing_address"
9640
+ });
9641
+ if (isError) {
9642
+ throw error;
9643
+ }
9644
+ const isReady = !isPending && !!order;
9645
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
9646
+ /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
9647
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Billing Address" }) }),
9648
+ /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
9649
+ ] }),
9650
+ isReady && /* @__PURE__ */ jsx(BillingAddressForm, { order })
9651
+ ] });
9652
+ };
9653
+ const BillingAddressForm = ({ order }) => {
9654
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
9655
+ const form = useForm({
9656
+ defaultValues: {
9657
+ first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
9658
+ last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
9659
+ company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
9660
+ address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
9661
+ address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
9662
+ city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
9663
+ province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
9664
+ country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
9665
+ postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
9666
+ phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
9667
+ },
9668
+ resolver: zodResolver(schema$4)
9669
+ });
9670
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9671
+ const { handleSuccess } = useRouteModal();
9672
+ const onSubmit = form.handleSubmit(async (data) => {
9673
+ await mutateAsync(
9674
+ { billing_address: data },
9675
+ {
9676
+ onSuccess: () => {
9677
+ handleSuccess();
9678
+ },
9679
+ onError: (error) => {
9680
+ toast.error(error.message);
9681
+ }
9682
+ }
9683
+ );
9684
+ });
9685
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
9686
+ KeyboundForm,
9687
+ {
9688
+ className: "flex flex-1 flex-col overflow-hidden",
9689
+ onSubmit,
9690
+ children: [
9691
+ /* @__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: [
9692
+ /* @__PURE__ */ jsx(
9693
+ Form$2.Field,
9694
+ {
9695
+ control: form.control,
9696
+ name: "country_code",
9697
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9698
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
9699
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
9700
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9701
+ ] })
9702
+ }
9703
+ ),
9704
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
9705
+ /* @__PURE__ */ jsx(
9706
+ Form$2.Field,
9707
+ {
9708
+ control: form.control,
9709
+ name: "first_name",
9710
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9711
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
9712
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9713
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9714
+ ] })
9715
+ }
9716
+ ),
9717
+ /* @__PURE__ */ jsx(
9718
+ Form$2.Field,
9719
+ {
9720
+ control: form.control,
9721
+ name: "last_name",
9722
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9723
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
9724
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9725
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9726
+ ] })
9727
+ }
9728
+ )
9729
+ ] }),
9730
+ /* @__PURE__ */ jsx(
9731
+ Form$2.Field,
9732
+ {
9733
+ control: form.control,
9734
+ name: "company",
9735
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9736
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
9737
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9738
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9739
+ ] })
9740
+ }
9741
+ ),
9742
+ /* @__PURE__ */ jsx(
9743
+ Form$2.Field,
9744
+ {
9745
+ control: form.control,
9746
+ name: "address_1",
9747
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9748
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
9749
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9750
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9751
+ ] })
9752
+ }
9753
+ ),
9754
+ /* @__PURE__ */ jsx(
9755
+ Form$2.Field,
9756
+ {
9757
+ control: form.control,
9758
+ name: "address_2",
9759
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9760
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
9761
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9762
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9763
+ ] })
9764
+ }
9765
+ ),
9766
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
9767
+ /* @__PURE__ */ jsx(
9768
+ Form$2.Field,
9769
+ {
9770
+ control: form.control,
9771
+ name: "postal_code",
9772
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9773
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
9774
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9775
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9776
+ ] })
9777
+ }
9778
+ ),
9779
+ /* @__PURE__ */ jsx(
9780
+ Form$2.Field,
9781
+ {
9782
+ control: form.control,
9783
+ name: "city",
9784
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9785
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
9786
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9787
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9788
+ ] })
9789
+ }
9790
+ )
9791
+ ] }),
9792
+ /* @__PURE__ */ jsx(
9793
+ Form$2.Field,
9794
+ {
9795
+ control: form.control,
9796
+ name: "province",
9797
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9798
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
9799
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9800
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9801
+ ] })
9802
+ }
9803
+ ),
9804
+ /* @__PURE__ */ jsx(
9805
+ Form$2.Field,
9806
+ {
9807
+ control: form.control,
9808
+ name: "phone",
9809
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9810
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
9811
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9812
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9813
+ ] })
9814
+ }
9815
+ )
9816
+ ] }) }),
9817
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
9818
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9819
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
9820
+ ] }) })
9821
+ ]
9822
+ }
9823
+ ) });
9824
+ };
9825
+ const schema$4 = addressSchema;
9657
9826
  const NumberInput = forwardRef(
9658
9827
  ({
9659
9828
  value,
@@ -11255,6 +11424,27 @@ function getPromotionIds(items, shippingMethods) {
11255
11424
  }
11256
11425
  return Array.from(promotionIds);
11257
11426
  }
11427
+ const CustomItems = () => {
11428
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
11429
+ /* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
11430
+ /* @__PURE__ */ jsx(CustomItemsForm, {})
11431
+ ] });
11432
+ };
11433
+ const CustomItemsForm = () => {
11434
+ const form = useForm({
11435
+ resolver: zodResolver(schema$3)
11436
+ });
11437
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
11438
+ /* @__PURE__ */ jsx(RouteDrawer.Body, {}),
11439
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
11440
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11441
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
11442
+ ] }) })
11443
+ ] }) });
11444
+ };
11445
+ const schema$3 = objectType({
11446
+ email: stringType().email()
11447
+ });
11258
11448
  const SalesChannel = () => {
11259
11449
  const { id } = useParams();
11260
11450
  const { draft_order, isPending, isError, error } = useDraftOrder(
@@ -11283,7 +11473,7 @@ const SalesChannelForm = ({ order }) => {
11283
11473
  defaultValues: {
11284
11474
  sales_channel_id: order.sales_channel_id || ""
11285
11475
  },
11286
- resolver: zodResolver(schema$3)
11476
+ resolver: zodResolver(schema$2)
11287
11477
  });
11288
11478
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11289
11479
  const { handleSuccess } = useRouteModal();
@@ -11358,7 +11548,7 @@ const SalesChannelField = ({ control, order }) => {
11358
11548
  }
11359
11549
  );
11360
11550
  };
11361
- const schema$3 = objectType({
11551
+ const schema$2 = objectType({
11362
11552
  sales_channel_id: stringType().min(1)
11363
11553
  });
11364
11554
  const STACKED_FOCUS_MODAL_ID = "shipping-form";
@@ -12200,7 +12390,7 @@ const ShippingAddressForm = ({ order }) => {
12200
12390
  postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12201
12391
  phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12202
12392
  },
12203
- resolver: zodResolver(schema$2)
12393
+ resolver: zodResolver(schema$1)
12204
12394
  });
12205
12395
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12206
12396
  const { handleSuccess } = useRouteModal();
@@ -12370,7 +12560,7 @@ const ShippingAddressForm = ({ order }) => {
12370
12560
  }
12371
12561
  ) });
12372
12562
  };
12373
- const schema$2 = addressSchema;
12563
+ const schema$1 = addressSchema;
12374
12564
  const TransferOwnership = () => {
12375
12565
  const { id } = useParams();
12376
12566
  const { draft_order, isPending, isError, error } = useDraftOrder(id, {
@@ -12394,7 +12584,7 @@ const TransferOwnershipForm = ({ order }) => {
12394
12584
  defaultValues: {
12395
12585
  customer_id: order.customer_id || ""
12396
12586
  },
12397
- resolver: zodResolver(schema$1)
12587
+ resolver: zodResolver(schema)
12398
12588
  });
12399
12589
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12400
12590
  const { handleSuccess } = useRouteModal();
@@ -12844,199 +13034,9 @@ const Illustration = () => {
12844
13034
  }
12845
13035
  );
12846
13036
  };
12847
- const schema$1 = objectType({
13037
+ const schema = objectType({
12848
13038
  customer_id: stringType().min(1)
12849
13039
  });
12850
- const BillingAddress = () => {
12851
- const { id } = useParams();
12852
- const { order, isPending, isError, error } = useOrder(id, {
12853
- fields: "+billing_address"
12854
- });
12855
- if (isError) {
12856
- throw error;
12857
- }
12858
- const isReady = !isPending && !!order;
12859
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
12860
- /* @__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" }) })
12863
- ] }),
12864
- isReady && /* @__PURE__ */ jsx(BillingAddressForm, { order })
12865
- ] });
12866
- };
12867
- const BillingAddressForm = ({ order }) => {
12868
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12869
- const form = useForm({
12870
- 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) ?? ""
12881
- },
12882
- resolver: zodResolver(schema)
12883
- });
12884
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12885
- const { handleSuccess } = useRouteModal();
12886
- const onSubmit = form.handleSubmit(async (data) => {
12887
- await mutateAsync(
12888
- { billing_address: data },
12889
- {
12890
- onSuccess: () => {
12891
- handleSuccess();
12892
- },
12893
- onError: (error) => {
12894
- toast.error(error.message);
12895
- }
12896
- }
12897
- );
12898
- });
12899
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
12900
- KeyboundForm,
12901
- {
12902
- className: "flex flex-1 flex-col overflow-hidden",
12903
- onSubmit,
12904
- children: [
12905
- /* @__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: [
12906
- /* @__PURE__ */ jsx(
12907
- Form$2.Field,
12908
- {
12909
- control: form.control,
12910
- name: "country_code",
12911
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12912
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
12913
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
12914
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12915
- ] })
12916
- }
12917
- ),
12918
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12919
- /* @__PURE__ */ jsx(
12920
- Form$2.Field,
12921
- {
12922
- control: form.control,
12923
- name: "first_name",
12924
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12925
- /* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
12926
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12927
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12928
- ] })
12929
- }
12930
- ),
12931
- /* @__PURE__ */ jsx(
12932
- Form$2.Field,
12933
- {
12934
- control: form.control,
12935
- name: "last_name",
12936
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12937
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
12938
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12939
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12940
- ] })
12941
- }
12942
- )
12943
- ] }),
12944
- /* @__PURE__ */ jsx(
12945
- Form$2.Field,
12946
- {
12947
- control: form.control,
12948
- name: "company",
12949
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12950
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
12951
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12952
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12953
- ] })
12954
- }
12955
- ),
12956
- /* @__PURE__ */ jsx(
12957
- Form$2.Field,
12958
- {
12959
- control: form.control,
12960
- name: "address_1",
12961
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12962
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
12963
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12964
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12965
- ] })
12966
- }
12967
- ),
12968
- /* @__PURE__ */ jsx(
12969
- Form$2.Field,
12970
- {
12971
- control: form.control,
12972
- name: "address_2",
12973
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12974
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
12975
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12976
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12977
- ] })
12978
- }
12979
- ),
12980
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12981
- /* @__PURE__ */ jsx(
12982
- Form$2.Field,
12983
- {
12984
- control: form.control,
12985
- name: "postal_code",
12986
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12987
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
12988
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12989
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12990
- ] })
12991
- }
12992
- ),
12993
- /* @__PURE__ */ jsx(
12994
- Form$2.Field,
12995
- {
12996
- control: form.control,
12997
- name: "city",
12998
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12999
- /* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
13000
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
13001
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
13002
- ] })
13003
- }
13004
- )
13005
- ] }),
13006
- /* @__PURE__ */ jsx(
13007
- Form$2.Field,
13008
- {
13009
- control: form.control,
13010
- name: "province",
13011
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
13012
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
13013
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
13014
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
13015
- ] })
13016
- }
13017
- ),
13018
- /* @__PURE__ */ jsx(
13019
- Form$2.Field,
13020
- {
13021
- control: form.control,
13022
- name: "phone",
13023
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
13024
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
13025
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
13026
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
13027
- ] })
13028
- }
13029
- )
13030
- ] }) }),
13031
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
13032
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
13033
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
13034
- ] }) })
13035
- ]
13036
- }
13037
- ) });
13038
- };
13039
- const schema = addressSchema;
13040
13040
  const widgetModule = { widgets: [] };
13041
13041
  const routeModule = {
13042
13042
  routes: [
@@ -13057,14 +13057,14 @@ const routeModule = {
13057
13057
  handle,
13058
13058
  loader,
13059
13059
  children: [
13060
- {
13061
- Component: CustomItems,
13062
- path: "/draft-orders/:id/custom-items"
13063
- },
13064
13060
  {
13065
13061
  Component: Email,
13066
13062
  path: "/draft-orders/:id/email"
13067
13063
  },
13064
+ {
13065
+ Component: BillingAddress,
13066
+ path: "/draft-orders/:id/billing-address"
13067
+ },
13068
13068
  {
13069
13069
  Component: Items,
13070
13070
  path: "/draft-orders/:id/items"
@@ -13077,6 +13077,10 @@ const routeModule = {
13077
13077
  Component: Promotions,
13078
13078
  path: "/draft-orders/:id/promotions"
13079
13079
  },
13080
+ {
13081
+ Component: CustomItems,
13082
+ path: "/draft-orders/:id/custom-items"
13083
+ },
13080
13084
  {
13081
13085
  Component: SalesChannel,
13082
13086
  path: "/draft-orders/:id/sales-channel"
@@ -13092,10 +13096,6 @@ const routeModule = {
13092
13096
  {
13093
13097
  Component: TransferOwnership,
13094
13098
  path: "/draft-orders/:id/transfer-ownership"
13095
- },
13096
- {
13097
- Component: BillingAddress,
13098
- path: "/draft-orders/:id/billing-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.2-preview-20251029000331",
3
+ "version": "2.11.2-preview-20251029060154",
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.2-preview-20251029000331",
39
+ "@medusajs/js-sdk": "2.11.2-preview-20251029060154",
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.2-preview-20251029000331",
49
- "@medusajs/cli": "2.11.2-preview-20251029000331",
50
- "@medusajs/framework": "2.11.2-preview-20251029000331",
51
- "@medusajs/icons": "2.11.2-preview-20251029000331",
52
- "@medusajs/test-utils": "2.11.2-preview-20251029000331",
53
- "@medusajs/types": "2.11.2-preview-20251029000331",
54
- "@medusajs/ui": "4.0.26-preview-20251029000331",
55
- "@medusajs/ui-preset": "2.11.2-preview-20251029000331",
48
+ "@medusajs/admin-sdk": "2.11.2-preview-20251029060154",
49
+ "@medusajs/cli": "2.11.2-preview-20251029060154",
50
+ "@medusajs/framework": "2.11.2-preview-20251029060154",
51
+ "@medusajs/icons": "2.11.2-preview-20251029060154",
52
+ "@medusajs/test-utils": "2.11.2-preview-20251029060154",
53
+ "@medusajs/types": "2.11.2-preview-20251029060154",
54
+ "@medusajs/ui": "4.0.26-preview-20251029060154",
55
+ "@medusajs/ui-preset": "2.11.2-preview-20251029060154",
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.2-preview-20251029000331",
73
- "@medusajs/cli": "2.11.2-preview-20251029000331",
74
- "@medusajs/framework": "2.11.2-preview-20251029000331",
75
- "@medusajs/icons": "2.11.2-preview-20251029000331",
76
- "@medusajs/test-utils": "2.11.2-preview-20251029000331",
77
- "@medusajs/ui": "4.0.26-preview-20251029000331",
72
+ "@medusajs/admin-sdk": "2.11.2-preview-20251029060154",
73
+ "@medusajs/cli": "2.11.2-preview-20251029060154",
74
+ "@medusajs/framework": "2.11.2-preview-20251029060154",
75
+ "@medusajs/icons": "2.11.2-preview-20251029060154",
76
+ "@medusajs/test-utils": "2.11.2-preview-20251029060154",
77
+ "@medusajs/ui": "4.0.26-preview-20251029060154",
78
78
  "lodash": "^4.17.21",
79
79
  "react-router-dom": "6.20.1"
80
80
  },