@medusajs/draft-order 2.11.4-preview-20251109060124 → 2.11.4-preview-20251109120135

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.
@@ -9568,217 +9568,6 @@ const ID = () => {
9568
9568
  /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Outlet, {})
9569
9569
  ] });
9570
9570
  };
9571
- const BillingAddress = () => {
9572
- const { id } = reactRouterDom.useParams();
9573
- const { order, isPending, isError, error } = useOrder(id, {
9574
- fields: "+billing_address"
9575
- });
9576
- if (isError) {
9577
- throw error;
9578
- }
9579
- const isReady = !isPending && !!order;
9580
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9581
- /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer.Header, { children: [
9582
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Billing Address" }) }),
9583
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
9584
- ] }),
9585
- isReady && /* @__PURE__ */ jsxRuntime.jsx(BillingAddressForm, { order })
9586
- ] });
9587
- };
9588
- const BillingAddressForm = ({ order }) => {
9589
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
9590
- const form = reactHookForm.useForm({
9591
- defaultValues: {
9592
- first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
9593
- last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
9594
- company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
9595
- address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
9596
- address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
9597
- city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
9598
- province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
9599
- country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
9600
- postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
9601
- phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
9602
- },
9603
- resolver: zod.zodResolver(schema$5)
9604
- });
9605
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9606
- const { handleSuccess } = useRouteModal();
9607
- const onSubmit = form.handleSubmit(async (data) => {
9608
- await mutateAsync(
9609
- { billing_address: data },
9610
- {
9611
- onSuccess: () => {
9612
- handleSuccess();
9613
- },
9614
- onError: (error) => {
9615
- ui.toast.error(error.message);
9616
- }
9617
- }
9618
- );
9619
- });
9620
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
9621
- KeyboundForm,
9622
- {
9623
- className: "flex flex-1 flex-col overflow-hidden",
9624
- onSubmit,
9625
- children: [
9626
- /* @__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: [
9627
- /* @__PURE__ */ jsxRuntime.jsx(
9628
- Form$2.Field,
9629
- {
9630
- control: form.control,
9631
- name: "country_code",
9632
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9633
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
9634
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
9635
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9636
- ] })
9637
- }
9638
- ),
9639
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
9640
- /* @__PURE__ */ jsxRuntime.jsx(
9641
- Form$2.Field,
9642
- {
9643
- control: form.control,
9644
- name: "first_name",
9645
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9646
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
9647
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9648
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9649
- ] })
9650
- }
9651
- ),
9652
- /* @__PURE__ */ jsxRuntime.jsx(
9653
- Form$2.Field,
9654
- {
9655
- control: form.control,
9656
- name: "last_name",
9657
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9658
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
9659
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9660
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9661
- ] })
9662
- }
9663
- )
9664
- ] }),
9665
- /* @__PURE__ */ jsxRuntime.jsx(
9666
- Form$2.Field,
9667
- {
9668
- control: form.control,
9669
- name: "company",
9670
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9671
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
9672
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9673
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9674
- ] })
9675
- }
9676
- ),
9677
- /* @__PURE__ */ jsxRuntime.jsx(
9678
- Form$2.Field,
9679
- {
9680
- control: form.control,
9681
- name: "address_1",
9682
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9683
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
9684
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9685
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9686
- ] })
9687
- }
9688
- ),
9689
- /* @__PURE__ */ jsxRuntime.jsx(
9690
- Form$2.Field,
9691
- {
9692
- control: form.control,
9693
- name: "address_2",
9694
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9695
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
9696
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9697
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9698
- ] })
9699
- }
9700
- ),
9701
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
9702
- /* @__PURE__ */ jsxRuntime.jsx(
9703
- Form$2.Field,
9704
- {
9705
- control: form.control,
9706
- name: "postal_code",
9707
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9708
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
9709
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9710
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9711
- ] })
9712
- }
9713
- ),
9714
- /* @__PURE__ */ jsxRuntime.jsx(
9715
- Form$2.Field,
9716
- {
9717
- control: form.control,
9718
- name: "city",
9719
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9720
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
9721
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9722
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9723
- ] })
9724
- }
9725
- )
9726
- ] }),
9727
- /* @__PURE__ */ jsxRuntime.jsx(
9728
- Form$2.Field,
9729
- {
9730
- control: form.control,
9731
- name: "province",
9732
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9733
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
9734
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9735
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9736
- ] })
9737
- }
9738
- ),
9739
- /* @__PURE__ */ jsxRuntime.jsx(
9740
- Form$2.Field,
9741
- {
9742
- control: form.control,
9743
- name: "phone",
9744
- render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
9745
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
9746
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
9747
- /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
9748
- ] })
9749
- }
9750
- )
9751
- ] }) }),
9752
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
9753
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9754
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
9755
- ] }) })
9756
- ]
9757
- }
9758
- ) });
9759
- };
9760
- const schema$5 = addressSchema;
9761
- const CustomItems = () => {
9762
- return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
9763
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
9764
- /* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
9765
- ] });
9766
- };
9767
- const CustomItemsForm = () => {
9768
- const form = reactHookForm.useForm({
9769
- resolver: zod.zodResolver(schema$4)
9770
- });
9771
- return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9772
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
9773
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
9774
- /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9775
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
9776
- ] }) })
9777
- ] }) });
9778
- };
9779
- const schema$4 = objectType({
9780
- email: stringType().email()
9781
- });
9782
9571
  const Email = () => {
9783
9572
  const { id } = reactRouterDom.useParams();
9784
9573
  const { order, isPending, isError, error } = useOrder(id, {
@@ -9801,7 +9590,7 @@ const EmailForm = ({ order }) => {
9801
9590
  defaultValues: {
9802
9591
  email: order.email ?? ""
9803
9592
  },
9804
- resolver: zod.zodResolver(schema$3)
9593
+ resolver: zod.zodResolver(schema$5)
9805
9594
  });
9806
9595
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9807
9596
  const { handleSuccess } = useRouteModal();
@@ -9844,7 +9633,7 @@ const EmailForm = ({ order }) => {
9844
9633
  }
9845
9634
  ) });
9846
9635
  };
9847
- const schema$3 = objectType({
9636
+ const schema$5 = objectType({
9848
9637
  email: stringType().email()
9849
9638
  });
9850
9639
  const NumberInput = React.forwardRef(
@@ -11476,7 +11265,7 @@ const SalesChannelForm = ({ order }) => {
11476
11265
  defaultValues: {
11477
11266
  sales_channel_id: order.sales_channel_id || ""
11478
11267
  },
11479
- resolver: zod.zodResolver(schema$2)
11268
+ resolver: zod.zodResolver(schema$4)
11480
11269
  });
11481
11270
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11482
11271
  const { handleSuccess } = useRouteModal();
@@ -11551,7 +11340,7 @@ const SalesChannelField = ({ control, order }) => {
11551
11340
  }
11552
11341
  );
11553
11342
  };
11554
- const schema$2 = objectType({
11343
+ const schema$4 = objectType({
11555
11344
  sales_channel_id: stringType().min(1)
11556
11345
  });
11557
11346
  const STACKED_FOCUS_MODAL_ID = "shipping-form";
@@ -12393,7 +12182,7 @@ const ShippingAddressForm = ({ order }) => {
12393
12182
  postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12394
12183
  phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12395
12184
  },
12396
- resolver: zod.zodResolver(schema$1)
12185
+ resolver: zod.zodResolver(schema$3)
12397
12186
  });
12398
12187
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12399
12188
  const { handleSuccess } = useRouteModal();
@@ -12563,7 +12352,7 @@ const ShippingAddressForm = ({ order }) => {
12563
12352
  }
12564
12353
  ) });
12565
12354
  };
12566
- const schema$1 = addressSchema;
12355
+ const schema$3 = addressSchema;
12567
12356
  const TransferOwnership = () => {
12568
12357
  const { id } = reactRouterDom.useParams();
12569
12358
  const { draft_order, isPending, isError, error } = useDraftOrder(id, {
@@ -12587,7 +12376,7 @@ const TransferOwnershipForm = ({ order }) => {
12587
12376
  defaultValues: {
12588
12377
  customer_id: order.customer_id || ""
12589
12378
  },
12590
- resolver: zod.zodResolver(schema)
12379
+ resolver: zod.zodResolver(schema$2)
12591
12380
  });
12592
12381
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12593
12382
  const { handleSuccess } = useRouteModal();
@@ -13037,9 +12826,220 @@ const Illustration = () => {
13037
12826
  }
13038
12827
  );
13039
12828
  };
13040
- const schema = objectType({
12829
+ const schema$2 = objectType({
13041
12830
  customer_id: stringType().min(1)
13042
12831
  });
12832
+ const BillingAddress = () => {
12833
+ const { id } = reactRouterDom.useParams();
12834
+ const { order, isPending, isError, error } = useOrder(id, {
12835
+ fields: "+billing_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 Billing Address" }) }),
12844
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
12845
+ ] }),
12846
+ isReady && /* @__PURE__ */ jsxRuntime.jsx(BillingAddressForm, { order })
12847
+ ] });
12848
+ };
12849
+ const BillingAddressForm = ({ 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.billing_address) == null ? void 0 : _a.first_name) ?? "",
12854
+ last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
12855
+ company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
12856
+ address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
12857
+ address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
12858
+ city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
12859
+ province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
12860
+ country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
12861
+ postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
12862
+ phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
12863
+ },
12864
+ resolver: zod.zodResolver(schema$1)
12865
+ });
12866
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12867
+ const { handleSuccess } = useRouteModal();
12868
+ const onSubmit = form.handleSubmit(async (data) => {
12869
+ await mutateAsync(
12870
+ { billing_address: data },
12871
+ {
12872
+ onSuccess: () => {
12873
+ handleSuccess();
12874
+ },
12875
+ onError: (error) => {
12876
+ ui.toast.error(error.message);
12877
+ }
12878
+ }
12879
+ );
12880
+ });
12881
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(
12882
+ KeyboundForm,
12883
+ {
12884
+ className: "flex flex-1 flex-col overflow-hidden",
12885
+ onSubmit,
12886
+ children: [
12887
+ /* @__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: [
12888
+ /* @__PURE__ */ jsxRuntime.jsx(
12889
+ Form$2.Field,
12890
+ {
12891
+ control: form.control,
12892
+ name: "country_code",
12893
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12894
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Country" }),
12895
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(CountrySelect, { ...field }) }),
12896
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12897
+ ] })
12898
+ }
12899
+ ),
12900
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12901
+ /* @__PURE__ */ jsxRuntime.jsx(
12902
+ Form$2.Field,
12903
+ {
12904
+ control: form.control,
12905
+ name: "first_name",
12906
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12907
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "First name" }),
12908
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12909
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12910
+ ] })
12911
+ }
12912
+ ),
12913
+ /* @__PURE__ */ jsxRuntime.jsx(
12914
+ Form$2.Field,
12915
+ {
12916
+ control: form.control,
12917
+ name: "last_name",
12918
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12919
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Last name" }),
12920
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12921
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12922
+ ] })
12923
+ }
12924
+ )
12925
+ ] }),
12926
+ /* @__PURE__ */ jsxRuntime.jsx(
12927
+ Form$2.Field,
12928
+ {
12929
+ control: form.control,
12930
+ name: "company",
12931
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12932
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Company" }),
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
+ /* @__PURE__ */ jsxRuntime.jsx(
12939
+ Form$2.Field,
12940
+ {
12941
+ control: form.control,
12942
+ name: "address_1",
12943
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12944
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Address" }),
12945
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12946
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12947
+ ] })
12948
+ }
12949
+ ),
12950
+ /* @__PURE__ */ jsxRuntime.jsx(
12951
+ Form$2.Field,
12952
+ {
12953
+ control: form.control,
12954
+ name: "address_2",
12955
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12956
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
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.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12963
+ /* @__PURE__ */ jsxRuntime.jsx(
12964
+ Form$2.Field,
12965
+ {
12966
+ control: form.control,
12967
+ name: "postal_code",
12968
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12969
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "Postal code" }),
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.jsx(
12976
+ Form$2.Field,
12977
+ {
12978
+ control: form.control,
12979
+ name: "city",
12980
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12981
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { children: "City" }),
12982
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
12983
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
12984
+ ] })
12985
+ }
12986
+ )
12987
+ ] }),
12988
+ /* @__PURE__ */ jsxRuntime.jsx(
12989
+ Form$2.Field,
12990
+ {
12991
+ control: form.control,
12992
+ name: "province",
12993
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
12994
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Province / State" }),
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
+ /* @__PURE__ */ jsxRuntime.jsx(
13001
+ Form$2.Field,
13002
+ {
13003
+ control: form.control,
13004
+ name: "phone",
13005
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(Form$2.Item, { children: [
13006
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Label, { optional: true, children: "Phone" }),
13007
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.Control, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.Input, { ...field }) }),
13008
+ /* @__PURE__ */ jsxRuntime.jsx(Form$2.ErrorMessage, {})
13009
+ ] })
13010
+ }
13011
+ )
13012
+ ] }) }),
13013
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
13014
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
13015
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
13016
+ ] }) })
13017
+ ]
13018
+ }
13019
+ ) });
13020
+ };
13021
+ const schema$1 = addressSchema;
13022
+ const CustomItems = () => {
13023
+ return /* @__PURE__ */ jsxRuntime.jsxs(RouteDrawer, { children: [
13024
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { children: "Edit Custom Items" }) }) }),
13025
+ /* @__PURE__ */ jsxRuntime.jsx(CustomItemsForm, {})
13026
+ ] });
13027
+ };
13028
+ const CustomItemsForm = () => {
13029
+ const form = reactHookForm.useForm({
13030
+ resolver: zod.zodResolver(schema)
13031
+ });
13032
+ return /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxRuntime.jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
13033
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Body, {}),
13034
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-end gap-2", children: [
13035
+ /* @__PURE__ */ jsxRuntime.jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
13036
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { size: "small", type: "submit", children: "Save" })
13037
+ ] }) })
13038
+ ] }) });
13039
+ };
13040
+ const schema = objectType({
13041
+ email: stringType().email()
13042
+ });
13043
13043
  const widgetModule = { widgets: [] };
