@medusajs/draft-order 2.10.0-preview-20250828031543 → 2.10.0-preview-20250828060153

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.
@@ -9750,27 +9750,6 @@ const BillingAddressForm = ({ order }) => {
9750
9750
  ) });
9751
9751
  };
9752
9752
  const schema$5 = addressSchema;
9753
- const CustomItems = () => {
9754
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9755
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
9756
- /* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
9757
- ] });
9758
- };
9759
- const CustomItemsForm = () => {
9760
- const form = reactHookForm.useForm({
9761
- resolver: zod.zodResolver(schema$4)
9762
- });
9763
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9764
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
9765
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
9766
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9767
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
9768
- ] }) })
9769
- ] }) });
9770
- };
9771
- const schema$4 = objectType({
9772
- email: stringType().email()
9773
- });
9774
9753
  const Email = () => {
9775
9754
  const { id } = reactRouterDom.useParams();
9776
9755
  const { order, isPending, isError, error } = useOrder(id, {
@@ -9793,7 +9772,7 @@ const EmailForm = ({ order }) => {
9793
9772
  defaultValues: {
9794
9773
  email: order.email ?? ""
9795
9774
  },
9796
- resolver: zod.zodResolver(schema$3)
9775
+ resolver: zod.zodResolver(schema$4)
9797
9776
  });
9798
9777
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9799
9778
  const { handleSuccess } = useRouteModal();
@@ -9836,6 +9815,27 @@ const EmailForm = ({ order }) => {
9836
9815
  }
9837
9816
  ) });
9838
9817
  };
9818
+ const schema$4 = objectType({
9819
+ email: stringType().email()
9820
+ });
9821
+ const CustomItems = () => {
9822
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9823
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
9824
+ /* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
9825
+ ] });
9826
+ };
9827
+ const CustomItemsForm = () => {
9828
+ const form = reactHookForm.useForm({
9829
+ resolver: zod.zodResolver(schema$3)
9830
+ });
9831
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9832
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
9833
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
9834
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9835
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
9836
+ ] }) })
9837
+ ] }) });
9838
+ };
9839
9839
  const schema$3 = objectType({
9840
9840
  email: stringType().email()
9841
9841
  });
@@ -11546,6 +11546,209 @@ const SalesChannelField = ({ control, order }) => {
11546
11546
  const schema$2 = objectType({
11547
11547
  sales_channel_id: stringType().min(1)
11548
11548
  });
11549
+ const ShippingAddress = () => {
11550
+ const { id } = reactRouterDom.useParams();
11551
+ const { order, isPending, isError, error } = useOrder(id, {
11552
+ fields: "+shipping_address"
11553
+ });
11554
+ if (isError) {
11555
+ throw error;
11556
+ }
11557
+ const isReady = !isPending && !!order;
11558
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
11559
+ /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
11560
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Shipping Address" }) }),
11561
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
11562
+ ] }),
11563
+ isReady && /* @__PURE__ */ jsxRuntime.jsx(ShippingAddressForm, { order })
11564
+ ] });
11565
+ };
11566
+ const ShippingAddressForm = ({ order }) => {
11567
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
11568
+ const form = reactHookForm.useForm({
11569
+ defaultValues: {
11570
+ first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
11571
+ last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
11572
+ company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
11573
+ address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
11574
+ address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
11575
+ city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
11576
+ province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
11577
+ country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
11578
+ postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
11579
+ phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
11580
+ },
11581
+ resolver: zod.zodResolver(schema$1)
11582
+ });
11583
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11584
+ const { handleSuccess } = useRouteModal();
11585
+ const onSubmit = form.handleSubmit(async (data) => {
11586
+ await mutateAsync(
11587
+ {
11588
+ shipping_address: {
11589
+ first_name: data.first_name,
11590
+ last_name: data.last_name,
11591
+ company: data.company,
11592
+ address_1: data.address_1,
11593
+ address_2: data.address_2,
11594
+ city: data.city,
11595
+ province: data.province,
11596
+ country_code: data.country_code,
11597
+ postal_code: data.postal_code,
11598
+ phone: data.phone
11599
+ }
11600
+ },
11601
+ {
11602
+ onSuccess: () => {
11603
+ handleSuccess();
11604
+ },
11605
+ onError: (error) => {
11606
+ ui.toast.error(error.message);
11607
+ }
11608
+ }
11609
+ );
11610
+ });
11611
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
11612
+ KeyboundForm,
11613
+ {
11614
+ className: "flex flex-1 flex-col overflow-hidden",
11615
+ onSubmit,
11616
+ children: [
11617
+ /* @__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: [
11618
+ /* @__PURE__ */ jsxRuntime.jsx(
11619
+ Form$2.Field,
11620
+ {
11621
+ control: form.control,
11622
+ name: "country_code",
11623
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11624
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
11625
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
11626
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11627
+ ] })
11628
+ }
11629
+ ),
11630
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
11631
+ /* @__PURE__ */ jsxRuntime.jsx(
11632
+ Form$2.Field,
11633
+ {
11634
+ control: form.control,
11635
+ name: "first_name",
11636
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11637
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
11638
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11639
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11640
+ ] })
11641
+ }
11642
+ ),
11643
+ /* @__PURE__ */ jsxRuntime.jsx(
11644
+ Form$2.Field,
11645
+ {
11646
+ control: form.control,
11647
+ name: "last_name",
11648
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11649
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
11650
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11651
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11652
+ ] })
11653
+ }
11654
+ )
11655
+ ] }),
11656
+ /* @__PURE__ */ jsxRuntime.jsx(
11657
+ Form$2.Field,
11658
+ {
11659
+ control: form.control,
11660
+ name: "company",
11661
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11662
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
11663
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11664
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11665
+ ] })
11666
+ }
11667
+ ),
11668
+ /* @__PURE__ */ jsxRuntime.jsx(
11669
+ Form$2.Field,
11670
+ {
11671
+ control: form.control,
11672
+ name: "address_1",
11673
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11674
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
11675
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11676
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11677
+ ] })
11678
+ }
11679
+ ),
11680
+ /* @__PURE__ */ jsxRuntime.jsx(
11681
+ Form$2.Field,
11682
+ {
11683
+ control: form.control,
11684
+ name: "address_2",
11685
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11686
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
11687
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11688
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11689
+ ] })
11690
+ }
11691
+ ),
11692
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
11693
+ /* @__PURE__ */ jsxRuntime.jsx(
11694
+ Form$2.Field,
11695
+ {
11696
+ control: form.control,
11697
+ name: "postal_code",
11698
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11699
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
11700
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11701
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11702
+ ] })
11703
+ }
11704
+ ),
11705
+ /* @__PURE__ */ jsxRuntime.jsx(
11706
+ Form$2.Field,
11707
+ {
11708
+ control: form.control,
11709
+ name: "city",
11710
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11711
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
11712
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11713
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11714
+ ] })
11715
+ }
11716
+ )
11717
+ ] }),
11718
+ /* @__PURE__ */ jsxRuntime.jsx(
11719
+ Form$2.Field,
11720
+ {
11721
+ control: form.control,
11722
+ name: "province",
11723
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11724
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
11725
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11726
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11727
+ ] })
11728
+ }
11729
+ ),
11730
+ /* @__PURE__ */ jsxRuntime.jsx(
11731
+ Form$2.Field,
11732
+ {
11733
+ control: form.control,
11734
+ name: "phone",
11735
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
11736
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
11737
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
11738
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
11739
+ ] })
11740
+ }
11741
+ )
11742
+ ] }) }),
11743
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
11744
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11745
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
11746
+ ] }) })
11747
+ ]
11748
+ }
11749
+ ) });
11750
+ };
11751
+ const schema$1 = addressSchema;
11549
11752
  const STACKED_FOCUS_MODAL_ID = "shipping-form";
11550
11753
  const Shipping = () => {
11551
11754
  var _a;
@@ -12376,7 +12579,7 @@ const TransferOwnershipForm = ({ order }) => {
12376
12579
  defaultValues: {
12377
12580
  customer_id: order.customer_id || ""
12378
12581
  },
12379
- resolver: zod.zodResolver(schema$1)
12582
+ resolver: zod.zodResolver(schema)
12380
12583
  });
12381
12584
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12382
12585
  const { handleSuccess } = useRouteModal();
@@ -12826,212 +13029,9 @@ const Illustration = () => {
12826
13029
  }
12827
13030
  );
12828
13031
  };
12829
- const schema$1 = objectType({
13032
+ const schema = objectType({
12830
13033
  customer_id: stringType().min(1)
12831
13034
  });
12832
- const ShippingAddress = () => {
12833
- const { id } = reactRouterDom.useParams();
12834
- const { order, isPending, isError, error } = useOrder(id, {
12835
- fields: "+shipping_address"
12836
- });
12837
- if (isError) {
12838
- throw error;
12839
- }
12840
- const isReady = !isPending && !!order;
12841
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
12842
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
12843
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Shipping Address" }) }),
12844
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
12845
- ] }),
12846
- isReady && /* @__PURE__ */ jsxRuntime.jsx(ShippingAddressForm, { order })
12847
- ] });
12848
- };
12849
- const ShippingAddressForm = ({ order }) => {
12850
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12851
- const form = reactHookForm.useForm({
12852
- defaultValues: {
12853
- first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
12854
- last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
12855
- company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
12856
- address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
12857
- address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
12858
- city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
12859
- province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
12860
- country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
12861
- postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12862
- phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12863
- },
12864
- resolver: zod.zodResolver(schema)
12865
- });
12866
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12867
- const { handleSuccess } = useRouteModal();
12868
- const onSubmit = form.handleSubmit(async (data) => {
12869
- await mutateAsync(
12870
- {
12871
- shipping_address: {
12872
- first_name: data.first_name,
12873
- last_name: data.last_name,
12874
- company: data.company,
12875
- address_1: data.address_1,
12876
- address_2: data.address_2,
12877
- city: data.city,
12878
- province: data.province,
12879
- country_code: data.country_code,
12880
- postal_code: data.postal_code,
12881
- phone: data.phone
12882
- }
12883
- },
12884
- {
12885
- onSuccess: () => {
12886
- handleSuccess();
12887
- },
12888
- onError: (error) => {
12889
- ui.toast.error(error.message);
12890
- }
12891
- }
12892
- );
12893
- });
12894
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
12895
- KeyboundForm,
12896
- {
12897
- className: "flex flex-1 flex-col overflow-hidden",
12898
- onSubmit,
12899
- children: [
12900
- /* @__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: [
12901
- /* @__PURE__ */ jsxRuntime.jsx(
12902
- Form$2.Field,
12903
- {
12904
- control: form.control,
12905
- name: "country_code",
12906
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12907
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
12908
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
12909
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12910
- ] })
12911
- }
12912
- ),
12913
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12914
- /* @__PURE__ */ jsxRuntime.jsx(
12915
- Form$2.Field,
12916
- {
12917
- control: form.control,
12918
- name: "first_name",
12919
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12920
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
12921
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12922
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12923
- ] })
12924
- }
12925
- ),
12926
- /* @__PURE__ */ jsxRuntime.jsx(
12927
- Form$2.Field,
12928
- {
12929
- control: form.control,
12930
- name: "last_name",
12931
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12932
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
12933
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12934
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12935
- ] })
12936
- }
12937
- )
12938
- ] }),
12939
- /* @__PURE__ */ jsxRuntime.jsx(
12940
- Form$2.Field,
12941
- {
12942
- control: form.control,
12943
- name: "company",
12944
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12945
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
12946
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12947
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12948
- ] })
12949
- }
12950
- ),
12951
- /* @__PURE__ */ jsxRuntime.jsx(
12952
- Form$2.Field,
12953
- {
12954
- control: form.control,
12955
- name: "address_1",
12956
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12957
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
12958
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12959
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12960
- ] })
12961
- }
12962
- ),
12963
- /* @__PURE__ */ jsxRuntime.jsx(
12964
- Form$2.Field,
12965
- {
12966
- control: form.control,
12967
- name: "address_2",
12968
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12969
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
12970
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12971
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12972
- ] })
12973
- }
12974
- ),
12975
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12976
- /* @__PURE__ */ jsxRuntime.jsx(
12977
- Form$2.Field,
12978
- {
12979
- control: form.control,
12980
- name: "postal_code",
12981
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12982
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
12983
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12984
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12985
- ] })
12986
- }
12987
- ),
12988
- /* @__PURE__ */ jsxRuntime.jsx(
12989
- Form$2.Field,
12990
- {
12991
- control: form.control,
12992
- name: "city",
12993
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12994
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
12995
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12996
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12997
- ] })
12998
- }
12999
- )
13000
- ] }),
13001
- /* @__PURE__ */ jsxRuntime.jsx(
13002
- Form$2.Field,
13003
- {
13004
- control: form.control,
13005
- name: "province",
13006
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
13007
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
13008
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
13009
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
13010
- ] })
13011
- }
13012
- ),
13013
- /* @__PURE__ */ jsxRuntime.jsx(
13014
- Form$2.Field,
13015
- {
13016
- control: form.control,
13017
- name: "phone",
13018
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
13019
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
13020
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
13021
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
13022
- ] })
13023
- }
13024
- )
13025
- ] }) }),
13026
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
13027
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
13028
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
13029
- ] }) })
13030
- ]
13031
- }
13032
- ) });
13033
- };
13034
- const schema = addressSchema;
13035
13035
  const widgetModule = { widgets: [] };