13044
13044
  const routeModule = {
13045
13045
  routes: [
@@ -13060,14 +13060,6 @@ const routeModule = {
13060
13060
  handle,
13061
13061
  loader,
13062
13062
  children: [
13063
- {
13064
- Component: BillingAddress,
13065
- path: "/draft-orders/:id/billing-address"
13066
- },
13067
- {
13068
- Component: CustomItems,
13069
- path: "/draft-orders/:id/custom-items"
13070
- },
13071
13063
  {
13072
13064
  Component: Email,
13073
13065
  path: "/draft-orders/:id/email"
@@ -13099,6 +13091,14 @@ const routeModule = {
13099
13091
  {
13100
13092
  Component: TransferOwnership,
13101
13093
  path: "/draft-orders/:id/transfer-ownership"
13094
+ },
13095
+ {
13096
+ Component: BillingAddress,
13097
+ path: "/draft-orders/:id/billing-address"
13098
+ },
13099
+ {
13100
+ Component: CustomItems,
13101
+ path: "/draft-orders/:id/custom-items"
13102
13102
  }
13103
13103
  ]
13104
13104
  }
@@ -9561,217 +9561,6 @@ const ID = () => {
9561
9561
  /* @__PURE__ */ jsx(Outlet, {})
9562
9562
  ] });
9563
9563
  };
9564
- const BillingAddress = () => {
9565
- const { id } = useParams();
9566
- const { order, isPending, isError, error } = useOrder(id, {
9567
- fields: "+billing_address"
9568
- });
9569
- if (isError) {
9570
- throw error;
9571
- }
9572
- const isReady = !isPending && !!order;
9573
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
9574
- /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
9575
- /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Billing Address" }) }),
9576
- /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
9577
- ] }),
9578
- isReady && /* @__PURE__ */ jsx(BillingAddressForm, { order })
9579
- ] });
9580
- };
9581
- const BillingAddressForm = ({ order }) => {
9582
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
9583
- const form = useForm({
9584
- defaultValues: {
9585
- first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
9586
- last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
9587
- company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
9588
- address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
9589
- address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
9590
- city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
9591
- province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
9592
- country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
9593
- postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
9594
- phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
9595
- },
9596
- resolver: zodResolver(schema$5)
9597
- });
9598
- const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9599
- const { handleSuccess } = useRouteModal();
9600
- const onSubmit = form.handleSubmit(async (data) => {
9601
- await mutateAsync(
9602
- { billing_address: data },
9603
- {
9604
- onSuccess: () => {
9605
- handleSuccess();
9606
- },
9607
- onError: (error) => {
9608
- toast.error(error.message);
9609
- }
9610
- }
9611
- );
9612
- });
9613
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
9614
- KeyboundForm,
9615
- {
9616
- className: "flex flex-1 flex-col overflow-hidden",
9617
- onSubmit,
9618
- children: [
9619
- /* @__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: [
9620
- /* @__PURE__ */ jsx(
9621
- Form$2.Field,
9622
- {
9623
- control: form.control,
9624
- name: "country_code",
9625
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9626
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
9627
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
9628
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9629
- ] })
9630
- }
9631
- ),
9632
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
9633
- /* @__PURE__ */ jsx(
9634
- Form$2.Field,
9635
- {
9636
- control: form.control,
9637
- name: "first_name",
9638
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9639
- /* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
9640
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9641
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9642
- ] })
9643
- }
9644
- ),
9645
- /* @__PURE__ */ jsx(
9646
- Form$2.Field,
9647
- {
9648
- control: form.control,
9649
- name: "last_name",
9650
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9651
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
9652
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9653
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9654
- ] })
9655
- }
9656
- )
9657
- ] }),
9658
- /* @__PURE__ */ jsx(
9659
- Form$2.Field,
9660
- {
9661
- control: form.control,
9662
- name: "company",
9663
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9664
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
9665
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9666
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9667
- ] })
9668
- }
9669
- ),
9670
- /* @__PURE__ */ jsx(
9671
- Form$2.Field,
9672
- {
9673
- control: form.control,
9674
- name: "address_1",
9675
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9676
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
9677
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9678
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9679
- ] })
9680
- }
9681
- ),
9682
- /* @__PURE__ */ jsx(
9683
- Form$2.Field,
9684
- {
9685
- control: form.control,
9686
- name: "address_2",
9687
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9688
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
9689
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9690
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9691
- ] })
9692
- }
9693
- ),
9694
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
9695
- /* @__PURE__ */ jsx(
9696
- Form$2.Field,
9697
- {
9698
- control: form.control,
9699
- name: "postal_code",
9700
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9701
- /* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
9702
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9703
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9704
- ] })
9705
- }
9706
- ),
9707
- /* @__PURE__ */ jsx(
9708
- Form$2.Field,
9709
- {
9710
- control: form.control,
9711
- name: "city",
9712
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9713
- /* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
9714
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9715
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9716
- ] })
9717
- }
9718
- )
9719
- ] }),
9720
- /* @__PURE__ */ jsx(
9721
- Form$2.Field,
9722
- {
9723
- control: form.control,
9724
- name: "province",
9725
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9726
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
9727
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9728
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9729
- ] })
9730
- }
9731
- ),
9732
- /* @__PURE__ */ jsx(
9733
- Form$2.Field,
9734
- {
9735
- control: form.control,
9736
- name: "phone",
9737
- render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
9738
- /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
9739
- /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
9740
- /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
9741
- ] })
9742
- }
9743
- )
9744
- ] }) }),
9745
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
9746
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9747
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
9748
- ] }) })
9749
- ]
9750
- }
9751
- ) });
9752
- };
9753
- const schema$5 = addressSchema;
9754
- const CustomItems = () => {
9755
- return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
9756
- /* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
9757
- /* @__PURE__ */ jsx(CustomItemsForm, {})
9758
- ] });
9759
- };
9760
- const CustomItemsForm = () => {
9761
- const form = useForm({
9762
- resolver: zodResolver(schema$4)
9763
- });
9764
- return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
9765
- /* @__PURE__ */ jsx(RouteDrawer.Body, {}),
9766
- /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
9767
- /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
9768
- /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
9769
- ] }) })
9770
- ] }) });
9771
- };
9772
- const schema$4 = objectType({
9773
- email: stringType().email()
9774
- });
9775
9564
  const Email = () => {
9776
9565
  const { id } = useParams();
9777
9566
  const { order, isPending, isError, error } = useOrder(id, {
@@ -9794,7 +9583,7 @@ const EmailForm = ({ order }) => {
9794
9583
  defaultValues: {
9795
9584
  email: order.email ?? ""
9796
9585
  },
9797
- resolver: zodResolver(schema$3)
9586
+ resolver: zodResolver(schema$5)
9798
9587
  });
9799
9588
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
9800
9589
  const { handleSuccess } = useRouteModal();
@@ -9837,7 +9626,7 @@ const EmailForm = ({ order }) => {
9837
9626
  }
9838
9627
  ) });