13036
13036
  const routeModule = {
13037
13037
  routes: [
@@ -13056,14 +13056,14 @@ const routeModule = {
13056
13056
  Component: BillingAddress,
13057
13057
  path: "/draft-orders/:id/billing-address"
13058
13058
  },
13059
- {
13060
- Component: CustomItems,
13061
- path: "/draft-orders/:id/custom-items"
13062
- },
13063
13059
  {
13064
13060
  Component: Email,
13065
13061
  path: "/draft-orders/:id/email"
13066
13062
  },
13063
+ {
13064
+ Component: CustomItems,
13065
+ path: "/draft-orders/:id/custom-items"
13066
+ },
13067
13067
  {
13068
13068
  Component: Items,
13069
13069
  path: "/draft-orders/:id/items"
@@ -13080,6 +13080,10 @@ const routeModule = {
13080
13080
  Component: SalesChannel,
13081
13081
  path: "/draft-orders/:id/sales-channel"
13082
13082
  },
13083
+ {
13084
+ Component: ShippingAddress,
13085
+ path: "/draft-orders/:id/shipping-address"
13086
+ },
13083
13087
  {
13084
13088
  Component: Shipping,
13085
13089
  path: "/draft-orders/:id/shipping"
@@ -13087,10 +13091,6 @@ const routeModule = {
13087
13091
  {
13088
13092
  Component: TransferOwnership,
13089
13093
  path: "/draft-orders/:id/transfer-ownership"
13090
- },
13091
- {
13092
- Component: ShippingAddress,
13093
- path: "/draft-orders/:id/shipping-address"
13094
13094
  }
13095
13095
  ]
13096
13096
  }
@@ -9744,27 +9744,6 @@ const BillingAddressForm = ({ order }) => {
9744
9744
  ) });
9745
9745
  };
9746
9746
  const schema$5 = addressSchema;
9747
- const CustomItems = () => {
9748
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
9749
- /* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
9750
- /* @__PURE__ */ jsx(CustomItemsForm, {})
9751
- ] });
9752
- };
9753
- const CustomItemsForm = () => {
9754
- const form = useForm({
9755
- resolver: zodResolver(schema$4)
9756
- });
9757
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9758
- /* @__PURE__ */ jsx(RouteDrawer.Body, {}),
9759
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
9760
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9761
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
9762
- ] }) })
9763
- ] }) });
9764
- };
9765
- const schema$4 = objectType({
9766
- email: stringType().email()
9767
- });
9768
9747
  const Email = () => {
9769
9748
  const { id } = useParams();
9770
9749
  const { order, isPending, isError, error } = useOrder(id, {
@@ -9787,7 +9766,7 @@ const EmailForm = ({ order }) => {
9787
9766
  defaultValues: {
9788
9767
  email: order.email ?? ""
9789
9768
  },
9790
- resolver: zodResolver(schema$3)
9769
+ resolver: zodResolver(schema$4)
9791
9770
  });
9792
9771
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9793
9772
  const { handleSuccess } = useRouteModal();
@@ -9830,6 +9809,27 @@ const EmailForm = ({ order }) => {
9830
9809
  }
9831
9810
  ) });
9832
9811
  };
9812
+ const schema$4 = objectType({
9813
+ email: stringType().email()
9814
+ });
9815
+ const CustomItems = () => {
9816
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
9817
+ /* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
9818
+ /* @__PURE__ */ jsx(CustomItemsForm, {})
9819
+ ] });
9820
+ };
9821
+ const CustomItemsForm = () => {
9822
+ const form = useForm({
9823
+ resolver: zodResolver(schema$3)
9824
+ });
9825
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9826
+ /* @__PURE__ */ jsx(RouteDrawer.Body, {}),
9827
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
9828
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9829
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
9830
+ ] }) })
9831
+ ] }) });
9832
+ };
9833
9833
  const schema$3 = objectType({
9834
9834
  email: stringType().email()
9835
9835
  });