9839
9628
  };
9840
- const schema$3 = objectType({
9629
+ const schema$5 = objectType({
9841
9630
  email: stringType().email()
9842
9631
  });
9843
9632
  const NumberInput = forwardRef(
@@ -11469,7 +11258,7 @@ const SalesChannelForm = ({ order }) => {
11469
11258
  defaultValues: {
11470
11259
  sales_channel_id: order.sales_channel_id || ""
11471
11260
  },
11472
- resolver: zodResolver(schema$2)
11261
+ resolver: zodResolver(schema$4)
11473
11262
  });
11474
11263
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
11475
11264
  const { handleSuccess } = useRouteModal();
@@ -11544,7 +11333,7 @@ const SalesChannelField = ({ control, order }) => {
11544
11333
  }
11545
11334
  );
11546
11335
  };
11547
- const schema$2 = objectType({
11336
+ const schema$4 = objectType({
11548
11337
  sales_channel_id: stringType().min(1)
11549
11338
  });
11550
11339
  const STACKED_FOCUS_MODAL_ID = "shipping-form";
@@ -12386,7 +12175,7 @@ const ShippingAddressForm = ({ order }) => {
12386
12175
  postal_code: ((_i = order.shipping_address) == null ? void 0 : _i.postal_code) ?? "",
12387
12176
  phone: ((_j = order.shipping_address) == null ? void 0 : _j.phone) ?? ""
12388
12177
  },
12389
- resolver: zodResolver(schema$1)
12178
+ resolver: zodResolver(schema$3)
12390
12179
  });
12391
12180
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12392
12181
  const { handleSuccess } = useRouteModal();
@@ -12556,7 +12345,7 @@ const ShippingAddressForm = ({ order }) => {
12556
12345
  }
12557
12346
  ) });
12558
12347
  };
12559
- const schema$1 = addressSchema;
12348
+ const schema$3 = addressSchema;
12560
12349
  const TransferOwnership = () => {
12561
12350
  const { id } = useParams();
12562
12351
  const { draft_order, isPending, isError, error } = useDraftOrder(id, {
@@ -12580,7 +12369,7 @@ const TransferOwnershipForm = ({ order }) => {
12580
12369
  defaultValues: {
12581
12370
  customer_id: order.customer_id || ""
12582
12371
  },
12583
- resolver: zodResolver(schema)
12372
+ resolver: zodResolver(schema$2)
12584
12373
  });
12585
12374
  const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12586
12375
  const { handleSuccess } = useRouteModal();
@@ -13030,9 +12819,220 @@ const Illustration = () => {
13030
12819
  }
13031
12820
  );
13032
12821
  };
13033
- const schema = objectType({
12822
+ const schema$2 = objectType({
13034
12823
  customer_id: stringType().min(1)
13035
12824
  });
12825
+ const BillingAddress = () => {
12826
+ const { id } = useParams();
12827
+ const { order, isPending, isError, error } = useOrder(id, {
12828
+ fields: "+billing_address"
12829
+ });
12830
+ if (isError) {
12831
+ throw error;
12832
+ }
12833
+ const isReady = !isPending && !!order;
12834
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
12835
+ /* @__PURE__ */ jsxs(RouteDrawer.Header, { children: [
12836
+ /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Billing Address" }) }),
12837
+ /* @__PURE__ */ jsx(RouteDrawer.Description, { asChild: true, children: /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Edit the billing address for the draft order" }) })
12838
+ ] }),
12839
+ isReady && /* @__PURE__ */ jsx(BillingAddressForm, { order })
12840
+ ] });
12841
+ };
12842
+ const BillingAddressForm = ({ order }) => {
12843
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
12844
+ const form = useForm({
12845
+ defaultValues: {
12846
+ first_name: ((_a = order.billing_address) == null ? void 0 : _a.first_name) ?? "",
12847
+ last_name: ((_b = order.billing_address) == null ? void 0 : _b.last_name) ?? "",
12848
+ company: ((_c = order.billing_address) == null ? void 0 : _c.company) ?? "",
12849
+ address_1: ((_d = order.billing_address) == null ? void 0 : _d.address_1) ?? "",
12850
+ address_2: ((_e = order.billing_address) == null ? void 0 : _e.address_2) ?? "",
12851
+ city: ((_f = order.billing_address) == null ? void 0 : _f.city) ?? "",
12852
+ province: ((_g = order.billing_address) == null ? void 0 : _g.province) ?? "",
12853
+ country_code: ((_h = order.billing_address) == null ? void 0 : _h.country_code) ?? "",
12854
+ postal_code: ((_i = order.billing_address) == null ? void 0 : _i.postal_code) ?? "",
12855
+ phone: ((_j = order.billing_address) == null ? void 0 : _j.phone) ?? ""
12856
+ },
12857
+ resolver: zodResolver(schema$1)
12858
+ });
12859
+ const { mutateAsync, isPending } = useUpdateDraftOrder(order.id);
12860
+ const { handleSuccess } = useRouteModal();
12861
+ const onSubmit = form.handleSubmit(async (data) => {
12862
+ await mutateAsync(
12863
+ { billing_address: data },
12864
+ {
12865
+ onSuccess: () => {
12866
+ handleSuccess();
12867
+ },
12868
+ onError: (error) => {
12869
+ toast.error(error.message);
12870
+ }
12871
+ }
12872
+ );
12873
+ });
12874
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(
12875
+ KeyboundForm,
12876
+ {
12877
+ className: "flex flex-1 flex-col overflow-hidden",
12878
+ onSubmit,
12879
+ children: [
12880
+ /* @__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: [
12881
+ /* @__PURE__ */ jsx(
12882
+ Form$2.Field,
12883
+ {
12884
+ control: form.control,
12885
+ name: "country_code",
12886
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12887
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Country" }),
12888
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(CountrySelect, { ...field }) }),
12889
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12890
+ ] })
12891
+ }
12892
+ ),
12893
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12894
+ /* @__PURE__ */ jsx(
12895
+ Form$2.Field,
12896
+ {
12897
+ control: form.control,
12898
+ name: "first_name",
12899
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12900
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "First name" }),
12901
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12902
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12903
+ ] })
12904
+ }
12905
+ ),
12906
+ /* @__PURE__ */ jsx(
12907
+ Form$2.Field,
12908
+ {
12909
+ control: form.control,
12910
+ name: "last_name",
12911
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12912
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Last name" }),
12913
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12914
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12915
+ ] })
12916
+ }
12917
+ )
12918
+ ] }),
12919
+ /* @__PURE__ */ jsx(
12920
+ Form$2.Field,
12921
+ {
12922
+ control: form.control,
12923
+ name: "company",
12924
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12925
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Company" }),
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: "address_1",
12936
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12937
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Address" }),
12938
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12939
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12940
+ ] })
12941
+ }
12942
+ ),
12943
+ /* @__PURE__ */ jsx(
12944
+ Form$2.Field,
12945
+ {
12946
+ control: form.control,
12947
+ name: "address_2",
12948
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12949
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Apartment, suite, etc." }),
12950
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12951
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12952
+ ] })
12953
+ }
12954
+ ),
12955
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
12956
+ /* @__PURE__ */ jsx(
12957
+ Form$2.Field,
12958
+ {
12959
+ control: form.control,
12960
+ name: "postal_code",
12961
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12962
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "Postal code" }),
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: "city",
12973
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12974
+ /* @__PURE__ */ jsx(Form$2.Label, { children: "City" }),
12975
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
12976
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
12977
+ ] })
12978
+ }
12979
+ )
12980
+ ] }),
12981
+ /* @__PURE__ */ jsx(
12982
+ Form$2.Field,
12983
+ {
12984
+ control: form.control,
12985
+ name: "province",
12986
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12987
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Province / State" }),
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: "phone",
12998
+ render: ({ field }) => /* @__PURE__ */ jsxs(Form$2.Item, { children: [
12999
+ /* @__PURE__ */ jsx(Form$2.Label, { optional: true, children: "Phone" }),
13000
+ /* @__PURE__ */ jsx(Form$2.Control, { children: /* @__PURE__ */ jsx(Input, { ...field }) }),
13001
+ /* @__PURE__ */ jsx(Form$2.ErrorMessage, {})
13002
+ ] })
13003
+ }
13004
+ )
13005
+ ] }) }),
13006
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
13007
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
13008
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", isLoading: isPending, children: "Save" })
13009
+ ] }) })
13010
+ ]
13011
+ }
13012
+ ) });
13013
+ };
13014
+ const schema$1 = addressSchema;
13015
+ const CustomItems = () => {
13016
+ return /* @__PURE__ */ jsxs(RouteDrawer, { children: [
13017
+ /* @__PURE__ */ jsx(RouteDrawer.Header, { children: /* @__PURE__ */ jsx(RouteDrawer.Title, { asChild: true, children: /* @__PURE__ */ jsx(Heading, { children: "Edit Custom Items" }) }) }),
13018
+ /* @__PURE__ */ jsx(CustomItemsForm, {})
13019
+ ] });
13020
+ };
13021
+ const CustomItemsForm = () => {
13022
+ const form = useForm({
13023
+ resolver: zodResolver(schema)
13024
+ });
13025
+ return /* @__PURE__ */ jsx(RouteDrawer.Form, { form, children: /* @__PURE__ */ jsxs(KeyboundForm, { className: "flex flex-1 flex-col", children: [
13026
+ /* @__PURE__ */ jsx(RouteDrawer.Body, {}),
13027
+ /* @__PURE__ */ jsx(RouteDrawer.Footer, { children: /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
13028
+ /* @__PURE__ */ jsx(RouteDrawer.Close, { asChild: true, children: /* @__PURE__ */ jsx(Button, { size: "small", variant: "secondary", children: "Cancel" }) }),
13029
+ /* @__PURE__ */ jsx(Button, { size: "small", type: "submit", children: "Save" })
13030
+ ] }) })
13031
+ ] }) });
13032
+ };
13033
+ const schema = objectType({
13034
+ email: stringType().email()
13035
+ });
13036
13036
  const widgetModule = { widgets: [] };