@@ -11540,6 +11540,209 @@ const SalesChannelField = ({ control, order }) => {
11540
11540
  const schema$2 = objectType({
11541
11541
  sales_channel_id: stringType().min(1)
11542
11542
  });
11543
+ const ShippingAddress = () => {
11544
+ const { id } = useParams();
11545
+ const { order, isPending, isError, error } = useOrder(id, {
11546
+ fields: "+shipping_address"
11547
+ });
11548
+ if (isError) {
11549
+ throw error;
11550
+ }
11551
+ const isReady = !isPending && !!order;
11552
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
11553
+ /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
11554
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Shipping Address" }) }),
11555
+ /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
11556
+ ] }),
11557
+ isReady && /* @__PURE__ */ jsx(ShippingAddressForm, { order })
11558
+ ] });
11559
+ };
11560
+ const ShippingAddressForm = ({ order }) => {
11561
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
11562
+ const form = useForm({
11563
+ defaultValues: {
11564
+ first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
11565
+ last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
11566
+ company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
11567
+ address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
11568
+ address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
11569
+ city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
11570
+ province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
11571
+ country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
11572
+ postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
11573
+ phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
11574
+ },
11575
+ resolver: zodResolver(schema$1)
11576
+ });
11577
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11578
+ const { handleSuccess } = useRouteModal();
11579
+ const onSubmit = form.handleSubmit(async (data) => {
11580
+ await mutateAsync(
11581
+ {
11582
+ shipping_address: {
11583
+ first_name: data.first_name,
11584
+ last_name: data.last_name,
11585
+ company: data.company,
11586
+ address_1: data.address_1,
11587
+ address_2: data.address_2,
11588
+ city: data.city,
11589
+ province: data.province,
11590
+ country_code: data.country_code,
11591
+ postal_code: data.postal_code,
11592
+ phone: data.phone
11593
+ }
11594
+ },
11595
+ {
11596
+ onSuccess: () => {
11597
+ handleSuccess();
11598
+ },
11599
+ onError: (error) => {
11600
+ toast.error(error.message);
11601
+ }
11602
+ }
11603
+ );
11604
+ });
11605
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
11606
+ KeyboundForm,
11607
+ {
11608
+ className: "flex flex-1 flex-col overflow-hidden",
11609
+ onSubmit,
11610
+ children: [
11611
+ /* @__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: [
11612
+ /* @__PURE__ */ jsx(
11613
+ Form$2.Field,
11614
+ {
11615
+ control: form.control,
11616
+ name: "country_code",
11617
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11618
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
11619
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
11620
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11621
+ ] })
11622
+ }
11623
+ ),
11624
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
11625
+ /* @__PURE__ */ jsx(
11626
+ Form$2.Field,
11627
+ {
11628
+ control: form.control,
11629
+ name: "first_name",
11630
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11631
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
11632
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11633
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11634
+ ] })
11635
+ }
11636
+ ),
11637
+ /* @__PURE__ */ jsx(
11638
+ Form$2.Field,
11639
+ {
11640
+ control: form.control,
11641
+ name: "last_name",
11642
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11643
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
11644
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11645
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11646
+ ] })
11647
+ }
11648
+ )
11649
+ ] }),
11650
+ /* @__PURE__ */ jsx(
11651
+ Form$2.Field,
11652
+ {
11653
+ control: form.control,
11654
+ name: "company",
11655
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11656
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
11657
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11658
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11659
+ ] })
11660
+ }
11661
+ ),
11662
+ /* @__PURE__ */ jsx(
11663
+ Form$2.Field,
11664
+ {
11665
+ control: form.control,
11666
+ name: "address_1",
11667
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11668
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
11669
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11670
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11671
+ ] })
11672
+ }
11673
+ ),
11674
+ /* @__PURE__ */ jsx(
11675
+ Form$2.Field,
11676
+ {
11677
+ control: form.control,
11678
+ name: "address_2",
11679
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11680
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
11681
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11682
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11683
+ ] })
11684
+ }
11685
+ ),
11686
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
11687
+ /* @__PURE__ */ jsx(
11688
+ Form$2.Field,
11689
+ {
11690
+ control: form.control,
11691
+ name: "postal_code",
11692
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11693
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
11694
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11695
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11696
+ ] })
11697
+ }
11698
+ ),
11699
+ /* @__PURE__ */ jsx(
11700
+ Form$2.Field,
11701
+ {
11702
+ control: form.control,
11703
+ name: "city",
11704
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11705
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
11706
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11707
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11708
+ ] })
11709
+ }
11710
+ )
11711
+ ] }),
11712
+ /* @__PURE__ */ jsx(
11713
+ Form$2.Field,
11714
+ {
11715
+ control: form.control,
11716
+ name: "province",
11717
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11718
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
11719
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11720
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11721
+ ] })
11722
+ }
11723
+ ),
11724
+ /* @__PURE__ */ jsx(
11725
+ Form$2.Field,
11726
+ {
11727
+ control: form.control,
11728
+ name: "phone",
11729
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
11730
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
11731
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
11732
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
11733
+ ] })
11734
+ }
11735
+ )
11736
+ ] }) }),
11737
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
11738
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
11739
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
11740
+ ] }) })
11741
+ ]
11742
+ }
11743
+ ) });
11744
+ };
11745
+ const schema$1 = addressSchema;
11543
11746
  const STACKED_FOCUS_MODAL_ID = "shipping-form";