13037
13037
  const routeModule = {
13038
13038
  routes: [
@@ -13053,14 +13053,6 @@ const routeModule = {
13053
13053
  handle,
13054
13054
  loader,
13055
13055
  children: [
13056
- {
13057
- Component: BillingAddress,
13058
- path: "/draft-orders/:id/billing-address"
13059
- },
13060
- {
13061
- Component: CustomItems,
13062
- path: "/draft-orders/:id/custom-items"
13063
- },
13064
13056
  {
13065
13057
  Component: Email,
13066
13058
  path: "/draft-orders/:id/email"
@@ -13092,6 +13084,14 @@ const routeModule = {
13092
13084
  {
13093
13085
  Component: TransferOwnership,
13094
13086
  path: "/draft-orders/:id/transfer-ownership"
13087
+ },
13088
+ {
13089
+ Component: BillingAddress,
13090
+ path: "/draft-orders/:id/billing-address"
13091
+ },
13092
+ {
13093
+ Component: CustomItems,
13094
+ path: "/draft-orders/:id/custom-items"
13095
13095
  }
13096
13096
  ]
13097
13097
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medusajs/draft-order",
3
- "version": "2.11.4-preview-20251109060124",
3
+ "version": "2.11.4-preview-20251109120135",
4
4
  "description": "A starter for Medusa plugins.",
5
5
  "author": "Medusa (https://medusajs.com)",
6
6
  "license": "MIT",
@@ -37,7 +37,7 @@
37
37
  "@ariakit/react": "^0.4.15",
38
38
  "@babel/runtime": "^7.26.10",
39
39
  "@hookform/resolvers": "3.4.2",
40
- "@medusajs/js-sdk": "2.11.4-preview-20251109060124",
40
+ "@medusajs/js-sdk": "2.11.4-preview-20251109120135",
41
41
  "@tanstack/react-query": "5.64.2",
42
42
  "@uiw/react-json-view": "^2.0.0-alpha.17",
43
43
  "date-fns": "^3.6.0",
@@ -48,22 +48,22 @@
48
48
  "react-hook-form": "7.49.1"
49
49
  },
50
50
  "devDependencies": {
51
- "@medusajs/admin-sdk": "2.11.4-preview-20251109060124",
52
- "@medusajs/cli": "2.11.4-preview-20251109060124",
53
- "@medusajs/framework": "2.11.4-preview-20251109060124",
54
- "@medusajs/icons": "2.11.4-preview-20251109060124",
55
- "@medusajs/test-utils": "2.11.4-preview-20251109060124",
56
- "@medusajs/types": "2.11.4-preview-20251109060124",
57
- "@medusajs/ui": "4.0.28-preview-20251109060124",
58
- "@medusajs/ui-preset": "2.11.4-preview-20251109060124"
51
+ "@medusajs/admin-sdk": "2.11.4-preview-20251109120135",
52
+ "@medusajs/cli": "2.11.4-preview-20251109120135",
53
+ "@medusajs/framework": "2.11.4-preview-20251109120135",
54
+ "@medusajs/icons": "2.11.4-preview-20251109120135",
55
+ "@medusajs/test-utils": "2.11.4-preview-20251109120135",
56
+ "@medusajs/types": "2.11.4-preview-20251109120135",
57
+ "@medusajs/ui": "4.0.28-preview-20251109120135",
58
+ "@medusajs/ui-preset": "2.11.4-preview-20251109120135"
59
59
  },
60
60
  "peerDependencies": {
61
- "@medusajs/admin-sdk": "2.11.4-preview-20251109060124",
62
- "@medusajs/cli": "2.11.4-preview-20251109060124",
63
- "@medusajs/framework": "2.11.4-preview-20251109060124",
64
- "@medusajs/icons": "2.11.4-preview-20251109060124",
65
- "@medusajs/test-utils": "2.11.4-preview-20251109060124",
66
- "@medusajs/ui": "4.0.28-preview-20251109060124",
61
+ "@medusajs/admin-sdk": "2.11.4-preview-20251109120135",
62
+ "@medusajs/cli": "2.11.4-preview-20251109120135",
63
+ "@medusajs/framework": "2.11.4-preview-20251109120135",
64
+ "@medusajs/icons": "2.11.4-preview-20251109120135",
65
+ "@medusajs/test-utils": "2.11.4-preview-20251109120135",
66
+ "@medusajs/ui": "4.0.28-preview-20251109120135",
67
67
  "react": "^18.3.1",
68
68
  "react-dom": "^18.3.1",
69
69
  "react-router-dom": "6.20.1"