11544
11747
  const Shipping = () => {
11545
11748
  var _a;
@@ -12370,7 +12573,7 @@ const TransferOwnershipForm = ({ order }) => {
12370
12573
  defaultValues: {
12371
12574
  customer_id: order.customer_id || ""
12372
12575
  },
12373
- resolver: zodResolver(schema$1)
12576
+ resolver: zodResolver(schema)
12374
12577
  });
12375
12578
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12376
12579
  const { handleSuccess } = useRouteModal();
@@ -12820,212 +13023,9 @@ const Illustration = () => {
12820
13023
  }
12821
13024
  );
12822
13025
  };
12823
- const schema$1 = objectType({
13026
+ const schema = objectType({
12824
13027
  customer_id: stringType().min(1)
12825
13028
  });
12826
- const ShippingAddress = () => {
12827
- const { id } = useParams();
12828
- const { order, isPending, isError, error } = useOrder(id, {
12829
- fields: "+shipping_address"
12830
- });
12831
- if (isError) {
12832
- throw error;
12833
- }
12834
- const isReady = !isPending && !!order;
12835
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
12836
- /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
12837
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Shipping Address" }) }),
12838
- /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the shipping address for the draft order" }) })
12839
- ] }),
12840
- isReady && /* @__PURE__ */ jsx(ShippingAddressForm, { order })
12841
- ] });
12842
- };
12843
- const ShippingAddressForm = ({ order }) => {
12844
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12845
- const form = useForm({
12846
- defaultValues: {
12847
- first_name: ((_a = order.shipping_address) == null ? void 0 : _a.first_name) ?? "",
12848
- last_name: ((_b = order.shipping_address) == null ? void 0 : _b.last_name) ?? "",
12849
- company: ((_c = order.shipping_address) == null ? void 0 : _c.company) ?? "",
12850
- address_1: ((_d = order.shipping_address) == null ? void 0 : _d.address_1) ?? "",
12851
- address_2: ((_e = order.shipping_address) == null ? void 0 : _e.address_2) ?? "",
12852
- city: ((_f = order.shipping_address) == null ? void 0 : _f.city) ?? "",
12853
- province: ((_g = order.shipping_address) == null ? void 0 : _g.province) ?? "",
12854
- country_code: ((_h = order.shipping_address) == null ? void 0 : _h.country_code) ?? "",
12855
- postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12856
- phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12857
- },
12858
- resolver: zodResolver(schema)
12859
- });
12860
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12861
- const { handleSuccess } = useRouteModal();
12862
- const onSubmit = form.handleSubmit(async (data) => {
12863
- await mutateAsync(
12864
- {
12865
- shipping_address: {
12866
- first_name: data.first_name,
12867
- last_name: data.last_name,
12868
- company: data.company,
12869
- address_1: data.address_1,
12870
- address_2: data.address_2,
12871
- city: data.city,
12872
- province: data.province,
12873
- country_code: data.country_code,
12874
- postal_code: data.postal_code,
12875
- phone: data.phone
12876
- }
12877
- },
12878
- {
12879
- onSuccess: () => {
12880
- handleSuccess();
12881
- },
12882
- onError: (error) => {
12883
- toast.error(error.message);
12884
- }
12885
- }
12886
- );
12887
- });
12888
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
12889
- KeyboundForm,
12890
- {
12891
- className: "flex flex-1 flex-col overflow-hidden",
12892
- onSubmit,
12893
- children: [
12894
- /* @__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: [
12895
- /* @__PURE__ */ jsx(
12896
- Form$2.Field,
12897
- {
12898
- control: form.control,
12899
- name: "country_code",
12900
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12901
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
12902
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
12903
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12904
- ] })
12905
- }
12906
- ),
12907
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12908
- /* @__PURE__ */ jsx(
12909
- Form$2.Field,
12910
- {
12911
- control: form.control,
12912
- name: "first_name",
12913
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12914
- /* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
12915
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12916
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12917
- ] })
12918
- }
12919
- ),
12920
- /* @__PURE__ */ jsx(
12921
- Form$2.Field,
12922
- {
12923
- control: form.control,
12924
- name: "last_name",
12925
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12926
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
12927
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12928
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12929
- ] })
12930
- }
12931
- )
12932
- ] }),
12933
- /* @__PURE__ */ jsx(
12934
- Form$2.Field,
12935
- {
12936
- control: form.control,
12937
- name: "company",
12938
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12939
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
12940
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12941
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12942
- ] })
12943
- }
12944
- ),
12945
- /* @__PURE__ */ jsx(
12946
- Form$2.Field,
12947
- {
12948
- control: form.control,
12949
- name: "address_1",
12950
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12951
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
12952
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12953
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12954
- ] })
12955
- }
12956
- ),
12957
- /* @__PURE__ */ jsx(
12958
- Form$2.Field,
12959
- {
12960
- control: form.control,
12961
- name: "address_2",
12962
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12963
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
12964
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12965
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12966
- ] })
12967
- }
12968
- ),
12969
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12970
- /* @__PURE__ */ jsx(
12971
- Form$2.Field,
12972
- {
12973
- control: form.control,
12974
- name: "postal_code",
12975
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12976
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
12977
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12978
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12979
- ] })
12980
- }
12981
- ),
12982
- /* @__PURE__ */ jsx(
12983
- Form$2.Field,
12984
- {
12985
- control: form.control,
12986
- name: "city",
12987
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12988
- /* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
12989
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12990
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12991
- ] })
12992
- }
12993
- )
12994
- ] }),
12995
- /* @__PURE__ */ jsx(
12996
- Form$2.Field,
12997
- {
12998
- control: form.control,
12999
- name: "province",
13000
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
13001
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
13002
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
13003
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
13004
- ] })
13005
- }
13006
- ),
13007
- /* @__PURE__ */ jsx(
13008
- Form$2.Field,
13009
- {
13010
- control: form.control,
13011
- name: "phone",
13012
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
13013
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
13014
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
13015
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
13016
- ] })
13017
- }
13018
- )
13019
- ] }) }),
13020
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
13021
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
13022
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
13023
- ] }) })
13024
- ]
13025
- }
13026
- ) });
13027
- };
13028
- const schema = addressSchema;
13029
13029
  const widgetModule = { widgets: [] };
13030
13030
  const routeModule = {
13031
13031
  routes: [
@@ -13050,14 +13050,14 @@ const routeModule = {
13050
13050
  Component: BillingAddress,
13051
13051
  path: "/draft-orders/:id/billing-address"
13052
13052
  },
13053
- {
13054
- Component: CustomItems,
13055
- path: "/draft-orders/:id/custom-items"
13056
- },
13057
13053
  {
13058
13054
  Component: Email,
13059
13055
  path: "/draft-orders/:id/email"
13060
13056
  },
13057
+ {
13058
+ Component: CustomItems,
13059
+ path: "/draft-orders/:id/custom-items"
13060
+ },
13061
13061
  {
13062
13062
  Component: Items,
13063
13063
  path: "/draft-orders/:id/items"
@@ -13074,6 +13074,10 @@ const routeModule = {
13074
13074
  Component: SalesChannel,
13075
13075
  path: "/draft-orders/:id/sales-channel"
13076
13076
  },
13077
+ {
13078
+ Component: ShippingAddress,
13079
+ path: "/draft-orders/:id/shipping-address"
13080
+ },
13077
13081
  {
13078
13082
  Component: Shipping,
13079
13083
  path: "/draft-orders/:id/shipping"
@@ -13081,10 +13085,6 @@ const routeModule = {
13081
13085
  {
13082
13086
  Component: TransferOwnership,
13083
13087
  path: "/draft-orders/:id/transfer-ownership"
13084
- },
13085
- {
13086
- Component: ShippingAddress,
13087
- path: "/draft-orders/:id/shipping-address"
13088
13088
  }
13089
13089
  ]
13090
13090
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medusajs/draft-order",
3
- "version": "2.10.0-preview-20250828031543",
3
+ "version": "2.10.0-preview-20250828060153",
4
4
  "description": "A starter for Medusa plugins.",
5
5
  "author": "Medusa (https://medusajs.com)",
6
6
  "license": "MIT",
@@ -36,7 +36,7 @@
36
36
  "dependencies": {
37
37
  "@ariakit/react": "^0.4.15",
38
38
  "@hookform/resolvers": "3.4.2",
39
- "@medusajs/js-sdk": "2.10.0-preview-20250828031543",
39
+ "@medusajs/js-sdk": "2.10.0-preview-20250828060153",
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,15 +45,15 @@
45
45
  "react-hook-form": "7.49.1"
46
46
  },
47
47
  "devDependencies": {
48
- "@medusajs/admin-sdk": "2.10.0-preview-20250828031543",
49
- "@medusajs/cli": "2.10.0-preview-20250828031543",
50
- "@medusajs/framework": "2.10.0-preview-20250828031543",
51
- "@medusajs/icons": "2.10.0-preview-20250828031543",
52
- "@medusajs/medusa": "2.10.0-preview-20250828031543",
53
- "@medusajs/test-utils": "2.10.0-preview-20250828031543",
54
- "@medusajs/types": "2.10.0-preview-20250828031543",
55
- "@medusajs/ui": "4.0.20-preview-20250828031543",
56
- "@medusajs/ui-preset": "2.10.0-preview-20250828031543",
48
+ "@medusajs/admin-sdk": "2.10.0-preview-20250828060153",
49
+ "@medusajs/cli": "2.10.0-preview-20250828060153",
50
+ "@medusajs/framework": "2.10.0-preview-20250828060153",
51
+ "@medusajs/icons": "2.10.0-preview-20250828060153",
52
+ "@medusajs/medusa": "2.10.0-preview-20250828060153",
53
+ "@medusajs/test-utils": "2.10.0-preview-20250828060153",
54
+ "@medusajs/types": "2.10.0-preview-20250828060153",
55
+ "@medusajs/ui": "4.0.20-preview-20250828060153",
56
+ "@medusajs/ui-preset": "2.10.0-preview-20250828060153",
57
57
  "@mikro-orm/cli": "6.4.3",
58
58
  "@mikro-orm/core": "6.4.3",
59
59
  "@mikro-orm/knex": "6.4.3",
@@ -77,13 +77,13 @@
77
77
  "yalc": "^1.0.0-pre.53"
78
78
  },
79
79
  "peerDependencies": {
80
- "@medusajs/admin-sdk": "2.10.0-preview-20250828031543",
81
- "@medusajs/cli": "2.10.0-preview-20250828031543",
82
- "@medusajs/framework": "2.10.0-preview-20250828031543",
83
- "@medusajs/icons": "2.10.0-preview-20250828031543",
84
- "@medusajs/medusa": "2.10.0-preview-20250828031543",
85
- "@medusajs/test-utils": "2.10.0-preview-20250828031543",
86
- "@medusajs/ui": "4.0.20-preview-20250828031543",
80
+ "@medusajs/admin-sdk": "2.10.0-preview-20250828060153",
81
+ "@medusajs/cli": "2.10.0-preview-20250828060153",
82
+ "@medusajs/framework": "2.10.0-preview-20250828060153",
83
+ "@medusajs/icons": "2.10.0-preview-20250828060153",
84
+ "@medusajs/medusa": "2.10.0-preview-20250828060153",
85
+ "@medusajs/test-utils": "2.10.0-preview-20250828060153",
86
+ "@medusajs/ui": "4.0.20-preview-20250828060153",
87
87
  "@mikro-orm/cli": "6.4.3",
88
88
  "@mikro-orm/core": "6.4.3",
89
89
  "@mikro-orm/knex": "6.4.3",